crypto-random 0.0.6 → 0.0.7
raw patch · 4 files changed
+17/−6 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Crypto.Random: grabEntropyIO :: Int -> EntropyPool -> IO SecureMem
Files
- Crypto/Random.hs +1/−0
- Crypto/Random/Entropy.hs +14/−4
- cbits/rdrand.c +1/−1
- crypto-random.cabal +1/−1
Crypto/Random.hs view
@@ -15,6 +15,7 @@ EntropyPool , createEntropyPool , grabEntropy+ , grabEntropyIO -- * Random generation , CPRG(..) , withRandomBytes
Crypto/Random/Entropy.hs view
@@ -13,6 +13,7 @@ , createTestEntropyPool , grabEntropyPtr , grabEntropy+ , grabEntropyIO ) where import Control.Monad (when)@@ -129,17 +130,26 @@ if pos == poolSize then replenish poolSize backends s >> return 0 else return pos- let m = min (poolSize - wrappedPos) left + let m = min (poolSize - wrappedPos) left copyBytes d (s `plusPtr` wrappedPos) m copyLoop (d `plusPtr` m) s (wrappedPos + m) (left - m) -- | Grab a chunk of entropy from the entropy pool.-{-# NOINLINE grabEntropy #-}-grabEntropy :: Int -> EntropyPool -> SecureMem-grabEntropy n pool = unsafePerformIO $ do+grabEntropyIO :: Int -> EntropyPool -> IO SecureMem+grabEntropyIO n pool = do out <- allocateSecureMem n withSecureMemPtr out $ grabEntropyPtr n pool return $ out++-- | Grab a chunk of entropy from the entropy pool.+--+-- Great care need to be taken here when using the output,+-- as this use unsafePerformIO to actually get entropy.+--+-- Use grabEntropyIO if unsure.+{-# NOINLINE grabEntropy #-}+grabEntropy :: Int -> EntropyPool -> SecureMem+grabEntropy n pool = unsafePerformIO $ grabEntropyIO n pool replenish :: Int -> [EntropyBackend] -> Ptr Word8 -> IO () replenish poolSize backends ptr = loop 0 backends ptr poolSize
cbits/rdrand.c view
@@ -87,7 +87,7 @@ inline_rdrand_rax(tmp, ok); if (!ok) return (orig_len - len);- *buffer = tmp;+ *((uint64_t *) buffer) = tmp; } if (len > 0) {
crypto-random.cabal view
@@ -1,5 +1,5 @@ Name: crypto-random-Version: 0.0.6+Version: 0.0.7 Description: Simple cryptographic random related types License: BSD3 License-file: LICENSE