]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/openssl/ec.h
Update copyright year
[thirdparty/openssl.git] / include / openssl / ec.h
1 /*
2 * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
4 *
5 * Licensed under the Apache License 2.0 (the "License"). You may not use
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
9 */
10
11 #ifndef OPENSSL_EC_H
12 # define OPENSSL_EC_H
13 # pragma once
14
15 # include <openssl/macros.h>
16 # ifndef OPENSSL_NO_DEPRECATED_3_0
17 # define HEADER_EC_H
18 # endif
19
20 # include <openssl/opensslconf.h>
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
70
71 /** Enum for the point conversion form as defined in X9.62 (ECDSA)
72 * for the encoding of a elliptic curve point (x,y) */
73 typedef enum {
74 /** the point is encoded as z||x, where the octet z specifies
75 * which solution of the quadratic equation y is */
76 POINT_CONVERSION_COMPRESSED = 2,
77 /** the point is encoded as z||x||y, where z is the octet 0x04 */
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
82 } point_conversion_form_t;
83
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
96 # include <openssl/params.h>
97 # ifndef OPENSSL_NO_DEPRECATED_3_0
98 typedef struct ec_method_st EC_METHOD;
99 # endif
100 typedef struct ec_group_st EC_GROUP;
101 typedef struct ec_point_st EC_POINT;
102 typedef struct ecpk_parameters_st ECPKPARAMETERS;
103 typedef struct ec_parameters_st ECPARAMETERS;
104
105 /********************************************************************/
106 /* EC_METHODs for curves over GF(p) */
107 /********************************************************************/
108
109 # ifndef OPENSSL_NO_DEPRECATED_3_0
110 /** Returns the basic GFp ec methods which provides the basis for the
111 * optimized methods.
112 * \return EC_METHOD object
113 */
114 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_simple_method(void);
115
116 /** Returns GFp methods using montgomery multiplication.
117 * \return EC_METHOD object
118 */
119 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_mont_method(void);
120
121 /** Returns GFp methods using optimized methods for NIST recommended curves
122 * \return EC_METHOD object
123 */
124 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nist_method(void);
125
126 # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
127 /** Returns 64-bit optimized methods for nistp224
128 * \return EC_METHOD object
129 */
130 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp224_method(void);
131
132 /** Returns 64-bit optimized methods for nistp256
133 * \return EC_METHOD object
134 */
135 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp256_method(void);
136
137 /** Returns 64-bit optimized methods for nistp521
138 * \return EC_METHOD object
139 */
140 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void);
141 # endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */
142
143 # ifndef OPENSSL_NO_EC2M
144 /********************************************************************/
145 /* EC_METHOD for curves over GF(2^m) */
146 /********************************************************************/
147
148 /** Returns the basic GF2m ec method
149 * \return EC_METHOD object
150 */
151 OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GF2m_simple_method(void);
152
153 # endif
154
155 /********************************************************************/
156 /* EC_GROUP functions */
157 /********************************************************************/
158
159 /**
160 * Creates a new EC_GROUP object
161 * \param meth EC_METHOD to use
162 * \return newly created EC_GROUP object or NULL in case of an error.
163 */
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 */
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
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
196 /** Creates a new EC_GROUP object and copies the content
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
203 /** Sets the generator and its order/cofactor of a EC_GROUP object.
204 * \param group EC_GROUP object
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.
209 * \return 1 on success and 0 if an error occurred
210 */
211 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
212 const BIGNUM *order, const BIGNUM *cofactor);
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
220 /** Returns the montgomery data for order(Generator)
221 * \param group EC_GROUP object
222 * \return the currently used montgomery data (possibly NULL).
223 */
224 BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);
225
226 /** Gets the order of a EC_GROUP
227 * \param group EC_GROUP object
228 * \param order BIGNUM to which the order is copied
229 * \param ctx unused
230 * \return 1 on success and 0 if an error occurred
231 */
232 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
233
234 /** Gets the order of an EC_GROUP
235 * \param group EC_GROUP object
236 * \return the group order
237 */
238 const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);
239
240 /** Gets the number of bits of the order of an EC_GROUP
241 * \param group EC_GROUP object
242 * \return number of bits of group order.
243 */
244 int EC_GROUP_order_bits(const EC_GROUP *group);
245
246 /** Gets the cofactor of a EC_GROUP
247 * \param group EC_GROUP object
248 * \param cofactor BIGNUM to which the cofactor is copied
249 * \param ctx unused
250 * \return 1 on success and 0 if an error occurred
251 */
252 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
253 BN_CTX *ctx);
254
255 /** Gets the cofactor of an EC_GROUP
256 * \param group EC_GROUP object
257 * \return the group cofactor
258 */
259 const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);
260
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);
266
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);
272
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
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
285 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
286 int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
287
288 void EC_GROUP_set_point_conversion_form(EC_GROUP *group,
289 point_conversion_form_t form);
290 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
291
292 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
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);
295
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)
298 * \param group EC_GROUP object
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
322 # ifndef OPENSSL_NO_DEPRECATED_3_0
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)
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)
330 * \return 1 on success and 0 if an error occurred
331 */
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);
337
338 /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
339 * \param group EC_GROUP object
340 * \param p BIGNUM with the prime number (GFp) or the polynomial
341 * defining the underlying field (GF2m)
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)
345 * \return 1 on success and 0 if an error occurred
346 */
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);
351
352 # ifndef OPENSSL_NO_EC2M
353 /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve
354 * \param group EC_GROUP object
355 * \param p BIGNUM with the prime number (GFp) or the polynomial
356 * defining the underlying field (GF2m)
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)
360 * \return 1 on success and 0 if an error occurred
361 */
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);
367
368 /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
369 * \param group EC_GROUP object
370 * \param p BIGNUM with the prime number (GFp) or the polynomial
371 * defining the underlying field (GF2m)
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)
375 * \return 1 on success and 0 if an error occurred
376 */
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
384 /** Returns the number of bits needed to represent a field element
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);
389
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 */
395 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
396
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)
408 * \return 0 if the groups are equal, 1 if not, or -1 on error
409 */
410 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
411
412 /*
413 * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after
414 * choosing an appropriate EC_METHOD
415 */
416
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 */
425 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
426 const BIGNUM *b, BN_CTX *ctx);
427 # ifndef OPENSSL_NO_EC2M
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 */
436 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,
437 const BIGNUM *b, BN_CTX *ctx);
438 # endif
439
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[],
451 OSSL_LIB_CTX *libctx, const char *propq);
452
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
457 * \param propq A property query string
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 */
462 EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq,
463 int nid);
464
465 /**
466 * Creates a EC_GROUP object with a curve specified by a NID. Same as
467 * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always
468 * NULL.
469 * \param nid NID of the OID of the curve name
470 * \return newly created EC_GROUP object with specified curve or NULL
471 * if an error occurred
472 */
473 EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
474
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
482 /** Creates an ECPARAMETERS object for the given EC_GROUP object.
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
498 /** Creates an ECPKPARAMETERS object for the given EC_GROUP object.
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
507 /********************************************************************/
508 /* handling of internal curves */
509 /********************************************************************/
510
511 typedef struct {
512 int nid;
513 const char *comment;
514 } EC_builtin_curve;
515
516 /*
517 * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all
518 * available curves or zero if a error occurred. In case r is not zero,
519 * nitems EC_builtin_curve structures are filled with the data of the first
520 * nitems internal groups
521 */
522 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
523
524 const char *EC_curve_nid2nist(int nid);
525 int EC_curve_nist2nid(const char *name);
526 int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only,
527 BN_CTX *ctx);
528
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
552 * \return 1 on success and 0 if an error occurred
553 */
554 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
555
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
560 * \return newly created EC_POINT object or NULL if an error occurred
561 */
562 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
563
564 /** Sets a point to infinity (neutral element)
565 * \param group underlying EC_GROUP object
566 * \param point EC_POINT to set to infinity
567 * \return 1 on success and 0 if an error occurred
568 */
569 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
570
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
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)
585 * \return 1 on success and 0 if an error occurred
586 */
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);
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)
599 * \return 1 on success and 0 if an error occurred
600 */
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 */
605
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
629 # ifndef OPENSSL_NO_DEPRECATED_3_0
630 /** Sets the affine coordinates of an EC_POINT. A synonym of
631 * EC_POINT_set_affine_coordinates
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)
637 * \return 1 on success and 0 if an error occurred
638 */
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);
642
643 /** Gets the affine coordinates of an EC_POINT. A synonym of
644 * EC_POINT_get_affine_coordinates
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)
650 * \return 1 on success and 0 if an error occurred
651 */
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 */
656
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
669 # ifndef OPENSSL_NO_DEPRECATED_3_0
670 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
671 * EC_POINT_set_compressed_coordinates
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)
677 * \return 1 on success and 0 if an error occurred
678 */
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
683 /** Sets the affine coordinates of an EC_POINT. A synonym of
684 * EC_POINT_set_affine_coordinates
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)
690 * \return 1 on success and 0 if an error occurred
691 */
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);
695
696 /** Gets the affine coordinates of an EC_POINT. A synonym of
697 * EC_POINT_get_affine_coordinates
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)
703 * \return 1 on success and 0 if an error occurred
704 */
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);
708
709 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
710 * EC_POINT_set_compressed_coordinates
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)
716 * \return 1 on success and 0 if an error occurred
717 */
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
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,
735 point_conversion_form_t form,
736 unsigned char *buf, size_t len, BN_CTX *ctx);
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)
744 * \return 1 on success and 0 if an error occurred
745 */
746 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
747 const unsigned char *buf, size_t len, BN_CTX *ctx);
748
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
754 * \param ctx BN_CTX object (optional)
755 * \return the length of the encoded octet string or 0 if an error occurred
756 */
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
761 /* other interfaces to point2oct/oct2point: */
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
772 char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
773 point_conversion_form_t form, BN_CTX *);
774 EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
775 EC_POINT *, BN_CTX *);
776
777 /********************************************************************/
778 /* functions for doing EC_POINT arithmetic */
779 /********************************************************************/
780
781 /** Computes the sum of two EC_POINT
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)
787 * \return 1 on success and 0 if an error occurred
788 */
789 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
790 const EC_POINT *b, BN_CTX *ctx);
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)
795 * \param a EC_POINT object
796 * \param ctx BN_CTX object (optional)
797 * \return 1 on success and 0 if an error occurred
798 */
799 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
800 BN_CTX *ctx);
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)
806 * \return 1 on success and 0 if an error occurred
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
817 /** Checks whether the point is on the curve
818 * \param group underlying EC_GROUP object
819 * \param point EC_POINT object to check
820 * \param ctx BN_CTX object (optional)
821 * \return 1 if the point is on the curve, 0 if not, or -1 on error
822 */
823 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
824 BN_CTX *ctx);
825
826 /** Compares two EC_POINTs
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)
831 * \return 1 if the points are not equal, 0 if they are, or -1 on error
832 */
833 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
834 BN_CTX *ctx);
835
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);
841
842 /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]
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)
846 * \param num number further summands
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)
850 * \return 1 on success and 0 if an error occurred
851 */
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 */
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)
865 * \return 1 on success and 0 if an error occurred
866 */
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);
869
870 # ifndef OPENSSL_NO_DEPRECATED_3_0
871 /** Stores multiples of generator for faster point multiplication
872 * \param group EC_GROUP object
873 * \param ctx BN_CTX object (optional)
874 * \return 1 on success and 0 if an error occurred
875 */
876 OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
877
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 */
882 OSSL_DEPRECATEDIN_3_0 int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
883 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
884
885 /********************************************************************/
886 /* ASN1 stuff */
887 /********************************************************************/
888
889 DECLARE_ASN1_ITEM(ECPKPARAMETERS)
890 DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS)
891 DECLARE_ASN1_ITEM(ECPARAMETERS)
892 DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)
893
894 /*
895 * EC_GROUP_get_basis_type() returns the NID of the basis type used to
896 * represent the field elements
897 */
898 int EC_GROUP_get_basis_type(const EC_GROUP *);
899 # ifndef OPENSSL_NO_EC2M
900 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
901 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
902 unsigned int *k2, unsigned int *k3);
903 # endif
904
905 EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
906 int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
907
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))
917
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 */
926
927 /********************************************************************/
928 /* EC_KEY functions */
929 /********************************************************************/
930
931 /* some values for the encoding_flag */
932 # define EC_PKEY_NO_PARAMETERS 0x001
933 # define EC_PKEY_NO_PUBKEY 0x002
934
935 /* some values for the flags field */
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
946
947 # ifndef OPENSSL_NO_DEPRECATED_3_0
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 */
954 OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, const char *propq);
955
956 /**
957 * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a
958 * NULL library context
959 * \return EC_KEY object or NULL if an error occurred.
960 */
961 OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new(void);
962
963 OSSL_DEPRECATEDIN_3_0 int EC_KEY_get_flags(const EC_KEY *key);
964
965 OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_flags(EC_KEY *key, int flags);
966
967 OSSL_DEPRECATEDIN_3_0 void EC_KEY_clear_flags(EC_KEY *key, int flags);
968
969 OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key);
970
971 /**
972 * Creates a new EC_KEY object using a named curve as underlying
973 * EC_GROUP object.
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.
978 * \return EC_KEY object or NULL if an error occurred.
979 */
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);
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
987 * library context and property query string.
988 * \param nid NID of the named curve.
989 * \return EC_KEY object or NULL if an error occurred.
990 */
991 OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid);
992
993 /** Frees a EC_KEY object.
994 * \param key EC_KEY object to be freed.
995 */
996 OSSL_DEPRECATEDIN_3_0 void EC_KEY_free(EC_KEY *key);
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 */
1003 OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
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 */
1009 OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_dup(const EC_KEY *src);
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 */
1015 OSSL_DEPRECATEDIN_3_0 int EC_KEY_up_ref(EC_KEY *key);
1016
1017 /** Returns the ENGINE object of a EC_KEY object
1018 * \param eckey EC_KEY object
1019 * \return the ENGINE object (possibly NULL).
1020 */
1021 OSSL_DEPRECATEDIN_3_0 ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey);
1022
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 */
1027 OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
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 */
1035 OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
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 */
1041 OSSL_DEPRECATEDIN_3_0 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
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 */
1049 OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
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 */
1055 OSSL_DEPRECATEDIN_3_0 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
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 */
1063 OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
1064
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 */
1071
1072 # define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
1073 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
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);
1078
1079 /* wrapper functions for the underlying EC_GROUP object */
1080 OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
1081
1082 /** Creates a table of pre-computed multiples of the generator to
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 */
1088 OSSL_DEPRECATEDIN_3_0 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
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 */
1094 OSSL_DEPRECATEDIN_3_0 int EC_KEY_generate_key(EC_KEY *key);
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 */
1100 OSSL_DEPRECATEDIN_3_0 int EC_KEY_check_key(const EC_KEY *key);
1101
1102 /** Indicates if an EC_KEY can be used for signing.
1103 * \param eckey the EC_KEY object
1104 * \return 1 if can can sign and 0 otherwise.
1105 */
1106 OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey);
1107
1108 /** Sets a public key from affine coordinates performing
1109 * necessary NIST PKV tests.
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 */
1115 OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key,
1116 BIGNUM *x,
1117 BIGNUM *y);
1118
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
1123 * \param ctx BN_CTX object (optional)
1124 * \return the length of the encoded octet string or 0 if an error occurred
1125 */
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);
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
1138 OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf,
1139 size_t len, BN_CTX *ctx);
1140
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
1148 OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf,
1149 size_t len);
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
1159 OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key,
1160 unsigned char *buf, size_t len);
1161
1162 /** Encodes an EC_KEY private key to an allocated octet string
1163 * \param eckey key to encode
1164 * \param pbuf returns pointer to allocated buffer
1165 * \return the length of the encoded octet string or 0 if an error occurred
1166 */
1167 OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey,
1168 unsigned char **pbuf);
1169
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 */
1180 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key,
1181 const unsigned char **in,
1182 long len);
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 */
1190 OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key,
1191 unsigned char **out);
1192
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 */
1204 OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key,
1205 const unsigned char **in,
1206 long len);
1207
1208 /** Encodes ec parameter and stores the result in a buffer.
1209 * \param key the EC_KEY object with ec parameters to encode
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 */
1214 OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key,
1215 unsigned char **out);
1216
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 */
1229 OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key,
1230 const unsigned char **in, long len);
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 */
1238 OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out);
1239
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 */
1245 OSSL_DEPRECATEDIN_3_0 int ECParameters_print(BIO *bp, const EC_KEY *key);
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
1250 * \param off line offset
1251 * \return 1 on success and 0 if an error occurred
1252 */
1253 OSSL_DEPRECATEDIN_3_0 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
1254
1255 # ifndef OPENSSL_NO_STDIO
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 */
1261 OSSL_DEPRECATEDIN_3_0 int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
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
1266 * \param off line offset
1267 * \return 1 on success and 0 if an error occurred
1268 */
1269 OSSL_DEPRECATEDIN_3_0 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
1270 # endif /* OPENSSL_NO_STDIO */
1271
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);
1278
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 */
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 */
1296
1297 typedef struct ECDSA_SIG_st ECDSA_SIG;
1298
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
1309 /** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp
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
1313 * \return the length of the DER encoded ECDSA_SIG object or a negative value
1314 * on error
1315 */
1316 DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG)
1317
1318 /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp
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 */
1325
1326 /** Accessor for r and s fields of ECDSA_SIG
1327 * \param sig pointer to ECDSA_SIG structure
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 */
1331 void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
1332
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
1343 /** Setter for r and s fields of ECDSA_SIG
1344 * \param sig pointer to ECDSA_SIG structure
1345 * \param r pointer to BIGNUM for r (may be NULL)
1346 * \param s pointer to BIGNUM for s (may be NULL)
1347 */
1348 int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
1349
1350 # ifndef OPENSSL_NO_DEPRECATED_3_0
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 */
1358 OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,
1359 int dgst_len, EC_KEY *eckey);
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)
1366 * \param rp BIGNUM with a pre-computed rp value (optional),
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 */
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);
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 */
1384 OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
1385 const ECDSA_SIG *sig, EC_KEY *eckey);
1386
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 */
1394 OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx,
1395 BIGNUM **kinv, BIGNUM **rp);
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 */
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);
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)
1419 * \param rp BIGNUM with a pre-computed rp value (optional),
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 */
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);
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 */
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);
1443
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 */
1448 OSSL_DEPRECATEDIN_3_0 int ECDSA_size(const EC_KEY *eckey);
1449
1450 /********************************************************************/
1451 /* EC_KEY_METHOD constructors, destructors, writers and accessors */
1452 /********************************************************************/
1453
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,
1539 int dgst_len,
1540 const ECDSA_SIG *sig,
1541 EC_KEY *eckey));
1542 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
1543
1544 # define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \
1545 d2i_ECParameters, x)
1546
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
1552 # endif
1553 # endif
1554
1555 # endif
1556 # ifdef __cplusplus
1557 }
1558 # endif
1559 #endif