variant_ssl_sys/handwritten/
bn.rs1use super::super::*;
2use libc::*;
3
4extern "C" {
5 pub fn BN_CTX_new() -> *mut BN_CTX;
6 #[cfg(ossl110)]
7 pub fn BN_CTX_secure_new() -> *mut BN_CTX;
8 pub fn BN_CTX_free(ctx: *mut BN_CTX);
9 pub fn BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int;
10 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
11 pub fn BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int;
12 pub fn BN_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int;
13 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
14 pub fn BN_pseudo_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int;
15 pub fn BN_new() -> *mut BIGNUM;
16 #[cfg(ossl110)]
17 pub fn BN_secure_new() -> *mut BIGNUM;
18 #[cfg(ossl110)]
19 pub fn BN_set_flags(b: *mut BIGNUM, n: c_int);
20 #[cfg(ossl110)]
21 pub fn BN_get_flags(b: *const BIGNUM, n: c_int) -> c_int;
22 pub fn BN_num_bits(bn: *const BIGNUM) -> c_int;
23 pub fn BN_clear_free(bn: *mut BIGNUM);
24 pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM;
25 pub fn BN_bn2bin(a: *const BIGNUM, to: *mut u8) -> c_int;
26 pub fn BN_bn2binpad(a: *const BIGNUM, to: *mut u8, tolen: c_int) -> c_int;
27 pub fn BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
28 pub fn BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
29 pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
30 pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
31 pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int);
32 pub fn BN_is_negative(b: *const BIGNUM) -> c_int;
33 pub fn BN_is_odd(b: *const BIGNUM) -> c_int;
34
35 pub fn BN_div(
36 dv: *mut BIGNUM,
37 rem: *mut BIGNUM,
38 a: *const BIGNUM,
39 b: *const BIGNUM,
40 ctx: *mut BN_CTX,
41 ) -> c_int;
42 pub fn BN_nnmod(
43 rem: *mut BIGNUM,
44 a: *const BIGNUM,
45 m: *const BIGNUM,
46 ctx: *mut BN_CTX,
47 ) -> c_int;
48 pub fn BN_mod_add(
49 r: *mut BIGNUM,
50 a: *const BIGNUM,
51 b: *const BIGNUM,
52 m: *const BIGNUM,
53 ctx: *mut BN_CTX,
54 ) -> c_int;
55 pub fn BN_mod_sub(
56 r: *mut BIGNUM,
57 a: *const BIGNUM,
58 b: *const BIGNUM,
59 m: *const BIGNUM,
60 ctx: *mut BN_CTX,
61 ) -> c_int;
62 pub fn BN_mod_mul(
63 r: *mut BIGNUM,
64 a: *const BIGNUM,
65 b: *const BIGNUM,
66 m: *const BIGNUM,
67 ctx: *mut BN_CTX,
68 ) -> c_int;
69 pub fn BN_mod_sqr(
70 r: *mut BIGNUM,
71 a: *const BIGNUM,
72 m: *const BIGNUM,
73 ctx: *mut BN_CTX,
74 ) -> c_int;
75 pub fn BN_mod_sqrt(
76 ret: *mut BIGNUM,
77 a: *const BIGNUM,
78 p: *const BIGNUM,
79 ctx: *mut BN_CTX,
80 ) -> *mut BIGNUM;
81
82 pub fn BN_mod_word(r: *const BIGNUM, w: BN_ULONG) -> BN_ULONG;
83 pub fn BN_div_word(r: *mut BIGNUM, w: BN_ULONG) -> BN_ULONG;
84 pub fn BN_mul_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
85 pub fn BN_add_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
86 pub fn BN_sub_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
87 pub fn BN_set_word(bn: *mut BIGNUM, n: BN_ULONG) -> c_int;
88
89 pub fn BN_cmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int;
90 pub fn BN_free(bn: *mut BIGNUM);
91 pub fn BN_is_bit_set(a: *const BIGNUM, n: c_int) -> c_int;
92 pub fn BN_lshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int;
93 pub fn BN_lshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int;
94 pub fn BN_exp(r: *mut BIGNUM, a: *const BIGNUM, p: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
95
96 pub fn BN_mod_exp(
97 r: *mut BIGNUM,
98 a: *const BIGNUM,
99 p: *const BIGNUM,
100 m: *const BIGNUM,
101 ctx: *mut BN_CTX,
102 ) -> c_int;
103
104 pub fn BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int;
105 pub fn BN_rshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int;
106 pub fn BN_rshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int;
107 pub fn BN_bn2hex(a: *const BIGNUM) -> *mut c_char;
108 pub fn BN_bn2dec(a: *const BIGNUM) -> *mut c_char;
109 pub fn BN_hex2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int;
110 pub fn BN_dec2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int;
111 pub fn BN_gcd(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
112 pub fn BN_mod_inverse(
113 r: *mut BIGNUM,
114 a: *const BIGNUM,
115 n: *const BIGNUM,
116 ctx: *mut BN_CTX,
117 ) -> *mut BIGNUM;
118 pub fn BN_clear(bn: *mut BIGNUM);
119 pub fn BN_dup(n: *const BIGNUM) -> *mut BIGNUM;
120 pub fn BN_ucmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int;
121 pub fn BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int;
122 pub fn BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int;
123
124 pub fn BN_generate_prime_ex(
125 r: *mut BIGNUM,
126 bits: c_int,
127 safe: c_int,
128 add: *const BIGNUM,
129 rem: *const BIGNUM,
130 cb: *mut BN_GENCB,
131 ) -> c_int;
132 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
133 pub fn BN_is_prime_ex(
134 p: *const BIGNUM,
135 checks: c_int,
136 ctx: *mut BN_CTX,
137 cb: *mut BN_GENCB,
138 ) -> c_int;
139 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
140 pub fn BN_is_prime_fasttest_ex(
141 p: *const BIGNUM,
142 checks: c_int,
143 ctx: *mut BN_CTX,
144 do_trial_division: c_int,
145 cb: *mut BN_GENCB,
146 ) -> c_int;
147}
148
149extern "C" {
150 pub fn BN_get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM;
151 pub fn BN_get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM;
152 pub fn BN_get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM;
153 pub fn BN_get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM;
154 pub fn BN_get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM;
155 pub fn BN_get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM;
156 pub fn BN_get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM;
157 pub fn BN_get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM;
158}