1 use libc::*;
2 
3 use *;
4 
5 #[cfg(target_pointer_width = "64")]
6 pub type BN_ULONG = c_ulonglong;
7 #[cfg(target_pointer_width = "32")]
8 pub type BN_ULONG = c_uint;
9 
10 extern "C" {
BN_CTX_new() -> *mut BN_CTX11     pub fn BN_CTX_new() -> *mut BN_CTX;
BN_CTX_free(ctx: *mut BN_CTX)12     pub fn BN_CTX_free(ctx: *mut BN_CTX);
BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int13     pub fn BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int;
BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int14     pub fn BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int;
BN_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int15     pub fn BN_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int;
BN_pseudo_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int16     pub fn BN_pseudo_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int;
BN_new() -> *mut BIGNUM17     pub fn BN_new() -> *mut BIGNUM;
BN_num_bits(bn: *const BIGNUM) -> c_int18     pub fn BN_num_bits(bn: *const BIGNUM) -> c_int;
BN_clear_free(bn: *mut BIGNUM)19     pub fn BN_clear_free(bn: *mut BIGNUM);
BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM20     pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM;
BN_bn2bin(a: *const BIGNUM, to: *mut u8) -> c_int21     pub fn BN_bn2bin(a: *const BIGNUM, to: *mut u8) -> c_int;
BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int22     pub fn BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int23     pub fn BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int;
BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int24     pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int25     pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
BN_set_negative(bn: *mut BIGNUM, n: c_int)26     pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int);
27     #[cfg(ossl110)]
BN_is_negative(b: *const ::BIGNUM) -> c_int28     pub fn BN_is_negative(b: *const ::BIGNUM) -> c_int;
29 
BN_div( dv: *mut BIGNUM, rem: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int30     pub fn BN_div(
31         dv: *mut BIGNUM,
32         rem: *mut BIGNUM,
33         a: *const BIGNUM,
34         b: *const BIGNUM,
35         ctx: *mut BN_CTX,
36     ) -> c_int;
BN_nnmod( rem: *mut BIGNUM, a: *const BIGNUM, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int37     pub fn BN_nnmod(
38         rem: *mut BIGNUM,
39         a: *const BIGNUM,
40         m: *const BIGNUM,
41         ctx: *mut BN_CTX,
42     ) -> c_int;
BN_mod_add( r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int43     pub fn BN_mod_add(
44         r: *mut BIGNUM,
45         a: *const BIGNUM,
46         b: *const BIGNUM,
47         m: *const BIGNUM,
48         ctx: *mut BN_CTX,
49     ) -> c_int;
BN_mod_sub( r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int50     pub fn BN_mod_sub(
51         r: *mut BIGNUM,
52         a: *const BIGNUM,
53         b: *const BIGNUM,
54         m: *const BIGNUM,
55         ctx: *mut BN_CTX,
56     ) -> c_int;
BN_mod_mul( r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int57     pub fn BN_mod_mul(
58         r: *mut BIGNUM,
59         a: *const BIGNUM,
60         b: *const BIGNUM,
61         m: *const BIGNUM,
62         ctx: *mut BN_CTX,
63     ) -> c_int;
BN_mod_sqr( r: *mut BIGNUM, a: *const BIGNUM, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int64     pub fn BN_mod_sqr(
65         r: *mut BIGNUM,
66         a: *const BIGNUM,
67         m: *const BIGNUM,
68         ctx: *mut BN_CTX,
69     ) -> c_int;
70 
BN_mod_word(r: *const BIGNUM, w: BN_ULONG) -> BN_ULONG71     pub fn BN_mod_word(r: *const BIGNUM, w: BN_ULONG) -> BN_ULONG;
BN_div_word(r: *mut BIGNUM, w: BN_ULONG) -> BN_ULONG72     pub fn BN_div_word(r: *mut BIGNUM, w: BN_ULONG) -> BN_ULONG;
BN_mul_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int73     pub fn BN_mul_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
BN_add_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int74     pub fn BN_add_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
BN_sub_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int75     pub fn BN_sub_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int;
BN_set_word(bn: *mut BIGNUM, n: BN_ULONG) -> c_int76     pub fn BN_set_word(bn: *mut BIGNUM, n: BN_ULONG) -> c_int;
77 
BN_cmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int78     pub fn BN_cmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int;
BN_free(bn: *mut BIGNUM)79     pub fn BN_free(bn: *mut BIGNUM);
BN_is_bit_set(a: *const BIGNUM, n: c_int) -> c_int80     pub fn BN_is_bit_set(a: *const BIGNUM, n: c_int) -> c_int;
BN_lshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int81     pub fn BN_lshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int;
BN_lshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int82     pub fn BN_lshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int;
BN_exp(r: *mut BIGNUM, a: *const BIGNUM, p: *const BIGNUM, ctx: *mut BN_CTX) -> c_int83     pub fn BN_exp(r: *mut BIGNUM, a: *const BIGNUM, p: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
84 
BN_mod_exp( r: *mut BIGNUM, a: *const BIGNUM, p: *const BIGNUM, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int85     pub fn BN_mod_exp(
86         r: *mut BIGNUM,
87         a: *const BIGNUM,
88         p: *const BIGNUM,
89         m: *const BIGNUM,
90         ctx: *mut BN_CTX,
91     ) -> c_int;
92 
BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int93     pub fn BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int;
BN_rshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int94     pub fn BN_rshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int;
BN_rshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int95     pub fn BN_rshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int;
BN_bn2hex(a: *const BIGNUM) -> *mut c_char96     pub fn BN_bn2hex(a: *const BIGNUM) -> *mut c_char;
BN_bn2dec(a: *const BIGNUM) -> *mut c_char97     pub fn BN_bn2dec(a: *const BIGNUM) -> *mut c_char;
BN_hex2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int98     pub fn BN_hex2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int;
BN_dec2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int99     pub fn BN_dec2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int;
BN_gcd(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int100     pub fn BN_gcd(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int;
BN_mod_inverse( r: *mut BIGNUM, a: *const BIGNUM, n: *const BIGNUM, ctx: *mut BN_CTX, ) -> *mut BIGNUM101     pub fn BN_mod_inverse(
102         r: *mut BIGNUM,
103         a: *const BIGNUM,
104         n: *const BIGNUM,
105         ctx: *mut BN_CTX,
106     ) -> *mut BIGNUM;
BN_clear(bn: *mut BIGNUM)107     pub fn BN_clear(bn: *mut BIGNUM);
BN_dup(n: *const BIGNUM) -> *mut BIGNUM108     pub fn BN_dup(n: *const BIGNUM) -> *mut BIGNUM;
BN_ucmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int109     pub fn BN_ucmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int;
BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int110     pub fn BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int;
BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int111     pub fn BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int;
112 
BN_generate_prime_ex( r: *mut BIGNUM, bits: c_int, safe: c_int, add: *const BIGNUM, rem: *const BIGNUM, cb: *mut BN_GENCB, ) -> c_int113     pub fn BN_generate_prime_ex(
114         r: *mut BIGNUM,
115         bits: c_int,
116         safe: c_int,
117         add: *const BIGNUM,
118         rem: *const BIGNUM,
119         cb: *mut BN_GENCB,
120     ) -> c_int;
BN_is_prime_ex( p: *const BIGNUM, checks: c_int, ctx: *mut BN_CTX, cb: *mut BN_GENCB, ) -> c_int121     pub fn BN_is_prime_ex(
122         p: *const BIGNUM,
123         checks: c_int,
124         ctx: *mut BN_CTX,
125         cb: *mut BN_GENCB,
126     ) -> c_int;
BN_is_prime_fasttest_ex( p: *const BIGNUM, checks: c_int, ctx: *mut BN_CTX, do_trial_division: c_int, cb: *mut BN_GENCB, ) -> c_int127     pub fn BN_is_prime_fasttest_ex(
128         p: *const BIGNUM,
129         checks: c_int,
130         ctx: *mut BN_CTX,
131         do_trial_division: c_int,
132         cb: *mut BN_GENCB,
133     ) -> c_int;
134 }
135 
136 cfg_if! {
137     if #[cfg(ossl110)] {
138         extern "C" {
139             pub fn BN_get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM;
140             pub fn BN_get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM;
141             pub fn BN_get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM;
142             pub fn BN_get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM;
143             pub fn BN_get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM;
144             pub fn BN_get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM;
145             pub fn BN_get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM;
146             pub fn BN_get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM;
147         }
148     } else {
149         extern "C" {
150             pub fn get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM;
151             pub fn get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM;
152             pub fn get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM;
153             pub fn get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM;
154             pub fn get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM;
155             pub fn get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM;
156             pub fn get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM;
157             pub fn get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM;
158         }
159     }
160 }
161