| Copyright | (c) 2023-2024 Apotheca Labs (c) 2024-2025 Haskell Foundation |
|---|---|
| License | BSD-3-Clause |
| Maintainer | joris@well-typed.com, leo@apotheca.io |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | GHC2021 |
Botan.Bindings.MPI
Description
Synopsis
- data BotanMPStruct
- newtype BotanMP = MkBotanMP {
- ptr :: Ptr BotanMPStruct
- botan_mp_destroy :: FinalizerPtr BotanMPStruct
- botan_mp_init :: Ptr BotanMP -> IO CInt
- botan_mp_to_hex :: BotanMP -> Ptr CChar -> IO CInt
- botan_mp_to_str :: BotanMP -> Word8 -> Ptr CChar -> Ptr CSize -> IO CInt
- botan_mp_clear :: BotanMP -> IO CInt
- botan_mp_set_from_int :: BotanMP -> CInt -> IO CInt
- botan_mp_set_from_mp :: BotanMP -> BotanMP -> IO CInt
- botan_mp_set_from_str :: BotanMP -> ConstPtr CChar -> IO CInt
- botan_mp_set_from_radix_str :: BotanMP -> ConstPtr CChar -> CSize -> IO CInt
- botan_mp_num_bits :: BotanMP -> Ptr CSize -> IO CInt
- botan_mp_num_bytes :: BotanMP -> Ptr CSize -> IO CInt
- botan_mp_to_bin :: BotanMP -> Ptr Word8 -> IO CInt
- botan_mp_from_bin :: BotanMP -> ConstPtr Word8 -> CSize -> IO CInt
- botan_mp_to_uint32 :: BotanMP -> Ptr Word32 -> IO CInt
- botan_mp_is_positive :: BotanMP -> IO CInt
- botan_mp_is_negative :: BotanMP -> IO CInt
- botan_mp_flip_sign :: BotanMP -> IO CInt
- botan_mp_is_zero :: BotanMP -> IO CInt
- botan_mp_add_u32 :: BotanMP -> BotanMP -> Word32 -> IO CInt
- botan_mp_sub_u32 :: BotanMP -> BotanMP -> Word32 -> IO CInt
- botan_mp_add :: BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_sub :: BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_mul :: BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_div :: BotanMP -> BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_mod_mul :: BotanMP -> BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_equal :: BotanMP -> BotanMP -> IO CInt
- botan_mp_cmp :: Ptr CInt -> BotanMP -> BotanMP -> IO CInt
- botan_mp_swap :: BotanMP -> BotanMP -> IO CInt
- botan_mp_powmod :: BotanMP -> BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_lshift :: BotanMP -> BotanMP -> CSize -> IO CInt
- botan_mp_rshift :: BotanMP -> BotanMP -> CSize -> IO CInt
- botan_mp_mod_inverse :: BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_rand_bits :: BotanMP -> BotanRNG -> CSize -> IO CInt
- botan_mp_rand_range :: BotanMP -> BotanRNG -> BotanMP -> BotanMP -> IO CInt
- botan_mp_gcd :: BotanMP -> BotanMP -> BotanMP -> IO CInt
- botan_mp_is_prime :: BotanMP -> BotanRNG -> CSize -> IO CInt
- botan_mp_get_bit :: BotanMP -> CSize -> IO CInt
- botan_mp_set_bit :: BotanMP -> CSize -> IO CInt
- botan_mp_clear_bit :: BotanMP -> CSize -> IO CInt
Documentation
data BotanMPStruct Source #
Opaque MP struct
Botan MP object
Constructors
| MkBotanMP | |
Fields
| |
Instances
| Storable BotanMP Source # | |
Defined in Botan.Bindings.MPI Methods peekElemOff :: Ptr BotanMP -> Int -> IO BotanMP pokeElemOff :: Ptr BotanMP -> Int -> BotanMP -> IO () peekByteOff :: Ptr b -> Int -> IO BotanMP pokeByteOff :: Ptr b -> Int -> BotanMP -> IO () | |
| Eq BotanMP Source # | |
| Ord BotanMP Source # | |
botan_mp_destroy :: FinalizerPtr BotanMPStruct Source #
Destroy (deallocate) an MPI
Arguments
| :: BotanMP | mp |
| -> Ptr CChar | out |
| -> IO CInt |
Convert the MPI to a hex string. Writes botan_mp_num_bytes(mp)*2 + 1 bytes
Arguments
| :: BotanMP | mp |
| -> Word8 | base |
| -> Ptr CChar | out |
| -> Ptr CSize | out_len |
| -> IO CInt |
Convert the MPI to a string. Currently base == 10 and base == 16 are supported.
NOTE: base 16 encoding has an `0x` prefix, base 10 does not.
NOTE: Despite the size ptr, this appears to be returning null-terminated CStrings
botan_mp_set_from_int Source #
Arguments
| :: BotanMP | mp |
| -> CInt | initial_value |
| -> IO CInt |
Set the MPI value from an int
Set the MPI value from another MP object
botan_mp_set_from_str Source #
Set the MPI value from a string
botan_mp_set_from_radix_str Source #
Set the MPI value from a string with arbitrary radix. For arbitrary being 10 or 16.
Arguments
| :: BotanMP | n |
| -> Ptr CSize | bits |
| -> IO CInt |
Return the number of significant bits in the MPI
Arguments
| :: BotanMP | n |
| -> Ptr CSize | bytes |
| -> IO CInt |
Return the number of significant bytes in the MPI
Arguments
| :: BotanMP | mp |
| -> Ptr Word8 | vec[] |
| -> IO CInt |
Convert the MPI to a big-endian binary string. Writes botan_mp_num_bytes to vec
Set an MP to the big-endian binary value
Arguments
| :: BotanMP | mp |
| -> Ptr Word32 | val |
| -> IO CInt |
Convert the MPI to a uint32_t, if possible. Fails if MPI is negative or too large.
Arguments
| :: BotanMP | mp |
| -> IO CInt |
This function should have been named mp_is_non_negative. Returns 1 iff mp is greater than *or equal to* zero. Use botan_mp_is_negative to detect negative numbers, botan_mp_is_zero to check for zero.
Arguments
| :: BotanMP | mp |
| -> IO CInt |
Arguments
| :: BotanMP | mp |
| -> IO CInt |
Returns 0 if x != y Returns 1 if x == y Returns negative number on error
Sets *result to comparison result: -1 if x 0 if x == y, 1 if x y Returns negative number on error or zero on success
Return (base^exponent) % modulus
Returns 0 if n is not prime Returns 1 if n is prime Returns negative number on error
Arguments
| :: BotanMP | n |
| -> CSize | bit |
| -> IO CInt |
Returns 0 if specified bit of n is not set Returns 1 if specified bit of n is set Returns negative number on error