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