crypton
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

Crypto.Random.Entropy

Description

 
Synopsis

Documentation

getEntropy :: ByteArray byteArray => Int -> IO byteArray Source #

Get some entropy from the system source of entropy

A negative length is an error. alloc would make an empty buffer of it, and the length itself, narrowed for the system call, could come out positive and be written into that buffer.

data EntropyError Source #

The system would not give the entropy it was asked for.

This is the one failure in the library with nothing to fall back on and nothing sensible to return: a key drawn from bytes that are not random is worse than no key. It used to be reported with error and fail, which left a caller no way to tell it from a bug in the library, and no way to say anything useful about it.

Constructors

NoEntropySource

The system offers no source of entropy at all. On Unix that means no getrandom(2), no getentropy(3) and no /dev to read from; a container built from nothing would look like this.

EntropyShort Int Int

The sources between them gave fewer bytes than were asked for, three times over. The two numbers are how many were wanted and how many arrived.

EntropySourceLost String

A source that could be opened once could not be opened again. The string names it.

Instances

Instances details
Eq EntropyError Source # 
Instance details

Defined in Crypto.Random.Entropy.Source

Methods

(==) :: EntropyError -> EntropyError -> Bool

(/=) :: EntropyError -> EntropyError -> Bool

Exception EntropyError Source # 
Instance details

Defined in Crypto.Random.Entropy.Source

Methods

toException :: EntropyError -> SomeException

fromException :: SomeException -> Maybe EntropyError

displayException :: EntropyError -> String

backtraceDesired :: EntropyError -> Bool

Show EntropyError Source # 
Instance details

Defined in Crypto.Random.Entropy.Source

Methods

showsPrec :: Int -> EntropyError -> ShowS

show :: EntropyError -> String

showList :: [EntropyError] -> ShowS