Copyright | © Jeremy Bornstein 2019 |
---|---|
License | Apache 2.0 |
Maintainer | jeremy@bornstein.org |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
The "seed expander" is a facility specified by NIST for generating pseudorandom data given a seed. It is not used in the actual NewHope key exchange and is provided here for completeness/isomorphism with the NewHope C reference library.
This module contains the public interface. Implementation definitions are in the Crypto.NewHope.Internal.SeedExpander module.
- Sample usage
let maxLen' = case maxLen 256 of Right value -> value Left x -> error (show x) let diversifier = case createDiversifier (BSC.pack "12345678") of Right value -> value Left x -> error (show x) let seed = (Internals.makeSeed "32 bytes of seed data go here...") let ctx = case seedexpanderInit seed diversifier maxLen' of Right value -> value Left x -> error (show x) let (ctx', buf) = case seedexpander ctx 16 of Right value -> value Left x r -> error (show x)
Synopsis
- data RNGError
- makeSeed :: Seedable a => a -> Seed
- class Seedable a
- maxLen :: MonadError RNGError m => Word64 -> m MaxLen
- createDiversifier :: MonadError RNGError m => ByteString -> m Diversifier
- seedexpanderInit :: MonadError RNGError m => Seed -> Diversifier -> MaxLen -> m Context
- seedexpander :: MonadError RNGError m => Context -> Word64 -> m (ByteString, Context)
Documentation
Error conditions detected in creation and use of Context
data
Preparing parameters
makeSeed :: Seedable a => a -> Seed Source #
Uses external entropy (precisely 32 bytes) to create a Seed
.
Seeds may be constructed using Strings or ByteStrings as source data.
Instances
Seedable String Source # | |
Defined in Crypto.NewHope.Internals | |
Seedable ByteString Source # | |
Defined in Crypto.NewHope.Internals makeSeed :: ByteString -> Seed Source # |
maxLen :: MonadError RNGError m => Word64 -> m MaxLen Source #
Specifies the maximum number of bytes that a Context
will generate.
createDiversifier :: MonadError RNGError m => ByteString -> m Diversifier Source #
Specifies eight bytes of data for use as part of the seed material to be expanded.
Expanding a seed
seedexpanderInit :: MonadError RNGError m => Seed -> Diversifier -> MaxLen -> m Context Source #
Create a Context
for generation of data.
seedexpander :: MonadError RNGError m => Context -> Word64 -> m (ByteString, Context) Source #
Generate pseudorandom data from the given Context
. The returned
pair contains the requested data and the next Context
to use.