diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-10-07 10:18:31 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-10-07 10:21:02 -0400 |
commit | 3e432c60d2c6b3fecd920e8053ba4e9a75965dbd (patch) | |
tree | 4d6d8bda9efe4fae54e5509703b30aa2097239f9 /ByteStrings.hs | |
parent | 8069f11684819fb229cfe9e40c680732776c7c9c (diff) | |
download | keysafe-3e432c60d2c6b3fecd920e8053ba4e9a75965dbd.tar.gz |
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.
Diffstat (limited to 'ByteStrings.hs')
-rw-r--r-- | ByteStrings.hs | 12 |
1 files changed, 12 insertions, 0 deletions
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 <id@joeyh.name> - - 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 |