From 3e432c60d2c6b3fecd920e8053ba4e9a75965dbd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 7 Oct 2016 10:18:31 -0400 Subject: Removed dependency on crypto-random. Use raaz for random bytestring generation exclusively. It was already used in all important places, but chaffing was using crypto-random. Note that System.Random is used for delays during chaffing and by random-shuffle. --- ByteStrings.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ByteStrings.hs') diff --git a/ByteStrings.hs b/ByteStrings.hs index 02e22ab..cecf617 100644 --- a/ByteStrings.hs +++ b/ByteStrings.hs @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} + {- Copyright 2016 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. @@ -6,6 +8,9 @@ module ByteStrings where import qualified Data.ByteString as B +import qualified Raaz +import Control.Monad +import Data.Word allByteStringsOfLength :: Int -> [B.ByteString] allByteStringsOfLength = go [] @@ -28,3 +33,10 @@ chunkByteString n = go [] | otherwise = let (h, t) = B.splitAt n b in go (h:cs) t + +instance Raaz.Random Word8 + +randomByteStringOfLength :: Int -> Raaz.SystemPRG -> IO B.ByteString +randomByteStringOfLength n prg = B.pack <$> replicateM n randbyte + where + randbyte = Raaz.random prg :: IO Word8 -- cgit v1.2.3