1use crate::ffi_types::c_int;
2
3use crate::ffi_types::{botan_view_bin_fn, botan_view_ctx, botan_view_str_fn};
4
5use crate::ffi_types::c_char;
6use crate::rng::botan_rng_t;
7
8pub enum botan_mp_struct {}
9pub type botan_mp_t = *mut botan_mp_struct;
10
11botan_ffi_functions! {
12
13 pub fn botan_mp_init(mp: *mut botan_mp_t) -> c_int;
14 pub fn botan_mp_destroy(mp: botan_mp_t) -> c_int;
15 pub fn botan_mp_to_hex(mp: botan_mp_t, out: *mut c_char) -> c_int;
16 pub fn botan_mp_to_str(
17 mp: botan_mp_t,
18 base: u8,
19 out: *mut c_char,
20 out_len: *mut usize,
21 ) -> c_int;
22 pub fn botan_mp_clear(mp: botan_mp_t) -> c_int;
23 pub fn botan_mp_set_from_int(mp: botan_mp_t, initial_value: c_int) -> c_int;
24 pub fn botan_mp_set_from_mp(dest: botan_mp_t, source: botan_mp_t) -> c_int;
25 pub fn botan_mp_set_from_str(dest: botan_mp_t, str: *const c_char) -> c_int;
26
27 pub fn botan_mp_set_from_radix_str(dest: botan_mp_t, str: *const c_char, radix: usize)
28 -> c_int;
29 pub fn botan_mp_num_bits(n: botan_mp_t, bits: *mut usize) -> c_int;
30 pub fn botan_mp_num_bytes(n: botan_mp_t, bytes: *mut usize) -> c_int;
31 pub fn botan_mp_to_bin(mp: botan_mp_t, vec: *mut u8) -> c_int;
32 pub fn botan_mp_from_bin(mp: botan_mp_t, vec: *const u8, vec_len: usize) -> c_int;
33 pub fn botan_mp_to_uint32(mp: botan_mp_t, val: *mut u32) -> c_int;
34 pub fn botan_mp_is_positive(mp: botan_mp_t) -> c_int;
35 pub fn botan_mp_is_negative(mp: botan_mp_t) -> c_int;
36 pub fn botan_mp_flip_sign(mp: botan_mp_t) -> c_int;
37 pub fn botan_mp_is_zero(mp: botan_mp_t) -> c_int;
38 pub fn botan_mp_is_odd(mp: botan_mp_t) -> c_int;
39 pub fn botan_mp_is_even(mp: botan_mp_t) -> c_int;
40 pub fn botan_mp_add(result: botan_mp_t, x: botan_mp_t, y: botan_mp_t) -> c_int;
41 pub fn botan_mp_sub(result: botan_mp_t, x: botan_mp_t, y: botan_mp_t) -> c_int;
42 pub fn botan_mp_add_u32(result: botan_mp_t, x: botan_mp_t, y: u32) -> c_int;
43 pub fn botan_mp_sub_u32(result: botan_mp_t, x: botan_mp_t, y: u32) -> c_int;
44 pub fn botan_mp_mul(result: botan_mp_t, x: botan_mp_t, y: botan_mp_t) -> c_int;
45 pub fn botan_mp_div(
46 quotient: botan_mp_t,
47 remainder: botan_mp_t,
48 x: botan_mp_t,
49 y: botan_mp_t,
50 ) -> c_int;
51 pub fn botan_mp_mod_mul(
52 result: botan_mp_t,
53 x: botan_mp_t,
54 y: botan_mp_t,
55 mod_: botan_mp_t,
56 ) -> c_int;
57 pub fn botan_mp_equal(x: botan_mp_t, y: botan_mp_t) -> c_int;
58 pub fn botan_mp_cmp(result: *mut c_int, x: botan_mp_t, y: botan_mp_t) -> c_int;
59 pub fn botan_mp_swap(x: botan_mp_t, y: botan_mp_t) -> c_int;
60 pub fn botan_mp_powmod(
61 out: botan_mp_t,
62 base: botan_mp_t,
63 exponent: botan_mp_t,
64 modulus: botan_mp_t,
65 ) -> c_int;
66 pub fn botan_mp_lshift(out: botan_mp_t, in_: botan_mp_t, shift: usize) -> c_int;
67 pub fn botan_mp_rshift(out: botan_mp_t, in_: botan_mp_t, shift: usize) -> c_int;
68 pub fn botan_mp_mod_inverse(out: botan_mp_t, in_: botan_mp_t, modulus: botan_mp_t) -> c_int;
69 pub fn botan_mp_rand_bits(rand_out: botan_mp_t, rng: botan_rng_t, bits: usize) -> c_int;
70 pub fn botan_mp_rand_range(
71 rand_out: botan_mp_t,
72 rng: botan_rng_t,
73 lower_bound: botan_mp_t,
74 upper_bound: botan_mp_t,
75 ) -> c_int;
76 pub fn botan_mp_gcd(out: botan_mp_t, x: botan_mp_t, y: botan_mp_t) -> c_int;
77 pub fn botan_mp_is_prime(n: botan_mp_t, rng: botan_rng_t, test_prob: usize) -> c_int;
78 pub fn botan_mp_get_bit(n: botan_mp_t, bit: usize) -> c_int;
79 pub fn botan_mp_set_bit(n: botan_mp_t, bit: usize) -> c_int;
80 pub fn botan_mp_clear_bit(n: botan_mp_t, bit: usize) -> c_int;
81
82 #[cfg(botan_ffi_20250829)]
83 pub fn botan_mp_view_hex(mp: botan_mp_t, ctx: botan_view_ctx, view: botan_view_str_fn)
84 -> c_int;
85
86 #[cfg(botan_ffi_20250829)]
87 pub fn botan_mp_view_str(
88 mp: botan_mp_t,
89 radix: u8,
90 ctx: botan_view_ctx,
91 view: botan_view_str_fn,
92 ) -> c_int;
93
94 #[cfg(botan_ffi_20250506)]
95 pub fn botan_mp_view_bin(mp: botan_mp_t, ctx: botan_view_ctx, view: botan_view_bin_fn)
96 -> c_int;
97
98}