Botan 2.19.3
Crypto and TLS for C&
|
#include <botan/ffi.h>
#include <botan/internal/ffi_util.h>
#include <botan/internal/ffi_rng.h>
#include <botan/internal/ffi_mp.h>
#include <botan/reducer.h>
#include <botan/numthry.h>
#include <botan/divide.h>
Go to the source code of this file.
int botan_mp_add | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 139 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_add_u32 | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
uint32_t | y | ||
) |
Definition at line 159 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_clear | ( | botan_mp_t | mp | ) |
Set the MPI to zero
Definition at line 31 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::clear().
int botan_mp_clear_bit | ( | botan_mp_t | n, |
size_t | bit | ||
) |
Clear the specified bit
Definition at line 297 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::clear_bit().
int botan_mp_cmp | ( | int * | result, |
const botan_mp_t | x_w, | ||
const botan_mp_t | y_w | ||
) |
Definition at line 220 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::BigInt::cmp(), and Botan_FFI::safe_get().
int botan_mp_destroy | ( | botan_mp_t | mp | ) |
Destroy (deallocate) an MPI
Definition at line 134 of file ffi_mp.cpp.
References BOTAN_FFI_CHECKED_DELETE.
int botan_mp_div | ( | botan_mp_t | quotient, |
botan_mp_t | remainder, | ||
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 189 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan_FFI::safe_get(), and Botan::vartime_divide().
int botan_mp_equal | ( | const botan_mp_t | x_w, |
const botan_mp_t | y_w | ||
) |
Definition at line 200 of file ffi_mp.cpp.
References BOTAN_FFI_RETURNING, and Botan_FFI::safe_get().
int botan_mp_flip_sign | ( | botan_mp_t | mp | ) |
Definition at line 89 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::flip_sign().
int botan_mp_from_bin | ( | botan_mp_t | mp, |
const uint8_t | bin[], | ||
size_t | bin_len | ||
) |
Definition at line 94 of file ffi_mp.cpp.
References Botan::BigInt::binary_decode(), and BOTAN_FFI_DO.
int botan_mp_gcd | ( | botan_mp_t | out, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 275 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::gcd(), and Botan_FFI::safe_get().
int botan_mp_get_bit | ( | const botan_mp_t | n, |
size_t | bit | ||
) |
Returns 0 if specified bit of n is not set Returns 1 if specified bit of n is set Returns negative number on error
Definition at line 287 of file ffi_mp.cpp.
References BOTAN_FFI_RETURNING.
int botan_mp_init | ( | botan_mp_t * | mp | ) |
Initialize an MPI
Definition at line 20 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, and Botan_FFI::ffi_guard_thunk().
int botan_mp_is_even | ( | const botan_mp_t | mp | ) |
Definition at line 215 of file ffi_mp.cpp.
References BOTAN_FFI_RETURNING, and Botan::BigInt::is_even().
int botan_mp_is_negative | ( | const botan_mp_t | mp | ) |
Return 1 iff mp is less than 0
Definition at line 79 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::is_negative().
int botan_mp_is_odd | ( | const botan_mp_t | mp | ) |
Definition at line 210 of file ffi_mp.cpp.
References BOTAN_FFI_RETURNING, and Botan::BigInt::is_odd().
int botan_mp_is_positive | ( | const botan_mp_t | mp | ) |
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.
Definition at line 84 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::is_positive().
int botan_mp_is_prime | ( | const botan_mp_t | n, |
botan_rng_t | rng, | ||
size_t | test_prob | ||
) |
Returns 0 if n is not prime Returns 1 if n is prime Returns negative number on error
Definition at line 281 of file ffi_mp.cpp.
References BOTAN_FFI_RETURNING, Botan::is_prime(), and Botan_FFI::safe_get().
int botan_mp_is_zero | ( | const botan_mp_t | mp | ) |
Definition at line 205 of file ffi_mp.cpp.
References BOTAN_FFI_RETURNING, and Botan::BigInt::is_zero().
int botan_mp_lshift | ( | botan_mp_t | out, |
const botan_mp_t | in, | ||
size_t | shift | ||
) |
Definition at line 237 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_mod_inverse | ( | botan_mp_t | out, |
const botan_mp_t | in, | ||
const botan_mp_t | modulus | ||
) |
Definition at line 247 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::inverse_mod(), and Botan_FFI::safe_get().
int botan_mp_mod_mul | ( | botan_mp_t | out, |
const botan_mp_t | x, | ||
const botan_mp_t | y, | ||
const botan_mp_t | modulus | ||
) |
Definition at line 252 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::Modular_Reducer::multiply(), and Botan_FFI::safe_get().
int botan_mp_mul | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 179 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_num_bits | ( | const botan_mp_t | n, |
size_t * | bits | ||
) |
Return the number of significant bits in the MPI
Definition at line 302 of file ffi_mp.cpp.
References Botan::BigInt::bits(), and BOTAN_FFI_DO.
int botan_mp_num_bytes | ( | const botan_mp_t | n, |
size_t * | bytes | ||
) |
Return the number of significant bytes in the MPI
Definition at line 307 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::bytes().
int botan_mp_powmod | ( | botan_mp_t | out, |
const botan_mp_t | base, | ||
const botan_mp_t | exponent, | ||
const botan_mp_t | modulus | ||
) |
Definition at line 231 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::power_mod(), and Botan_FFI::safe_get().
int botan_mp_rand_bits | ( | botan_mp_t | rand_out, |
botan_rng_t | rng, | ||
size_t | bits | ||
) |
Definition at line 260 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::RandomNumberGenerator::randomize(), and Botan_FFI::safe_get().
int botan_mp_rand_range | ( | botan_mp_t | rand_out, |
botan_rng_t | rng, | ||
const botan_mp_t | lower, | ||
const botan_mp_t | upper | ||
) |
Definition at line 266 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan::BigInt::random_integer(), and Botan_FFI::safe_get().
int botan_mp_rshift | ( | botan_mp_t | out, |
const botan_mp_t | in, | ||
size_t | shift | ||
) |
Definition at line 242 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_set_bit | ( | botan_mp_t | n, |
size_t | bit | ||
) |
Set the specified bit
Definition at line 292 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::set_bit().
int botan_mp_set_from_int | ( | botan_mp_t | mp, |
int | initial_value | ||
) |
Set the MPI value from an int
Definition at line 36 of file ffi_mp.cpp.
References BOTAN_FFI_DO.
int botan_mp_set_from_mp | ( | botan_mp_t | dest, |
const botan_mp_t | source | ||
) |
Set the MPI value from another MP object
Definition at line 74 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_set_from_radix_str | ( | botan_mp_t | dest, |
const char * | str, | ||
size_t | radix | ||
) |
Set the MPI value from a string with arbitrary radix. For arbitrary being 10 or 16.
Definition at line 56 of file ffi_mp.cpp.
References BOTAN_FFI_DO, BOTAN_FFI_ERROR_NOT_IMPLEMENTED, Botan::cast_char_ptr_to_uint8(), Botan::BigInt::Decimal, and Botan::BigInt::Hexadecimal.
int botan_mp_set_from_str | ( | botan_mp_t | dest, |
const char * | str | ||
) |
int botan_mp_sub | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 149 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_sub_u32 | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
uint32_t | y | ||
) |
Definition at line 169 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan_FFI::safe_get().
int botan_mp_swap | ( | botan_mp_t | x_w, |
botan_mp_t | y_w | ||
) |
Definition at line 225 of file ffi_mp.cpp.
References BOTAN_FFI_DO, Botan_FFI::safe_get(), and Botan::BigInt::swap().
int botan_mp_to_bin | ( | const botan_mp_t | mp, |
uint8_t | vec[] | ||
) |
Definition at line 120 of file ffi_mp.cpp.
References Botan::BigInt::binary_encode(), and BOTAN_FFI_DO.
int botan_mp_to_hex | ( | const botan_mp_t | mp, |
char * | out | ||
) |
Convert the MPI to a hex string. Writes botan_mp_num_bytes(mp)*2 + 1 bytes
Definition at line 99 of file ffi_mp.cpp.
References BOTAN_FFI_DO, and Botan::BigInt::to_hex_string().
int botan_mp_to_str | ( | const botan_mp_t | mp, |
uint8_t | base, | ||
char * | out, | ||
size_t * | out_len | ||
) |
Convert the MPI to a string. Currently base == 10 and base == 16 are supported.
Definition at line 107 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_BAD_PARAMETER, BOTAN_FFI_RETURNING, and Botan_FFI::write_str_output().
int botan_mp_to_uint32 | ( | const botan_mp_t | mp, |
uint32_t * | val | ||
) |
Definition at line 125 of file ffi_mp.cpp.
References BOTAN_FFI_DO, BOTAN_FFI_ERROR_NULL_POINTER, and Botan::BigInt::to_u32bit().