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