Botan 3.0.0
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/internal/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 132 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::safe_get(), and y.
int botan_mp_add_u32 | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
uint32_t | y | ||
) |
Definition at line 152 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::safe_get(), and y.
int botan_mp_clear | ( | botan_mp_t | mp | ) |
int botan_mp_clear_bit | ( | botan_mp_t | n, |
size_t | bit | ||
) |
int botan_mp_cmp | ( | int * | result, |
const botan_mp_t | x_w, | ||
const botan_mp_t | y_w | ||
) |
Definition at line 213 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_mp_destroy | ( | botan_mp_t | mp | ) |
Destroy (deallocate) an MPI
Definition at line 127 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 182 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::safe_get(), Botan::vartime_divide(), and y.
int botan_mp_equal | ( | const botan_mp_t | x_w, |
const botan_mp_t | y_w | ||
) |
Definition at line 193 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_mp_flip_sign | ( | botan_mp_t | mp | ) |
Definition at line 83 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_from_bin | ( | botan_mp_t | mp, |
const uint8_t | bin[], | ||
size_t | bin_len | ||
) |
Definition at line 88 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_gcd | ( | botan_mp_t | out, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 268 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan::gcd(), Botan_FFI::safe_get(), and y.
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 280 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 208 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_is_negative | ( | const botan_mp_t | mp | ) |
Return 1 iff mp is less than 0
Definition at line 73 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_is_odd | ( | const botan_mp_t | mp | ) |
Definition at line 203 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 78 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 274 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan::is_prime(), and Botan_FFI::safe_get().
int botan_mp_is_zero | ( | const botan_mp_t | mp | ) |
Definition at line 198 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_lshift | ( | botan_mp_t | out, |
const botan_mp_t | in, | ||
size_t | shift | ||
) |
Definition at line 230 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 240 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 245 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan::Modular_Reducer::multiply(), Botan_FFI::safe_get(), and y.
int botan_mp_mul | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 172 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::safe_get(), and y.
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 295 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 300 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 224 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 253 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 259 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 235 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_mp_set_bit | ( | botan_mp_t | n, |
size_t | bit | ||
) |
int botan_mp_set_from_int | ( | botan_mp_t | mp, |
int | initial_value | ||
) |
Set the MPI value from an int
Definition at line 37 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan::BigInt::from_s32().
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 68 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 49 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, 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 | ||
) |
Set the MPI value from a string
Definition at line 44 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_sub | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
const botan_mp_t | y | ||
) |
Definition at line 142 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::safe_get(), and y.
int botan_mp_sub_u32 | ( | botan_mp_t | result, |
const botan_mp_t | x, | ||
uint32_t | y | ||
) |
Definition at line 162 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::safe_get(), and y.
int botan_mp_swap | ( | botan_mp_t | x_w, |
botan_mp_t | y_w | ||
) |
Definition at line 218 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_mp_to_bin | ( | const botan_mp_t | mp, |
uint8_t | vec[] | ||
) |
Definition at line 113 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 93 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
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 101 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_BAD_PARAMETER, BOTAN_FFI_VISIT, and Botan_FFI::write_str_output().
int botan_mp_to_uint32 | ( | const botan_mp_t | mp, |
uint32_t * | val | ||
) |
Definition at line 118 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.