cryptonite/Crypto/Random/Entropy/Source.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
766 B
Haskell

-- |
-- Module : Crypto.Random.Entropy.Source
-- License : BSD-style
-- Maintainer : Vincent Hanquez <vincent@snarc.org>
-- Stability : experimental
-- Portability : Good
--
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
module Crypto.Random.Entropy.Source where
import Foreign.Ptr
import Data.Word (Word8)
-- | A handle to an entropy maker, either a system capability
-- or a hardware generator.
class EntropySource a where
-- | try to open an handle for this source
entropyOpen :: IO (Maybe a)
-- | try to gather a number of entropy bytes into a buffer.
-- return the number of actual bytes gathered
entropyGather :: a -> Ptr Word8 -> Int -> IO Int
-- | Close an open handle
entropyClose :: a -> IO ()