]>
Commit | Line | Data |
---|---|---|
35b73a1f | 1 | /* |
4333b89f | 2 | * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved. |
aa8f3d76 | 3 | * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved |
6cc5e19d | 4 | * |
48f4ad77 | 5 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
21dcbebc RS |
6 | * this file except in compliance with the License. You can obtain a copy |
7 | * in the file LICENSE in the source distribution or at | |
8 | * https://www.openssl.org/source/license.html | |
6cc5e19d | 9 | */ |
21dcbebc | 10 | |
ae4186b0 DMSP |
11 | #ifndef OPENSSL_EC_H |
12 | # define OPENSSL_EC_H | |
d86167ec DMSP |
13 | # pragma once |
14 | ||
15 | # include <openssl/macros.h> | |
936c2b9e | 16 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
d86167ec DMSP |
17 | # define HEADER_EC_H |
18 | # endif | |
6cc5e19d | 19 | |
0f113f3e | 20 | # include <openssl/opensslconf.h> |
565b3399 RL |
21 | # include <openssl/types.h> |
22 | ||
23 | # ifdef __cplusplus | |
24 | extern "C" { | |
25 | # endif | |
26 | ||
27 | /* Values for EVP_PKEY_CTX_set_ec_param_enc() */ | |
28 | # define OPENSSL_EC_EXPLICIT_CURVE 0x000 | |
29 | # define OPENSSL_EC_NAMED_CURVE 0x001 | |
30 | ||
31 | int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); | |
32 | int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc); | |
33 | int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int cofactor_mode); | |
34 | int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx); | |
35 | ||
36 | int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX *ctx, int kdf); | |
37 | int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX *ctx); | |
38 | ||
39 | int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); | |
40 | int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); | |
41 | ||
42 | int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); | |
43 | int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); | |
44 | ||
45 | int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, | |
46 | int len); | |
47 | int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); | |
48 | ||
49 | # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) | |
50 | # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) | |
51 | # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) | |
52 | # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) | |
53 | # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) | |
54 | # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) | |
55 | # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) | |
56 | # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) | |
57 | # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) | |
58 | # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) | |
59 | ||
60 | /* KDF types */ | |
61 | # define EVP_PKEY_ECDH_KDF_NONE 1 | |
62 | # define EVP_PKEY_ECDH_KDF_X9_63 2 | |
63 | /* | |
64 | * The old name for EVP_PKEY_ECDH_KDF_X9_63 | |
65 | * The ECDH KDF specification has been mistakenly attributed to ANSI X9.62, | |
66 | * it is actually specified in ANSI X9.63. | |
67 | * This identifier is retained for backwards compatibility | |
68 | */ | |
69 | # define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63 | |
87c9c659 | 70 | |
ba12070f NL |
71 | /** Enum for the point conversion form as defined in X9.62 (ECDSA) |
72 | * for the encoding of a elliptic curve point (x,y) */ | |
3a12ce01 | 73 | typedef enum { |
0f113f3e | 74 | /** the point is encoded as z||x, where the octet z specifies |
ba12070f | 75 | * which solution of the quadratic equation y is */ |
0f113f3e | 76 | POINT_CONVERSION_COMPRESSED = 2, |
91d2728b | 77 | /** the point is encoded as z||x||y, where z is the octet 0x04 */ |
0f113f3e MC |
78 | POINT_CONVERSION_UNCOMPRESSED = 4, |
79 | /** the point is encoded as z||x||y, where the octet z specifies | |
80 | * which solution of the quadratic equation y is */ | |
81 | POINT_CONVERSION_HYBRID = 6 | |
3a12ce01 BM |
82 | } point_conversion_form_t; |
83 | ||
3d34bedf MC |
84 | # ifndef OPENSSL_NO_EC |
85 | # include <openssl/asn1.h> | |
86 | # include <openssl/symhacks.h> | |
87 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 | |
88 | # include <openssl/bn.h> | |
89 | # endif | |
90 | # include <openssl/ecerr.h> | |
91 | ||
92 | # ifndef OPENSSL_ECC_MAX_FIELD_BITS | |
93 | # define OPENSSL_ECC_MAX_FIELD_BITS 661 | |
94 | # endif | |
95 | ||
c0f39ded | 96 | # include <openssl/params.h> |
23ccae80 | 97 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
3a12ce01 | 98 | typedef struct ec_method_st EC_METHOD; |
23ccae80 | 99 | # endif |
60b350a3 | 100 | typedef struct ec_group_st EC_GROUP; |
3a12ce01 | 101 | typedef struct ec_point_st EC_POINT; |
60b350a3 RS |
102 | typedef struct ecpk_parameters_st ECPKPARAMETERS; |
103 | typedef struct ec_parameters_st ECPARAMETERS; | |
3a12ce01 | 104 | |
ba12070f | 105 | /********************************************************************/ |
0f113f3e | 106 | /* EC_METHODs for curves over GF(p) */ |
ba12070f NL |
107 | /********************************************************************/ |
108 | ||
5b5eea4b | 109 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
ba12070f | 110 | /** Returns the basic GFp ec methods which provides the basis for the |
0f113f3e | 111 | * optimized methods. |
ba12070f | 112 | * \return EC_METHOD object |
3a12ce01 | 113 | */ |
5b5eea4b | 114 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_simple_method(void); |
ba12070f NL |
115 | |
116 | /** Returns GFp methods using montgomery multiplication. | |
117 | * \return EC_METHOD object | |
118 | */ | |
5b5eea4b | 119 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_mont_method(void); |
ba12070f NL |
120 | |
121 | /** Returns GFp methods using optimized methods for NIST recommended curves | |
122 | * \return EC_METHOD object | |
123 | */ | |
5b5eea4b | 124 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nist_method(void); |
3a12ce01 | 125 | |
5b5eea4b | 126 | # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 |
04daec86 BM |
127 | /** Returns 64-bit optimized methods for nistp224 |
128 | * \return EC_METHOD object | |
129 | */ | |
5b5eea4b | 130 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp224_method(void); |
3e00b4c9 BM |
131 | |
132 | /** Returns 64-bit optimized methods for nistp256 | |
133 | * \return EC_METHOD object | |
134 | */ | |
5b5eea4b | 135 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp256_method(void); |
3e00b4c9 BM |
136 | |
137 | /** Returns 64-bit optimized methods for nistp521 | |
138 | * \return EC_METHOD object | |
139 | */ | |
5b5eea4b SL |
140 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void); |
141 | # endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */ | |
ba12070f | 142 | |
5b5eea4b | 143 | # ifndef OPENSSL_NO_EC2M |
0f113f3e | 144 | /********************************************************************/ |
ba12070f NL |
145 | /* EC_METHOD for curves over GF(2^m) */ |
146 | /********************************************************************/ | |
147 | ||
0f113f3e | 148 | /** Returns the basic GF2m ec method |
ba12070f | 149 | * \return EC_METHOD object |
7793f30e | 150 | */ |
5b5eea4b | 151 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GF2m_simple_method(void); |
7793f30e | 152 | |
5b5eea4b | 153 | # endif |
3a12ce01 | 154 | |
ba12070f NL |
155 | /********************************************************************/ |
156 | /* EC_GROUP functions */ | |
157 | /********************************************************************/ | |
158 | ||
a9612d6c MC |
159 | /** |
160 | * Creates a new EC_GROUP object | |
a9612d6c | 161 | * \param meth EC_METHOD to use |
ba12070f NL |
162 | * \return newly created EC_GROUP object or NULL in case of an error. |
163 | */ | |
5b5eea4b SL |
164 | OSSL_DEPRECATEDIN_3_0 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); |
165 | ||
166 | /** Clears and frees a EC_GROUP object | |
167 | * \param group EC_GROUP object to be cleared and freed. | |
168 | */ | |
169 | OSSL_DEPRECATEDIN_3_0 void EC_GROUP_clear_free(EC_GROUP *group); | |
170 | ||
171 | /** Returns the EC_METHOD of the EC_GROUP object. | |
172 | * \param group EC_GROUP object | |
173 | * \return EC_METHOD used in this EC_GROUP object. | |
174 | */ | |
175 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); | |
176 | ||
177 | /** Returns the field type of the EC_METHOD. | |
178 | * \param meth EC_METHOD object | |
179 | * \return NID of the underlying field type OID. | |
180 | */ | |
181 | OSSL_DEPRECATEDIN_3_0 int EC_METHOD_get_field_type(const EC_METHOD *meth); | |
182 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f NL |
183 | |
184 | /** Frees a EC_GROUP object | |
185 | * \param group EC_GROUP object to be freed. | |
186 | */ | |
187 | void EC_GROUP_free(EC_GROUP *group); | |
188 | ||
ba12070f NL |
189 | /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. |
190 | * \param dst destination EC_GROUP object | |
191 | * \param src source EC_GROUP object | |
192 | * \return 1 on success and 0 if an error occurred. | |
193 | */ | |
194 | int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); | |
195 | ||
9fdcc21f | 196 | /** Creates a new EC_GROUP object and copies the content |
ba12070f NL |
197 | * form src to the newly created EC_KEY object |
198 | * \param src source EC_GROUP object | |
199 | * \return newly created EC_GROUP object or NULL in case of an error. | |
200 | */ | |
201 | EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); | |
202 | ||
68756b12 | 203 | /** Sets the generator and its order/cofactor of a EC_GROUP object. |
0f113f3e | 204 | * \param group EC_GROUP object |
ba12070f NL |
205 | * \param generator EC_POINT object with the generator. |
206 | * \param order the order of the group generated by the generator. | |
207 | * \param cofactor the index of the sub-group generated by the generator | |
208 | * in the group of all points on the elliptic curve. | |
478b50cf | 209 | * \return 1 on success and 0 if an error occurred |
ba12070f | 210 | */ |
0f113f3e MC |
211 | int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, |
212 | const BIGNUM *order, const BIGNUM *cofactor); | |
ba12070f NL |
213 | |
214 | /** Returns the generator of a EC_GROUP object. | |
215 | * \param group EC_GROUP object | |
216 | * \return the currently used generator (possibly NULL). | |
217 | */ | |
218 | const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); | |
219 | ||
f54be179 AP |
220 | /** Returns the montgomery data for order(Generator) |
221 | * \param group EC_GROUP object | |
14f46560 | 222 | * \return the currently used montgomery data (possibly NULL). |
f54be179 AP |
223 | */ |
224 | BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); | |
225 | ||
ba12070f NL |
226 | /** Gets the order of a EC_GROUP |
227 | * \param group EC_GROUP object | |
228 | * \param order BIGNUM to which the order is copied | |
a773b52a | 229 | * \param ctx unused |
478b50cf | 230 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
231 | */ |
232 | int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); | |
48fe4d62 | 233 | |
be2e334f DSH |
234 | /** Gets the order of an EC_GROUP |
235 | * \param group EC_GROUP object | |
236 | * \return the group order | |
237 | */ | |
be2e334f DSH |
238 | const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group); |
239 | ||
8483a003 | 240 | /** Gets the number of bits of the order of an EC_GROUP |
be2e334f DSH |
241 | * \param group EC_GROUP object |
242 | * \return number of bits of group order. | |
243 | */ | |
be2e334f DSH |
244 | int EC_GROUP_order_bits(const EC_GROUP *group); |
245 | ||
ba12070f NL |
246 | /** Gets the cofactor of a EC_GROUP |
247 | * \param group EC_GROUP object | |
248 | * \param cofactor BIGNUM to which the cofactor is copied | |
a773b52a | 249 | * \param ctx unused |
478b50cf | 250 | * \return 1 on success and 0 if an error occurred |
ba12070f | 251 | */ |
0f113f3e MC |
252 | int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, |
253 | BN_CTX *ctx); | |
b6db386f | 254 | |
be2e334f DSH |
255 | /** Gets the cofactor of an EC_GROUP |
256 | * \param group EC_GROUP object | |
257 | * \return the group cofactor | |
258 | */ | |
be2e334f DSH |
259 | const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group); |
260 | ||
ba12070f NL |
261 | /** Sets the name of a EC_GROUP object |
262 | * \param group EC_GROUP object | |
263 | * \param nid NID of the curve name OID | |
264 | */ | |
265 | void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); | |
b6db386f | 266 | |
ba12070f NL |
267 | /** Returns the curve name of a EC_GROUP object |
268 | * \param group EC_GROUP object | |
269 | * \return NID of the curve name OID or 0 if not set. | |
270 | */ | |
271 | int EC_GROUP_get_curve_name(const EC_GROUP *group); | |
945e15a2 | 272 | |
fa1f0306 DA |
273 | /** Gets the field of an EC_GROUP |
274 | * \param group EC_GROUP object | |
275 | * \return the group field | |
276 | */ | |
277 | const BIGNUM *EC_GROUP_get0_field(const EC_GROUP *group); | |
278 | ||
23ccae80 BB |
279 | /** Returns the field type of the EC_GROUP. |
280 | * \param group EC_GROUP object | |
281 | * \return NID of the underlying field type OID. | |
282 | */ | |
283 | int EC_GROUP_get_field_type(const EC_GROUP *group); | |
284 | ||
ba12070f NL |
285 | void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); |
286 | int EC_GROUP_get_asn1_flag(const EC_GROUP *group); | |
5f3d6f70 | 287 | |
0f113f3e MC |
288 | void EC_GROUP_set_point_conversion_form(EC_GROUP *group, |
289 | point_conversion_form_t form); | |
5f3d6f70 BM |
290 | point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); |
291 | ||
9945b460 | 292 | unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); |
5f3d6f70 BM |
293 | size_t EC_GROUP_get_seed_len(const EC_GROUP *); |
294 | size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); | |
48fe4d62 | 295 | |
8e3cced7 MC |
296 | /** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp) |
297 | * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) | |
ba12070f | 298 | * \param group EC_GROUP object |
8e3cced7 MC |
299 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
300 | * defining the underlying field (GF2m) | |
301 | * \param a BIGNUM with parameter a of the equation | |
302 | * \param b BIGNUM with parameter b of the equation | |
303 | * \param ctx BN_CTX object (optional) | |
304 | * \return 1 on success and 0 if an error occurred | |
305 | */ | |
306 | int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, | |
307 | const BIGNUM *b, BN_CTX *ctx); | |
308 | ||
309 | /** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp) | |
310 | * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) | |
311 | * \param group EC_GROUP object | |
312 | * \param p BIGNUM with the prime number (GFp) or the polynomial | |
313 | * defining the underlying field (GF2m) | |
314 | * \param a BIGNUM for parameter a of the equation | |
315 | * \param b BIGNUM for parameter b of the equation | |
316 | * \param ctx BN_CTX object (optional) | |
317 | * \return 1 on success and 0 if an error occurred | |
318 | */ | |
319 | int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, | |
320 | BN_CTX *ctx); | |
321 | ||
5b5eea4b | 322 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
8e3cced7 MC |
323 | /** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve |
324 | * \param group EC_GROUP object | |
325 | * \param p BIGNUM with the prime number (GFp) or the polynomial | |
326 | * defining the underlying field (GF2m) | |
ba12070f NL |
327 | * \param a BIGNUM with parameter a of the equation |
328 | * \param b BIGNUM with parameter b of the equation | |
329 | * \param ctx BN_CTX object (optional) | |
478b50cf | 330 | * \return 1 on success and 0 if an error occurred |
ba12070f | 331 | */ |
5b5eea4b SL |
332 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GFp(EC_GROUP *group, |
333 | const BIGNUM *p, | |
334 | const BIGNUM *a, | |
335 | const BIGNUM *b, | |
336 | BN_CTX *ctx); | |
ba12070f | 337 | |
8e3cced7 | 338 | /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve |
ba12070f | 339 | * \param group EC_GROUP object |
8e3cced7 MC |
340 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
341 | * defining the underlying field (GF2m) | |
ba12070f NL |
342 | * \param a BIGNUM for parameter a of the equation |
343 | * \param b BIGNUM for parameter b of the equation | |
344 | * \param ctx BN_CTX object (optional) | |
478b50cf | 345 | * \return 1 on success and 0 if an error occurred |
ba12070f | 346 | */ |
5b5eea4b SL |
347 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, |
348 | BIGNUM *p, | |
349 | BIGNUM *a, BIGNUM *b, | |
350 | BN_CTX *ctx); | |
ba12070f | 351 | |
5b5eea4b | 352 | # ifndef OPENSSL_NO_EC2M |
8e3cced7 | 353 | /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve |
ba12070f | 354 | * \param group EC_GROUP object |
8e3cced7 MC |
355 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
356 | * defining the underlying field (GF2m) | |
ba12070f NL |
357 | * \param a BIGNUM with parameter a of the equation |
358 | * \param b BIGNUM with parameter b of the equation | |
359 | * \param ctx BN_CTX object (optional) | |
478b50cf | 360 | * \return 1 on success and 0 if an error occurred |
ba12070f | 361 | */ |
5b5eea4b SL |
362 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, |
363 | const BIGNUM *p, | |
364 | const BIGNUM *a, | |
365 | const BIGNUM *b, | |
366 | BN_CTX *ctx); | |
ba12070f | 367 | |
8e3cced7 | 368 | /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve |
ba12070f | 369 | * \param group EC_GROUP object |
8e3cced7 MC |
370 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
371 | * defining the underlying field (GF2m) | |
ba12070f NL |
372 | * \param a BIGNUM for parameter a of the equation |
373 | * \param b BIGNUM for parameter b of the equation | |
374 | * \param ctx BN_CTX object (optional) | |
478b50cf | 375 | * \return 1 on success and 0 if an error occurred |
ba12070f | 376 | */ |
5b5eea4b SL |
377 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, |
378 | BIGNUM *p, | |
379 | BIGNUM *a, BIGNUM *b, | |
380 | BN_CTX *ctx); | |
381 | # endif /* OPENSSL_NO_EC2M */ | |
382 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
383 | ||
0f113f3e | 384 | /** Returns the number of bits needed to represent a field element |
ba12070f NL |
385 | * \param group EC_GROUP object |
386 | * \return number of bits needed to represent a field element | |
387 | */ | |
388 | int EC_GROUP_get_degree(const EC_GROUP *group); | |
3a12ce01 | 389 | |
ba12070f NL |
390 | /** Checks whether the parameter in the EC_GROUP define a valid ec group |
391 | * \param group EC_GROUP object | |
392 | * \param ctx BN_CTX object (optional) | |
393 | * \return 1 if group is a valid ec group and 0 otherwise | |
394 | */ | |
af28dd6c | 395 | int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); |
945e15a2 | 396 | |
ba12070f NL |
397 | /** Checks whether the discriminant of the elliptic curve is zero or not |
398 | * \param group EC_GROUP object | |
399 | * \param ctx BN_CTX object (optional) | |
400 | * \return 1 if the discriminant is not zero and 0 otherwise | |
401 | */ | |
402 | int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); | |
403 | ||
404 | /** Compares two EC_GROUP objects | |
405 | * \param a first EC_GROUP object | |
406 | * \param b second EC_GROUP object | |
407 | * \param ctx BN_CTX object (optional) | |
14f46560 | 408 | * \return 0 if the groups are equal, 1 if not, or -1 on error |
ba12070f NL |
409 | */ |
410 | int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); | |
ada0e717 | 411 | |
0f113f3e MC |
412 | /* |
413 | * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after | |
414 | * choosing an appropriate EC_METHOD | |
415 | */ | |
945e15a2 | 416 | |
ba12070f NL |
417 | /** Creates a new EC_GROUP object with the specified parameters defined |
418 | * over GFp (defined by the equation y^2 = x^3 + a*x + b) | |
419 | * \param p BIGNUM with the prime number | |
420 | * \param a BIGNUM with the parameter a of the equation | |
421 | * \param b BIGNUM with the parameter b of the equation | |
422 | * \param ctx BN_CTX object (optional) | |
423 | * \return newly created EC_GROUP object with the specified parameters | |
424 | */ | |
0f113f3e MC |
425 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, |
426 | const BIGNUM *b, BN_CTX *ctx); | |
ee8db22e | 427 | # ifndef OPENSSL_NO_EC2M |
ba12070f NL |
428 | /** Creates a new EC_GROUP object with the specified parameters defined |
429 | * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) | |
430 | * \param p BIGNUM with the polynomial defining the underlying field | |
431 | * \param a BIGNUM with the parameter a of the equation | |
432 | * \param b BIGNUM with the parameter b of the equation | |
433 | * \param ctx BN_CTX object (optional) | |
434 | * \return newly created EC_GROUP object with the specified parameters | |
435 | */ | |
0f113f3e MC |
436 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, |
437 | const BIGNUM *b, BN_CTX *ctx); | |
ee8db22e | 438 | # endif |
60b350a3 | 439 | |
c0f39ded SL |
440 | /** |
441 | * Creates a EC_GROUP object with a curve specified by parameters. | |
442 | * The parameters may be explicit or a named curve, | |
443 | * \param params A list of parameters describing the group. | |
444 | * \param libctx The associated library context or NULL for the default | |
445 | * context | |
446 | * \param propq A property query string | |
447 | * \return newly created EC_GROUP object with specified parameters or NULL | |
448 | * if an error occurred | |
449 | */ | |
450 | EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], | |
b4250010 | 451 | OSSL_LIB_CTX *libctx, const char *propq); |
c0f39ded | 452 | |
a9612d6c MC |
453 | /** |
454 | * Creates a EC_GROUP object with a curve specified by a NID | |
455 | * \param libctx The associated library context or NULL for the default | |
456 | * context | |
2da8d4eb | 457 | * \param propq A property query string |
a9612d6c MC |
458 | * \param nid NID of the OID of the curve name |
459 | * \return newly created EC_GROUP object with specified curve or NULL | |
460 | * if an error occurred | |
461 | */ | |
b4250010 | 462 | EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq, |
d8652be0 | 463 | int nid); |
a9612d6c MC |
464 | |
465 | /** | |
466 | * Creates a EC_GROUP object with a curve specified by a NID. Same as | |
d8652be0 | 467 | * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always |
2da8d4eb | 468 | * NULL. |
a9612d6c | 469 | * \param nid NID of the OID of the curve name |
ba12070f NL |
470 | * \return newly created EC_GROUP object with specified curve or NULL |
471 | * if an error occurred | |
472 | */ | |
8b15c740 | 473 | EC_GROUP *EC_GROUP_new_by_curve_name(int nid); |
ba12070f | 474 | |
60b350a3 RS |
475 | /** Creates a new EC_GROUP object from an ECPARAMETERS object |
476 | * \param params pointer to the ECPARAMETERS object | |
477 | * \return newly created EC_GROUP object with specified curve or NULL | |
478 | * if an error occurred | |
479 | */ | |
480 | EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); | |
481 | ||
436ad81f | 482 | /** Creates an ECPARAMETERS object for the given EC_GROUP object. |
60b350a3 RS |
483 | * \param group pointer to the EC_GROUP object |
484 | * \param params pointer to an existing ECPARAMETERS object or NULL | |
485 | * \return pointer to the new ECPARAMETERS object or NULL | |
486 | * if an error occurred. | |
487 | */ | |
488 | ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, | |
489 | ECPARAMETERS *params); | |
490 | ||
491 | /** Creates a new EC_GROUP object from an ECPKPARAMETERS object | |
492 | * \param params pointer to an existing ECPKPARAMETERS object, or NULL | |
493 | * \return newly created EC_GROUP object with specified curve, or NULL | |
494 | * if an error occurred | |
495 | */ | |
496 | EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); | |
497 | ||
436ad81f | 498 | /** Creates an ECPKPARAMETERS object for the given EC_GROUP object. |
60b350a3 RS |
499 | * \param group pointer to the EC_GROUP object |
500 | * \param params pointer to an existing ECPKPARAMETERS object or NULL | |
501 | * \return pointer to the new ECPKPARAMETERS object or NULL | |
502 | * if an error occurred. | |
503 | */ | |
504 | ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, | |
505 | ECPKPARAMETERS *params); | |
506 | ||
ba12070f NL |
507 | /********************************************************************/ |
508 | /* handling of internal curves */ | |
509 | /********************************************************************/ | |
510 | ||
0f113f3e MC |
511 | typedef struct { |
512 | int nid; | |
513 | const char *comment; | |
514 | } EC_builtin_curve; | |
ba12070f | 515 | |
0f113f3e MC |
516 | /* |
517 | * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all | |
8483a003 | 518 | * available curves or zero if a error occurred. In case r is not zero, |
0f113f3e MC |
519 | * nitems EC_builtin_curve structures are filled with the data of the first |
520 | * nitems internal groups | |
521 | */ | |
65b1d31d | 522 | size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); |
7eb18f12 | 523 | |
64095ce9 DSH |
524 | const char *EC_curve_nid2nist(int nid); |
525 | int EC_curve_nist2nid(const char *name); | |
a9612d6c MC |
526 | int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only, |
527 | BN_CTX *ctx); | |
7e31164a | 528 | |
ba12070f NL |
529 | /********************************************************************/ |
530 | /* EC_POINT functions */ | |
531 | /********************************************************************/ | |
532 | ||
533 | /** Creates a new EC_POINT object for the specified EC_GROUP | |
534 | * \param group EC_GROUP the underlying EC_GROUP object | |
535 | * \return newly created EC_POINT object or NULL if an error occurred | |
536 | */ | |
537 | EC_POINT *EC_POINT_new(const EC_GROUP *group); | |
538 | ||
539 | /** Frees a EC_POINT object | |
540 | * \param point EC_POINT object to be freed | |
541 | */ | |
542 | void EC_POINT_free(EC_POINT *point); | |
543 | ||
544 | /** Clears and frees a EC_POINT object | |
545 | * \param point EC_POINT object to be cleared and freed | |
546 | */ | |
547 | void EC_POINT_clear_free(EC_POINT *point); | |
548 | ||
549 | /** Copies EC_POINT object | |
550 | * \param dst destination EC_POINT object | |
551 | * \param src source EC_POINT object | |
478b50cf | 552 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
553 | */ |
554 | int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); | |
945e15a2 | 555 | |
ba12070f NL |
556 | /** Creates a new EC_POINT object and copies the content of the supplied |
557 | * EC_POINT | |
558 | * \param src source EC_POINT object | |
559 | * \param group underlying the EC_GROUP object | |
0f113f3e | 560 | * \return newly created EC_POINT object or NULL if an error occurred |
ba12070f NL |
561 | */ |
562 | EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); | |
0f113f3e | 563 | |
ba12070f NL |
564 | /** Sets a point to infinity (neutral element) |
565 | * \param group underlying EC_GROUP object | |
566 | * \param point EC_POINT to set to infinity | |
478b50cf | 567 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
568 | */ |
569 | int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); | |
570 | ||
5b5eea4b SL |
571 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
572 | /** Returns the EC_METHOD used in EC_POINT object | |
573 | * \param point EC_POINT object | |
574 | * \return the EC_METHOD used | |
575 | */ | |
576 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); | |
577 | ||
ba12070f NL |
578 | /** Sets the jacobian projective coordinates of a EC_POINT over GFp |
579 | * \param group underlying EC_GROUP object | |
580 | * \param p EC_POINT object | |
581 | * \param x BIGNUM with the x-coordinate | |
582 | * \param y BIGNUM with the y-coordinate | |
583 | * \param z BIGNUM with the z-coordinate | |
584 | * \param ctx BN_CTX object (optional) | |
478b50cf | 585 | * \return 1 on success and 0 if an error occurred |
ba12070f | 586 | */ |
5b5eea4b SL |
587 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_Jprojective_coordinates_GFp |
588 | (const EC_GROUP *group, EC_POINT *p, | |
589 | const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, | |
590 | BN_CTX *ctx); | |
ba12070f NL |
591 | |
592 | /** Gets the jacobian projective coordinates of a EC_POINT over GFp | |
593 | * \param group underlying EC_GROUP object | |
594 | * \param p EC_POINT object | |
595 | * \param x BIGNUM for the x-coordinate | |
596 | * \param y BIGNUM for the y-coordinate | |
597 | * \param z BIGNUM for the z-coordinate | |
598 | * \param ctx BN_CTX object (optional) | |
478b50cf | 599 | * \return 1 on success and 0 if an error occurred |
ba12070f | 600 | */ |
5b5eea4b SL |
601 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_Jprojective_coordinates_GFp |
602 | (const EC_GROUP *group, const EC_POINT *p, | |
603 | BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); | |
604 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f | 605 | |
8e3cced7 MC |
606 | /** Sets the affine coordinates of an EC_POINT |
607 | * \param group underlying EC_GROUP object | |
608 | * \param p EC_POINT object | |
609 | * \param x BIGNUM with the x-coordinate | |
610 | * \param y BIGNUM with the y-coordinate | |
611 | * \param ctx BN_CTX object (optional) | |
612 | * \return 1 on success and 0 if an error occurred | |
613 | */ | |
614 | int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, | |
615 | const BIGNUM *x, const BIGNUM *y, | |
616 | BN_CTX *ctx); | |
617 | ||
618 | /** Gets the affine coordinates of an EC_POINT. | |
619 | * \param group underlying EC_GROUP object | |
620 | * \param p EC_POINT object | |
621 | * \param x BIGNUM for the x-coordinate | |
622 | * \param y BIGNUM for the y-coordinate | |
623 | * \param ctx BN_CTX object (optional) | |
624 | * \return 1 on success and 0 if an error occurred | |
625 | */ | |
626 | int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, | |
627 | BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | |
628 | ||
5b5eea4b | 629 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
8e3cced7 MC |
630 | /** Sets the affine coordinates of an EC_POINT. A synonym of |
631 | * EC_POINT_set_affine_coordinates | |
ba12070f NL |
632 | * \param group underlying EC_GROUP object |
633 | * \param p EC_POINT object | |
634 | * \param x BIGNUM with the x-coordinate | |
635 | * \param y BIGNUM with the y-coordinate | |
636 | * \param ctx BN_CTX object (optional) | |
478b50cf | 637 | * \return 1 on success and 0 if an error occurred |
ba12070f | 638 | */ |
5b5eea4b SL |
639 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GFp |
640 | (const EC_GROUP *group, EC_POINT *p, | |
641 | const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); | |
ba12070f | 642 | |
8e3cced7 MC |
643 | /** Gets the affine coordinates of an EC_POINT. A synonym of |
644 | * EC_POINT_get_affine_coordinates | |
ba12070f NL |
645 | * \param group underlying EC_GROUP object |
646 | * \param p EC_POINT object | |
647 | * \param x BIGNUM for the x-coordinate | |
648 | * \param y BIGNUM for the y-coordinate | |
649 | * \param ctx BN_CTX object (optional) | |
478b50cf | 650 | * \return 1 on success and 0 if an error occurred |
ba12070f | 651 | */ |
5b5eea4b SL |
652 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GFp |
653 | (const EC_GROUP *group, const EC_POINT *p, | |
654 | BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | |
655 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f | 656 | |
8e3cced7 MC |
657 | /** Sets the x9.62 compressed coordinates of a EC_POINT |
658 | * \param group underlying EC_GROUP object | |
659 | * \param p EC_POINT object | |
660 | * \param x BIGNUM with x-coordinate | |
661 | * \param y_bit integer with the y-Bit (either 0 or 1) | |
662 | * \param ctx BN_CTX object (optional) | |
663 | * \return 1 on success and 0 if an error occurred | |
664 | */ | |
665 | int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, | |
666 | const BIGNUM *x, int y_bit, | |
667 | BN_CTX *ctx); | |
668 | ||
5b5eea4b | 669 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
8e3cced7 MC |
670 | /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of |
671 | * EC_POINT_set_compressed_coordinates | |
ba12070f NL |
672 | * \param group underlying EC_GROUP object |
673 | * \param p EC_POINT object | |
674 | * \param x BIGNUM with x-coordinate | |
675 | * \param y_bit integer with the y-Bit (either 0 or 1) | |
676 | * \param ctx BN_CTX object (optional) | |
478b50cf | 677 | * \return 1 on success and 0 if an error occurred |
ba12070f | 678 | */ |
5b5eea4b SL |
679 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GFp |
680 | (const EC_GROUP *group, EC_POINT *p, | |
681 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | |
682 | # ifndef OPENSSL_NO_EC2M | |
8e3cced7 MC |
683 | /** Sets the affine coordinates of an EC_POINT. A synonym of |
684 | * EC_POINT_set_affine_coordinates | |
ba12070f NL |
685 | * \param group underlying EC_GROUP object |
686 | * \param p EC_POINT object | |
687 | * \param x BIGNUM with the x-coordinate | |
688 | * \param y BIGNUM with the y-coordinate | |
689 | * \param ctx BN_CTX object (optional) | |
478b50cf | 690 | * \return 1 on success and 0 if an error occurred |
ba12070f | 691 | */ |
5b5eea4b SL |
692 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GF2m |
693 | (const EC_GROUP *group, EC_POINT *p, | |
694 | const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); | |
ba12070f | 695 | |
8e3cced7 MC |
696 | /** Gets the affine coordinates of an EC_POINT. A synonym of |
697 | * EC_POINT_get_affine_coordinates | |
ba12070f NL |
698 | * \param group underlying EC_GROUP object |
699 | * \param p EC_POINT object | |
700 | * \param x BIGNUM for the x-coordinate | |
701 | * \param y BIGNUM for the y-coordinate | |
702 | * \param ctx BN_CTX object (optional) | |
478b50cf | 703 | * \return 1 on success and 0 if an error occurred |
ba12070f | 704 | */ |
5b5eea4b SL |
705 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GF2m |
706 | (const EC_GROUP *group, const EC_POINT *p, | |
707 | BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | |
ba12070f | 708 | |
8e3cced7 MC |
709 | /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of |
710 | * EC_POINT_set_compressed_coordinates | |
ba12070f NL |
711 | * \param group underlying EC_GROUP object |
712 | * \param p EC_POINT object | |
713 | * \param x BIGNUM with x-coordinate | |
714 | * \param y_bit integer with the y-Bit (either 0 or 1) | |
715 | * \param ctx BN_CTX object (optional) | |
478b50cf | 716 | * \return 1 on success and 0 if an error occurred |
ba12070f | 717 | */ |
5b5eea4b SL |
718 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GF2m |
719 | (const EC_GROUP *group, EC_POINT *p, | |
720 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | |
721 | # endif | |
722 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
723 | ||
ba12070f NL |
724 | /** Encodes a EC_POINT object to a octet string |
725 | * \param group underlying EC_GROUP object | |
726 | * \param p EC_POINT object | |
727 | * \param form point conversion form | |
728 | * \param buf memory buffer for the result. If NULL the function returns | |
729 | * required buffer size. | |
730 | * \param len length of the memory buffer | |
731 | * \param ctx BN_CTX object (optional) | |
732 | * \return the length of the encoded octet string or 0 if an error occurred | |
733 | */ | |
734 | size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, | |
0f113f3e MC |
735 | point_conversion_form_t form, |
736 | unsigned char *buf, size_t len, BN_CTX *ctx); | |
ba12070f NL |
737 | |
738 | /** Decodes a EC_POINT from a octet string | |
739 | * \param group underlying EC_GROUP object | |
740 | * \param p EC_POINT object | |
741 | * \param buf memory buffer with the encoded ec point | |
742 | * \param len length of the encoded ec point | |
743 | * \param ctx BN_CTX object (optional) | |
478b50cf | 744 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
745 | */ |
746 | int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, | |
0f113f3e | 747 | const unsigned char *buf, size_t len, BN_CTX *ctx); |
7d7db13e | 748 | |
981bd8a2 DSH |
749 | /** Encodes an EC_POINT object to an allocated octet string |
750 | * \param group underlying EC_GROUP object | |
751 | * \param point EC_POINT object | |
752 | * \param form point conversion form | |
753 | * \param pbuf returns pointer to allocated buffer | |
981bd8a2 DSH |
754 | * \param ctx BN_CTX object (optional) |
755 | * \return the length of the encoded octet string or 0 if an error occurred | |
756 | */ | |
981bd8a2 DSH |
757 | size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, |
758 | point_conversion_form_t form, | |
759 | unsigned char **pbuf, BN_CTX *ctx); | |
760 | ||
6cbe6382 | 761 | /* other interfaces to point2oct/oct2point: */ |
c1131e6a SL |
762 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
763 | OSSL_DEPRECATEDIN_3_0 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, | |
764 | const EC_POINT *, | |
765 | point_conversion_form_t form, | |
766 | BIGNUM *, BN_CTX *); | |
767 | OSSL_DEPRECATEDIN_3_0 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, | |
768 | const BIGNUM *, | |
769 | EC_POINT *, BN_CTX *); | |
770 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
771 | ||
6cbe6382 | 772 | char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, |
0f113f3e | 773 | point_conversion_form_t form, BN_CTX *); |
6cbe6382 | 774 | EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, |
0f113f3e | 775 | EC_POINT *, BN_CTX *); |
3a12ce01 | 776 | |
ba12070f NL |
777 | /********************************************************************/ |
778 | /* functions for doing EC_POINT arithmetic */ | |
779 | /********************************************************************/ | |
780 | ||
0f113f3e | 781 | /** Computes the sum of two EC_POINT |
ba12070f NL |
782 | * \param group underlying EC_GROUP object |
783 | * \param r EC_POINT object for the result (r = a + b) | |
784 | * \param a EC_POINT object with the first summand | |
785 | * \param b EC_POINT object with the second summand | |
786 | * \param ctx BN_CTX object (optional) | |
478b50cf | 787 | * \return 1 on success and 0 if an error occurred |
ba12070f | 788 | */ |
0f113f3e MC |
789 | int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, |
790 | const EC_POINT *b, BN_CTX *ctx); | |
ba12070f NL |
791 | |
792 | /** Computes the double of a EC_POINT | |
793 | * \param group underlying EC_GROUP object | |
794 | * \param r EC_POINT object for the result (r = 2 * a) | |
0f113f3e | 795 | * \param a EC_POINT object |
ba12070f | 796 | * \param ctx BN_CTX object (optional) |
478b50cf | 797 | * \return 1 on success and 0 if an error occurred |
ba12070f | 798 | */ |
0f113f3e MC |
799 | int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, |
800 | BN_CTX *ctx); | |
ba12070f NL |
801 | |
802 | /** Computes the inverse of a EC_POINT | |
803 | * \param group underlying EC_GROUP object | |
804 | * \param a EC_POINT object to be inverted (it's used for the result as well) | |
805 | * \param ctx BN_CTX object (optional) | |
478b50cf | 806 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
807 | */ |
808 | int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); | |
809 | ||
810 | /** Checks whether the point is the neutral element of the group | |
811 | * \param group the underlying EC_GROUP object | |
812 | * \param p EC_POINT object | |
813 | * \return 1 if the point is the neutral element and 0 otherwise | |
814 | */ | |
815 | int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); | |
816 | ||
0f113f3e | 817 | /** Checks whether the point is on the curve |
ba12070f NL |
818 | * \param group underlying EC_GROUP object |
819 | * \param point EC_POINT object to check | |
820 | * \param ctx BN_CTX object (optional) | |
14f46560 | 821 | * \return 1 if the point is on the curve, 0 if not, or -1 on error |
ba12070f | 822 | */ |
0f113f3e MC |
823 | int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, |
824 | BN_CTX *ctx); | |
ba12070f | 825 | |
0f113f3e | 826 | /** Compares two EC_POINTs |
ba12070f NL |
827 | * \param group underlying EC_GROUP object |
828 | * \param a first EC_POINT object | |
829 | * \param b second EC_POINT object | |
830 | * \param ctx BN_CTX object (optional) | |
14f46560 | 831 | * \return 1 if the points are not equal, 0 if they are, or -1 on error |
ba12070f | 832 | */ |
0f113f3e MC |
833 | int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, |
834 | BN_CTX *ctx); | |
fb171e53 | 835 | |
5b5eea4b SL |
836 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
837 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_make_affine(const EC_GROUP *group, | |
838 | EC_POINT *point, BN_CTX *ctx); | |
839 | OSSL_DEPRECATEDIN_3_0 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, | |
840 | EC_POINT *points[], BN_CTX *ctx); | |
fb171e53 | 841 | |
14f46560 | 842 | /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] |
ba12070f NL |
843 | * \param group underlying EC_GROUP object |
844 | * \param r EC_POINT object for the result | |
845 | * \param n BIGNUM with the multiplier for the group generator (optional) | |
8483a003 | 846 | * \param num number further summands |
ba12070f NL |
847 | * \param p array of size num of EC_POINT objects |
848 | * \param m array of size num of BIGNUM objects | |
849 | * \param ctx BN_CTX object (optional) | |
478b50cf | 850 | * \return 1 on success and 0 if an error occurred |
ba12070f | 851 | */ |
5b5eea4b SL |
852 | OSSL_DEPRECATEDIN_3_0 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, |
853 | const BIGNUM *n, size_t num, | |
854 | const EC_POINT *p[], const BIGNUM *m[], | |
855 | BN_CTX *ctx); | |
856 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f NL |
857 | |
858 | /** Computes r = generator * n + q * m | |
859 | * \param group underlying EC_GROUP object | |
860 | * \param r EC_POINT object for the result | |
861 | * \param n BIGNUM with the multiplier for the group generator (optional) | |
862 | * \param q EC_POINT object with the first factor of the second summand | |
863 | * \param m BIGNUM with the second factor of the second summand | |
864 | * \param ctx BN_CTX object (optional) | |
478b50cf | 865 | * \return 1 on success and 0 if an error occurred |
ba12070f | 866 | */ |
0f113f3e MC |
867 | int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, |
868 | const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); | |
3a12ce01 | 869 | |
5b5eea4b | 870 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
ba12070f NL |
871 | /** Stores multiples of generator for faster point multiplication |
872 | * \param group EC_GROUP object | |
873 | * \param ctx BN_CTX object (optional) | |
478b50cf | 874 | * \return 1 on success and 0 if an error occurred |
ba12070f | 875 | */ |
5b5eea4b | 876 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); |
6cc5e19d | 877 | |
ba12070f NL |
878 | /** Reports whether a precomputation has been done |
879 | * \param group EC_GROUP object | |
880 | * \return 1 if a pre-computation has been done and 0 otherwise | |
881 | */ | |
5b5eea4b SL |
882 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_have_precompute_mult(const EC_GROUP *group); |
883 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
6cc5e19d | 884 | |
ba12070f NL |
885 | /********************************************************************/ |
886 | /* ASN1 stuff */ | |
887 | /********************************************************************/ | |
8aefe253 | 888 | |
60b350a3 | 889 | DECLARE_ASN1_ITEM(ECPKPARAMETERS) |
9ba6f347 | 890 | DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS) |
60b350a3 | 891 | DECLARE_ASN1_ITEM(ECPARAMETERS) |
9ba6f347 | 892 | DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) |
60b350a3 | 893 | |
0f113f3e MC |
894 | /* |
895 | * EC_GROUP_get_basis_type() returns the NID of the basis type used to | |
896 | * represent the field elements | |
897 | */ | |
34f1f2a8 | 898 | int EC_GROUP_get_basis_type(const EC_GROUP *); |
ee8db22e | 899 | # ifndef OPENSSL_NO_EC2M |
34f1f2a8 | 900 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); |
0f113f3e MC |
901 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, |
902 | unsigned int *k2, unsigned int *k3); | |
ee8db22e | 903 | # endif |
8aefe253 | 904 | |
6343829a | 905 | EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); |
458c2917 BM |
906 | int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); |
907 | ||
ee8db22e P |
908 | # define d2i_ECPKParameters_bio(bp,x) \ |
909 | ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x) | |
910 | # define i2d_ECPKParameters_bio(bp,x) \ | |
911 | ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x) | |
912 | # define d2i_ECPKParameters_fp(fp,x) \ | |
913 | (EC_GROUP *)ASN1_d2i_fp(NULL, (char *(*)())d2i_ECPKParameters, (fp), \ | |
914 | (unsigned char **)(x)) | |
915 | # define i2d_ECPKParameters_fp(fp,x) \ | |
916 | ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x)) | |
5f3d6f70 | 917 | |
5b5eea4b SL |
918 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
919 | OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, | |
920 | int off); | |
921 | # ifndef OPENSSL_NO_STDIO | |
922 | OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, | |
923 | int off); | |
924 | # endif | |
925 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f NL |
926 | |
927 | /********************************************************************/ | |
928 | /* EC_KEY functions */ | |
929 | /********************************************************************/ | |
930 | ||
14a7cfb3 | 931 | /* some values for the encoding_flag */ |
ee8db22e P |
932 | # define EC_PKEY_NO_PARAMETERS 0x001 |
933 | # define EC_PKEY_NO_PUBKEY 0x002 | |
14a7cfb3 | 934 | |
cac4fb58 | 935 | /* some values for the flags field */ |
5b5eea4b SL |
936 | # define EC_FLAG_SM2_RANGE 0x0004 |
937 | # define EC_FLAG_COFACTOR_ECDH 0x1000 | |
938 | # define EC_FLAG_CHECK_NAMED_GROUP 0x2000 | |
939 | # define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000 | |
940 | # define EC_FLAG_CHECK_NAMED_GROUP_MASK \ | |
941 | (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST) | |
942 | ||
943 | /* Deprecated flags - it was using 0x01..0x02 */ | |
944 | # define EC_FLAG_NON_FIPS_ALLOW 0x0000 | |
945 | # define EC_FLAG_FIPS_CHECKED 0x0000 | |
cac4fb58 | 946 | |
5b5eea4b | 947 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
a9612d6c MC |
948 | /** |
949 | * Creates a new EC_KEY object. | |
950 | * \param ctx The library context for to use for this EC_KEY. May be NULL in | |
951 | * which case the default library context is used. | |
952 | * \return EC_KEY object or NULL if an error occurred. | |
953 | */ | |
5b5eea4b | 954 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, const char *propq); |
a9612d6c MC |
955 | |
956 | /** | |
d8652be0 | 957 | * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a |
2da8d4eb | 958 | * NULL library context |
ba12070f NL |
959 | * \return EC_KEY object or NULL if an error occurred. |
960 | */ | |
5b5eea4b | 961 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new(void); |
ba12070f | 962 | |
5b5eea4b | 963 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_get_flags(const EC_KEY *key); |
cac4fb58 | 964 | |
5b5eea4b | 965 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_flags(EC_KEY *key, int flags); |
cac4fb58 | 966 | |
5b5eea4b | 967 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_clear_flags(EC_KEY *key, int flags); |
cac4fb58 | 968 | |
5b5eea4b | 969 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key); |
fe2f8aec | 970 | |
a9612d6c MC |
971 | /** |
972 | * Creates a new EC_KEY object using a named curve as underlying | |
ba12070f | 973 | * EC_GROUP object. |
2da8d4eb MC |
974 | * \param ctx The library context for to use for this EC_KEY. May be NULL in |
975 | * which case the default library context is used. | |
976 | * \param propq Any property query string | |
977 | * \param nid NID of the named curve. | |
a9612d6c MC |
978 | * \return EC_KEY object or NULL if an error occurred. |
979 | */ | |
5b5eea4b SL |
980 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX *ctx, |
981 | const char *propq, | |
982 | int nid); | |
a9612d6c MC |
983 | |
984 | /** | |
985 | * Creates a new EC_KEY object using a named curve as underlying | |
986 | * EC_GROUP object. Same as calling EC_KEY_new_by_curve_name_ex with a NULL | |
2da8d4eb | 987 | * library context and property query string. |
ba12070f | 988 | * \param nid NID of the named curve. |
0f113f3e | 989 | * \return EC_KEY object or NULL if an error occurred. |
ba12070f | 990 | */ |
5b5eea4b | 991 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid); |
a9612d6c | 992 | |
ba12070f NL |
993 | /** Frees a EC_KEY object. |
994 | * \param key EC_KEY object to be freed. | |
995 | */ | |
5b5eea4b | 996 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_free(EC_KEY *key); |
ba12070f NL |
997 | |
998 | /** Copies a EC_KEY object. | |
999 | * \param dst destination EC_KEY object | |
1000 | * \param src src EC_KEY object | |
1001 | * \return dst or NULL if an error occurred. | |
1002 | */ | |
5b5eea4b | 1003 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); |
ba12070f NL |
1004 | |
1005 | /** Creates a new EC_KEY object and copies the content from src to it. | |
1006 | * \param src the source EC_KEY object | |
1007 | * \return newly created EC_KEY object or NULL if an error occurred. | |
1008 | */ | |
5b5eea4b | 1009 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_dup(const EC_KEY *src); |
ba12070f NL |
1010 | |
1011 | /** Increases the internal reference count of a EC_KEY object. | |
1012 | * \param key EC_KEY object | |
1013 | * \return 1 on success and 0 if an error occurred. | |
1014 | */ | |
5b5eea4b | 1015 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_up_ref(EC_KEY *key); |
ba12070f | 1016 | |
d1da335c | 1017 | /** Returns the ENGINE object of a EC_KEY object |
28c0a61b | 1018 | * \param eckey EC_KEY object |
d1da335c RL |
1019 | * \return the ENGINE object (possibly NULL). |
1020 | */ | |
5b5eea4b | 1021 | OSSL_DEPRECATEDIN_3_0 ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey); |
d1da335c | 1022 | |
ba12070f NL |
1023 | /** Returns the EC_GROUP object of a EC_KEY object |
1024 | * \param key EC_KEY object | |
1025 | * \return the EC_GROUP object (possibly NULL). | |
1026 | */ | |
5b5eea4b | 1027 | OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); |
ba12070f NL |
1028 | |
1029 | /** Sets the EC_GROUP of a EC_KEY object. | |
1030 | * \param key EC_KEY object | |
1031 | * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY | |
1032 | * object will use an own copy of the EC_GROUP). | |
1033 | * \return 1 on success and 0 if an error occurred. | |
1034 | */ | |
5b5eea4b | 1035 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); |
ba12070f NL |
1036 | |
1037 | /** Returns the private key of a EC_KEY object. | |
1038 | * \param key EC_KEY object | |
1039 | * \return a BIGNUM with the private key (possibly NULL). | |
1040 | */ | |
5b5eea4b | 1041 | OSSL_DEPRECATEDIN_3_0 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); |
ba12070f NL |
1042 | |
1043 | /** Sets the private key of a EC_KEY object. | |
1044 | * \param key EC_KEY object | |
1045 | * \param prv BIGNUM with the private key (note: the EC_KEY object | |
1046 | * will use an own copy of the BIGNUM). | |
1047 | * \return 1 on success and 0 if an error occurred. | |
1048 | */ | |
5b5eea4b | 1049 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); |
ba12070f NL |
1050 | |
1051 | /** Returns the public key of a EC_KEY object. | |
1052 | * \param key the EC_KEY object | |
1053 | * \return a EC_POINT object with the public key (possibly NULL) | |
1054 | */ | |
5b5eea4b | 1055 | OSSL_DEPRECATEDIN_3_0 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); |
ba12070f NL |
1056 | |
1057 | /** Sets the public key of a EC_KEY object. | |
1058 | * \param key EC_KEY object | |
1059 | * \param pub EC_POINT object with the public key (note: the EC_KEY object | |
1060 | * will use an own copy of the EC_POINT object). | |
1061 | * \return 1 on success and 0 if an error occurred. | |
1062 | */ | |
5b5eea4b | 1063 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); |
ba12070f | 1064 | |
5b5eea4b SL |
1065 | OSSL_DEPRECATEDIN_3_0 unsigned EC_KEY_get_enc_flags(const EC_KEY *key); |
1066 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); | |
1067 | OSSL_DEPRECATEDIN_3_0 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); | |
1068 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_conv_form(EC_KEY *eckey, | |
1069 | point_conversion_form_t cform); | |
1070 | # endif /*OPENSSL_NO_DEPRECATED_3_0 */ | |
3aef36ff | 1071 | |
ee8db22e | 1072 | # define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ |
3aef36ff | 1073 | CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) |
5b5eea4b SL |
1074 | |
1075 | # ifndef OPENSSL_NO_DEPRECATED_3_0 | |
1076 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); | |
1077 | OSSL_DEPRECATEDIN_3_0 void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); | |
3aef36ff | 1078 | |
9dd84053 | 1079 | /* wrapper functions for the underlying EC_GROUP object */ |
5b5eea4b | 1080 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); |
ba12070f | 1081 | |
0f113f3e | 1082 | /** Creates a table of pre-computed multiples of the generator to |
ba12070f NL |
1083 | * accelerate further EC_KEY operations. |
1084 | * \param key EC_KEY object | |
1085 | * \param ctx BN_CTX object (optional) | |
1086 | * \return 1 on success and 0 if an error occurred. | |
1087 | */ | |
5b5eea4b | 1088 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); |
ba12070f NL |
1089 | |
1090 | /** Creates a new ec private (and optional a new public) key. | |
1091 | * \param key EC_KEY object | |
1092 | * \return 1 on success and 0 if an error occurred. | |
1093 | */ | |
5b5eea4b | 1094 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_generate_key(EC_KEY *key); |
ba12070f NL |
1095 | |
1096 | /** Verifies that a private and/or public key is valid. | |
1097 | * \param key the EC_KEY object | |
1098 | * \return 1 on success and 0 otherwise. | |
1099 | */ | |
5b5eea4b | 1100 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_check_key(const EC_KEY *key); |
ba12070f | 1101 | |
4b0555ec | 1102 | /** Indicates if an EC_KEY can be used for signing. |
f5fd3848 | 1103 | * \param eckey the EC_KEY object |
4b0555ec DSH |
1104 | * \return 1 if can can sign and 0 otherwise. |
1105 | */ | |
5b5eea4b | 1106 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey); |
4b0555ec | 1107 | |
8483a003 | 1108 | /** Sets a public key from affine coordinates performing |
478b50cf | 1109 | * necessary NIST PKV tests. |
fef1c40b DSH |
1110 | * \param key the EC_KEY object |
1111 | * \param x public key x coordinate | |
1112 | * \param y public key y coordinate | |
1113 | * \return 1 on success and 0 otherwise. | |
1114 | */ | |
5b5eea4b SL |
1115 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, |
1116 | BIGNUM *x, | |
1117 | BIGNUM *y); | |
ba12070f | 1118 | |
981bd8a2 DSH |
1119 | /** Encodes an EC_KEY public key to an allocated octet string |
1120 | * \param key key to encode | |
1121 | * \param form point conversion form | |
1122 | * \param pbuf returns pointer to allocated buffer | |
981bd8a2 DSH |
1123 | * \param ctx BN_CTX object (optional) |
1124 | * \return the length of the encoded octet string or 0 if an error occurred | |
1125 | */ | |
5b5eea4b SL |
1126 | OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key, |
1127 | point_conversion_form_t form, | |
1128 | unsigned char **pbuf, BN_CTX *ctx); | |
981bd8a2 DSH |
1129 | |
1130 | /** Decodes a EC_KEY public key from a octet string | |
1131 | * \param key key to decode | |
1132 | * \param buf memory buffer with the encoded ec point | |
1133 | * \param len length of the encoded ec point | |
1134 | * \param ctx BN_CTX object (optional) | |
1135 | * \return 1 on success and 0 if an error occurred | |
1136 | */ | |
1137 | ||
5b5eea4b SL |
1138 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, |
1139 | size_t len, BN_CTX *ctx); | |
981bd8a2 | 1140 | |
cf241395 DSH |
1141 | /** Decodes an EC_KEY private key from an octet string |
1142 | * \param key key to decode | |
1143 | * \param buf memory buffer with the encoded private key | |
1144 | * \param len length of the encoded key | |
1145 | * \return 1 on success and 0 if an error occurred | |
1146 | */ | |
1147 | ||
5b5eea4b SL |
1148 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, |
1149 | size_t len); | |
cf241395 DSH |
1150 | |
1151 | /** Encodes a EC_KEY private key to an octet string | |
1152 | * \param key key to encode | |
1153 | * \param buf memory buffer for the result. If NULL the function returns | |
1154 | * required buffer size. | |
1155 | * \param len length of the memory buffer | |
1156 | * \return the length of the encoded octet string or 0 if an error occurred | |
1157 | */ | |
1158 | ||
5b5eea4b SL |
1159 | OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key, |
1160 | unsigned char *buf, size_t len); | |
cf241395 | 1161 | |
7fc7d1a7 | 1162 | /** Encodes an EC_KEY private key to an allocated octet string |
f5fd3848 | 1163 | * \param eckey key to encode |
7fc7d1a7 DSH |
1164 | * \param pbuf returns pointer to allocated buffer |
1165 | * \return the length of the encoded octet string or 0 if an error occurred | |
1166 | */ | |
5b5eea4b SL |
1167 | OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey, |
1168 | unsigned char **pbuf); | |
cf241395 | 1169 | |
ba12070f NL |
1170 | /********************************************************************/ |
1171 | /* de- and encoding functions for SEC1 ECPrivateKey */ | |
1172 | /********************************************************************/ | |
1173 | ||
1174 | /** Decodes a private key from a memory buffer. | |
1175 | * \param key a pointer to a EC_KEY object which should be used (or NULL) | |
1176 | * \param in pointer to memory with the DER encoded private key | |
1177 | * \param len length of the DER encoded private key | |
1178 | * \return the decoded private key or NULL if an error occurred. | |
1179 | */ | |
5b5eea4b SL |
1180 | OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, |
1181 | const unsigned char **in, | |
1182 | long len); | |
ba12070f NL |
1183 | |
1184 | /** Encodes a private key object and stores the result in a buffer. | |
1185 | * \param key the EC_KEY object to encode | |
1186 | * \param out the buffer for the result (if NULL the function returns number | |
1187 | * of bytes needed). | |
1188 | * \return 1 on success and 0 if an error occurred. | |
1189 | */ | |
5b5eea4b SL |
1190 | OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key, |
1191 | unsigned char **out); | |
ba12070f | 1192 | |
ba12070f NL |
1193 | /********************************************************************/ |
1194 | /* de- and encoding functions for EC parameters */ | |
1195 | /********************************************************************/ | |
1196 | ||
1197 | /** Decodes ec parameter from a memory buffer. | |
1198 | * \param key a pointer to a EC_KEY object which should be used (or NULL) | |
1199 | * \param in pointer to memory with the DER encoded ec parameters | |
1200 | * \param len length of the DER encoded ec parameters | |
1201 | * \return a EC_KEY object with the decoded parameters or NULL if an error | |
1202 | * occurred. | |
1203 | */ | |
5b5eea4b SL |
1204 | OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key, |
1205 | const unsigned char **in, | |
1206 | long len); | |
ba12070f NL |
1207 | |
1208 | /** Encodes ec parameter and stores the result in a buffer. | |
1afd7fa9 | 1209 | * \param key the EC_KEY object with ec parameters to encode |
ba12070f NL |
1210 | * \param out the buffer for the result (if NULL the function returns number |
1211 | * of bytes needed). | |
1212 | * \return 1 on success and 0 if an error occurred. | |
1213 | */ | |
5b5eea4b SL |
1214 | OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key, |
1215 | unsigned char **out); | |
ba12070f | 1216 | |
ba12070f NL |
1217 | /********************************************************************/ |
1218 | /* de- and encoding functions for EC public key */ | |
1219 | /* (octet string, not DER -- hence 'o2i' and 'i2o') */ | |
1220 | /********************************************************************/ | |
1221 | ||
1222 | /** Decodes a ec public key from a octet string. | |
1223 | * \param key a pointer to a EC_KEY object which should be used | |
1224 | * \param in memory buffer with the encoded public key | |
1225 | * \param len length of the encoded public key | |
1226 | * \return EC_KEY object with decoded public key or NULL if an error | |
1227 | * occurred. | |
1228 | */ | |
5b5eea4b SL |
1229 | OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key, |
1230 | const unsigned char **in, long len); | |
ba12070f NL |
1231 | |
1232 | /** Encodes a ec public key in an octet string. | |
1233 | * \param key the EC_KEY object with the public key | |
1234 | * \param out the buffer for the result (if NULL the function returns number | |
1235 | * of bytes needed). | |
1236 | * \return 1 on success and 0 if an error occurred | |
1237 | */ | |
5b5eea4b | 1238 | OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); |
14a7cfb3 | 1239 | |
ba12070f NL |
1240 | /** Prints out the ec parameters on human readable form. |
1241 | * \param bp BIO object to which the information is printed | |
1242 | * \param key EC_KEY object | |
1243 | * \return 1 on success and 0 if an error occurred | |
1244 | */ | |
5b5eea4b | 1245 | OSSL_DEPRECATEDIN_3_0 int ECParameters_print(BIO *bp, const EC_KEY *key); |
ba12070f NL |
1246 | |
1247 | /** Prints out the contents of a EC_KEY object | |
1248 | * \param bp BIO object to which the information is printed | |
1249 | * \param key EC_KEY object | |
0f113f3e | 1250 | * \param off line offset |
ba12070f NL |
1251 | * \return 1 on success and 0 if an error occurred |
1252 | */ | |
5b5eea4b | 1253 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); |
ba12070f | 1254 | |
5b5eea4b | 1255 | # ifndef OPENSSL_NO_STDIO |
ba12070f NL |
1256 | /** Prints out the ec parameters on human readable form. |
1257 | * \param fp file descriptor to which the information is printed | |
1258 | * \param key EC_KEY object | |
1259 | * \return 1 on success and 0 if an error occurred | |
1260 | */ | |
5b5eea4b | 1261 | OSSL_DEPRECATEDIN_3_0 int ECParameters_print_fp(FILE *fp, const EC_KEY *key); |
ba12070f NL |
1262 | |
1263 | /** Prints out the contents of a EC_KEY object | |
1264 | * \param fp file descriptor to which the information is printed | |
1265 | * \param key EC_KEY object | |
0f113f3e | 1266 | * \param off line offset |
ba12070f NL |
1267 | * \return 1 on success and 0 if an error occurred |
1268 | */ | |
5b5eea4b SL |
1269 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); |
1270 | # endif /* OPENSSL_NO_STDIO */ | |
0bee0e62 | 1271 | |
5b5eea4b SL |
1272 | OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_OpenSSL(void); |
1273 | OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_default_method(void); | |
1274 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); | |
1275 | OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); | |
1276 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); | |
1277 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_method(ENGINE *engine); | |
28572b57 | 1278 | |
ffd89124 AS |
1279 | /** The old name for ecdh_KDF_X9_63 |
1280 | * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62, | |
1281 | * it is actually specified in ANSI X9.63. | |
1282 | * This identifier is retained for backwards compatibility | |
1283 | */ | |
5b5eea4b SL |
1284 | OSSL_DEPRECATEDIN_3_0 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, |
1285 | const unsigned char *Z, size_t Zlen, | |
1286 | const unsigned char *sinfo, | |
1287 | size_t sinfolen, const EVP_MD *md); | |
1288 | ||
1289 | OSSL_DEPRECATEDIN_3_0 int ECDH_compute_key(void *out, size_t outlen, | |
1290 | const EC_POINT *pub_key, | |
1291 | const EC_KEY *ecdh, | |
1292 | void *(*KDF)(const void *in, | |
1293 | size_t inlen, void *out, | |
1294 | size_t *outlen)); | |
1295 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
a22a7e70 | 1296 | |
714b2abb DSH |
1297 | typedef struct ECDSA_SIG_st ECDSA_SIG; |
1298 | ||
ef5b2ba6 DSH |
1299 | /** Allocates and initialize a ECDSA_SIG structure |
1300 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | |
1301 | */ | |
1302 | ECDSA_SIG *ECDSA_SIG_new(void); | |
1303 | ||
1304 | /** frees a ECDSA_SIG structure | |
1305 | * \param sig pointer to the ECDSA_SIG structure | |
1306 | */ | |
1307 | void ECDSA_SIG_free(ECDSA_SIG *sig); | |
1308 | ||
9fdcc21f | 1309 | /** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp |
ef5b2ba6 DSH |
1310 | * (*pp += length of the DER encoded signature)). |
1311 | * \param sig pointer to the ECDSA_SIG object | |
1312 | * \param pp pointer to a unsigned char pointer for the output or NULL | |
bbda7997 MC |
1313 | * \return the length of the DER encoded ECDSA_SIG object or a negative value |
1314 | * on error | |
ef5b2ba6 | 1315 | */ |
9fdcc21f | 1316 | DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG) |
ef5b2ba6 | 1317 | |
9fdcc21f | 1318 | /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp |
ef5b2ba6 DSH |
1319 | * (*pp += len)). |
1320 | * \param sig pointer to ECDSA_SIG pointer (may be NULL) | |
1321 | * \param pp memory buffer with the DER encoded signature | |
1322 | * \param len length of the buffer | |
1323 | * \return pointer to the decoded ECDSA_SIG structure (or NULL) | |
1324 | */ | |
ef5b2ba6 | 1325 | |
7236e3c8 | 1326 | /** Accessor for r and s fields of ECDSA_SIG |
0396401d | 1327 | * \param sig pointer to ECDSA_SIG structure |
7236e3c8 DSH |
1328 | * \param pr pointer to BIGNUM pointer for r (may be NULL) |
1329 | * \param ps pointer to BIGNUM pointer for s (may be NULL) | |
1330 | */ | |
9267c11b | 1331 | void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); |
7236e3c8 | 1332 | |
0396401d DMSP |
1333 | /** Accessor for r field of ECDSA_SIG |
1334 | * \param sig pointer to ECDSA_SIG structure | |
1335 | */ | |
1336 | const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); | |
1337 | ||
1338 | /** Accessor for s field of ECDSA_SIG | |
1339 | * \param sig pointer to ECDSA_SIG structure | |
1340 | */ | |
1341 | const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); | |
1342 | ||
6a571a18 | 1343 | /** Setter for r and s fields of ECDSA_SIG |
0396401d | 1344 | * \param sig pointer to ECDSA_SIG structure |
a0cef658 DMSP |
1345 | * \param r pointer to BIGNUM for r (may be NULL) |
1346 | * \param s pointer to BIGNUM for s (may be NULL) | |
6a571a18 | 1347 | */ |
1d454d58 | 1348 | int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); |
6a571a18 | 1349 | |
5b5eea4b | 1350 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
180eec16 DSH |
1351 | /** Computes the ECDSA signature of the given hash value using |
1352 | * the supplied private key and returns the created signature. | |
1353 | * \param dgst pointer to the hash value | |
1354 | * \param dgst_len length of the hash value | |
1355 | * \param eckey EC_KEY object containing a private EC key | |
1356 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | |
1357 | */ | |
5b5eea4b SL |
1358 | OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, |
1359 | int dgst_len, EC_KEY *eckey); | |
180eec16 DSH |
1360 | |
1361 | /** Computes ECDSA signature of a given hash value using the supplied | |
1362 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | |
1363 | * \param dgst pointer to the hash value to sign | |
1364 | * \param dgstlen length of the hash value | |
1365 | * \param kinv BIGNUM with a pre-computed inverse k (optional) | |
8483a003 | 1366 | * \param rp BIGNUM with a pre-computed rp value (optional), |
180eec16 DSH |
1367 | * see ECDSA_sign_setup |
1368 | * \param eckey EC_KEY object containing a private EC key | |
1369 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | |
1370 | */ | |
5b5eea4b SL |
1371 | OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, |
1372 | int dgstlen, const BIGNUM *kinv, | |
1373 | const BIGNUM *rp, EC_KEY *eckey); | |
180eec16 DSH |
1374 | |
1375 | /** Verifies that the supplied signature is a valid ECDSA | |
1376 | * signature of the supplied hash value using the supplied public key. | |
1377 | * \param dgst pointer to the hash value | |
1378 | * \param dgst_len length of the hash value | |
1379 | * \param sig ECDSA_SIG structure | |
1380 | * \param eckey EC_KEY object containing a public EC key | |
1381 | * \return 1 if the signature is valid, 0 if the signature is invalid | |
1382 | * and -1 on error | |
1383 | */ | |
5b5eea4b SL |
1384 | OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, |
1385 | const ECDSA_SIG *sig, EC_KEY *eckey); | |
180eec16 | 1386 | |
bd3602eb DSH |
1387 | /** Precompute parts of the signing operation |
1388 | * \param eckey EC_KEY object containing a private EC key | |
1389 | * \param ctx BN_CTX object (optional) | |
1390 | * \param kinv BIGNUM pointer for the inverse of k | |
1391 | * \param rp BIGNUM pointer for x coordinate of k * generator | |
1392 | * \return 1 on success and 0 otherwise | |
1393 | */ | |
5b5eea4b SL |
1394 | OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, |
1395 | BIGNUM **kinv, BIGNUM **rp); | |
bd3602eb DSH |
1396 | |
1397 | /** Computes ECDSA signature of a given hash value using the supplied | |
1398 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | |
1399 | * \param type this parameter is ignored | |
1400 | * \param dgst pointer to the hash value to sign | |
1401 | * \param dgstlen length of the hash value | |
1402 | * \param sig memory for the DER encoded created signature | |
1403 | * \param siglen pointer to the length of the returned signature | |
1404 | * \param eckey EC_KEY object containing a private EC key | |
1405 | * \return 1 on success and 0 otherwise | |
1406 | */ | |
5b5eea4b SL |
1407 | OSSL_DEPRECATEDIN_3_0 int ECDSA_sign(int type, const unsigned char *dgst, |
1408 | int dgstlen, unsigned char *sig, | |
1409 | unsigned int *siglen, EC_KEY *eckey); | |
bd3602eb DSH |
1410 | |
1411 | /** Computes ECDSA signature of a given hash value using the supplied | |
1412 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | |
1413 | * \param type this parameter is ignored | |
1414 | * \param dgst pointer to the hash value to sign | |
1415 | * \param dgstlen length of the hash value | |
1416 | * \param sig buffer to hold the DER encoded signature | |
1417 | * \param siglen pointer to the length of the returned signature | |
1418 | * \param kinv BIGNUM with a pre-computed inverse k (optional) | |
8483a003 | 1419 | * \param rp BIGNUM with a pre-computed rp value (optional), |
bd3602eb DSH |
1420 | * see ECDSA_sign_setup |
1421 | * \param eckey EC_KEY object containing a private EC key | |
1422 | * \return 1 on success and 0 otherwise | |
1423 | */ | |
5b5eea4b SL |
1424 | OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_ex(int type, const unsigned char *dgst, |
1425 | int dgstlen, unsigned char *sig, | |
1426 | unsigned int *siglen, const BIGNUM *kinv, | |
1427 | const BIGNUM *rp, EC_KEY *eckey); | |
bd3602eb DSH |
1428 | |
1429 | /** Verifies that the given signature is valid ECDSA signature | |
1430 | * of the supplied hash value using the specified public key. | |
1431 | * \param type this parameter is ignored | |
1432 | * \param dgst pointer to the hash value | |
1433 | * \param dgstlen length of the hash value | |
1434 | * \param sig pointer to the DER encoded signature | |
1435 | * \param siglen length of the DER encoded signature | |
1436 | * \param eckey EC_KEY object containing a public EC key | |
1437 | * \return 1 if the signature is valid, 0 if the signature is invalid | |
1438 | * and -1 on error | |
1439 | */ | |
5b5eea4b SL |
1440 | OSSL_DEPRECATEDIN_3_0 int ECDSA_verify(int type, const unsigned char *dgst, |
1441 | int dgstlen, const unsigned char *sig, | |
1442 | int siglen, EC_KEY *eckey); | |
7236e3c8 | 1443 | |
cf517a6d DSH |
1444 | /** Returns the maximum length of the DER encoded signature |
1445 | * \param eckey EC_KEY object | |
1446 | * \return numbers of bytes required for the DER encoded signature | |
1447 | */ | |
5b5eea4b | 1448 | OSSL_DEPRECATEDIN_3_0 int ECDSA_size(const EC_KEY *eckey); |
cf517a6d | 1449 | |
7bb75a5d DSH |
1450 | /********************************************************************/ |
1451 | /* EC_KEY_METHOD constructors, destructors, writers and accessors */ | |
1452 | /********************************************************************/ | |
1453 | ||
5b5eea4b SL |
1454 | OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); |
1455 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); | |
1456 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_init | |
1457 | (EC_KEY_METHOD *meth, | |
1458 | int (*init)(EC_KEY *key), | |
1459 | void (*finish)(EC_KEY *key), | |
1460 | int (*copy)(EC_KEY *dest, const EC_KEY *src), | |
1461 | int (*set_group)(EC_KEY *key, const EC_GROUP *grp), | |
1462 | int (*set_private)(EC_KEY *key, const BIGNUM *priv_key), | |
1463 | int (*set_public)(EC_KEY *key, const EC_POINT *pub_key)); | |
1464 | ||
1465 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, | |
1466 | int (*keygen)(EC_KEY *key)); | |
1467 | ||
1468 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_compute_key | |
1469 | (EC_KEY_METHOD *meth, | |
1470 | int (*ckey)(unsigned char **psec, size_t *pseclen, | |
1471 | const EC_POINT *pub_key, const EC_KEY *ecdh)); | |
1472 | ||
1473 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_sign | |
1474 | (EC_KEY_METHOD *meth, | |
1475 | int (*sign)(int type, const unsigned char *dgst, | |
1476 | int dlen, unsigned char *sig, | |
1477 | unsigned int *siglen, | |
1478 | const BIGNUM *kinv, const BIGNUM *r, | |
1479 | EC_KEY *eckey), | |
1480 | int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, | |
1481 | BIGNUM **kinvp, BIGNUM **rp), | |
1482 | ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, | |
1483 | int dgst_len, | |
1484 | const BIGNUM *in_kinv, | |
1485 | const BIGNUM *in_r, | |
1486 | EC_KEY *eckey)); | |
1487 | ||
1488 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_verify | |
1489 | (EC_KEY_METHOD *meth, | |
1490 | int (*verify)(int type, const unsigned | |
1491 | char *dgst, int dgst_len, | |
1492 | const unsigned char *sigbuf, | |
1493 | int sig_len, EC_KEY *eckey), | |
1494 | int (*verify_sig)(const unsigned char *dgst, | |
1495 | int dgst_len, const ECDSA_SIG *sig, | |
1496 | EC_KEY *eckey)); | |
1497 | ||
1498 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_init | |
1499 | (const EC_KEY_METHOD *meth, | |
1500 | int (**pinit)(EC_KEY *key), | |
1501 | void (**pfinish)(EC_KEY *key), | |
1502 | int (**pcopy)(EC_KEY *dest, const EC_KEY *src), | |
1503 | int (**pset_group)(EC_KEY *key, const EC_GROUP *grp), | |
1504 | int (**pset_private)(EC_KEY *key, const BIGNUM *priv_key), | |
1505 | int (**pset_public)(EC_KEY *key, const EC_POINT *pub_key)); | |
1506 | ||
1507 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_keygen | |
1508 | (const EC_KEY_METHOD *meth, int (**pkeygen)(EC_KEY *key)); | |
1509 | ||
1510 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_compute_key | |
1511 | (const EC_KEY_METHOD *meth, | |
1512 | int (**pck)(unsigned char **psec, | |
1513 | size_t *pseclen, | |
1514 | const EC_POINT *pub_key, | |
1515 | const EC_KEY *ecdh)); | |
1516 | ||
1517 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_sign | |
1518 | (const EC_KEY_METHOD *meth, | |
1519 | int (**psign)(int type, const unsigned char *dgst, | |
1520 | int dlen, unsigned char *sig, | |
1521 | unsigned int *siglen, | |
1522 | const BIGNUM *kinv, const BIGNUM *r, | |
1523 | EC_KEY *eckey), | |
1524 | int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, | |
1525 | BIGNUM **kinvp, BIGNUM **rp), | |
1526 | ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, | |
1527 | int dgst_len, | |
1528 | const BIGNUM *in_kinv, | |
1529 | const BIGNUM *in_r, | |
1530 | EC_KEY *eckey)); | |
1531 | ||
1532 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_verify | |
1533 | (const EC_KEY_METHOD *meth, | |
1534 | int (**pverify)(int type, const unsigned | |
1535 | char *dgst, int dgst_len, | |
1536 | const unsigned char *sigbuf, | |
1537 | int sig_len, EC_KEY *eckey), | |
1538 | int (**pverify_sig)(const unsigned char *dgst, | |
579422c8 | 1539 | int dgst_len, |
5b5eea4b SL |
1540 | const ECDSA_SIG *sig, |
1541 | EC_KEY *eckey)); | |
1542 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
579422c8 P |
1543 | |
1544 | # define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \ | |
5b5eea4b | 1545 | d2i_ECParameters, x) |
458c2917 | 1546 | |
ee8db22e P |
1547 | # ifndef __cplusplus |
1548 | # if defined(__SUNPRO_C) | |
1549 | # if __SUNPRO_C >= 0x520 | |
1550 | # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) | |
1551 | # endif | |
0f113f3e | 1552 | # endif |
ad0db060 | 1553 | # endif |
ad0db060 | 1554 | |
565b3399 RL |
1555 | # endif |
1556 | # ifdef __cplusplus | |
65e81670 | 1557 | } |
3c27208f | 1558 | # endif |
5acaa495 | 1559 | #endif |