| License | BSD-style |
|---|---|
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Stability | experimental |
| Portability | Good |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.Random.Entropy
Description
Synopsis
- getEntropy :: ByteArray byteArray => Int -> IO byteArray
- data EntropyError
- = NoEntropySource
- | EntropyShort Int Int
- | EntropySourceLost String
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 |
| 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
| Eq EntropyError Source # | |
Defined in Crypto.Random.Entropy.Source | |
| Exception EntropyError Source # | |
Defined in Crypto.Random.Entropy.Source Methods toException :: EntropyError -> SomeException fromException :: SomeException -> Maybe EntropyError displayException :: EntropyError -> String backtraceDesired :: EntropyError -> Bool | |
| Show EntropyError Source # | |
Defined in Crypto.Random.Entropy.Source Methods showsPrec :: Int -> EntropyError -> ShowS show :: EntropyError -> String showList :: [EntropyError] -> ShowS | |