1use 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 #[cfg(any(ossl110, libressl340))]
27 pub fn BN_bn2binpad(a: *const BIGNUM, to: *mut u8, tolen: c_int) -> c_int;
28 pub fn BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
29 pub fn BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
30 pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
31 pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
32 pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int);
33 #[cfg(any(ossl110, libressl350))]
34 pub fn BN_is_negative(b: *const BIGNUM) -> c_int;
35 #[cfg(any(ossl110, libressl350))]
36 pub fn BN_is_odd(b: *const BIGNUM) -> c_int;
37
38 pub fn BN_div(
39 dv: *mut BIGNUM,
40 rem: *mut BIGNUM,
41 a: *const BIGNUM,
42 b: *const BIGNUM,
43 ctx: *mut BN_CTX,
44 ) -> c_int;
45 pub fn BN_nnmod(
46 rem: *mut BIGNUM,
47 a: *const BIGNUM,
48 m: *const BIGNUM,
49 ctx: *mut BN_CTX,
50 ) -> c_int;
51 pub fn BN_mod_add(
52 r: *mut BIGNUM,
53 a: *const BIGNUM,
54 b: *const BIGNUM,
55 m: *const BIGNUM,
56 ctx: *mut BN_CTX,
57 ) -> c_int;
58 pub fn BN_mod_sub(
59 r: *mut BIGNUM,
60 a: *const BIGNUM,
61 b: *const BIGNUM,
62 m: *const BIGNUM,
63 ctx: *mut BN_CTX,
64 ) -> c_int;
65 pub fn BN_mod_mul(
66 r: *mut BIGNUM,
67 a: *const BIGNUM,
68 b: *const BIGNUM,
69 m: *const BIGNUM,
70 ctx: *mut BN_CTX,
71 ) -> c_int;
72 pub fn BN_mod_sqr(
73 r: *mut BIGNUM,
74 a: *const BIGNUM,
75 m: *const BIGNUM,
76 ctx: *mut BN_CTX,
77 ) -> c_int;
78 pub fn BN_mod_sqrt(
79 ret: *mut BIGNUM,
80 a: *const BIGNUM,
81 p: *const BIGNUM,
82 ctx: *mut BN_CTX,
83 ) -> *mut BIGNUM;
84
85 pub fn BN_mod_word(r: *const BIGNUM, w: BN_ULONG) -> BN_ULONG;
86 pub fn BN_div_word(r: *mut BIGNUM, w: BN_ULONG) -> BN_ULONG;
87 pub fn BN_mul_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
88 pub fn BN_add_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
89 pub fn BN_sub_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
90 pub fn BN_set_word(bn: *mut BIGNUM, n: BN_ULONG) -> c_int;
91
92 pub fn BN_cmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int;
93 pub fn BN_free(bn: *mut BIGNUM);
94 pub fn BN_is_bit_set(a: *const BIGNUM, n: c_int) -> c_int;
95 pub fn BN_lshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int;
96 pub fn BN_lshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int;
97 pub fn BN_exp(r: *mut BIGNUM, a: *const BIGNUM, p: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
98
99 pub fn BN_mod_exp(
100 r: *mut BIGNUM,
101 a: *const BIGNUM,
102 p: *const BIGNUM,
103 m: *const BIGNUM,
104 ctx: *mut BN_CTX,
105 ) -> c_int;
106
107 pub fn BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int;
108 pub fn BN_rshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int;
109 pub fn BN_rshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int;
110 pub fn BN_bn2hex(a: *const BIGNUM) -> *mut c_char;
111 pub fn BN_bn2dec(a: *const BIGNUM) -> *mut c_char;
112 pub fn BN_hex2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int;
113 pub fn BN_dec2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int;
114 pub fn BN_gcd(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
115 pub fn BN_mod_inverse(
116 r: *mut BIGNUM,
117 a: *const BIGNUM,
118 n: *const BIGNUM,
119 ctx: *mut BN_CTX,
120 ) -> *mut BIGNUM;
121 pub fn BN_clear(bn: *mut BIGNUM);
122 pub fn BN_dup(n: *const BIGNUM) -> *mut BIGNUM;
123 pub fn BN_ucmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int;
124 pub fn BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int;
125 pub fn BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int;
126
127 pub fn BN_generate_prime_ex(
128 r: *mut BIGNUM,
129 bits: c_int,
130 safe: c_int,
131 add: *const BIGNUM,
132 rem: *const BIGNUM,
133 cb: *mut BN_GENCB,
134 ) -> c_int;
135 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
136 pub fn BN_is_prime_ex(
137 p: *const BIGNUM,
138 checks: c_int,
139 ctx: *mut BN_CTX,
140 cb: *mut BN_GENCB,
141 ) -> c_int;
142 #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))]
143 pub fn BN_is_prime_fasttest_ex(
144 p: *const BIGNUM,
145 checks: c_int,
146 ctx: *mut BN_CTX,
147 do_trial_division: c_int,
148 cb: *mut BN_GENCB,
149 ) -> c_int;
150}
151
152cfg_if! {
153 if #[cfg(any(ossl110, libressl350))] {
154 extern "C" {
155 pub fn BN_get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM;
156 pub fn BN_get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM;
157 pub fn BN_get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM;
158 pub fn BN_get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM;
159 pub fn BN_get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM;
160 pub fn BN_get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM;
161 pub fn BN_get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM;
162 pub fn BN_get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM;
163 }
164 } else {
165 extern "C" {
166 pub fn get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM;
167 pub fn get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM;
168 pub fn get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM;
169 pub fn get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM;
170 pub fn get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM;
171 pub fn get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM;
172 pub fn get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM;
173 pub fn get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM;
174 }
175 }
176}
177