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