| License | BSD-style |
|---|---|
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Stability | experimental |
| Portability | Good |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Crypto.Random.Entropy.Unsafe
Description
Synopsis
- replenish :: Int -> [EntropyBackend] -> Ptr Word8 -> IO ()
- data EntropyError
- data EntropyBackend
- supportedBackends :: [IO (Maybe EntropyBackend)]
- gatherBackend :: EntropyBackend -> Ptr Word8 -> Int -> IO Int
Documentation
replenish :: Int -> [EntropyBackend] -> Ptr Word8 -> IO () Source #
Refill the entropy in a buffer
Call each entropy backend in turn until the buffer has been replenished.
Throws EntropyError: NoEntropySource when there is no backend at all,
and EntropyShort when three passes over the backends still leave the
buffer unfilled.
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
| Exception EntropyError Source # | |
Defined in Crypto.Random.Entropy.Source Methods toException :: EntropyError -> SomeException # fromException :: SomeException -> Maybe EntropyError # displayException :: EntropyError -> String # | |
| Show EntropyError Source # | |
Defined in Crypto.Random.Entropy.Source Methods showsPrec :: Int -> EntropyError -> ShowS # show :: EntropyError -> String # showList :: [EntropyError] -> ShowS # | |
| Eq EntropyError Source # | |
Defined in Crypto.Random.Entropy.Source | |
data EntropyBackend Source #
Any Entropy Backend
supportedBackends :: [IO (Maybe EntropyBackend)] Source #
All supported backends, best first.
The system call comes before everything else: it is the kernel's own generator, it needs no descriptor, and it is what the rest of the world reaches for now. The device files are what is left when the system has no such call.
RDRAND is deliberately not here, though it used to be first on x86. A
list like this one is a list of alternatives, and whichever answers
first decides the bytes on its own -- which is the one thing #298 says
RDRAND should not do. Nor does it contribute anywhere else: every
system this builds for already feeds the instruction into the pool the
call above draws from, so asking it again adds nothing. See the note in
cbits/crypton_sysdrg.c.