{-# LANGUAGE CApiFFI #-}
module Botan.Bindings.RNG where
import Botan.Bindings.Prelude
data {-# CTYPE "botan/ffi.h" "struct botan_rng_struct" #-} BotanRNGStruct
newtype {-# CTYPE "botan/ffi.h" "botan_rng_t" #-} BotanRNG
= MkBotanRNG { BotanRNG -> Ptr BotanRNGStruct
runBotanRNG :: Ptr BotanRNGStruct }
deriving newtype (BotanRNG -> BotanRNG -> Bool
(BotanRNG -> BotanRNG -> Bool)
-> (BotanRNG -> BotanRNG -> Bool) -> Eq BotanRNG
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotanRNG -> BotanRNG -> Bool
== :: BotanRNG -> BotanRNG -> Bool
$c/= :: BotanRNG -> BotanRNG -> Bool
/= :: BotanRNG -> BotanRNG -> Bool
Eq, Eq BotanRNG
Eq BotanRNG
-> (BotanRNG -> BotanRNG -> Ordering)
-> (BotanRNG -> BotanRNG -> Bool)
-> (BotanRNG -> BotanRNG -> Bool)
-> (BotanRNG -> BotanRNG -> Bool)
-> (BotanRNG -> BotanRNG -> Bool)
-> (BotanRNG -> BotanRNG -> BotanRNG)
-> (BotanRNG -> BotanRNG -> BotanRNG)
-> Ord BotanRNG
BotanRNG -> BotanRNG -> Bool
BotanRNG -> BotanRNG -> Ordering
BotanRNG -> BotanRNG -> BotanRNG
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BotanRNG -> BotanRNG -> Ordering
compare :: BotanRNG -> BotanRNG -> Ordering
$c< :: BotanRNG -> BotanRNG -> Bool
< :: BotanRNG -> BotanRNG -> Bool
$c<= :: BotanRNG -> BotanRNG -> Bool
<= :: BotanRNG -> BotanRNG -> Bool
$c> :: BotanRNG -> BotanRNG -> Bool
> :: BotanRNG -> BotanRNG -> Bool
$c>= :: BotanRNG -> BotanRNG -> Bool
>= :: BotanRNG -> BotanRNG -> Bool
$cmax :: BotanRNG -> BotanRNG -> BotanRNG
max :: BotanRNG -> BotanRNG -> BotanRNG
$cmin :: BotanRNG -> BotanRNG -> BotanRNG
min :: BotanRNG -> BotanRNG -> BotanRNG
Ord, Ptr BotanRNG -> IO BotanRNG
Ptr BotanRNG -> Int -> IO BotanRNG
Ptr BotanRNG -> Int -> BotanRNG -> IO ()
Ptr BotanRNG -> BotanRNG -> IO ()
BotanRNG -> Int
(BotanRNG -> Int)
-> (BotanRNG -> Int)
-> (Ptr BotanRNG -> Int -> IO BotanRNG)
-> (Ptr BotanRNG -> Int -> BotanRNG -> IO ())
-> (forall b. Ptr b -> Int -> IO BotanRNG)
-> (forall b. Ptr b -> Int -> BotanRNG -> IO ())
-> (Ptr BotanRNG -> IO BotanRNG)
-> (Ptr BotanRNG -> BotanRNG -> IO ())
-> Storable BotanRNG
forall b. Ptr b -> Int -> IO BotanRNG
forall b. Ptr b -> Int -> BotanRNG -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: BotanRNG -> Int
sizeOf :: BotanRNG -> Int
$calignment :: BotanRNG -> Int
alignment :: BotanRNG -> Int
$cpeekElemOff :: Ptr BotanRNG -> Int -> IO BotanRNG
peekElemOff :: Ptr BotanRNG -> Int -> IO BotanRNG
$cpokeElemOff :: Ptr BotanRNG -> Int -> BotanRNG -> IO ()
pokeElemOff :: Ptr BotanRNG -> Int -> BotanRNG -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO BotanRNG
peekByteOff :: forall b. Ptr b -> Int -> IO BotanRNG
$cpokeByteOff :: forall b. Ptr b -> Int -> BotanRNG -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> BotanRNG -> IO ()
$cpeek :: Ptr BotanRNG -> IO BotanRNG
peek :: Ptr BotanRNG -> IO BotanRNG
$cpoke :: Ptr BotanRNG -> BotanRNG -> IO ()
poke :: Ptr BotanRNG -> BotanRNG -> IO ()
Storable)
foreign import capi safe "botan/ffi.h &botan_rng_destroy"
botan_rng_destroy
:: FinalizerPtr BotanRNGStruct
pattern BOTAN_RNG_TYPE_SYSTEM
, BOTAN_RNG_TYPE_USER
, BOTAN_RNG_TYPE_USER_THREADSAFE
, BOTAN_RNG_TYPE_RDRAND
:: (Eq a, IsString a) => a
pattern $mBOTAN_RNG_TYPE_SYSTEM :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_RNG_TYPE_SYSTEM :: forall a. (Eq a, IsString a) => a
BOTAN_RNG_TYPE_SYSTEM = "system"
pattern $mBOTAN_RNG_TYPE_USER :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_RNG_TYPE_USER :: forall a. (Eq a, IsString a) => a
BOTAN_RNG_TYPE_USER = "user"
pattern $mBOTAN_RNG_TYPE_USER_THREADSAFE :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_RNG_TYPE_USER_THREADSAFE :: forall a. (Eq a, IsString a) => a
BOTAN_RNG_TYPE_USER_THREADSAFE = "user-threadsafe"
pattern $mBOTAN_RNG_TYPE_RDRAND :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_RNG_TYPE_RDRAND :: forall a. (Eq a, IsString a) => a
BOTAN_RNG_TYPE_RDRAND = "rdrand"
foreign import capi safe "botan/ffi.h botan_rng_init"
botan_rng_init
:: Ptr BotanRNG
-> ConstPtr CChar
-> IO CInt
type BotanRNGGetCallback ctx
= Ptr ctx
-> Ptr Word8
-> CSize
-> IO CInt
foreign import ccall "wrapper"
mallocBotanRNGGetCallbackFunPtr
:: BotanRNGGetCallback ctx
-> IO (FunPtr (BotanRNGGetCallback ctx))
type BotanRNGAddEntropyCallback ctx
= Ptr ctx
-> ConstPtr Word8
-> CSize
-> IO CInt
foreign import ccall "wrapper"
mallocBotanRNGAddEntropyCallbackFunPtr
:: BotanRNGAddEntropyCallback ctx
-> IO (FunPtr (BotanRNGAddEntropyCallback ctx))
type BotanRNGDestroyCallback ctx
= Ptr ctx
-> IO ()
foreign import ccall "wrapper"
mallocBotanRNGDestroyCallbackFunPtr
:: BotanRNGDestroyCallback ctx
-> IO (FunPtr (BotanRNGDestroyCallback ctx))
foreign import capi safe "botan/ffi.h botan_rng_init_custom"
botan_rng_init_custom
:: Ptr BotanRNG
-> ConstPtr CChar
-> Ptr ctx
-> FunPtr (BotanRNGGetCallback ctx)
-> FunPtr (BotanRNGAddEntropyCallback ctx)
-> FunPtr (BotanRNGDestroyCallback ctx)
-> IO CInt
foreign import capi safe "botan/ffi.h botan_rng_get"
botan_rng_get
:: BotanRNG
-> Ptr Word8
-> CSize
-> IO CInt
foreign import capi safe "botan/ffi.h botan_system_rng_get"
botan_system_rng_get
:: Ptr Word8
-> CSize
-> IO CInt
foreign import capi safe "botan/ffi.h botan_rng_reseed"
botan_rng_reseed
:: BotanRNG
-> CSize
-> IO CInt
foreign import capi safe "botan/ffi.h botan_rng_reseed_from_rng"
botan_rng_reseed_from_rng
:: BotanRNG
-> BotanRNG
-> CSize
-> IO CInt
foreign import capi safe "botan/ffi.h botan_rng_add_entropy"
botan_rng_add_entropy
:: BotanRNG
-> ConstPtr Word8
-> CSize
-> IO CInt