keystore-0.8.1.0: src/Data/KeyStore/KS/CPRNG.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.KeyStore.KS.CPRNG
( CPRNG
, newCPRNG
, testCPRNG
, generateCPRNG
) where
import Crypto.Random
import qualified Data.ByteString as B
newtype CPRNG
= CPRNG { _CPRNG :: SystemRNG }
deriving (CPRG)
newCPRNG :: IO CPRNG
newCPRNG = cprgCreate <$> createEntropyPool
testCPRNG :: CPRNG
testCPRNG = cprgSetReseedThreshold 0 $
cprgCreate $ createTestEntropyPool "Data.CertStore.Tools"
generateCPRNG :: Int -> CPRNG -> (B.ByteString,CPRNG)
generateCPRNG = cprgGenerate