cryptonite/Crypto/Random/Entropy.hs
Vincent Hanquez adca793a9f Reorganize entropy interfaces.
* separate pool into a different module
* only export by default a simple gathering function
* export an unsafe module with all the memory methods
2014-08-25 08:00:10 +01:00

25 lines
628 B
Haskell

-- |
-- Module : Crypto.Random.Entropy
-- License : BSD-style
-- Maintainer : Vincent Hanquez <vincent@snarc.org>
-- Stability : experimental
-- Portability : Good
--
module Crypto.Random.Entropy
( getEntropy
) where
import Data.Maybe (catMaybes)
import Data.SecureMem
import Crypto.Random.Types
import Crypto.Random.Entropy.Unsafe
-- | Get some entropy from the system source of entropy
getEntropy :: Int -> IO Random
getEntropy n = do
backends <- catMaybes `fmap` sequence supportedBackends
out <- allocateSecureMem n
withSecureMemPtr out $ replenish n backends
return $ Random out