packages feed

cprng-aes 0.6.0 → 0.6.1

raw patch · 3 files changed

+21/−26 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Crypto/Random/AESCtr.hs view
@@ -41,10 +41,10 @@ -- -- By default, this generator will automatically reseed after generating -- 1 megabyte of data.-data AESRNG = AESRNG { aesrngState     :: RNG+data AESRNG = AESRNG { aesrngState     :: !RNG                      , aesrngEntropy   :: EntropyPool-                     , aesrngThreshold :: Int -- ^ in number of generated block-                     , aesrngCache     :: ByteString }+                     , aesrngThreshold :: !Int -- ^ in number of generated block+                     , aesrngCache     :: !ByteString }  instance Show AESRNG where     show _ = "aesrng[..]"@@ -55,8 +55,7 @@     , aesrngEntropy      = entPool     , aesrngThreshold    = 1024 -- in blocks generated, so 1mb     , aesrngCache        = B.empty }-  where rng = RNG entropy cnt 0 key-        (key, cnt, entropy) = makeParams b+  where rng = makeRNG b  -- | make an AES RNG from an EntropyPool. --@@ -99,15 +98,10 @@ reseedThreshold :: AESRNG -> AESRNG reseedThreshold rng     | getNbChunksGenerated (aesrngState rng) >= lvl =-         let ent = toBytes $ grabEntropy 64 (aesrngEntropy rng)-          in rng { aesrngState = reseedState ent (aesrngState rng) }+         let newRngState = makeRNG $ toBytes $ grabEntropy 64 (aesrngEntropy rng)+          in rng { aesrngState = newRngState }     | otherwise  = rng-  where-        lvl = aesrngThreshold rng-        reseedState :: ByteString -> RNG -> RNG-        reseedState b g@(RNG _ cnt1 _ _) = RNG left cnt2 0 key2-            where -- (r16, _)           = genNextChunk g-                  (key2, cnt2, left) = makeParams b+  where lvl = aesrngThreshold rng  instance CPRG AESRNG where     cprgCreate                      = make
Crypto/Random/AESCtr/Internal.hs view
@@ -15,27 +15,28 @@ import qualified Data.ByteString as B  {-| An opaque object containing an AES CPRNG -}-data RNG = RNG-    {-# UNPACK #-} !ByteString -- left over entropy. can be use to reseed-    {-# UNPACK #-} !AES.AESIV  -- counter-    {-# UNPACK #-} !Int        -- number of chunks generated since reseed-    {-# UNPACK #-} !AES.AES    -- AES context+data RNG = RNG !AES.AESIV !Int !AES.AES  getNbChunksGenerated :: RNG -> Int-getNbChunksGenerated (RNG _ _ c _) = c+getNbChunksGenerated (RNG _ c _) = c -makeParams :: ByteString -> (AES.AES, AES.AESIV, ByteString)-makeParams b = key `seq` entropy `seq` (key, AES.aesIV_ cnt, entropy)+makeParams :: ByteString -> (AES.AES, AES.AESIV)+makeParams b = key `seq` iv `seq` (key, iv)   where (keyBS, r1) = B.splitAt 32 b-        (cnt, r2)   = B.splitAt 16 r1-        !entropy    = B.copy r2+        (cnt, _)    = B.splitAt 16 r1         !key        = AES.initAES keyBS+        !iv         = AES.aesIV_ $ B.copy cnt +makeRNG :: ByteString -> RNG+makeRNG b = RNG iv 0 key+  where (key,iv) = makeParams b+ chunkSize :: Int chunkSize = 1024  genNextChunk :: RNG -> (ByteString, RNG)-genNextChunk (RNG entropy counter nbChunks key) = (chunk, newrng)+genNextChunk (RNG counter nbChunks key) =+    chunk `seq` newrng `seq` (chunk, newrng)   where-        newrng = RNG entropy newCounter (nbChunks+1) key+        newrng = RNG newCounter (nbChunks+1) key         (chunk,newCounter) = AES.genCounter key counter chunkSize
cprng-aes.cabal view
@@ -1,5 +1,5 @@ Name:                cprng-aes-Version:             0.6.0+Version:             0.6.1 Description:              Simple crypto pseudo-random-number-generator with really good randomness property.     .