File: Source.hs

package info (click to toggle)
haskell-crypto-random 0.0.9-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 96 kB
  • sloc: haskell: 401; ansic: 52; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- |
-- Module      : Crypto.Random.Entropy.Source
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : Good
--
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 ()