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 BotanMPStruct
- newtype BotanMP = MkBotanMP {}
- 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
Instances
Storable BotanMP Source # | |
Eq BotanMP Source # | |
Ord BotanMP Source # | |
botan_mp_destroy :: FinalizerPtr BotanMPStruct Source #
Destroy (deallocate) an MPI
Convert the MPI to a hex string. Writes botan_mp_num_bytes(mp)*2 + 1 bytes
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 #
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.
Return the number of significant bits in the MPI
Return the number of significant bytes in the MPI
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
Convert the MPI to a uint32_t, if possible. Fails if MPI is negative or too large.
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.
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
Returns 0 if specified bit of n is not set Returns 1 if specified bit of n is set Returns negative number on error