9#include <botan/internal/ffi_util.h>
10#include <botan/internal/ffi_rng.h>
11#include <botan/internal/ffi_mp.h>
12#include <botan/reducer.h>
13#include <botan/numthry.h>
14#include <botan/divide.h>
39 if(initial_value >= 0)
68 const size_t len = strlen(str);
103 std::memcpy(out, hex.c_str(), 1 + hex.size());
111 if(digit_base == 0 || digit_base == 10)
113 else if(digit_base == 16)
163 res +=
static_cast<Botan::word
>(y);
165 res =
safe_get(x) +
static_cast<Botan::word
>(y);
173 res -=
static_cast<Botan::word
>(y);
175 res =
safe_get(x) -
static_cast<Botan::word
>(y);
void binary_decode(const uint8_t buf[], size_t length)
static BigInt random_integer(RandomNumberGenerator &rng, const BigInt &min, const BigInt &max)
uint32_t to_u32bit() const
int32_t cmp(const BigInt &n, bool check_signs=true) const
void binary_encode(uint8_t buf[]) const
std::string to_hex_string() const
BigInt multiply(const BigInt &x, const BigInt &y) const
virtual void randomize(uint8_t output[], size_t length)=0
struct botan_mp_struct * botan_mp_t
struct botan_rng_struct * botan_rng_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_ERROR_NULL_POINTER
@ BOTAN_FFI_ERROR_BAD_PARAMETER
int botan_mp_set_from_int(botan_mp_t mp, int initial_value)
int botan_mp_set_from_mp(botan_mp_t dest, const botan_mp_t source)
int botan_mp_to_bin(const botan_mp_t mp, uint8_t vec[])
int botan_mp_sub(botan_mp_t result, const botan_mp_t x, const botan_mp_t y)
int botan_mp_gcd(botan_mp_t out, const botan_mp_t x, const botan_mp_t y)
int botan_mp_rand_range(botan_mp_t rand_out, botan_rng_t rng, const botan_mp_t lower, const botan_mp_t upper)
int botan_mp_add_u32(botan_mp_t result, const botan_mp_t x, uint32_t y)
int botan_mp_num_bits(const botan_mp_t mp, size_t *bits)
int botan_mp_set_bit(botan_mp_t mp, size_t bit)
int botan_mp_num_bytes(const botan_mp_t mp, size_t *bytes)
int botan_mp_mul(botan_mp_t result, const botan_mp_t x, const botan_mp_t y)
int botan_mp_is_zero(const botan_mp_t mp)
int botan_mp_sub_u32(botan_mp_t result, const botan_mp_t x, uint32_t y)
int botan_mp_is_even(const botan_mp_t mp)
int botan_mp_destroy(botan_mp_t mp)
int botan_mp_mod_mul(botan_mp_t out, const botan_mp_t x, const botan_mp_t y, const botan_mp_t modulus)
int botan_mp_is_prime(const botan_mp_t mp, botan_rng_t rng, size_t test_prob)
int botan_mp_is_positive(const botan_mp_t mp)
int botan_mp_set_from_str(botan_mp_t mp, const char *str)
int botan_mp_init(botan_mp_t *mp_out)
int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng, size_t bits)
int botan_mp_clear_bit(botan_mp_t mp, size_t bit)
int botan_mp_flip_sign(botan_mp_t mp)
int botan_mp_mod_inverse(botan_mp_t out, const botan_mp_t in, const botan_mp_t modulus)
int botan_mp_clear(botan_mp_t mp)
int botan_mp_to_str(const botan_mp_t mp, uint8_t digit_base, char *out, size_t *out_len)
int botan_mp_is_odd(const botan_mp_t mp)
int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, const botan_mp_t x, const botan_mp_t y)
int botan_mp_rshift(botan_mp_t out, const botan_mp_t in, size_t shift)
int botan_mp_powmod(botan_mp_t out, const botan_mp_t base, const botan_mp_t exponent, const botan_mp_t modulus)
int botan_mp_to_uint32(const botan_mp_t mp, uint32_t *val)
int botan_mp_cmp(int *result, const botan_mp_t x_w, const botan_mp_t y_w)
int botan_mp_set_from_radix_str(botan_mp_t mp, const char *str, size_t radix)
int botan_mp_is_negative(const botan_mp_t mp)
int botan_mp_equal(const botan_mp_t x_w, const botan_mp_t y_w)
int botan_mp_to_hex(const botan_mp_t mp, char *out)
int botan_mp_swap(botan_mp_t x_w, botan_mp_t y_w)
int botan_mp_add(botan_mp_t result, const botan_mp_t x, const botan_mp_t y)
int botan_mp_from_bin(botan_mp_t mp, const uint8_t bin[], size_t bin_len)
int botan_mp_lshift(botan_mp_t out, const botan_mp_t in, size_t shift)
int botan_mp_get_bit(const botan_mp_t mp, size_t bit)
#define BOTAN_FFI_DO(T, obj, param, block)
#define BOTAN_FFI_CHECKED_DELETE(o)
#define BOTAN_FFI_RETURNING(T, obj, param, block)
int ffi_guard_thunk(const char *func_name, std::function< int()> thunk)
T & safe_get(botan_struct< T, M > *p)
int write_str_output(uint8_t out[], size_t *out_len, const std::string &str)
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
bool is_prime(const BigInt &n, RandomNumberGenerator &rng, size_t prob, bool is_random)
BigInt gcd(const BigInt &a, const BigInt &b)
void vartime_divide(const BigInt &x, const BigInt &y_arg, BigInt &q_out, BigInt &r_out)
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
const uint8_t * cast_char_ptr_to_uint8(const char *s)