|
Botan 3.12.0
Crypto and TLS for C&
|
#include <botan/ffi.h>#include <botan/assert.h>#include <botan/numthry.h>#include <botan/internal/barrett.h>#include <botan/internal/divide.h>#include <botan/internal/ffi_mp.h>#include <botan/internal/ffi_rng.h>#include <botan/internal/ffi_util.h>#include <botan/internal/mem_utils.h>#include <botan/internal/mod_inv.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 153 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 173 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 227 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
| int botan_mp_destroy | ( | botan_mp_t | mp | ) |
Destroy (deallocate) an MPI
Definition at line 149 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 203 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 211 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 72 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 76 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_mp_gcd | ( | botan_mp_t | out, |
| const botan_mp_t | x, | ||
| const botan_mp_t | y ) |
Definition at line 274 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 282 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
| int botan_mp_init | ( | botan_mp_t * | mp | ) |
Initialize an MPI
Definition at line 24 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, Botan_FFI::ffi_guard_thunk(), and Botan_FFI::ffi_new_object().
| int botan_mp_is_even | ( | const botan_mp_t | mp | ) |
Definition at line 223 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 64 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT.
| int botan_mp_is_odd | ( | const botan_mp_t | mp | ) |
Definition at line 219 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 68 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 278 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 215 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 244 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 252 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan::inverse_mod_general(), Botan_FFI::safe_get(), and Botan::BigInt::zero().
| 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 258 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, Botan::Barrett_Reduction::for_secret_modulus(), 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 193 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 294 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and 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 301 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and 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 239 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 265 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 269 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 248 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 39 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 60 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 47 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and Botan::BigInt::from_radix_digits().
| int botan_mp_set_from_str | ( | botan_mp_t | dest, |
| const char * | str ) |
Set the MPI value from a string
Definition at line 43 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 163 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 183 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 234 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 128 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_mp_to_hex | ( | botan_mp_t | mp, |
| char * | out ) |
Convert the MPI to a hex string. Writes up to botan_mp_num_bytes(mp)*2 + 5 bytes
Prefer botan_mp_view_hex
Definition at line 83 of file ffi_mp.cpp.
References BOTAN_ASSERT_NOMSG, BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_mp_to_str | ( | botan_mp_t | mp, |
| uint8_t | radix, | ||
| char * | out, | ||
| size_t * | out_len ) |
Convert the MPI to a string. Currently radix == 10 and radix == 16 are supported.
Definition at line 104 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 142 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_mp_view_bin | ( | const botan_mp_t | mp, |
| botan_view_ctx | ctx, | ||
| botan_view_bin_fn | view ) |
Definition at line 135 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().
| int botan_mp_view_hex | ( | botan_mp_t | mp, |
| botan_view_ctx | ctx, | ||
| botan_view_str_fn | view ) |
View the hex string encoding of the MPI.
Definition at line 97 of file ffi_mp.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().
| int botan_mp_view_str | ( | botan_mp_t | mp, |
| uint8_t | radix, | ||
| botan_view_ctx | ctx, | ||
| botan_view_str_fn | view ) |
View the MPI as a radix-N integer. Currently only radix 10 and radix 16 are supported
Definition at line 116 of file ffi_mp.cpp.
References BOTAN_FFI_ERROR_BAD_PARAMETER, BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().