Copyright | (c) Leo D 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | leo@apotheca.io |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data BotanRNGStruct
- newtype BotanRNG = MkBotanRNG {}
- botan_rng_destroy :: FinalizerPtr BotanRNGStruct
- pattern BOTAN_RNG_TYPE_SYSTEM :: (Eq a, IsString a) => a
- pattern BOTAN_RNG_TYPE_USER :: (Eq a, IsString a) => a
- pattern BOTAN_RNG_TYPE_USER_THREADSAFE :: (Eq a, IsString a) => a
- pattern BOTAN_RNG_TYPE_RDRAND :: (Eq a, IsString a) => a
- botan_rng_init :: Ptr BotanRNG -> ConstPtr CChar -> IO CInt
- type BotanRNGGetCallback ctx = Ptr ctx -> Ptr Word8 -> CSize -> IO CInt
- mallocBotanRNGGetCallbackFunPtr :: BotanRNGGetCallback ctx -> IO (FunPtr (BotanRNGGetCallback ctx))
- type BotanRNGAddEntropyCallback ctx = Ptr ctx -> ConstPtr Word8 -> CSize -> IO CInt
- mallocBotanRNGAddEntropyCallbackFunPtr :: BotanRNGAddEntropyCallback ctx -> IO (FunPtr (BotanRNGAddEntropyCallback ctx))
- type BotanRNGDestroyCallback ctx = Ptr ctx -> IO ()
- mallocBotanRNGDestroyCallbackFunPtr :: BotanRNGDestroyCallback ctx -> IO (FunPtr (BotanRNGDestroyCallback ctx))
- botan_rng_init_custom :: Ptr BotanRNG -> ConstPtr CChar -> Ptr ctx -> FunPtr (BotanRNGGetCallback ctx) -> FunPtr (BotanRNGAddEntropyCallback ctx) -> FunPtr (BotanRNGDestroyCallback ctx) -> IO CInt
- botan_rng_get :: BotanRNG -> Ptr Word8 -> CSize -> IO CInt
- botan_system_rng_get :: Ptr Word8 -> CSize -> IO CInt
- botan_rng_reseed :: BotanRNG -> CSize -> IO CInt
- botan_rng_reseed_from_rng :: BotanRNG -> BotanRNG -> CSize -> IO CInt
- botan_rng_add_entropy :: BotanRNG -> ConstPtr Word8 -> CSize -> IO CInt
Documentation
data BotanRNGStruct Source #
Opaque RNG struct
Botan RNG object
Instances
Storable BotanRNG Source # | |
Eq BotanRNG Source # | |
Ord BotanRNG Source # | |
Defined in Botan.Bindings.RNG |
botan_rng_destroy :: FinalizerPtr BotanRNGStruct Source #
Frees all resources of the random number generator object
pattern BOTAN_RNG_TYPE_SYSTEM :: (Eq a, IsString a) => a Source #
pattern BOTAN_RNG_TYPE_USER :: (Eq a, IsString a) => a Source #
pattern BOTAN_RNG_TYPE_USER_THREADSAFE :: (Eq a, IsString a) => a Source #
pattern BOTAN_RNG_TYPE_RDRAND :: (Eq a, IsString a) => a Source #
Initialize a random number generator object
rng_type has the possible values:
- "system": system RNG
- "user": userspace RNG
- "user-threadsafe": userspace RNG, with internal locking
- "rdrand": directly read RDRAND
Set rng_type to null to let the library choose some default.
type BotanRNGGetCallback ctx Source #
Callback for getting random bytes from the rng, return 0 for success
mallocBotanRNGGetCallbackFunPtr :: BotanRNGGetCallback ctx -> IO (FunPtr (BotanRNGGetCallback ctx)) Source #
type BotanRNGAddEntropyCallback ctx Source #
Callback for adding entropy to the rng, return 0 for success
mallocBotanRNGAddEntropyCallbackFunPtr :: BotanRNGAddEntropyCallback ctx -> IO (FunPtr (BotanRNGAddEntropyCallback ctx)) Source #
type BotanRNGDestroyCallback ctx Source #
Callback called when rng is destroyed
mallocBotanRNGDestroyCallbackFunPtr :: BotanRNGDestroyCallback ctx -> IO (FunPtr (BotanRNGDestroyCallback ctx)) Source #
botan_rng_init_custom Source #
:: Ptr BotanRNG | rng_out |
-> ConstPtr CChar | rng_name: name of the rng |
-> Ptr ctx | context: an application-specific context passed to the callback functions |
-> FunPtr (BotanRNGGetCallback ctx) | get_cb |
-> FunPtr (BotanRNGAddEntropyCallback ctx) | add_entropy_cb: may be NULL |
-> FunPtr (BotanRNGDestroyCallback ctx) | destroy_cb: may be NULL |
-> IO CInt |
Initialize a custom random number generator from a set of callback functions
:: BotanRNG | rng: rng object |
-> Ptr Word8 | out: output buffer of size out_len |
-> CSize | out_len: number of requested bytes |
-> IO CInt | 0 on success, negative on failure |
Get random bytes from a random number generators
:: Ptr Word8 | out: output buffer of size out_len |
-> CSize | out_len: number of requested bytes |
-> IO CInt | 0 on success, negative on failure |
Get random bytes from system random number generator
:: BotanRNG | rng: rng object |
-> CSize | bits: number of bits to reseed with |
-> IO CInt | 0 on success, a negative value on failure |
Reseed a random number generator
Uses the System_RNG as a seed generator.