1 use libc::*;
2 
3 use *;
4 
5 #[repr(C)]
6 #[derive(Copy, Clone)]
7 pub enum point_conversion_form_t {
8     POINT_CONVERSION_COMPRESSED = 2,
9     POINT_CONVERSION_UNCOMPRESSED = 4,
10     POINT_CONVERSION_HYBRID = 6,
11 }
12 
13 pub enum EC_METHOD {}
14 pub enum EC_GROUP {}
15 pub enum EC_POINT {}
16 
17 pub const OPENSSL_EC_NAMED_CURVE: c_int = 1;
18 
19 extern "C" {
20     #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
EC_GF2m_simple_method() -> *const EC_METHOD21     pub fn EC_GF2m_simple_method() -> *const EC_METHOD;
22 
EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP23     pub fn EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP;
24 
EC_GROUP_free(group: *mut EC_GROUP)25     pub fn EC_GROUP_free(group: *mut EC_GROUP);
26 
EC_GROUP_get_order( group: *const EC_GROUP, order: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int27     pub fn EC_GROUP_get_order(
28         group: *const EC_GROUP,
29         order: *mut BIGNUM,
30         ctx: *mut BN_CTX,
31     ) -> c_int;
32 
EC_GROUP_get_cofactor( group: *const EC_GROUP, cofactor: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int33     pub fn EC_GROUP_get_cofactor(
34         group: *const EC_GROUP,
35         cofactor: *mut BIGNUM,
36         ctx: *mut BN_CTX,
37     ) -> c_int;
38 
EC_GROUP_get0_generator(group: *const EC_GROUP) -> *const EC_POINT39     pub fn EC_GROUP_get0_generator(group: *const EC_GROUP) -> *const EC_POINT;
40 
EC_GROUP_get_curve_name(group: *const EC_GROUP) -> c_int41     pub fn EC_GROUP_get_curve_name(group: *const EC_GROUP) -> c_int;
42 
EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int)43     pub fn EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int);
44 
EC_GROUP_get_curve_GFp( group: *const EC_GROUP, p: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int45     pub fn EC_GROUP_get_curve_GFp(
46         group: *const EC_GROUP,
47         p: *mut BIGNUM,
48         a: *mut BIGNUM,
49         b: *mut BIGNUM,
50         ctx: *mut BN_CTX,
51     ) -> c_int;
52 
53     #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
EC_GROUP_get_curve_GF2m( group: *const EC_GROUP, p: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int54     pub fn EC_GROUP_get_curve_GF2m(
55         group: *const EC_GROUP,
56         p: *mut BIGNUM,
57         a: *mut BIGNUM,
58         b: *mut BIGNUM,
59         ctx: *mut BN_CTX,
60     ) -> c_int;
61 
EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int62     pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int;
63 
64     #[cfg(ossl110)]
EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int65     pub fn EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int;
66 
EC_GROUP_new_curve_GFp( p: *const BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX, ) -> *mut EC_GROUP67     pub fn EC_GROUP_new_curve_GFp(
68         p: *const BIGNUM,
69         a: *const BIGNUM,
70         b: *const BIGNUM,
71         ctx: *mut BN_CTX,
72     ) -> *mut EC_GROUP;
73 
74     #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
EC_GROUP_new_curve_GF2m( p: *const BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX, ) -> *mut EC_GROUP75     pub fn EC_GROUP_new_curve_GF2m(
76         p: *const BIGNUM,
77         a: *const BIGNUM,
78         b: *const BIGNUM,
79         ctx: *mut BN_CTX,
80     ) -> *mut EC_GROUP;
81 
EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP82     pub fn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP;
83 
EC_POINT_is_at_infinity(group: *const EC_GROUP, point: *const EC_POINT) -> c_int84     pub fn EC_POINT_is_at_infinity(group: *const EC_GROUP, point: *const EC_POINT) -> c_int;
85 
EC_POINT_is_on_curve( group: *const EC_GROUP, point: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int86     pub fn EC_POINT_is_on_curve(
87         group: *const EC_GROUP,
88         point: *const EC_POINT,
89         ctx: *mut BN_CTX,
90     ) -> c_int;
91 
EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT92     pub fn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT;
93 
EC_POINT_free(point: *mut EC_POINT)94     pub fn EC_POINT_free(point: *mut EC_POINT);
95 
EC_POINT_dup(p: *const EC_POINT, group: *const EC_GROUP) -> *mut EC_POINT96     pub fn EC_POINT_dup(p: *const EC_POINT, group: *const EC_GROUP) -> *mut EC_POINT;
97 
98     #[cfg(ossl111)]
EC_POINT_get_affine_coordinates( group: *const EC_GROUP, p: *const EC_POINT, x: *mut BIGNUM, y: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int99     pub fn EC_POINT_get_affine_coordinates(
100         group: *const EC_GROUP,
101         p: *const EC_POINT,
102         x: *mut BIGNUM,
103         y: *mut BIGNUM,
104         ctx: *mut BN_CTX,
105     ) -> c_int;
106 
EC_POINT_get_affine_coordinates_GFp( group: *const EC_GROUP, p: *const EC_POINT, x: *mut BIGNUM, y: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int107     pub fn EC_POINT_get_affine_coordinates_GFp(
108         group: *const EC_GROUP,
109         p: *const EC_POINT,
110         x: *mut BIGNUM,
111         y: *mut BIGNUM,
112         ctx: *mut BN_CTX,
113     ) -> c_int;
114 
115     #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
EC_POINT_get_affine_coordinates_GF2m( group: *const EC_GROUP, p: *const EC_POINT, x: *mut BIGNUM, y: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int116     pub fn EC_POINT_get_affine_coordinates_GF2m(
117         group: *const EC_GROUP,
118         p: *const EC_POINT,
119         x: *mut BIGNUM,
120         y: *mut BIGNUM,
121         ctx: *mut BN_CTX,
122     ) -> c_int;
123 
EC_POINT_point2oct( group: *const EC_GROUP, p: *const EC_POINT, form: point_conversion_form_t, buf: *mut c_uchar, len: size_t, ctx: *mut BN_CTX, ) -> size_t124     pub fn EC_POINT_point2oct(
125         group: *const EC_GROUP,
126         p: *const EC_POINT,
127         form: point_conversion_form_t,
128         buf: *mut c_uchar,
129         len: size_t,
130         ctx: *mut BN_CTX,
131     ) -> size_t;
132 
EC_POINT_oct2point( group: *const EC_GROUP, p: *mut EC_POINT, buf: *const c_uchar, len: size_t, ctx: *mut BN_CTX, ) -> c_int133     pub fn EC_POINT_oct2point(
134         group: *const EC_GROUP,
135         p: *mut EC_POINT,
136         buf: *const c_uchar,
137         len: size_t,
138         ctx: *mut BN_CTX,
139     ) -> c_int;
140 
EC_POINT_add( group: *const EC_GROUP, r: *mut EC_POINT, a: *const EC_POINT, b: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int141     pub fn EC_POINT_add(
142         group: *const EC_GROUP,
143         r: *mut EC_POINT,
144         a: *const EC_POINT,
145         b: *const EC_POINT,
146         ctx: *mut BN_CTX,
147     ) -> c_int;
148 
EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int149     pub fn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int;
150 
EC_POINT_cmp( group: *const EC_GROUP, a: *const EC_POINT, b: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int151     pub fn EC_POINT_cmp(
152         group: *const EC_GROUP,
153         a: *const EC_POINT,
154         b: *const EC_POINT,
155         ctx: *mut BN_CTX,
156     ) -> c_int;
157 
EC_POINT_mul( group: *const EC_GROUP, r: *mut EC_POINT, n: *const BIGNUM, q: *const EC_POINT, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int158     pub fn EC_POINT_mul(
159         group: *const EC_GROUP,
160         r: *mut EC_POINT,
161         n: *const BIGNUM,
162         q: *const EC_POINT,
163         m: *const BIGNUM,
164         ctx: *mut BN_CTX,
165     ) -> c_int;
166 
EC_KEY_new() -> *mut EC_KEY167     pub fn EC_KEY_new() -> *mut EC_KEY;
168 
EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY169     pub fn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY;
170 
EC_KEY_free(key: *mut EC_KEY)171     pub fn EC_KEY_free(key: *mut EC_KEY);
172 
EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY173     pub fn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY;
174 
EC_KEY_up_ref(key: *mut EC_KEY) -> c_int175     pub fn EC_KEY_up_ref(key: *mut EC_KEY) -> c_int;
176 
EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP177     pub fn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP;
178 
EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int179     pub fn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int;
180 
EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM181     pub fn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM;
182 
EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int183     pub fn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int;
184 
EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT185     pub fn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT;
186 
EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int187     pub fn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int;
188 
EC_KEY_generate_key(key: *mut EC_KEY) -> c_int189     pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int;
190 
EC_KEY_check_key(key: *const EC_KEY) -> c_int191     pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int;
192 
EC_KEY_set_public_key_affine_coordinates( key: *mut EC_KEY, x: *mut BIGNUM, y: *mut BIGNUM, ) -> c_int193     pub fn EC_KEY_set_public_key_affine_coordinates(
194         key: *mut EC_KEY,
195         x: *mut BIGNUM,
196         y: *mut BIGNUM,
197     ) -> c_int;
198 }
199 
200 cfg_if! {
201     if #[cfg(any(ossl110, libressl280))] {
202         pub enum ECDSA_SIG {}
203     } else {
204         #[repr(C)]
205         pub struct ECDSA_SIG {
206             pub r: *mut BIGNUM,
207             pub s: *mut BIGNUM,
208         }
209     }
210 }
211 
212 extern "C" {
ECDSA_SIG_new() -> *mut ECDSA_SIG213     pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG;
214 
ECDSA_SIG_free(sig: *mut ECDSA_SIG)215     pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG);
216 
217     #[cfg(any(ossl110, libressl273))]
ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM)218     pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM);
219 
220     #[cfg(any(ossl110, libressl273))]
ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int221     pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int;
222 
ECDSA_do_sign( dgst: *const c_uchar, dgst_len: c_int, eckey: *mut EC_KEY, ) -> *mut ECDSA_SIG223     pub fn ECDSA_do_sign(
224         dgst: *const c_uchar,
225         dgst_len: c_int,
226         eckey: *mut EC_KEY,
227     ) -> *mut ECDSA_SIG;
228 
ECDSA_do_verify( dgst: *const c_uchar, dgst_len: c_int, sig: *const ECDSA_SIG, eckey: *mut EC_KEY, ) -> c_int229     pub fn ECDSA_do_verify(
230         dgst: *const c_uchar,
231         dgst_len: c_int,
232         sig: *const ECDSA_SIG,
233         eckey: *mut EC_KEY,
234     ) -> c_int;
235 
d2i_ECDSA_SIG( sig: *mut *mut ECDSA_SIG, inp: *mut *const c_uchar, length: c_long, ) -> *mut ECDSA_SIG236     pub fn d2i_ECDSA_SIG(
237         sig: *mut *mut ECDSA_SIG,
238         inp: *mut *const c_uchar,
239         length: c_long,
240     ) -> *mut ECDSA_SIG;
241 
i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int242     pub fn i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int;
243 }
244