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 
EC_GROUP_new_curve_GFp( p: *const BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX, ) -> *mut EC_GROUP64     pub fn EC_GROUP_new_curve_GFp(
65         p: *const BIGNUM,
66         a: *const BIGNUM,
67         b: *const BIGNUM,
68         ctx: *mut BN_CTX,
69     ) -> *mut EC_GROUP;
70 
71     #[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_GROUP72     pub fn EC_GROUP_new_curve_GF2m(
73         p: *const BIGNUM,
74         a: *const BIGNUM,
75         b: *const BIGNUM,
76         ctx: *mut BN_CTX,
77     ) -> *mut EC_GROUP;
78 
EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP79     pub fn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP;
80 
EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT81     pub fn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT;
82 
EC_POINT_free(point: *mut EC_POINT)83     pub fn EC_POINT_free(point: *mut EC_POINT);
84 
EC_POINT_dup( p: *const EC_POINT, group: *const EC_GROUP, ) -> *mut EC_POINT85     pub fn EC_POINT_dup(
86         p: *const EC_POINT,
87         group: *const EC_GROUP,
88     ) -> *mut EC_POINT;
89 
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_int90     pub fn EC_POINT_get_affine_coordinates_GFp(
91         group: *const EC_GROUP,
92         p: *const EC_POINT,
93         x: *mut BIGNUM,
94         y: *mut BIGNUM,
95         ctx: *mut BN_CTX,
96     ) -> c_int;
97 
98     #[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_int99     pub fn EC_POINT_get_affine_coordinates_GF2m(
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_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_t107     pub fn EC_POINT_point2oct(
108         group: *const EC_GROUP,
109         p: *const EC_POINT,
110         form: point_conversion_form_t,
111         buf: *mut c_uchar,
112         len: size_t,
113         ctx: *mut BN_CTX,
114     ) -> size_t;
115 
EC_POINT_oct2point( group: *const EC_GROUP, p: *mut EC_POINT, buf: *const c_uchar, len: size_t, ctx: *mut BN_CTX, ) -> c_int116     pub fn EC_POINT_oct2point(
117         group: *const EC_GROUP,
118         p: *mut EC_POINT,
119         buf: *const c_uchar,
120         len: size_t,
121         ctx: *mut BN_CTX,
122     ) -> c_int;
123 
EC_POINT_add( group: *const EC_GROUP, r: *mut EC_POINT, a: *const EC_POINT, b: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int124     pub fn EC_POINT_add(
125         group: *const EC_GROUP,
126         r: *mut EC_POINT,
127         a: *const EC_POINT,
128         b: *const EC_POINT,
129         ctx: *mut BN_CTX,
130     ) -> c_int;
131 
EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int132     pub fn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int;
133 
EC_POINT_cmp( group: *const EC_GROUP, a: *const EC_POINT, b: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int134     pub fn EC_POINT_cmp(
135         group: *const EC_GROUP,
136         a: *const EC_POINT,
137         b: *const EC_POINT,
138         ctx: *mut BN_CTX,
139     ) -> c_int;
140 
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_int141     pub fn EC_POINT_mul(
142         group: *const EC_GROUP,
143         r: *mut EC_POINT,
144         n: *const BIGNUM,
145         q: *const EC_POINT,
146         m: *const BIGNUM,
147         ctx: *mut BN_CTX,
148     ) -> c_int;
149 
EC_KEY_new() -> *mut EC_KEY150     pub fn EC_KEY_new() -> *mut EC_KEY;
151 
EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY152     pub fn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY;
153 
EC_KEY_free(key: *mut EC_KEY)154     pub fn EC_KEY_free(key: *mut EC_KEY);
155 
EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY156     pub fn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY;
157 
EC_KEY_up_ref(key: *mut EC_KEY) -> c_int158     pub fn EC_KEY_up_ref(key: *mut EC_KEY) -> c_int;
159 
EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP160     pub fn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP;
161 
EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int162     pub fn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int;
163 
EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM164     pub fn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM;
165 
EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int166     pub fn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int;
167 
EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT168     pub fn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT;
169 
EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int170     pub fn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int;
171 
EC_KEY_generate_key(key: *mut EC_KEY) -> c_int172     pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int;
173 
EC_KEY_check_key(key: *const EC_KEY) -> c_int174     pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int;
175 
EC_KEY_set_public_key_affine_coordinates( key: *mut EC_KEY, x: *mut BIGNUM, y: *mut BIGNUM, ) -> c_int176     pub fn EC_KEY_set_public_key_affine_coordinates(
177         key: *mut EC_KEY,
178         x: *mut BIGNUM,
179         y: *mut BIGNUM,
180     ) -> c_int;
181 }
182 
183 cfg_if! {
184     if #[cfg(any(ossl110, libressl280))] {
185         pub enum ECDSA_SIG {}
186     } else {
187         #[repr(C)]
188         pub struct ECDSA_SIG {
189             pub r: *mut BIGNUM,
190             pub s: *mut BIGNUM,
191         }
192     }
193 }
194 
195 extern "C" {
ECDSA_SIG_new() -> *mut ECDSA_SIG196     pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG;
197 
ECDSA_SIG_free(sig: *mut ECDSA_SIG)198     pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG);
199 
200     #[cfg(any(ossl110, libressl273))]
ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM)201     pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM);
202 
203     #[cfg(any(ossl110, libressl273))]
ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int204     pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int;
205 
ECDSA_do_sign( dgst: *const c_uchar, dgst_len: c_int, eckey: *mut EC_KEY, ) -> *mut ECDSA_SIG206     pub fn ECDSA_do_sign(
207         dgst: *const c_uchar,
208         dgst_len: c_int,
209         eckey: *mut EC_KEY,
210     ) -> *mut ECDSA_SIG;
211 
ECDSA_do_verify( dgst: *const c_uchar, dgst_len: c_int, sig: *const ECDSA_SIG, eckey: *mut EC_KEY, ) -> c_int212     pub fn ECDSA_do_verify(
213         dgst: *const c_uchar,
214         dgst_len: c_int,
215         sig: *const ECDSA_SIG,
216         eckey: *mut EC_KEY,
217     ) -> c_int;
218 
d2i_ECDSA_SIG( sig: *mut *mut ECDSA_SIG, inp: *mut *const c_uchar, length: c_long, ) -> *mut ECDSA_SIG219     pub fn d2i_ECDSA_SIG(
220         sig: *mut *mut ECDSA_SIG,
221         inp: *mut *const c_uchar,
222         length: c_long,
223     ) -> *mut ECDSA_SIG;
224 
i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int225     pub fn i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int;
226 }
227