2 * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* ====================================================================
11 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
13 * Portions of the attached software ("Contribution") are developed by
14 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
16 * The Contribution is licensed pursuant to the OpenSSL open source
17 * license provided above.
19 * The elliptic curve binary polynomial software is originally written by
20 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
27 # include <openssl/opensslconf.h>
29 # ifndef OPENSSL_NO_EC
30 # include <openssl/asn1.h>
31 # include <openssl/symhacks.h>
32 # if OPENSSL_API_COMPAT < 0x10100000L
33 # include <openssl/bn.h>
39 # ifndef OPENSSL_ECC_MAX_FIELD_BITS
40 # define OPENSSL_ECC_MAX_FIELD_BITS 661
43 /** Enum for the point conversion form as defined in X9.62 (ECDSA)
44 * for the encoding of a elliptic curve point (x,y) */
46 /** the point is encoded as z||x, where the octet z specifies
47 * which solution of the quadratic equation y is */
48 POINT_CONVERSION_COMPRESSED
= 2,
49 /** the point is encoded as z||x||y, where z is the octet 0x04 */
50 POINT_CONVERSION_UNCOMPRESSED
= 4,
51 /** the point is encoded as z||x||y, where the octet z specifies
52 * which solution of the quadratic equation y is */
53 POINT_CONVERSION_HYBRID
= 6
54 } point_conversion_form_t
;
56 typedef struct ec_method_st EC_METHOD
;
57 typedef struct ec_group_st EC_GROUP
;
58 typedef struct ec_point_st EC_POINT
;
59 typedef struct ecpk_parameters_st ECPKPARAMETERS
;
60 typedef struct ec_parameters_st ECPARAMETERS
;
62 /********************************************************************/
63 /* EC_METHODs for curves over GF(p) */
64 /********************************************************************/
66 /** Returns the basic GFp ec methods which provides the basis for the
68 * \return EC_METHOD object
70 const EC_METHOD
*EC_GFp_simple_method(void);
72 /** Returns GFp methods using montgomery multiplication.
73 * \return EC_METHOD object
75 const EC_METHOD
*EC_GFp_mont_method(void);
77 /** Returns GFp methods using optimized methods for NIST recommended curves
78 * \return EC_METHOD object
80 const EC_METHOD
*EC_GFp_nist_method(void);
82 # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
83 # ifndef OPENSSL_SYS_WIN32
84 /** Returns 64-bit optimized methods for nistp224
85 * \return EC_METHOD object
87 const EC_METHOD
*EC_GFp_nistp224_method(void);
89 /** Returns 64-bit optimized methods for nistp256
90 * \return EC_METHOD object
92 const EC_METHOD
*EC_GFp_nistp256_method(void);
94 /** Returns 64-bit optimized methods for nistp521
95 * \return EC_METHOD object
97 const EC_METHOD
*EC_GFp_nistp521_method(void);
101 # ifndef OPENSSL_NO_EC2M
102 /********************************************************************/
103 /* EC_METHOD for curves over GF(2^m) */
104 /********************************************************************/
106 /** Returns the basic GF2m ec method
107 * \return EC_METHOD object
109 const EC_METHOD
*EC_GF2m_simple_method(void);
113 /********************************************************************/
114 /* EC_GROUP functions */
115 /********************************************************************/
117 /** Creates a new EC_GROUP object
118 * \param meth EC_METHOD to use
119 * \return newly created EC_GROUP object or NULL in case of an error.
121 EC_GROUP
*EC_GROUP_new(const EC_METHOD
*meth
);
123 /** Frees a EC_GROUP object
124 * \param group EC_GROUP object to be freed.
126 void EC_GROUP_free(EC_GROUP
*group
);
128 /** Clears and frees a EC_GROUP object
129 * \param group EC_GROUP object to be cleared and freed.
131 void EC_GROUP_clear_free(EC_GROUP
*group
);
133 /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
134 * \param dst destination EC_GROUP object
135 * \param src source EC_GROUP object
136 * \return 1 on success and 0 if an error occurred.
138 int EC_GROUP_copy(EC_GROUP
*dst
, const EC_GROUP
*src
);
140 /** Creates a new EC_GROUP object and copies the copies the content
141 * form src to the newly created EC_KEY object
142 * \param src source EC_GROUP object
143 * \return newly created EC_GROUP object or NULL in case of an error.
145 EC_GROUP
*EC_GROUP_dup(const EC_GROUP
*src
);
147 /** Returns the EC_METHOD of the EC_GROUP object.
148 * \param group EC_GROUP object
149 * \return EC_METHOD used in this EC_GROUP object.
151 const EC_METHOD
*EC_GROUP_method_of(const EC_GROUP
*group
);
153 /** Returns the field type of the EC_METHOD.
154 * \param meth EC_METHOD object
155 * \return NID of the underlying field type OID.
157 int EC_METHOD_get_field_type(const EC_METHOD
*meth
);
159 /** Sets the generator and it's order/cofactor of a EC_GROUP object.
160 * \param group EC_GROUP object
161 * \param generator EC_POINT object with the generator.
162 * \param order the order of the group generated by the generator.
163 * \param cofactor the index of the sub-group generated by the generator
164 * in the group of all points on the elliptic curve.
165 * \return 1 on success and 0 if an error occurred
167 int EC_GROUP_set_generator(EC_GROUP
*group
, const EC_POINT
*generator
,
168 const BIGNUM
*order
, const BIGNUM
*cofactor
);
170 /** Returns the generator of a EC_GROUP object.
171 * \param group EC_GROUP object
172 * \return the currently used generator (possibly NULL).
174 const EC_POINT
*EC_GROUP_get0_generator(const EC_GROUP
*group
);
176 /** Returns the montgomery data for order(Generator)
177 * \param group EC_GROUP object
178 * \return the currently used generator (possibly NULL).
180 BN_MONT_CTX
*EC_GROUP_get_mont_data(const EC_GROUP
*group
);
182 /** Gets the order of a EC_GROUP
183 * \param group EC_GROUP object
184 * \param order BIGNUM to which the order is copied
186 * \return 1 on success and 0 if an error occurred
188 int EC_GROUP_get_order(const EC_GROUP
*group
, BIGNUM
*order
, BN_CTX
*ctx
);
190 /** Gets the order of an EC_GROUP
191 * \param group EC_GROUP object
192 * \return the group order
195 const BIGNUM
*EC_GROUP_get0_order(const EC_GROUP
*group
);
197 /** Gets the number of bits of the order of an EC_GROUP
198 * \param group EC_GROUP object
199 * \return number of bits of group order.
202 int EC_GROUP_order_bits(const EC_GROUP
*group
);
204 /** Gets the cofactor of a EC_GROUP
205 * \param group EC_GROUP object
206 * \param cofactor BIGNUM to which the cofactor is copied
208 * \return 1 on success and 0 if an error occurred
210 int EC_GROUP_get_cofactor(const EC_GROUP
*group
, BIGNUM
*cofactor
,
213 /** Gets the cofactor of an EC_GROUP
214 * \param group EC_GROUP object
215 * \return the group cofactor
218 const BIGNUM
*EC_GROUP_get0_cofactor(const EC_GROUP
*group
);
220 /** Sets the name of a EC_GROUP object
221 * \param group EC_GROUP object
222 * \param nid NID of the curve name OID
224 void EC_GROUP_set_curve_name(EC_GROUP
*group
, int nid
);
226 /** Returns the curve name of a EC_GROUP object
227 * \param group EC_GROUP object
228 * \return NID of the curve name OID or 0 if not set.
230 int EC_GROUP_get_curve_name(const EC_GROUP
*group
);
232 void EC_GROUP_set_asn1_flag(EC_GROUP
*group
, int flag
);
233 int EC_GROUP_get_asn1_flag(const EC_GROUP
*group
);
235 void EC_GROUP_set_point_conversion_form(EC_GROUP
*group
,
236 point_conversion_form_t form
);
237 point_conversion_form_t
EC_GROUP_get_point_conversion_form(const EC_GROUP
*);
239 unsigned char *EC_GROUP_get0_seed(const EC_GROUP
*x
);
240 size_t EC_GROUP_get_seed_len(const EC_GROUP
*);
241 size_t EC_GROUP_set_seed(EC_GROUP
*, const unsigned char *, size_t len
);
243 /** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
244 * \param group EC_GROUP object
245 * \param p BIGNUM with the prime number
246 * \param a BIGNUM with parameter a of the equation
247 * \param b BIGNUM with parameter b of the equation
248 * \param ctx BN_CTX object (optional)
249 * \return 1 on success and 0 if an error occurred
251 int EC_GROUP_set_curve_GFp(EC_GROUP
*group
, const BIGNUM
*p
, const BIGNUM
*a
,
252 const BIGNUM
*b
, BN_CTX
*ctx
);
254 /** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
255 * \param group EC_GROUP object
256 * \param p BIGNUM for the prime number
257 * \param a BIGNUM for parameter a of the equation
258 * \param b BIGNUM for parameter b of the equation
259 * \param ctx BN_CTX object (optional)
260 * \return 1 on success and 0 if an error occurred
262 int EC_GROUP_get_curve_GFp(const EC_GROUP
*group
, BIGNUM
*p
, BIGNUM
*a
,
263 BIGNUM
*b
, BN_CTX
*ctx
);
265 # ifndef OPENSSL_NO_EC2M
266 /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
267 * \param group EC_GROUP object
268 * \param p BIGNUM with the polynomial defining the underlying field
269 * \param a BIGNUM with parameter a of the equation
270 * \param b BIGNUM with parameter b of the equation
271 * \param ctx BN_CTX object (optional)
272 * \return 1 on success and 0 if an error occurred
274 int EC_GROUP_set_curve_GF2m(EC_GROUP
*group
, const BIGNUM
*p
, const BIGNUM
*a
,
275 const BIGNUM
*b
, BN_CTX
*ctx
);
277 /** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
278 * \param group EC_GROUP object
279 * \param p BIGNUM for the polynomial defining the underlying field
280 * \param a BIGNUM for parameter a of the equation
281 * \param b BIGNUM for parameter b of the equation
282 * \param ctx BN_CTX object (optional)
283 * \return 1 on success and 0 if an error occurred
285 int EC_GROUP_get_curve_GF2m(const EC_GROUP
*group
, BIGNUM
*p
, BIGNUM
*a
,
286 BIGNUM
*b
, BN_CTX
*ctx
);
288 /** Returns the number of bits needed to represent a field element
289 * \param group EC_GROUP object
290 * \return number of bits needed to represent a field element
292 int EC_GROUP_get_degree(const EC_GROUP
*group
);
294 /** Checks whether the parameter in the EC_GROUP define a valid ec group
295 * \param group EC_GROUP object
296 * \param ctx BN_CTX object (optional)
297 * \return 1 if group is a valid ec group and 0 otherwise
299 int EC_GROUP_check(const EC_GROUP
*group
, BN_CTX
*ctx
);
301 /** Checks whether the discriminant of the elliptic curve is zero or not
302 * \param group EC_GROUP object
303 * \param ctx BN_CTX object (optional)
304 * \return 1 if the discriminant is not zero and 0 otherwise
306 int EC_GROUP_check_discriminant(const EC_GROUP
*group
, BN_CTX
*ctx
);
308 /** Compares two EC_GROUP objects
309 * \param a first EC_GROUP object
310 * \param b second EC_GROUP object
311 * \param ctx BN_CTX object (optional)
312 * \return 0 if both groups are equal and 1 otherwise
314 int EC_GROUP_cmp(const EC_GROUP
*a
, const EC_GROUP
*b
, BN_CTX
*ctx
);
317 * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after
318 * choosing an appropriate EC_METHOD
321 /** Creates a new EC_GROUP object with the specified parameters defined
322 * over GFp (defined by the equation y^2 = x^3 + a*x + b)
323 * \param p BIGNUM with the prime number
324 * \param a BIGNUM with the parameter a of the equation
325 * \param b BIGNUM with the parameter b of the equation
326 * \param ctx BN_CTX object (optional)
327 * \return newly created EC_GROUP object with the specified parameters
329 EC_GROUP
*EC_GROUP_new_curve_GFp(const BIGNUM
*p
, const BIGNUM
*a
,
330 const BIGNUM
*b
, BN_CTX
*ctx
);
331 # ifndef OPENSSL_NO_EC2M
332 /** Creates a new EC_GROUP object with the specified parameters defined
333 * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
334 * \param p BIGNUM with the polynomial defining the underlying field
335 * \param a BIGNUM with the parameter a of the equation
336 * \param b BIGNUM with the parameter b of the equation
337 * \param ctx BN_CTX object (optional)
338 * \return newly created EC_GROUP object with the specified parameters
340 EC_GROUP
*EC_GROUP_new_curve_GF2m(const BIGNUM
*p
, const BIGNUM
*a
,
341 const BIGNUM
*b
, BN_CTX
*ctx
);
344 /** Creates a EC_GROUP object with a curve specified by a NID
345 * \param nid NID of the OID of the curve name
346 * \return newly created EC_GROUP object with specified curve or NULL
347 * if an error occurred
349 EC_GROUP
*EC_GROUP_new_by_curve_name(int nid
);
351 /** Creates a new EC_GROUP object from an ECPARAMETERS object
352 * \param params pointer to the ECPARAMETERS object
353 * \return newly created EC_GROUP object with specified curve or NULL
354 * if an error occurred
356 EC_GROUP
*EC_GROUP_new_from_ecparameters(const ECPARAMETERS
*params
);
358 /** Creates an ECPARAMETERS object for the the given EC_GROUP object.
359 * \param group pointer to the EC_GROUP object
360 * \param params pointer to an existing ECPARAMETERS object or NULL
361 * \return pointer to the new ECPARAMETERS object or NULL
362 * if an error occurred.
364 ECPARAMETERS
*EC_GROUP_get_ecparameters(const EC_GROUP
*group
,
365 ECPARAMETERS
*params
);
367 /** Creates a new EC_GROUP object from an ECPKPARAMETERS object
368 * \param params pointer to an existing ECPKPARAMETERS object, or NULL
369 * \return newly created EC_GROUP object with specified curve, or NULL
370 * if an error occurred
372 EC_GROUP
*EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS
*params
);
374 /** Creates an ECPKPARAMETERS object for the the given EC_GROUP object.
375 * \param group pointer to the EC_GROUP object
376 * \param params pointer to an existing ECPKPARAMETERS object or NULL
377 * \return pointer to the new ECPKPARAMETERS object or NULL
378 * if an error occurred.
380 ECPKPARAMETERS
*EC_GROUP_get_ecpkparameters(const EC_GROUP
*group
,
381 ECPKPARAMETERS
*params
);
383 /********************************************************************/
384 /* handling of internal curves */
385 /********************************************************************/
393 * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all
394 * available curves or zero if a error occurred. In case r is not zero,
395 * nitems EC_builtin_curve structures are filled with the data of the first
396 * nitems internal groups
398 size_t EC_get_builtin_curves(EC_builtin_curve
*r
, size_t nitems
);
400 const char *EC_curve_nid2nist(int nid
);
401 int EC_curve_nist2nid(const char *name
);
403 /********************************************************************/
404 /* EC_POINT functions */
405 /********************************************************************/
407 /** Creates a new EC_POINT object for the specified EC_GROUP
408 * \param group EC_GROUP the underlying EC_GROUP object
409 * \return newly created EC_POINT object or NULL if an error occurred
411 EC_POINT
*EC_POINT_new(const EC_GROUP
*group
);
413 /** Frees a EC_POINT object
414 * \param point EC_POINT object to be freed
416 void EC_POINT_free(EC_POINT
*point
);
418 /** Clears and frees a EC_POINT object
419 * \param point EC_POINT object to be cleared and freed
421 void EC_POINT_clear_free(EC_POINT
*point
);
423 /** Copies EC_POINT object
424 * \param dst destination EC_POINT object
425 * \param src source EC_POINT object
426 * \return 1 on success and 0 if an error occurred
428 int EC_POINT_copy(EC_POINT
*dst
, const EC_POINT
*src
);
430 /** Creates a new EC_POINT object and copies the content of the supplied
432 * \param src source EC_POINT object
433 * \param group underlying the EC_GROUP object
434 * \return newly created EC_POINT object or NULL if an error occurred
436 EC_POINT
*EC_POINT_dup(const EC_POINT
*src
, const EC_GROUP
*group
);
438 /** Returns the EC_METHOD used in EC_POINT object
439 * \param point EC_POINT object
440 * \return the EC_METHOD used
442 const EC_METHOD
*EC_POINT_method_of(const EC_POINT
*point
);
444 /** Sets a point to infinity (neutral element)
445 * \param group underlying EC_GROUP object
446 * \param point EC_POINT to set to infinity
447 * \return 1 on success and 0 if an error occurred
449 int EC_POINT_set_to_infinity(const EC_GROUP
*group
, EC_POINT
*point
);
451 /** Sets the jacobian projective coordinates of a EC_POINT over GFp
452 * \param group underlying EC_GROUP object
453 * \param p EC_POINT object
454 * \param x BIGNUM with the x-coordinate
455 * \param y BIGNUM with the y-coordinate
456 * \param z BIGNUM with the z-coordinate
457 * \param ctx BN_CTX object (optional)
458 * \return 1 on success and 0 if an error occurred
460 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP
*group
,
461 EC_POINT
*p
, const BIGNUM
*x
,
462 const BIGNUM
*y
, const BIGNUM
*z
,
465 /** Gets the jacobian projective coordinates of a EC_POINT over GFp
466 * \param group underlying EC_GROUP object
467 * \param p EC_POINT object
468 * \param x BIGNUM for the x-coordinate
469 * \param y BIGNUM for the y-coordinate
470 * \param z BIGNUM for the z-coordinate
471 * \param ctx BN_CTX object (optional)
472 * \return 1 on success and 0 if an error occurred
474 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP
*group
,
475 const EC_POINT
*p
, BIGNUM
*x
,
476 BIGNUM
*y
, BIGNUM
*z
,
479 /** Sets the affine coordinates of a EC_POINT over GFp
480 * \param group underlying EC_GROUP object
481 * \param p EC_POINT object
482 * \param x BIGNUM with the x-coordinate
483 * \param y BIGNUM with the y-coordinate
484 * \param ctx BN_CTX object (optional)
485 * \return 1 on success and 0 if an error occurred
487 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP
*group
, EC_POINT
*p
,
488 const BIGNUM
*x
, const BIGNUM
*y
,
491 /** Gets the affine coordinates of a EC_POINT over GFp
492 * \param group underlying EC_GROUP object
493 * \param p EC_POINT object
494 * \param x BIGNUM for the x-coordinate
495 * \param y BIGNUM for the y-coordinate
496 * \param ctx BN_CTX object (optional)
497 * \return 1 on success and 0 if an error occurred
499 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP
*group
,
500 const EC_POINT
*p
, BIGNUM
*x
,
501 BIGNUM
*y
, BN_CTX
*ctx
);
503 /** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
504 * \param group underlying EC_GROUP object
505 * \param p EC_POINT object
506 * \param x BIGNUM with x-coordinate
507 * \param y_bit integer with the y-Bit (either 0 or 1)
508 * \param ctx BN_CTX object (optional)
509 * \return 1 on success and 0 if an error occurred
511 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP
*group
,
512 EC_POINT
*p
, const BIGNUM
*x
,
513 int y_bit
, BN_CTX
*ctx
);
514 # ifndef OPENSSL_NO_EC2M
515 /** Sets the affine coordinates of a EC_POINT over GF2m
516 * \param group underlying EC_GROUP object
517 * \param p EC_POINT object
518 * \param x BIGNUM with the x-coordinate
519 * \param y BIGNUM with the y-coordinate
520 * \param ctx BN_CTX object (optional)
521 * \return 1 on success and 0 if an error occurred
523 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP
*group
, EC_POINT
*p
,
524 const BIGNUM
*x
, const BIGNUM
*y
,
527 /** Gets the affine coordinates of a EC_POINT over GF2m
528 * \param group underlying EC_GROUP object
529 * \param p EC_POINT object
530 * \param x BIGNUM for the x-coordinate
531 * \param y BIGNUM for the y-coordinate
532 * \param ctx BN_CTX object (optional)
533 * \return 1 on success and 0 if an error occurred
535 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP
*group
,
536 const EC_POINT
*p
, BIGNUM
*x
,
537 BIGNUM
*y
, BN_CTX
*ctx
);
539 /** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
540 * \param group underlying EC_GROUP object
541 * \param p EC_POINT object
542 * \param x BIGNUM with x-coordinate
543 * \param y_bit integer with the y-Bit (either 0 or 1)
544 * \param ctx BN_CTX object (optional)
545 * \return 1 on success and 0 if an error occurred
547 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP
*group
,
548 EC_POINT
*p
, const BIGNUM
*x
,
549 int y_bit
, BN_CTX
*ctx
);
551 /** Encodes a EC_POINT object to a octet string
552 * \param group underlying EC_GROUP object
553 * \param p EC_POINT object
554 * \param form point conversion form
555 * \param buf memory buffer for the result. If NULL the function returns
556 * required buffer size.
557 * \param len length of the memory buffer
558 * \param ctx BN_CTX object (optional)
559 * \return the length of the encoded octet string or 0 if an error occurred
561 size_t EC_POINT_point2oct(const EC_GROUP
*group
, const EC_POINT
*p
,
562 point_conversion_form_t form
,
563 unsigned char *buf
, size_t len
, BN_CTX
*ctx
);
565 /** Decodes a EC_POINT from a octet string
566 * \param group underlying EC_GROUP object
567 * \param p EC_POINT object
568 * \param buf memory buffer with the encoded ec point
569 * \param len length of the encoded ec point
570 * \param ctx BN_CTX object (optional)
571 * \return 1 on success and 0 if an error occurred
573 int EC_POINT_oct2point(const EC_GROUP
*group
, EC_POINT
*p
,
574 const unsigned char *buf
, size_t len
, BN_CTX
*ctx
);
576 /** Encodes an EC_POINT object to an allocated octet string
577 * \param group underlying EC_GROUP object
578 * \param point EC_POINT object
579 * \param form point conversion form
580 * \param pbuf returns pointer to allocated buffer
581 * \param len length of the memory buffer
582 * \param ctx BN_CTX object (optional)
583 * \return the length of the encoded octet string or 0 if an error occurred
586 size_t EC_POINT_point2buf(const EC_GROUP
*group
, const EC_POINT
*point
,
587 point_conversion_form_t form
,
588 unsigned char **pbuf
, BN_CTX
*ctx
);
590 /* other interfaces to point2oct/oct2point: */
591 BIGNUM
*EC_POINT_point2bn(const EC_GROUP
*, const EC_POINT
*,
592 point_conversion_form_t form
, BIGNUM
*, BN_CTX
*);
593 EC_POINT
*EC_POINT_bn2point(const EC_GROUP
*, const BIGNUM
*,
594 EC_POINT
*, BN_CTX
*);
595 char *EC_POINT_point2hex(const EC_GROUP
*, const EC_POINT
*,
596 point_conversion_form_t form
, BN_CTX
*);
597 EC_POINT
*EC_POINT_hex2point(const EC_GROUP
*, const char *,
598 EC_POINT
*, BN_CTX
*);
600 /********************************************************************/
601 /* functions for doing EC_POINT arithmetic */
602 /********************************************************************/
604 /** Computes the sum of two EC_POINT
605 * \param group underlying EC_GROUP object
606 * \param r EC_POINT object for the result (r = a + b)
607 * \param a EC_POINT object with the first summand
608 * \param b EC_POINT object with the second summand
609 * \param ctx BN_CTX object (optional)
610 * \return 1 on success and 0 if an error occurred
612 int EC_POINT_add(const EC_GROUP
*group
, EC_POINT
*r
, const EC_POINT
*a
,
613 const EC_POINT
*b
, BN_CTX
*ctx
);
615 /** Computes the double of a EC_POINT
616 * \param group underlying EC_GROUP object
617 * \param r EC_POINT object for the result (r = 2 * a)
618 * \param a EC_POINT object
619 * \param ctx BN_CTX object (optional)
620 * \return 1 on success and 0 if an error occurred
622 int EC_POINT_dbl(const EC_GROUP
*group
, EC_POINT
*r
, const EC_POINT
*a
,
625 /** Computes the inverse of a EC_POINT
626 * \param group underlying EC_GROUP object
627 * \param a EC_POINT object to be inverted (it's used for the result as well)
628 * \param ctx BN_CTX object (optional)
629 * \return 1 on success and 0 if an error occurred
631 int EC_POINT_invert(const EC_GROUP
*group
, EC_POINT
*a
, BN_CTX
*ctx
);
633 /** Checks whether the point is the neutral element of the group
634 * \param group the underlying EC_GROUP object
635 * \param p EC_POINT object
636 * \return 1 if the point is the neutral element and 0 otherwise
638 int EC_POINT_is_at_infinity(const EC_GROUP
*group
, const EC_POINT
*p
);
640 /** Checks whether the point is on the curve
641 * \param group underlying EC_GROUP object
642 * \param point EC_POINT object to check
643 * \param ctx BN_CTX object (optional)
644 * \return 1 if point if on the curve and 0 otherwise
646 int EC_POINT_is_on_curve(const EC_GROUP
*group
, const EC_POINT
*point
,
649 /** Compares two EC_POINTs
650 * \param group underlying EC_GROUP object
651 * \param a first EC_POINT object
652 * \param b second EC_POINT object
653 * \param ctx BN_CTX object (optional)
654 * \return 0 if both points are equal and a value != 0 otherwise
656 int EC_POINT_cmp(const EC_GROUP
*group
, const EC_POINT
*a
, const EC_POINT
*b
,
659 int EC_POINT_make_affine(const EC_GROUP
*group
, EC_POINT
*point
, BN_CTX
*ctx
);
660 int EC_POINTs_make_affine(const EC_GROUP
*group
, size_t num
,
661 EC_POINT
*points
[], BN_CTX
*ctx
);
663 /** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]
664 * \param group underlying EC_GROUP object
665 * \param r EC_POINT object for the result
666 * \param n BIGNUM with the multiplier for the group generator (optional)
667 * \param num number further summands
668 * \param p array of size num of EC_POINT objects
669 * \param m array of size num of BIGNUM objects
670 * \param ctx BN_CTX object (optional)
671 * \return 1 on success and 0 if an error occurred
673 int EC_POINTs_mul(const EC_GROUP
*group
, EC_POINT
*r
, const BIGNUM
*n
,
674 size_t num
, const EC_POINT
*p
[], const BIGNUM
*m
[],
677 /** Computes r = generator * n + q * m
678 * \param group underlying EC_GROUP object
679 * \param r EC_POINT object for the result
680 * \param n BIGNUM with the multiplier for the group generator (optional)
681 * \param q EC_POINT object with the first factor of the second summand
682 * \param m BIGNUM with the second factor of the second summand
683 * \param ctx BN_CTX object (optional)
684 * \return 1 on success and 0 if an error occurred
686 int EC_POINT_mul(const EC_GROUP
*group
, EC_POINT
*r
, const BIGNUM
*n
,
687 const EC_POINT
*q
, const BIGNUM
*m
, BN_CTX
*ctx
);
689 /** Stores multiples of generator for faster point multiplication
690 * \param group EC_GROUP object
691 * \param ctx BN_CTX object (optional)
692 * \return 1 on success and 0 if an error occurred
694 int EC_GROUP_precompute_mult(EC_GROUP
*group
, BN_CTX
*ctx
);
696 /** Reports whether a precomputation has been done
697 * \param group EC_GROUP object
698 * \return 1 if a pre-computation has been done and 0 otherwise
700 int EC_GROUP_have_precompute_mult(const EC_GROUP
*group
);
702 /********************************************************************/
704 /********************************************************************/
706 DECLARE_ASN1_ITEM(ECPKPARAMETERS
)
707 DECLARE_ASN1_ITEM(ECPARAMETERS
)
710 * EC_GROUP_get_basis_type() returns the NID of the basis type used to
711 * represent the field elements
713 int EC_GROUP_get_basis_type(const EC_GROUP
*);
714 # ifndef OPENSSL_NO_EC2M
715 int EC_GROUP_get_trinomial_basis(const EC_GROUP
*, unsigned int *k
);
716 int EC_GROUP_get_pentanomial_basis(const EC_GROUP
*, unsigned int *k1
,
717 unsigned int *k2
, unsigned int *k3
);
720 # define OPENSSL_EC_EXPLICIT_CURVE 0x000
721 # define OPENSSL_EC_NAMED_CURVE 0x001
723 EC_GROUP
*d2i_ECPKParameters(EC_GROUP
**, const unsigned char **in
, long len
);
724 int i2d_ECPKParameters(const EC_GROUP
*, unsigned char **out
);
726 # define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
727 # define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
728 # define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
729 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
730 # define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
731 (unsigned char *)(x))
733 int ECPKParameters_print(BIO
*bp
, const EC_GROUP
*x
, int off
);
734 # ifndef OPENSSL_NO_STDIO
735 int ECPKParameters_print_fp(FILE *fp
, const EC_GROUP
*x
, int off
);
738 /********************************************************************/
739 /* EC_KEY functions */
740 /********************************************************************/
742 /* some values for the encoding_flag */
743 # define EC_PKEY_NO_PARAMETERS 0x001
744 # define EC_PKEY_NO_PUBKEY 0x002
746 /* some values for the flags field */
747 # define EC_FLAG_NON_FIPS_ALLOW 0x1
748 # define EC_FLAG_FIPS_CHECKED 0x2
749 # define EC_FLAG_COFACTOR_ECDH 0x1000
751 /** Creates a new EC_KEY object.
752 * \return EC_KEY object or NULL if an error occurred.
754 EC_KEY
*EC_KEY_new(void);
756 int EC_KEY_get_flags(const EC_KEY
*key
);
758 void EC_KEY_set_flags(EC_KEY
*key
, int flags
);
760 void EC_KEY_clear_flags(EC_KEY
*key
, int flags
);
762 /** Creates a new EC_KEY object using a named curve as underlying
764 * \param nid NID of the named curve.
765 * \return EC_KEY object or NULL if an error occurred.
767 EC_KEY
*EC_KEY_new_by_curve_name(int nid
);
769 /** Frees a EC_KEY object.
770 * \param key EC_KEY object to be freed.
772 void EC_KEY_free(EC_KEY
*key
);
774 /** Copies a EC_KEY object.
775 * \param dst destination EC_KEY object
776 * \param src src EC_KEY object
777 * \return dst or NULL if an error occurred.
779 EC_KEY
*EC_KEY_copy(EC_KEY
*dst
, EC_KEY
*src
);
781 /** Creates a new EC_KEY object and copies the content from src to it.
782 * \param src the source EC_KEY object
783 * \return newly created EC_KEY object or NULL if an error occurred.
785 EC_KEY
*EC_KEY_dup(EC_KEY
*src
);
787 /** Increases the internal reference count of a EC_KEY object.
788 * \param key EC_KEY object
789 * \return 1 on success and 0 if an error occurred.
791 int EC_KEY_up_ref(EC_KEY
*key
);
793 /** Returns the EC_GROUP object of a EC_KEY object
794 * \param key EC_KEY object
795 * \return the EC_GROUP object (possibly NULL).
797 const EC_GROUP
*EC_KEY_get0_group(const EC_KEY
*key
);
799 /** Sets the EC_GROUP of a EC_KEY object.
800 * \param key EC_KEY object
801 * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
802 * object will use an own copy of the EC_GROUP).
803 * \return 1 on success and 0 if an error occurred.
805 int EC_KEY_set_group(EC_KEY
*key
, const EC_GROUP
*group
);
807 /** Returns the private key of a EC_KEY object.
808 * \param key EC_KEY object
809 * \return a BIGNUM with the private key (possibly NULL).
811 const BIGNUM
*EC_KEY_get0_private_key(const EC_KEY
*key
);
813 /** Sets the private key of a EC_KEY object.
814 * \param key EC_KEY object
815 * \param prv BIGNUM with the private key (note: the EC_KEY object
816 * will use an own copy of the BIGNUM).
817 * \return 1 on success and 0 if an error occurred.
819 int EC_KEY_set_private_key(EC_KEY
*key
, const BIGNUM
*prv
);
821 /** Returns the public key of a EC_KEY object.
822 * \param key the EC_KEY object
823 * \return a EC_POINT object with the public key (possibly NULL)
825 const EC_POINT
*EC_KEY_get0_public_key(const EC_KEY
*key
);
827 /** Sets the public key of a EC_KEY object.
828 * \param key EC_KEY object
829 * \param pub EC_POINT object with the public key (note: the EC_KEY object
830 * will use an own copy of the EC_POINT object).
831 * \return 1 on success and 0 if an error occurred.
833 int EC_KEY_set_public_key(EC_KEY
*key
, const EC_POINT
*pub
);
835 unsigned EC_KEY_get_enc_flags(const EC_KEY
*key
);
836 void EC_KEY_set_enc_flags(EC_KEY
*eckey
, unsigned int flags
);
837 point_conversion_form_t
EC_KEY_get_conv_form(const EC_KEY
*key
);
838 void EC_KEY_set_conv_form(EC_KEY
*eckey
, point_conversion_form_t cform
);
840 #define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
841 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
842 int EC_KEY_set_ex_data(EC_KEY
*key
, int idx
, void *arg
);
843 void *EC_KEY_get_ex_data(const EC_KEY
*key
, int idx
);
845 /* wrapper functions for the underlying EC_GROUP object */
846 void EC_KEY_set_asn1_flag(EC_KEY
*eckey
, int asn1_flag
);
848 /** Creates a table of pre-computed multiples of the generator to
849 * accelerate further EC_KEY operations.
850 * \param key EC_KEY object
851 * \param ctx BN_CTX object (optional)
852 * \return 1 on success and 0 if an error occurred.
854 int EC_KEY_precompute_mult(EC_KEY
*key
, BN_CTX
*ctx
);
856 /** Creates a new ec private (and optional a new public) key.
857 * \param key EC_KEY object
858 * \return 1 on success and 0 if an error occurred.
860 int EC_KEY_generate_key(EC_KEY
*key
);
862 /** Verifies that a private and/or public key is valid.
863 * \param key the EC_KEY object
864 * \return 1 on success and 0 otherwise.
866 int EC_KEY_check_key(const EC_KEY
*key
);
868 /** Indicates if an EC_KEY can be used for signing.
869 * \param key the EC_KEY object
870 * \return 1 if can can sign and 0 otherwise.
872 int EC_KEY_can_sign(const EC_KEY
*eckey
);
874 /** Sets a public key from affine coordinates performing
875 * necessary NIST PKV tests.
876 * \param key the EC_KEY object
877 * \param x public key x coordinate
878 * \param y public key y coordinate
879 * \return 1 on success and 0 otherwise.
881 int EC_KEY_set_public_key_affine_coordinates(EC_KEY
*key
, BIGNUM
*x
,
884 /** Encodes an EC_KEY public key to an allocated octet string
885 * \param key key to encode
886 * \param form point conversion form
887 * \param pbuf returns pointer to allocated buffer
888 * \param len length of the memory buffer
889 * \param ctx BN_CTX object (optional)
890 * \return the length of the encoded octet string or 0 if an error occurred
893 size_t EC_KEY_key2buf(const EC_KEY
*key
, point_conversion_form_t form
,
894 unsigned char **pbuf
, BN_CTX
*ctx
);
896 /** Decodes a EC_KEY public key from a octet string
897 * \param key key to decode
898 * \param buf memory buffer with the encoded ec point
899 * \param len length of the encoded ec point
900 * \param ctx BN_CTX object (optional)
901 * \return 1 on success and 0 if an error occurred
904 int EC_KEY_oct2key(EC_KEY
*key
, const unsigned char *buf
, size_t len
,
907 /** Decodes an EC_KEY private key from an octet string
908 * \param key key to decode
909 * \param buf memory buffer with the encoded private key
910 * \param len length of the encoded key
911 * \return 1 on success and 0 if an error occurred
914 int EC_KEY_oct2priv(EC_KEY
*key
, unsigned char *buf
, size_t len
);
916 /** Encodes a EC_KEY private key to an octet string
917 * \param key key to encode
918 * \param buf memory buffer for the result. If NULL the function returns
919 * required buffer size.
920 * \param len length of the memory buffer
921 * \return the length of the encoded octet string or 0 if an error occurred
924 size_t EC_KEY_priv2oct(const EC_KEY
*key
, unsigned char *buf
, size_t len
);
926 /** Encodes an EC_KEY private key to an allocated octet string
927 * \param key key to encode
928 * \param pbuf returns pointer to allocated buffer
929 * \return the length of the encoded octet string or 0 if an error occurred
932 size_t EC_KEY_priv2buf(const EC_KEY
*eckey
, unsigned char **pbuf
);
934 /********************************************************************/
935 /* de- and encoding functions for SEC1 ECPrivateKey */
936 /********************************************************************/
938 /** Decodes a private key from a memory buffer.
939 * \param key a pointer to a EC_KEY object which should be used (or NULL)
940 * \param in pointer to memory with the DER encoded private key
941 * \param len length of the DER encoded private key
942 * \return the decoded private key or NULL if an error occurred.
944 EC_KEY
*d2i_ECPrivateKey(EC_KEY
**key
, const unsigned char **in
, long len
);
946 /** Encodes a private key object and stores the result in a buffer.
947 * \param key the EC_KEY object to encode
948 * \param out the buffer for the result (if NULL the function returns number
950 * \return 1 on success and 0 if an error occurred.
952 int i2d_ECPrivateKey(EC_KEY
*key
, unsigned char **out
);
954 /********************************************************************/
955 /* de- and encoding functions for EC parameters */
956 /********************************************************************/
958 /** Decodes ec parameter from a memory buffer.
959 * \param key a pointer to a EC_KEY object which should be used (or NULL)
960 * \param in pointer to memory with the DER encoded ec parameters
961 * \param len length of the DER encoded ec parameters
962 * \return a EC_KEY object with the decoded parameters or NULL if an error
965 EC_KEY
*d2i_ECParameters(EC_KEY
**key
, const unsigned char **in
, long len
);
967 /** Encodes ec parameter and stores the result in a buffer.
968 * \param key the EC_KEY object with ec parameters to encode
969 * \param out the buffer for the result (if NULL the function returns number
971 * \return 1 on success and 0 if an error occurred.
973 int i2d_ECParameters(EC_KEY
*key
, unsigned char **out
);
975 /********************************************************************/
976 /* de- and encoding functions for EC public key */
977 /* (octet string, not DER -- hence 'o2i' and 'i2o') */
978 /********************************************************************/
980 /** Decodes a ec public key from a octet string.
981 * \param key a pointer to a EC_KEY object which should be used
982 * \param in memory buffer with the encoded public key
983 * \param len length of the encoded public key
984 * \return EC_KEY object with decoded public key or NULL if an error
987 EC_KEY
*o2i_ECPublicKey(EC_KEY
**key
, const unsigned char **in
, long len
);
989 /** Encodes a ec public key in an octet string.
990 * \param key the EC_KEY object with the public key
991 * \param out the buffer for the result (if NULL the function returns number
993 * \return 1 on success and 0 if an error occurred
995 int i2o_ECPublicKey(EC_KEY
*key
, unsigned char **out
);
997 /** Prints out the ec parameters on human readable form.
998 * \param bp BIO object to which the information is printed
999 * \param key EC_KEY object
1000 * \return 1 on success and 0 if an error occurred
1002 int ECParameters_print(BIO
*bp
, const EC_KEY
*key
);
1004 /** Prints out the contents of a EC_KEY object
1005 * \param bp BIO object to which the information is printed
1006 * \param key EC_KEY object
1007 * \param off line offset
1008 * \return 1 on success and 0 if an error occurred
1010 int EC_KEY_print(BIO
*bp
, const EC_KEY
*key
, int off
);
1012 # ifndef OPENSSL_NO_STDIO
1013 /** Prints out the ec parameters on human readable form.
1014 * \param fp file descriptor to which the information is printed
1015 * \param key EC_KEY object
1016 * \return 1 on success and 0 if an error occurred
1018 int ECParameters_print_fp(FILE *fp
, const EC_KEY
*key
);
1020 /** Prints out the contents of a EC_KEY object
1021 * \param fp file descriptor to which the information is printed
1022 * \param key EC_KEY object
1023 * \param off line offset
1024 * \return 1 on success and 0 if an error occurred
1026 int EC_KEY_print_fp(FILE *fp
, const EC_KEY
*key
, int off
);
1030 const EC_KEY_METHOD
*EC_KEY_OpenSSL(void);
1031 const EC_KEY_METHOD
*EC_KEY_get_default_method(void);
1032 void EC_KEY_set_default_method(const EC_KEY_METHOD
*meth
);
1033 const EC_KEY_METHOD
*EC_KEY_get_method(const EC_KEY
*key
);
1034 int EC_KEY_set_method(EC_KEY
*key
, const EC_KEY_METHOD
*meth
);
1035 EC_KEY
*EC_KEY_new_method(ENGINE
*engine
);
1037 int ECDH_KDF_X9_62(unsigned char *out
, size_t outlen
,
1038 const unsigned char *Z
, size_t Zlen
,
1039 const unsigned char *sinfo
, size_t sinfolen
,
1042 int ECDH_compute_key(void *out
, size_t outlen
, const EC_POINT
*pub_key
,
1044 void *(*KDF
) (const void *in
, size_t inlen
,
1045 void *out
, size_t *outlen
));
1047 typedef struct ECDSA_SIG_st ECDSA_SIG
;
1049 /** Allocates and initialize a ECDSA_SIG structure
1050 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1052 ECDSA_SIG
*ECDSA_SIG_new(void);
1054 /** frees a ECDSA_SIG structure
1055 * \param sig pointer to the ECDSA_SIG structure
1057 void ECDSA_SIG_free(ECDSA_SIG
*sig
);
1059 /** DER encode content of ECDSA_SIG object (note: this function modifies *pp
1060 * (*pp += length of the DER encoded signature)).
1061 * \param sig pointer to the ECDSA_SIG object
1062 * \param pp pointer to a unsigned char pointer for the output or NULL
1063 * \return the length of the DER encoded ECDSA_SIG object or 0
1065 int i2d_ECDSA_SIG(const ECDSA_SIG
*sig
, unsigned char **pp
);
1067 /** Decodes a DER encoded ECDSA signature (note: this function changes *pp
1069 * \param sig pointer to ECDSA_SIG pointer (may be NULL)
1070 * \param pp memory buffer with the DER encoded signature
1071 * \param len length of the buffer
1072 * \return pointer to the decoded ECDSA_SIG structure (or NULL)
1074 ECDSA_SIG
*d2i_ECDSA_SIG(ECDSA_SIG
**sig
, const unsigned char **pp
, long len
);
1076 /** Accessor for r and s fields of ECDSA_SIG
1077 * \param sig pointer to ECDSA_SIG pointer
1078 * \param pr pointer to BIGNUM pointer for r (may be NULL)
1079 * \param ps pointer to BIGNUM pointer for s (may be NULL)
1081 void ECDSA_SIG_get0(BIGNUM
**pr
, BIGNUM
**ps
, const ECDSA_SIG
*sig
);
1083 /** Computes the ECDSA signature of the given hash value using
1084 * the supplied private key and returns the created signature.
1085 * \param dgst pointer to the hash value
1086 * \param dgst_len length of the hash value
1087 * \param eckey EC_KEY object containing a private EC key
1088 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1090 ECDSA_SIG
*ECDSA_do_sign(const unsigned char *dgst
, int dgst_len
,
1093 /** Computes ECDSA signature of a given hash value using the supplied
1094 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1095 * \param dgst pointer to the hash value to sign
1096 * \param dgstlen length of the hash value
1097 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1098 * \param rp BIGNUM with a pre-computed rp value (optional),
1099 * see ECDSA_sign_setup
1100 * \param eckey EC_KEY object containing a private EC key
1101 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1103 ECDSA_SIG
*ECDSA_do_sign_ex(const unsigned char *dgst
, int dgstlen
,
1104 const BIGNUM
*kinv
, const BIGNUM
*rp
,
1107 /** Verifies that the supplied signature is a valid ECDSA
1108 * signature of the supplied hash value using the supplied public key.
1109 * \param dgst pointer to the hash value
1110 * \param dgst_len length of the hash value
1111 * \param sig ECDSA_SIG structure
1112 * \param eckey EC_KEY object containing a public EC key
1113 * \return 1 if the signature is valid, 0 if the signature is invalid
1116 int ECDSA_do_verify(const unsigned char *dgst
, int dgst_len
,
1117 const ECDSA_SIG
*sig
, EC_KEY
*eckey
);
1119 /** Precompute parts of the signing operation
1120 * \param eckey EC_KEY object containing a private EC key
1121 * \param ctx BN_CTX object (optional)
1122 * \param kinv BIGNUM pointer for the inverse of k
1123 * \param rp BIGNUM pointer for x coordinate of k * generator
1124 * \return 1 on success and 0 otherwise
1126 int ECDSA_sign_setup(EC_KEY
*eckey
, BN_CTX
*ctx
, BIGNUM
**kinv
, BIGNUM
**rp
);
1128 /** Computes ECDSA signature of a given hash value using the supplied
1129 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1130 * \param type this parameter is ignored
1131 * \param dgst pointer to the hash value to sign
1132 * \param dgstlen length of the hash value
1133 * \param sig memory for the DER encoded created signature
1134 * \param siglen pointer to the length of the returned signature
1135 * \param eckey EC_KEY object containing a private EC key
1136 * \return 1 on success and 0 otherwise
1138 int ECDSA_sign(int type
, const unsigned char *dgst
, int dgstlen
,
1139 unsigned char *sig
, unsigned int *siglen
, EC_KEY
*eckey
);
1141 /** Computes ECDSA signature of a given hash value using the supplied
1142 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1143 * \param type this parameter is ignored
1144 * \param dgst pointer to the hash value to sign
1145 * \param dgstlen length of the hash value
1146 * \param sig buffer to hold the DER encoded signature
1147 * \param siglen pointer to the length of the returned signature
1148 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1149 * \param rp BIGNUM with a pre-computed rp value (optional),
1150 * see ECDSA_sign_setup
1151 * \param eckey EC_KEY object containing a private EC key
1152 * \return 1 on success and 0 otherwise
1154 int ECDSA_sign_ex(int type
, const unsigned char *dgst
, int dgstlen
,
1155 unsigned char *sig
, unsigned int *siglen
,
1156 const BIGNUM
*kinv
, const BIGNUM
*rp
, EC_KEY
*eckey
);
1158 /** Verifies that the given signature is valid ECDSA signature
1159 * of the supplied hash value using the specified public key.
1160 * \param type this parameter is ignored
1161 * \param dgst pointer to the hash value
1162 * \param dgstlen length of the hash value
1163 * \param sig pointer to the DER encoded signature
1164 * \param siglen length of the DER encoded signature
1165 * \param eckey EC_KEY object containing a public EC key
1166 * \return 1 if the signature is valid, 0 if the signature is invalid
1169 int ECDSA_verify(int type
, const unsigned char *dgst
, int dgstlen
,
1170 const unsigned char *sig
, int siglen
, EC_KEY
*eckey
);
1172 /** Returns the maximum length of the DER encoded signature
1173 * \param eckey EC_KEY object
1174 * \return numbers of bytes required for the DER encoded signature
1176 int ECDSA_size(const EC_KEY
*eckey
);
1178 /********************************************************************/
1179 /* EC_KEY_METHOD constructors, destructors, writers and accessors */
1180 /********************************************************************/
1182 EC_KEY_METHOD
*EC_KEY_METHOD_new(const EC_KEY_METHOD
*meth
);
1183 void EC_KEY_METHOD_free(EC_KEY_METHOD
*meth
);
1184 void EC_KEY_METHOD_set_init(EC_KEY_METHOD
*meth
,
1185 int (*init
)(EC_KEY
*key
),
1186 void (*finish
)(EC_KEY
*key
),
1187 int (*copy
)(EC_KEY
*dest
, const EC_KEY
*src
),
1188 int (*set_group
)(EC_KEY
*key
, const EC_GROUP
*grp
),
1189 int (*set_private
)(EC_KEY
*key
,
1190 const BIGNUM
*priv_key
),
1191 int (*set_public
)(EC_KEY
*key
,
1192 const EC_POINT
*pub_key
));
1194 void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD
*meth
,
1195 int (*keygen
)(EC_KEY
*key
));
1197 void EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD
*meth
,
1198 int (*ckey
)(unsigned char **psec
,
1200 const EC_POINT
*pub_key
,
1201 const EC_KEY
*ecdh
));
1203 void EC_KEY_METHOD_set_sign(EC_KEY_METHOD
*meth
,
1204 int (*sign
)(int type
, const unsigned char *dgst
,
1205 int dlen
, unsigned char *sig
,
1206 unsigned int *siglen
,
1207 const BIGNUM
*kinv
, const BIGNUM
*r
,
1209 int (*sign_setup
)(EC_KEY
*eckey
, BN_CTX
*ctx_in
,
1210 BIGNUM
**kinvp
, BIGNUM
**rp
),
1211 ECDSA_SIG
*(*sign_sig
)(const unsigned char *dgst
,
1213 const BIGNUM
*in_kinv
,
1217 void EC_KEY_METHOD_set_verify(EC_KEY_METHOD
*meth
,
1218 int (*verify
)(int type
, const unsigned
1219 char *dgst
, int dgst_len
,
1220 const unsigned char *sigbuf
,
1221 int sig_len
, EC_KEY
*eckey
),
1222 int (*verify_sig
)(const unsigned char *dgst
,
1224 const ECDSA_SIG
*sig
,
1227 void EC_KEY_METHOD_get_init(EC_KEY_METHOD
*meth
,
1228 int (**pinit
)(EC_KEY
*key
),
1229 void (**pfinish
)(EC_KEY
*key
),
1230 int (**pcopy
)(EC_KEY
*dest
, const EC_KEY
*src
),
1231 int (**pset_group
)(EC_KEY
*key
,
1232 const EC_GROUP
*grp
),
1233 int (**pset_private
)(EC_KEY
*key
,
1234 const BIGNUM
*priv_key
),
1235 int (**pset_public
)(EC_KEY
*key
,
1236 const EC_POINT
*pub_key
));
1238 void EC_KEY_METHOD_get_keygen(EC_KEY_METHOD
*meth
,
1239 int (**pkeygen
)(EC_KEY
*key
));
1241 void EC_KEY_METHOD_get_compute_key(EC_KEY_METHOD
*meth
,
1242 int (**pck
)(unsigned char **psec
,
1244 const EC_POINT
*pub_key
,
1245 const EC_KEY
*ecdh
));
1247 void EC_KEY_METHOD_get_sign(EC_KEY_METHOD
*meth
,
1248 int (**psign
)(int type
, const unsigned char *dgst
,
1249 int dlen
, unsigned char *sig
,
1250 unsigned int *siglen
,
1251 const BIGNUM
*kinv
, const BIGNUM
*r
,
1253 int (**psign_setup
)(EC_KEY
*eckey
, BN_CTX
*ctx_in
,
1254 BIGNUM
**kinvp
, BIGNUM
**rp
),
1255 ECDSA_SIG
*(**psign_sig
)(const unsigned char *dgst
,
1257 const BIGNUM
*in_kinv
,
1261 void EC_KEY_METHOD_get_verify(EC_KEY_METHOD
*meth
,
1262 int (**pverify
)(int type
, const unsigned
1263 char *dgst
, int dgst_len
,
1264 const unsigned char *sigbuf
,
1265 int sig_len
, EC_KEY
*eckey
),
1266 int (**pverify_sig
)(const unsigned char *dgst
,
1268 const ECDSA_SIG
*sig
,
1271 # define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
1273 # ifndef __cplusplus
1274 # if defined(__SUNPRO_C)
1275 # if __SUNPRO_C >= 0x520
1276 # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
1281 # define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
1282 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1283 EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
1284 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
1286 # define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \
1287 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1288 EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
1289 EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)
1291 # define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \
1292 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1293 EVP_PKEY_OP_DERIVE, \
1294 EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)
1296 # define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \
1297 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1298 EVP_PKEY_OP_DERIVE, \
1299 EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)
1301 # define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \
1302 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1303 EVP_PKEY_OP_DERIVE, \
1304 EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)
1306 # define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \
1307 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1308 EVP_PKEY_OP_DERIVE, \
1309 EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)
1311 # define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \
1312 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1313 EVP_PKEY_OP_DERIVE, \
1314 EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)
1316 # define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \
1317 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1318 EVP_PKEY_OP_DERIVE, \
1319 EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)
1321 # define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \
1322 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1323 EVP_PKEY_OP_DERIVE, \
1324 EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)
1326 # define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \
1327 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1328 EVP_PKEY_OP_DERIVE, \
1329 EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)
1331 # define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \
1332 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1333 EVP_PKEY_OP_DERIVE, \
1334 EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)
1336 # define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \
1337 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1338 EVP_PKEY_OP_DERIVE, \
1339 EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)
1341 # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
1342 # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
1343 # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3)
1344 # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4)
1345 # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5)
1346 # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6)
1347 # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7)
1348 # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8)
1349 # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
1350 # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
1352 # define EVP_PKEY_ECDH_KDF_NONE 1
1353 # define EVP_PKEY_ECDH_KDF_X9_62 2
1355 /* BEGIN ERROR CODES */
1357 * The following lines are auto generated by the script mkerr.pl. Any changes
1358 * made after this point may be overwritten when the script is next run.
1360 void ERR_load_EC_strings(void);
1362 /* Error codes for the EC functions. */
1364 /* Function codes. */
1365 # define EC_F_BN_TO_FELEM 224
1366 # define EC_F_COMPUTE_WNAF 143
1367 # define EC_F_D2I_ECPARAMETERS 144
1368 # define EC_F_D2I_ECPKPARAMETERS 145
1369 # define EC_F_D2I_ECPRIVATEKEY 146
1370 # define EC_F_DO_EC_KEY_PRINT 221
1371 # define EC_F_ECDH_CMS_DECRYPT 238
1372 # define EC_F_ECDH_CMS_SET_SHARED_INFO 239
1373 # define EC_F_ECDH_COMPUTE_KEY 246
1374 # define EC_F_ECDH_SIMPLE_COMPUTE_KEY 257
1375 # define EC_F_ECDSA_DO_SIGN_EX 251
1376 # define EC_F_ECDSA_DO_VERIFY 252
1377 # define EC_F_ECDSA_SIGN_EX 254
1378 # define EC_F_ECDSA_SIGN_SETUP 248
1379 # define EC_F_ECDSA_VERIFY 253
1380 # define EC_F_ECKEY_PARAM2TYPE 223
1381 # define EC_F_ECKEY_PARAM_DECODE 212
1382 # define EC_F_ECKEY_PRIV_DECODE 213
1383 # define EC_F_ECKEY_PRIV_ENCODE 214
1384 # define EC_F_ECKEY_PUB_DECODE 215
1385 # define EC_F_ECKEY_PUB_ENCODE 216
1386 # define EC_F_ECKEY_TYPE2PARAM 220
1387 # define EC_F_ECPARAMETERS_PRINT 147
1388 # define EC_F_ECPARAMETERS_PRINT_FP 148
1389 # define EC_F_ECPKPARAMETERS_PRINT 149
1390 # define EC_F_ECPKPARAMETERS_PRINT_FP 150
1391 # define EC_F_ECP_NISTZ256_GET_AFFINE 240
1392 # define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243
1393 # define EC_F_ECP_NISTZ256_POINTS_MUL 241
1394 # define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244
1395 # define EC_F_ECP_NISTZ256_WINDOWED_MUL 242
1396 # define EC_F_ECP_NIST_MOD_192 203
1397 # define EC_F_ECP_NIST_MOD_224 204
1398 # define EC_F_ECP_NIST_MOD_256 205
1399 # define EC_F_ECP_NIST_MOD_521 206
1400 # define EC_F_EC_ASN1_GROUP2CURVE 153
1401 # define EC_F_EC_ASN1_GROUP2FIELDID 154
1402 # define EC_F_EC_ASN1_GROUP2PARAMETERS 155
1403 # define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156
1404 # define EC_F_EC_ASN1_PARAMETERS2GROUP 157
1405 # define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158
1406 # define EC_F_EC_EX_DATA_SET_DATA 211
1407 # define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
1408 # define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
1409 # define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
1410 # define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
1411 # define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
1412 # define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
1413 # define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
1414 # define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
1415 # define EC_F_EC_GFP_MONT_FIELD_DECODE 133
1416 # define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
1417 # define EC_F_EC_GFP_MONT_FIELD_MUL 131
1418 # define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
1419 # define EC_F_EC_GFP_MONT_FIELD_SQR 132
1420 # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
1421 # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135
1422 # define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225
1423 # define EC_F_EC_GFP_NISTP224_POINTS_MUL 228
1424 # define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
1425 # define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230
1426 # define EC_F_EC_GFP_NISTP256_POINTS_MUL 231
1427 # define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
1428 # define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233
1429 # define EC_F_EC_GFP_NISTP521_POINTS_MUL 234
1430 # define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
1431 # define EC_F_EC_GFP_NIST_FIELD_MUL 200
1432 # define EC_F_EC_GFP_NIST_FIELD_SQR 201
1433 # define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
1434 # define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
1435 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
1436 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
1437 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
1438 # define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
1439 # define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
1440 # define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
1441 # define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
1442 # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
1443 # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
1444 # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
1445 # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
1446 # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
1447 # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
1448 # define EC_F_EC_GROUP_CHECK 170
1449 # define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
1450 # define EC_F_EC_GROUP_COPY 106
1451 # define EC_F_EC_GROUP_GET0_GENERATOR 139
1452 # define EC_F_EC_GROUP_GET_COFACTOR 140
1453 # define EC_F_EC_GROUP_GET_CURVE_GF2M 172
1454 # define EC_F_EC_GROUP_GET_CURVE_GFP 130
1455 # define EC_F_EC_GROUP_GET_DEGREE 173
1456 # define EC_F_EC_GROUP_GET_ECPARAMETERS 261
1457 # define EC_F_EC_GROUP_GET_ECPKPARAMETERS 262
1458 # define EC_F_EC_GROUP_GET_ORDER 141
1459 # define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
1460 # define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
1461 # define EC_F_EC_GROUP_NEW 108
1462 # define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
1463 # define EC_F_EC_GROUP_NEW_FROM_DATA 175
1464 # define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263
1465 # define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264
1466 # define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
1467 # define EC_F_EC_GROUP_SET_CURVE_GF2M 176
1468 # define EC_F_EC_GROUP_SET_CURVE_GFP 109
1469 # define EC_F_EC_GROUP_SET_EXTRA_DATA 110
1470 # define EC_F_EC_GROUP_SET_GENERATOR 111
1471 # define EC_F_EC_KEY_CHECK_KEY 177
1472 # define EC_F_EC_KEY_COPY 178
1473 # define EC_F_EC_KEY_GENERATE_KEY 179
1474 # define EC_F_EC_KEY_NEW 182
1475 # define EC_F_EC_KEY_NEW_METHOD 245
1476 # define EC_F_EC_KEY_OCT2PRIV 255
1477 # define EC_F_EC_KEY_PRINT 180
1478 # define EC_F_EC_KEY_PRINT_FP 181
1479 # define EC_F_EC_KEY_PRIV2OCT 256
1480 # define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229
1481 # define EC_F_EC_KEY_SIMPLE_CHECK_KEY 258
1482 # define EC_F_EC_KEY_SIMPLE_OCT2PRIV 259
1483 # define EC_F_EC_KEY_SIMPLE_PRIV2OCT 260
1484 # define EC_F_EC_POINTS_MAKE_AFFINE 136
1485 # define EC_F_EC_POINT_ADD 112
1486 # define EC_F_EC_POINT_CMP 113
1487 # define EC_F_EC_POINT_COPY 114
1488 # define EC_F_EC_POINT_DBL 115
1489 # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
1490 # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
1491 # define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
1492 # define EC_F_EC_POINT_INVERT 210
1493 # define EC_F_EC_POINT_IS_AT_INFINITY 118
1494 # define EC_F_EC_POINT_IS_ON_CURVE 119
1495 # define EC_F_EC_POINT_MAKE_AFFINE 120
1496 # define EC_F_EC_POINT_MUL 184
1497 # define EC_F_EC_POINT_NEW 121
1498 # define EC_F_EC_POINT_OCT2POINT 122
1499 # define EC_F_EC_POINT_POINT2OCT 123
1500 # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
1501 # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
1502 # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
1503 # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
1504 # define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
1505 # define EC_F_EC_POINT_SET_TO_INFINITY 127
1506 # define EC_F_EC_PRE_COMP_DUP 207
1507 # define EC_F_EC_PRE_COMP_NEW 196
1508 # define EC_F_EC_WNAF_MUL 187
1509 # define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
1510 # define EC_F_I2D_ECPARAMETERS 190
1511 # define EC_F_I2D_ECPKPARAMETERS 191
1512 # define EC_F_I2D_ECPRIVATEKEY 192
1513 # define EC_F_I2O_ECPUBLICKEY 151
1514 # define EC_F_NISTP224_PRE_COMP_NEW 227
1515 # define EC_F_NISTP256_PRE_COMP_NEW 236
1516 # define EC_F_NISTP521_PRE_COMP_NEW 237
1517 # define EC_F_O2I_ECPUBLICKEY 152
1518 # define EC_F_OLD_EC_PRIV_DECODE 222
1519 # define EC_F_OSSL_ECDH_COMPUTE_KEY 247
1520 # define EC_F_OSSL_ECDSA_SIGN_SIG 249
1521 # define EC_F_OSSL_ECDSA_VERIFY_SIG 250
1522 # define EC_F_PKEY_EC_CTRL 197
1523 # define EC_F_PKEY_EC_CTRL_STR 198
1524 # define EC_F_PKEY_EC_DERIVE 217
1525 # define EC_F_PKEY_EC_KEYGEN 199
1526 # define EC_F_PKEY_EC_PARAMGEN 219
1527 # define EC_F_PKEY_EC_SIGN 218
1530 # define EC_R_ASN1_ERROR 115
1531 # define EC_R_ASN1_UNKNOWN_FIELD 116
1532 # define EC_R_BAD_SIGNATURE 156
1533 # define EC_R_BIGNUM_OUT_OF_RANGE 144
1534 # define EC_R_BUFFER_TOO_SMALL 100
1535 # define EC_R_COORDINATES_OUT_OF_RANGE 146
1536 # define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160
1537 # define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159
1538 # define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
1539 # define EC_R_DECODE_ERROR 142
1540 # define EC_R_DISCRIMINANT_IS_ZERO 118
1541 # define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
1542 # define EC_R_FIELD_TOO_LARGE 143
1543 # define EC_R_GF2M_NOT_SUPPORTED 147
1544 # define EC_R_GROUP2PKPARAMETERS_FAILURE 120
1545 # define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
1546 # define EC_R_INCOMPATIBLE_OBJECTS 101
1547 # define EC_R_INVALID_ARGUMENT 112
1548 # define EC_R_INVALID_COMPRESSED_POINT 110
1549 # define EC_R_INVALID_COMPRESSION_BIT 109
1550 # define EC_R_INVALID_CURVE 141
1551 # define EC_R_INVALID_DIGEST 151
1552 # define EC_R_INVALID_DIGEST_TYPE 138
1553 # define EC_R_INVALID_ENCODING 102
1554 # define EC_R_INVALID_FIELD 103
1555 # define EC_R_INVALID_FORM 104
1556 # define EC_R_INVALID_GROUP_ORDER 122
1557 # define EC_R_INVALID_OUTPUT_LENGTH 161
1558 # define EC_R_INVALID_PENTANOMIAL_BASIS 132
1559 # define EC_R_INVALID_PRIVATE_KEY 123
1560 # define EC_R_INVALID_TRINOMIAL_BASIS 137
1561 # define EC_R_KDF_FAILED 153
1562 # define EC_R_KDF_PARAMETER_ERROR 148
1563 # define EC_R_KEYS_NOT_SET 140
1564 # define EC_R_MISSING_PARAMETERS 124
1565 # define EC_R_MISSING_PRIVATE_KEY 125
1566 # define EC_R_NEED_NEW_SETUP_VALUES 157
1567 # define EC_R_NOT_A_NIST_PRIME 135
1568 # define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136
1569 # define EC_R_NOT_IMPLEMENTED 126
1570 # define EC_R_NOT_INITIALIZED 111
1571 # define EC_R_NO_FIELD_MOD 133
1572 # define EC_R_NO_PARAMETERS_SET 139
1573 # define EC_R_NO_PRIVATE_VALUE 154
1574 # define EC_R_OPERATION_NOT_SUPPORTED 152
1575 # define EC_R_PASSED_NULL_PARAMETER 134
1576 # define EC_R_PEER_KEY_ERROR 149
1577 # define EC_R_PKPARAMETERS2GROUP_FAILURE 127
1578 # define EC_R_POINT_ARITHMETIC_FAILURE 155
1579 # define EC_R_POINT_AT_INFINITY 106
1580 # define EC_R_POINT_IS_NOT_ON_CURVE 107
1581 # define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158
1582 # define EC_R_SHARED_INFO_ERROR 150
1583 # define EC_R_SLOT_FULL 108
1584 # define EC_R_UNDEFINED_GENERATOR 113
1585 # define EC_R_UNDEFINED_ORDER 128
1586 # define EC_R_UNKNOWN_GROUP 129
1587 # define EC_R_UNKNOWN_ORDER 114
1588 # define EC_R_UNSUPPORTED_FIELD 131
1589 # define EC_R_WRONG_CURVE_PARAMETERS 145
1590 # define EC_R_WRONG_ORDER 130