Copyright | Dong Han 2021 |
---|---|
License | BSD |
Maintainer | winterland1989@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Several different RNG types are implemented. Some access hardware RNGs, which are only available on certain platforms. Others are mostly useful in specific situations.
Synopsis
- data RNGType
- data RNG
- newRNG :: HasCallStack => RNGType -> IO RNG
- getRNG :: HasCallStack => IO RNG
- getRandom :: HasCallStack => RNG -> Int -> IO Bytes
- reseedRNG :: HasCallStack => RNG -> Int -> IO ()
- reseedRNGFromRNG :: HasCallStack => RNG -> RNG -> Int -> IO ()
- addEntropyRNG :: HasCallStack => RNG -> Bytes -> IO ()
- withRNG :: RNG -> (BotanStructT -> IO a) -> IO a
RNG
RNG types.
Instances
Eq RNGType Source # | |
Ord RNGType Source # | |
Show RNGType Source # | |
Generic RNGType Source # | |
JSON RNGType Source # | |
Print RNGType Source # | |
Defined in Z.Crypto.RNG toUTF8BuilderP :: Int -> RNGType -> Builder () # | |
type Rep RNGType Source # | |
Defined in Z.Crypto.RNG type Rep RNGType = D1 ('MetaData "RNGType" "Z.Crypto.RNG" "Z-Botan-0.4.0.0-Cymuol1BxyD6d85e6LsrR5" 'False) (C1 ('MetaCons "SystemRNG" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AutoSeededRNG" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ProcessorRNG" 'PrefixI 'False) (U1 :: Type -> Type))) |
Opaque botan RNG type.
Instances
Show RNG Source # | |
Generic RNG Source # | |
Print RNG Source # | |
Defined in Z.Crypto.RNG toUTF8BuilderP :: Int -> RNG -> Builder () # | |
type Rep RNG Source # | |
Defined in Z.Crypto.RNG type Rep RNG = D1 ('MetaData "RNG" "Z.Crypto.RNG" "Z-Botan-0.4.0.0-Cymuol1BxyD6d85e6LsrR5" 'True) (C1 ('MetaCons "RNG" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BotanStruct))) |
newRNG :: HasCallStack => RNGType -> IO RNG Source #
Initialize a random number generator object from the given RNGType
getRNG :: HasCallStack => IO RNG Source #
Get an autoseeded RNG from a global RNG pool divide by haskell capability.
Botan internal use a lock to protect user-space RNG, which may cause contention if shared. This function will fetch an autoseeded RNG from a global RNG pool, which is recommended under concurrent settings.
getRandom :: HasCallStack => RNG -> Int -> IO Bytes Source #
Get random bytes from a random number generator.
reseedRNG :: HasCallStack => RNG -> Int -> IO () Source #
Reseeds the random number generator with bits number of bits from the SystemRNG
.
reseedRNGFromRNG :: HasCallStack => RNG -> RNG -> Int -> IO () Source #
Reseeds the random number generator with bits number of bits from the given source RNG.
addEntropyRNG :: HasCallStack => RNG -> Bytes -> IO () Source #
Adds the provided seed material to the internal RNG state.
This call may be ignored by certain RNG instances (such as ProcessorRNG
or, on some systems, the SystemRNG
).