1use super::super::*;
2use libc::*;
3
4#[repr(C)]
5#[derive(Copy, Clone)]
6pub enum point_conversion_form_t {
7 POINT_CONVERSION_COMPRESSED = 2,
8 POINT_CONVERSION_UNCOMPRESSED = 4,
9 POINT_CONVERSION_HYBRID = 6,
10}
11
12pub enum EC_METHOD {}
13pub enum EC_GROUP {}
14pub enum EC_POINT {}
15
16extern "C" {
17 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
18 pub fn EC_GF2m_simple_method() -> *const EC_METHOD;
19
20 pub fn EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP;
21
22 pub fn EC_GROUP_free(group: *mut EC_GROUP);
23
24 pub fn EC_GROUP_get_order(
25 group: *const EC_GROUP,
26 order: *mut BIGNUM,
27 ctx: *mut BN_CTX,
28 ) -> c_int;
29
30 pub fn EC_GROUP_get_cofactor(
31 group: *const EC_GROUP,
32 cofactor: *mut BIGNUM,
33 ctx: *mut BN_CTX,
34 ) -> c_int;
35
36 pub fn EC_GROUP_get0_generator(group: *const EC_GROUP) -> *const EC_POINT;
37
38 pub fn EC_GROUP_set_generator(
39 group: *mut EC_GROUP,
40 generator: *const EC_POINT,
41 order: *const BIGNUM,
42 cofactor: *const BIGNUM,
43 ) -> c_int;
44
45 pub fn EC_GROUP_get_curve_name(group: *const EC_GROUP) -> c_int;
46
47 pub fn EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int);
48
49 pub fn EC_GROUP_get_asn1_flag(group: *const EC_GROUP) -> c_int;
50
51 pub fn EC_GROUP_get_curve_GFp(
52 group: *const EC_GROUP,
53 p: *mut BIGNUM,
54 a: *mut BIGNUM,
55 b: *mut BIGNUM,
56 ctx: *mut BN_CTX,
57 ) -> c_int;
58
59 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
60 pub fn EC_GROUP_get_curve_GF2m(
61 group: *const EC_GROUP,
62 p: *mut BIGNUM,
63 a: *mut BIGNUM,
64 b: *mut BIGNUM,
65 ctx: *mut BN_CTX,
66 ) -> c_int;
67
68 pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int;
69
70 #[cfg(ossl110)]
71 pub fn EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int;
72
73 pub fn EC_GROUP_new_curve_GFp(
74 p: *const BIGNUM,
75 a: *const BIGNUM,
76 b: *const BIGNUM,
77 ctx: *mut BN_CTX,
78 ) -> *mut EC_GROUP;
79
80 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
81 pub fn EC_GROUP_new_curve_GF2m(
82 p: *const BIGNUM,
83 a: *const BIGNUM,
84 b: *const BIGNUM,
85 ctx: *mut BN_CTX,
86 ) -> *mut EC_GROUP;
87
88 pub fn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP;
89
90 pub fn EC_POINT_is_at_infinity(group: *const EC_GROUP, point: *const EC_POINT) -> c_int;
91
92 pub fn EC_POINT_is_on_curve(
93 group: *const EC_GROUP,
94 point: *const EC_POINT,
95 ctx: *mut BN_CTX,
96 ) -> c_int;
97
98 pub fn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT;
99
100 pub fn EC_POINT_free(point: *mut EC_POINT);
101
102 pub fn EC_POINT_dup(p: *const EC_POINT, group: *const EC_GROUP) -> *mut EC_POINT;
103
104 #[cfg(any(ossl111, boringssl, libressl350))]
105 pub fn EC_POINT_get_affine_coordinates(
106 group: *const EC_GROUP,
107 p: *const EC_POINT,
108 x: *mut BIGNUM,
109 y: *mut BIGNUM,
110 ctx: *mut BN_CTX,
111 ) -> c_int;
112
113 pub fn EC_POINT_get_affine_coordinates_GFp(
114 group: *const EC_GROUP,
115 p: *const EC_POINT,
116 x: *mut BIGNUM,
117 y: *mut BIGNUM,
118 ctx: *mut BN_CTX,
119 ) -> c_int;
120
121 pub fn EC_POINT_set_affine_coordinates_GFp(
122 group: *const EC_GROUP,
123 p: *mut EC_POINT,
124 x: *const BIGNUM,
125 y: *const BIGNUM,
126 ctx: *mut BN_CTX,
127 ) -> c_int;
128
129 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
130 pub fn EC_POINT_get_affine_coordinates_GF2m(
131 group: *const EC_GROUP,
132 p: *const EC_POINT,
133 x: *mut BIGNUM,
134 y: *mut BIGNUM,
135 ctx: *mut BN_CTX,
136 ) -> c_int;
137
138 pub fn EC_POINT_point2oct(
139 group: *const EC_GROUP,
140 p: *const EC_POINT,
141 form: point_conversion_form_t,
142 buf: *mut c_uchar,
143 len: size_t,
144 ctx: *mut BN_CTX,
145 ) -> size_t;
146
147 pub fn EC_POINT_oct2point(
148 group: *const EC_GROUP,
149 p: *mut EC_POINT,
150 buf: *const c_uchar,
151 len: size_t,
152 ctx: *mut BN_CTX,
153 ) -> c_int;
154
155 pub fn EC_POINT_point2hex(
156 group: *const EC_GROUP,
157 p: *const EC_POINT,
158 form: point_conversion_form_t,
159 ctx: *mut BN_CTX,
160 ) -> *mut c_char;
161
162 pub fn EC_POINT_hex2point(
163 group: *const EC_GROUP,
164 s: *const c_char,
165 p: *mut EC_POINT,
166 ctx: *mut BN_CTX,
167 ) -> *mut EC_POINT;
168
169 pub fn EC_POINT_add(
170 group: *const EC_GROUP,
171 r: *mut EC_POINT,
172 a: *const EC_POINT,
173 b: *const EC_POINT,
174 ctx: *mut BN_CTX,
175 ) -> c_int;
176
177 pub fn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int;
178
179 pub fn EC_POINT_cmp(
180 group: *const EC_GROUP,
181 a: *const EC_POINT,
182 b: *const EC_POINT,
183 ctx: *mut BN_CTX,
184 ) -> c_int;
185
186 pub fn EC_POINT_mul(
187 group: *const EC_GROUP,
188 r: *mut EC_POINT,
189 n: *const BIGNUM,
190 q: *const EC_POINT,
191 m: *const BIGNUM,
192 ctx: *mut BN_CTX,
193 ) -> c_int;
194
195 pub fn EC_KEY_new() -> *mut EC_KEY;
196
197 pub fn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY;
198
199 pub fn EC_KEY_free(key: *mut EC_KEY);
200
201 pub fn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY;
202
203 pub fn EC_KEY_up_ref(key: *mut EC_KEY) -> c_int;
204
205 pub fn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP;
206
207 pub fn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int;
208
209 pub fn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM;
210
211 pub fn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int;
212
213 pub fn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT;
214
215 pub fn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int;
216
217 pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int;
218
219 pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int;
220
221 pub fn EC_KEY_set_public_key_affine_coordinates(
222 key: *mut EC_KEY,
223 x: *mut BIGNUM,
224 y: *mut BIGNUM,
225 ) -> c_int;
226}
227
228cfg_if! {
229 if #[cfg(any(ossl110, libressl280))] {
230 pub enum ECDSA_SIG {}
231 } else {
232 #[repr(C)]
233 pub struct ECDSA_SIG {
234 pub r: *mut BIGNUM,
235 pub s: *mut BIGNUM,
236 }
237 }
238}
239
240extern "C" {
241 pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG;
242
243 pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG);
244
245 #[cfg(any(ossl110, libressl273))]
246 pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM);
247
248 #[cfg(any(ossl110, libressl273))]
249 pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int;
250
251 pub fn ECDSA_do_sign(
252 dgst: *const c_uchar,
253 dgst_len: c_int,
254 eckey: *mut EC_KEY,
255 ) -> *mut ECDSA_SIG;
256
257 pub fn ECDSA_do_verify(
258 dgst: *const c_uchar,
259 dgst_len: c_int,
260 sig: *const ECDSA_SIG,
261 eckey: *mut EC_KEY,
262 ) -> c_int;
263
264 pub fn d2i_ECDSA_SIG(
265 sig: *mut *mut ECDSA_SIG,
266 inp: *mut *const c_uchar,
267 length: c_long,
268 ) -> *mut ECDSA_SIG;
269
270 pub fn i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int;
271}
272