* separate pool into a different module * only export by default a simple gathering function * export an unsafe module with all the memory methods
25 lines
628 B
Haskell
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
|