Botan 3.6.1
Crypto and TLS for C&
|
#include <botan/ffi.h>
#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/internal/divide.h>
#include <botan/internal/ffi_mp.h>
#include <botan/internal/ffi_rng.h>
#include <botan/internal/ffi_util.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 116 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 134 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
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 185 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 112 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 161 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 169 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 75 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 79 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 227 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan::gcd(), and Botan_FFI::safe_get().
int botan_mp_get_bit | ( | 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 235 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_init | ( | botan_mp_t * | mp | ) |
Initialize an MPI
Definition at line 21 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 181 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_is_negative | ( | botan_mp_t | mp | ) |
Return 1 iff mp is less than 0
Definition at line 67 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_is_odd | ( | const botan_mp_t | mp | ) |
Definition at line 177 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_is_positive | ( | 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 71 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_is_prime | ( | 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 231 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 173 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 199 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 207 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 211 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 152 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_mp_num_bits | ( | botan_mp_t | n, |
size_t * | bits ) |
Return the number of significant bits in the MPI
Definition at line 247 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_num_bytes | ( | botan_mp_t | n, |
size_t * | bytes ) |
Return the number of significant bytes in the MPI
Definition at line 251 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 194 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 218 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 222 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 203 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, |
botan_mp_t | source ) |
Set the MPI value from another MP object
Definition at line 63 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 45 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 41 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 125 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, 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 143 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_mp_swap | ( | botan_mp_t | x_w, |
botan_mp_t | y_w ) |
Definition at line 189 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 101 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_to_hex | ( | 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 83 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
int botan_mp_to_str | ( | 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 90 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 105 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.