]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/openssl/ec.h
various spelling fixes
[thirdparty/openssl.git] / include / openssl / ec.h
1 /*
2 * Originally written by Bodo Moeller for the OpenSSL project.
3 */
4 /* ====================================================================
5 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * 3. All advertising materials mentioning features or use of this
20 * software must display the following acknowledgment:
21 * "This product includes software developed by the OpenSSL Project
22 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23 *
24 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 * endorse or promote products derived from this software without
26 * prior written permission. For written permission, please contact
27 * openssl-core@openssl.org.
28 *
29 * 5. Products derived from this software may not be called "OpenSSL"
30 * nor may "OpenSSL" appear in their names without prior written
31 * permission of the OpenSSL Project.
32 *
33 * 6. Redistributions of any form whatsoever must retain the following
34 * acknowledgment:
35 * "This product includes software developed by the OpenSSL Project
36 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 * OF THE POSSIBILITY OF SUCH DAMAGE.
50 * ====================================================================
51 *
52 * This product includes cryptographic software written by Eric Young
53 * (eay@cryptsoft.com). This product includes software written by Tim
54 * Hudson (tjh@cryptsoft.com).
55 *
56 */
57 /* ====================================================================
58 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
59 *
60 * Portions of the attached software ("Contribution") are developed by
61 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
62 *
63 * The Contribution is licensed pursuant to the OpenSSL open source
64 * license provided above.
65 *
66 * The elliptic curve binary polynomial software is originally written by
67 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
68 *
69 */
70
71 #ifndef HEADER_EC_H
72 # define HEADER_EC_H
73
74 # include <openssl/opensslconf.h>
75
76 # ifndef OPENSSL_NO_EC
77 # include <openssl/asn1.h>
78 # include <openssl/symhacks.h>
79 # if OPENSSL_API_COMPAT < 0x10100000L
80 # include <openssl/bn.h>
81 # endif
82 # ifdef __cplusplus
83 extern "C" {
84 # endif
85
86 # ifndef OPENSSL_ECC_MAX_FIELD_BITS
87 # define OPENSSL_ECC_MAX_FIELD_BITS 661
88 # endif
89
90 /** Enum for the point conversion form as defined in X9.62 (ECDSA)
91 * for the encoding of a elliptic curve point (x,y) */
92 typedef enum {
93 /** the point is encoded as z||x, where the octet z specifies
94 * which solution of the quadratic equation y is */
95 POINT_CONVERSION_COMPRESSED = 2,
96 /** the point is encoded as z||x||y, where z is the octet 0x04 */
97 POINT_CONVERSION_UNCOMPRESSED = 4,
98 /** the point is encoded as z||x||y, where the octet z specifies
99 * which solution of the quadratic equation y is */
100 POINT_CONVERSION_HYBRID = 6
101 } point_conversion_form_t;
102
103 typedef struct ec_method_st EC_METHOD;
104 typedef struct ec_group_st EC_GROUP;
105 typedef struct ec_point_st EC_POINT;
106 typedef struct ecpk_parameters_st ECPKPARAMETERS;
107 typedef struct ec_parameters_st ECPARAMETERS;
108
109 /********************************************************************/
110 /* EC_METHODs for curves over GF(p) */
111 /********************************************************************/
112
113 /** Returns the basic GFp ec methods which provides the basis for the
114 * optimized methods.
115 * \return EC_METHOD object
116 */
117 const EC_METHOD *EC_GFp_simple_method(void);
118
119 /** Returns GFp methods using montgomery multiplication.
120 * \return EC_METHOD object
121 */
122 const EC_METHOD *EC_GFp_mont_method(void);
123
124 /** Returns GFp methods using optimized methods for NIST recommended curves
125 * \return EC_METHOD object
126 */
127 const EC_METHOD *EC_GFp_nist_method(void);
128
129 # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
130 # ifndef OPENSSL_SYS_WIN32
131 /** Returns 64-bit optimized methods for nistp224
132 * \return EC_METHOD object
133 */
134 const EC_METHOD *EC_GFp_nistp224_method(void);
135
136 /** Returns 64-bit optimized methods for nistp256
137 * \return EC_METHOD object
138 */
139 const EC_METHOD *EC_GFp_nistp256_method(void);
140
141 /** Returns 64-bit optimized methods for nistp521
142 * \return EC_METHOD object
143 */
144 const EC_METHOD *EC_GFp_nistp521_method(void);
145 # endif
146 # endif
147
148 # ifndef OPENSSL_NO_EC2M
149 /********************************************************************/
150 /* EC_METHOD for curves over GF(2^m) */
151 /********************************************************************/
152
153 /** Returns the basic GF2m ec method
154 * \return EC_METHOD object
155 */
156 const EC_METHOD *EC_GF2m_simple_method(void);
157
158 # endif
159
160 /********************************************************************/
161 /* EC_GROUP functions */
162 /********************************************************************/
163
164 /** Creates a new EC_GROUP object
165 * \param meth EC_METHOD to use
166 * \return newly created EC_GROUP object or NULL in case of an error.
167 */
168 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
169
170 /** Frees a EC_GROUP object
171 * \param group EC_GROUP object to be freed.
172 */
173 void EC_GROUP_free(EC_GROUP *group);
174
175 /** Clears and frees a EC_GROUP object
176 * \param group EC_GROUP object to be cleared and freed.
177 */
178 void EC_GROUP_clear_free(EC_GROUP *group);
179
180 /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
181 * \param dst destination EC_GROUP object
182 * \param src source EC_GROUP object
183 * \return 1 on success and 0 if an error occurred.
184 */
185 int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
186
187 /** Creates a new EC_GROUP object and copies the copies the content
188 * form src to the newly created EC_KEY object
189 * \param src source EC_GROUP object
190 * \return newly created EC_GROUP object or NULL in case of an error.
191 */
192 EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
193
194 /** Returns the EC_METHOD of the EC_GROUP object.
195 * \param group EC_GROUP object
196 * \return EC_METHOD used in this EC_GROUP object.
197 */
198 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
199
200 /** Returns the field type of the EC_METHOD.
201 * \param meth EC_METHOD object
202 * \return NID of the underlying field type OID.
203 */
204 int EC_METHOD_get_field_type(const EC_METHOD *meth);
205
206 /** Sets the generator and it's order/cofactor of a EC_GROUP object.
207 * \param group EC_GROUP object
208 * \param generator EC_POINT object with the generator.
209 * \param order the order of the group generated by the generator.
210 * \param cofactor the index of the sub-group generated by the generator
211 * in the group of all points on the elliptic curve.
212 * \return 1 on success and 0 if an error occurred
213 */
214 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
215 const BIGNUM *order, const BIGNUM *cofactor);
216
217 /** Returns the generator of a EC_GROUP object.
218 * \param group EC_GROUP object
219 * \return the currently used generator (possibly NULL).
220 */
221 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
222
223 /** Returns the montgomery data for order(Generator)
224 * \param group EC_GROUP object
225 * \return the currently used generator (possibly NULL).
226 */
227 BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);
228
229 /** Gets the order of a EC_GROUP
230 * \param group EC_GROUP object
231 * \param order BIGNUM to which the order is copied
232 * \param ctx unused
233 * \return 1 on success and 0 if an error occurred
234 */
235 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
236
237 /** Gets the order of an EC_GROUP
238 * \param group EC_GROUP object
239 * \return the group order
240 */
241
242 const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);
243
244 /** Gets the number of bits of the order of an EC_GROUP
245 * \param group EC_GROUP object
246 * \return number of bits of group order.
247 */
248
249 int EC_GROUP_order_bits(const EC_GROUP *group);
250
251 /** Gets the cofactor of a EC_GROUP
252 * \param group EC_GROUP object
253 * \param cofactor BIGNUM to which the cofactor is copied
254 * \param ctx unused
255 * \return 1 on success and 0 if an error occurred
256 */
257 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
258 BN_CTX *ctx);
259
260 /** Gets the cofactor of an EC_GROUP
261 * \param group EC_GROUP object
262 * \return the group cofactor
263 */
264
265 const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);
266
267 /** Sets the name of a EC_GROUP object
268 * \param group EC_GROUP object
269 * \param nid NID of the curve name OID
270 */
271 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
272
273 /** Returns the curve name of a EC_GROUP object
274 * \param group EC_GROUP object
275 * \return NID of the curve name OID or 0 if not set.
276 */
277 int EC_GROUP_get_curve_name(const EC_GROUP *group);
278
279 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
280 int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
281
282 void EC_GROUP_set_point_conversion_form(EC_GROUP *group,
283 point_conversion_form_t form);
284 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
285
286 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
287 size_t EC_GROUP_get_seed_len(const EC_GROUP *);
288 size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
289
290 /** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
291 * \param group EC_GROUP object
292 * \param p BIGNUM with the prime number
293 * \param a BIGNUM with parameter a of the equation
294 * \param b BIGNUM with parameter b of the equation
295 * \param ctx BN_CTX object (optional)
296 * \return 1 on success and 0 if an error occurred
297 */
298 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
299 const BIGNUM *b, BN_CTX *ctx);
300
301 /** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
302 * \param group EC_GROUP object
303 * \param p BIGNUM for the prime number
304 * \param a BIGNUM for parameter a of the equation
305 * \param b BIGNUM for parameter b of the equation
306 * \param ctx BN_CTX object (optional)
307 * \return 1 on success and 0 if an error occurred
308 */
309 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
310 BIGNUM *b, BN_CTX *ctx);
311
312 # ifndef OPENSSL_NO_EC2M
313 /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
314 * \param group EC_GROUP object
315 * \param p BIGNUM with the polynomial defining the underlying field
316 * \param a BIGNUM with parameter a of the equation
317 * \param b BIGNUM with parameter b of the equation
318 * \param ctx BN_CTX object (optional)
319 * \return 1 on success and 0 if an error occurred
320 */
321 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
322 const BIGNUM *b, BN_CTX *ctx);
323
324 /** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
325 * \param group EC_GROUP object
326 * \param p BIGNUM for the polynomial defining the underlying field
327 * \param a BIGNUM for parameter a of the equation
328 * \param b BIGNUM for 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 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
333 BIGNUM *b, BN_CTX *ctx);
334 # endif
335 /** Returns the number of bits needed to represent a field element
336 * \param group EC_GROUP object
337 * \return number of bits needed to represent a field element
338 */
339 int EC_GROUP_get_degree(const EC_GROUP *group);
340
341 /** Checks whether the parameter in the EC_GROUP define a valid ec group
342 * \param group EC_GROUP object
343 * \param ctx BN_CTX object (optional)
344 * \return 1 if group is a valid ec group and 0 otherwise
345 */
346 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
347
348 /** Checks whether the discriminant of the elliptic curve is zero or not
349 * \param group EC_GROUP object
350 * \param ctx BN_CTX object (optional)
351 * \return 1 if the discriminant is not zero and 0 otherwise
352 */
353 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
354
355 /** Compares two EC_GROUP objects
356 * \param a first EC_GROUP object
357 * \param b second EC_GROUP object
358 * \param ctx BN_CTX object (optional)
359 * \return 0 if both groups are equal and 1 otherwise
360 */
361 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
362
363 /*
364 * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after
365 * choosing an appropriate EC_METHOD
366 */
367
368 /** Creates a new EC_GROUP object with the specified parameters defined
369 * over GFp (defined by the equation y^2 = x^3 + a*x + b)
370 * \param p BIGNUM with the prime number
371 * \param a BIGNUM with the parameter a of the equation
372 * \param b BIGNUM with the parameter b of the equation
373 * \param ctx BN_CTX object (optional)
374 * \return newly created EC_GROUP object with the specified parameters
375 */
376 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
377 const BIGNUM *b, BN_CTX *ctx);
378 # ifndef OPENSSL_NO_EC2M
379 /** Creates a new EC_GROUP object with the specified parameters defined
380 * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
381 * \param p BIGNUM with the polynomial defining the underlying field
382 * \param a BIGNUM with the parameter a of the equation
383 * \param b BIGNUM with the parameter b of the equation
384 * \param ctx BN_CTX object (optional)
385 * \return newly created EC_GROUP object with the specified parameters
386 */
387 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,
388 const BIGNUM *b, BN_CTX *ctx);
389 # endif
390
391 /** Creates a EC_GROUP object with a curve specified by a NID
392 * \param nid NID of the OID of the curve name
393 * \return newly created EC_GROUP object with specified curve or NULL
394 * if an error occurred
395 */
396 EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
397
398 /** Creates a new EC_GROUP object from an ECPARAMETERS object
399 * \param params pointer to the ECPARAMETERS object
400 * \return newly created EC_GROUP object with specified curve or NULL
401 * if an error occurred
402 */
403 EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params);
404
405 /** Creates an ECPARAMETERS object for the the given EC_GROUP object.
406 * \param group pointer to the EC_GROUP object
407 * \param params pointer to an existing ECPARAMETERS object or NULL
408 * \return pointer to the new ECPARAMETERS object or NULL
409 * if an error occurred.
410 */
411 ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,
412 ECPARAMETERS *params);
413
414 /** Creates a new EC_GROUP object from an ECPKPARAMETERS object
415 * \param params pointer to an existing ECPKPARAMETERS object, or NULL
416 * \return newly created EC_GROUP object with specified curve, or NULL
417 * if an error occurred
418 */
419 EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params);
420
421 /** Creates an ECPKPARAMETERS object for the the given EC_GROUP object.
422 * \param group pointer to the EC_GROUP object
423 * \param params pointer to an existing ECPKPARAMETERS object or NULL
424 * \return pointer to the new ECPKPARAMETERS object or NULL
425 * if an error occurred.
426 */
427 ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group,
428 ECPKPARAMETERS *params);
429
430 /********************************************************************/
431 /* handling of internal curves */
432 /********************************************************************/
433
434 typedef struct {
435 int nid;
436 const char *comment;
437 } EC_builtin_curve;
438
439 /*
440 * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all
441 * available curves or zero if a error occurred. In case r is not zero,
442 * nitems EC_builtin_curve structures are filled with the data of the first
443 * nitems internal groups
444 */
445 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
446
447 const char *EC_curve_nid2nist(int nid);
448 int EC_curve_nist2nid(const char *name);
449
450 /********************************************************************/
451 /* EC_POINT functions */
452 /********************************************************************/
453
454 /** Creates a new EC_POINT object for the specified EC_GROUP
455 * \param group EC_GROUP the underlying EC_GROUP object
456 * \return newly created EC_POINT object or NULL if an error occurred
457 */
458 EC_POINT *EC_POINT_new(const EC_GROUP *group);
459
460 /** Frees a EC_POINT object
461 * \param point EC_POINT object to be freed
462 */
463 void EC_POINT_free(EC_POINT *point);
464
465 /** Clears and frees a EC_POINT object
466 * \param point EC_POINT object to be cleared and freed
467 */
468 void EC_POINT_clear_free(EC_POINT *point);
469
470 /** Copies EC_POINT object
471 * \param dst destination EC_POINT object
472 * \param src source EC_POINT object
473 * \return 1 on success and 0 if an error occurred
474 */
475 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
476
477 /** Creates a new EC_POINT object and copies the content of the supplied
478 * EC_POINT
479 * \param src source EC_POINT object
480 * \param group underlying the EC_GROUP object
481 * \return newly created EC_POINT object or NULL if an error occurred
482 */
483 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
484
485 /** Returns the EC_METHOD used in EC_POINT object
486 * \param point EC_POINT object
487 * \return the EC_METHOD used
488 */
489 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
490
491 /** Sets a point to infinity (neutral element)
492 * \param group underlying EC_GROUP object
493 * \param point EC_POINT to set to infinity
494 * \return 1 on success and 0 if an error occurred
495 */
496 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
497
498 /** Sets the jacobian projective coordinates of a EC_POINT over GFp
499 * \param group underlying EC_GROUP object
500 * \param p EC_POINT object
501 * \param x BIGNUM with the x-coordinate
502 * \param y BIGNUM with the y-coordinate
503 * \param z BIGNUM with the z-coordinate
504 * \param ctx BN_CTX object (optional)
505 * \return 1 on success and 0 if an error occurred
506 */
507 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,
508 EC_POINT *p, const BIGNUM *x,
509 const BIGNUM *y, const BIGNUM *z,
510 BN_CTX *ctx);
511
512 /** Gets the jacobian projective coordinates of a EC_POINT over GFp
513 * \param group underlying EC_GROUP object
514 * \param p EC_POINT object
515 * \param x BIGNUM for the x-coordinate
516 * \param y BIGNUM for the y-coordinate
517 * \param z BIGNUM for the z-coordinate
518 * \param ctx BN_CTX object (optional)
519 * \return 1 on success and 0 if an error occurred
520 */
521 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
522 const EC_POINT *p, BIGNUM *x,
523 BIGNUM *y, BIGNUM *z,
524 BN_CTX *ctx);
525
526 /** Sets the affine coordinates of a EC_POINT over GFp
527 * \param group underlying EC_GROUP object
528 * \param p EC_POINT object
529 * \param x BIGNUM with the x-coordinate
530 * \param y BIGNUM with the y-coordinate
531 * \param ctx BN_CTX object (optional)
532 * \return 1 on success and 0 if an error occurred
533 */
534 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
535 const BIGNUM *x, const BIGNUM *y,
536 BN_CTX *ctx);
537
538 /** Gets the affine coordinates of a EC_POINT over GFp
539 * \param group underlying EC_GROUP object
540 * \param p EC_POINT object
541 * \param x BIGNUM for the x-coordinate
542 * \param y BIGNUM for the y-coordinate
543 * \param ctx BN_CTX object (optional)
544 * \return 1 on success and 0 if an error occurred
545 */
546 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
547 const EC_POINT *p, BIGNUM *x,
548 BIGNUM *y, BN_CTX *ctx);
549
550 /** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
551 * \param group underlying EC_GROUP object
552 * \param p EC_POINT object
553 * \param x BIGNUM with x-coordinate
554 * \param y_bit integer with the y-Bit (either 0 or 1)
555 * \param ctx BN_CTX object (optional)
556 * \return 1 on success and 0 if an error occurred
557 */
558 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
559 EC_POINT *p, const BIGNUM *x,
560 int y_bit, BN_CTX *ctx);
561 # ifndef OPENSSL_NO_EC2M
562 /** Sets the affine coordinates of a EC_POINT over GF2m
563 * \param group underlying EC_GROUP object
564 * \param p EC_POINT object
565 * \param x BIGNUM with the x-coordinate
566 * \param y BIGNUM with the y-coordinate
567 * \param ctx BN_CTX object (optional)
568 * \return 1 on success and 0 if an error occurred
569 */
570 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
571 const BIGNUM *x, const BIGNUM *y,
572 BN_CTX *ctx);
573
574 /** Gets the affine coordinates of a EC_POINT over GF2m
575 * \param group underlying EC_GROUP object
576 * \param p EC_POINT object
577 * \param x BIGNUM for the x-coordinate
578 * \param y BIGNUM for the y-coordinate
579 * \param ctx BN_CTX object (optional)
580 * \return 1 on success and 0 if an error occurred
581 */
582 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
583 const EC_POINT *p, BIGNUM *x,
584 BIGNUM *y, BN_CTX *ctx);
585
586 /** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
587 * \param group underlying EC_GROUP object
588 * \param p EC_POINT object
589 * \param x BIGNUM with x-coordinate
590 * \param y_bit integer with the y-Bit (either 0 or 1)
591 * \param ctx BN_CTX object (optional)
592 * \return 1 on success and 0 if an error occurred
593 */
594 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
595 EC_POINT *p, const BIGNUM *x,
596 int y_bit, BN_CTX *ctx);
597 # endif
598 /** Encodes a EC_POINT object to a octet string
599 * \param group underlying EC_GROUP object
600 * \param p EC_POINT object
601 * \param form point conversion form
602 * \param buf memory buffer for the result. If NULL the function returns
603 * required buffer size.
604 * \param len length of the memory buffer
605 * \param ctx BN_CTX object (optional)
606 * \return the length of the encoded octet string or 0 if an error occurred
607 */
608 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
609 point_conversion_form_t form,
610 unsigned char *buf, size_t len, BN_CTX *ctx);
611
612 /** Decodes a EC_POINT from a octet string
613 * \param group underlying EC_GROUP object
614 * \param p EC_POINT object
615 * \param buf memory buffer with the encoded ec point
616 * \param len length of the encoded ec point
617 * \param ctx BN_CTX object (optional)
618 * \return 1 on success and 0 if an error occurred
619 */
620 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
621 const unsigned char *buf, size_t len, BN_CTX *ctx);
622
623 /** Encodes an EC_POINT object to an allocated octet string
624 * \param group underlying EC_GROUP object
625 * \param point EC_POINT object
626 * \param form point conversion form
627 * \param pbuf returns pointer to allocated buffer
628 * \param len length of the memory buffer
629 * \param ctx BN_CTX object (optional)
630 * \return the length of the encoded octet string or 0 if an error occurred
631 */
632
633 size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
634 point_conversion_form_t form,
635 unsigned char **pbuf, BN_CTX *ctx);
636
637 /* other interfaces to point2oct/oct2point: */
638 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
639 point_conversion_form_t form, BIGNUM *, BN_CTX *);
640 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
641 EC_POINT *, BN_CTX *);
642 char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
643 point_conversion_form_t form, BN_CTX *);
644 EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
645 EC_POINT *, BN_CTX *);
646
647 /********************************************************************/
648 /* functions for doing EC_POINT arithmetic */
649 /********************************************************************/
650
651 /** Computes the sum of two EC_POINT
652 * \param group underlying EC_GROUP object
653 * \param r EC_POINT object for the result (r = a + b)
654 * \param a EC_POINT object with the first summand
655 * \param b EC_POINT object with the second summand
656 * \param ctx BN_CTX object (optional)
657 * \return 1 on success and 0 if an error occurred
658 */
659 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
660 const EC_POINT *b, BN_CTX *ctx);
661
662 /** Computes the double of a EC_POINT
663 * \param group underlying EC_GROUP object
664 * \param r EC_POINT object for the result (r = 2 * a)
665 * \param a EC_POINT object
666 * \param ctx BN_CTX object (optional)
667 * \return 1 on success and 0 if an error occurred
668 */
669 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
670 BN_CTX *ctx);
671
672 /** Computes the inverse of a EC_POINT
673 * \param group underlying EC_GROUP object
674 * \param a EC_POINT object to be inverted (it's used for the result as well)
675 * \param ctx BN_CTX object (optional)
676 * \return 1 on success and 0 if an error occurred
677 */
678 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
679
680 /** Checks whether the point is the neutral element of the group
681 * \param group the underlying EC_GROUP object
682 * \param p EC_POINT object
683 * \return 1 if the point is the neutral element and 0 otherwise
684 */
685 int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
686
687 /** Checks whether the point is on the curve
688 * \param group underlying EC_GROUP object
689 * \param point EC_POINT object to check
690 * \param ctx BN_CTX object (optional)
691 * \return 1 if point if on the curve and 0 otherwise
692 */
693 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
694 BN_CTX *ctx);
695
696 /** Compares two EC_POINTs
697 * \param group underlying EC_GROUP object
698 * \param a first EC_POINT object
699 * \param b second EC_POINT object
700 * \param ctx BN_CTX object (optional)
701 * \return 0 if both points are equal and a value != 0 otherwise
702 */
703 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
704 BN_CTX *ctx);
705
706 int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
707 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num,
708 EC_POINT *points[], BN_CTX *ctx);
709
710 /** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]
711 * \param group underlying EC_GROUP object
712 * \param r EC_POINT object for the result
713 * \param n BIGNUM with the multiplier for the group generator (optional)
714 * \param num number further summands
715 * \param p array of size num of EC_POINT objects
716 * \param m array of size num of BIGNUM objects
717 * \param ctx BN_CTX object (optional)
718 * \return 1 on success and 0 if an error occurred
719 */
720 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,
721 size_t num, const EC_POINT *p[], const BIGNUM *m[],
722 BN_CTX *ctx);
723
724 /** Computes r = generator * n + q * m
725 * \param group underlying EC_GROUP object
726 * \param r EC_POINT object for the result
727 * \param n BIGNUM with the multiplier for the group generator (optional)
728 * \param q EC_POINT object with the first factor of the second summand
729 * \param m BIGNUM with the second factor of the second summand
730 * \param ctx BN_CTX object (optional)
731 * \return 1 on success and 0 if an error occurred
732 */
733 int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,
734 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
735
736 /** Stores multiples of generator for faster point multiplication
737 * \param group EC_GROUP object
738 * \param ctx BN_CTX object (optional)
739 * \return 1 on success and 0 if an error occurred
740 */
741 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
742
743 /** Reports whether a precomputation has been done
744 * \param group EC_GROUP object
745 * \return 1 if a pre-computation has been done and 0 otherwise
746 */
747 int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
748
749 /********************************************************************/
750 /* ASN1 stuff */
751 /********************************************************************/
752
753 DECLARE_ASN1_ITEM(ECPKPARAMETERS)
754 DECLARE_ASN1_ITEM(ECPARAMETERS)
755
756 /*
757 * EC_GROUP_get_basis_type() returns the NID of the basis type used to
758 * represent the field elements
759 */
760 int EC_GROUP_get_basis_type(const EC_GROUP *);
761 # ifndef OPENSSL_NO_EC2M
762 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
763 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
764 unsigned int *k2, unsigned int *k3);
765 # endif
766
767 # define OPENSSL_EC_EXPLICIT_CURVE 0x000
768 # define OPENSSL_EC_NAMED_CURVE 0x001
769
770 EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
771 int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
772
773 # define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
774 # define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
775 # define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
776 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
777 # define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
778 (unsigned char *)(x))
779
780 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
781 # ifndef OPENSSL_NO_STDIO
782 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
783 # endif
784
785 /********************************************************************/
786 /* EC_KEY functions */
787 /********************************************************************/
788
789 /* some values for the encoding_flag */
790 # define EC_PKEY_NO_PARAMETERS 0x001
791 # define EC_PKEY_NO_PUBKEY 0x002
792
793 /* some values for the flags field */
794 # define EC_FLAG_NON_FIPS_ALLOW 0x1
795 # define EC_FLAG_FIPS_CHECKED 0x2
796 # define EC_FLAG_COFACTOR_ECDH 0x1000
797
798 /** Creates a new EC_KEY object.
799 * \return EC_KEY object or NULL if an error occurred.
800 */
801 EC_KEY *EC_KEY_new(void);
802
803 int EC_KEY_get_flags(const EC_KEY *key);
804
805 void EC_KEY_set_flags(EC_KEY *key, int flags);
806
807 void EC_KEY_clear_flags(EC_KEY *key, int flags);
808
809 /** Creates a new EC_KEY object using a named curve as underlying
810 * EC_GROUP object.
811 * \param nid NID of the named curve.
812 * \return EC_KEY object or NULL if an error occurred.
813 */
814 EC_KEY *EC_KEY_new_by_curve_name(int nid);
815
816 /** Frees a EC_KEY object.
817 * \param key EC_KEY object to be freed.
818 */
819 void EC_KEY_free(EC_KEY *key);
820
821 /** Copies a EC_KEY object.
822 * \param dst destination EC_KEY object
823 * \param src src EC_KEY object
824 * \return dst or NULL if an error occurred.
825 */
826 EC_KEY *EC_KEY_copy(EC_KEY *dst, EC_KEY *src);
827
828 /** Creates a new EC_KEY object and copies the content from src to it.
829 * \param src the source EC_KEY object
830 * \return newly created EC_KEY object or NULL if an error occurred.
831 */
832 EC_KEY *EC_KEY_dup(EC_KEY *src);
833
834 /** Increases the internal reference count of a EC_KEY object.
835 * \param key EC_KEY object
836 * \return 1 on success and 0 if an error occurred.
837 */
838 int EC_KEY_up_ref(EC_KEY *key);
839
840 /** Returns the EC_GROUP object of a EC_KEY object
841 * \param key EC_KEY object
842 * \return the EC_GROUP object (possibly NULL).
843 */
844 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
845
846 /** Sets the EC_GROUP of a EC_KEY object.
847 * \param key EC_KEY object
848 * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
849 * object will use an own copy of the EC_GROUP).
850 * \return 1 on success and 0 if an error occurred.
851 */
852 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
853
854 /** Returns the private key of a EC_KEY object.
855 * \param key EC_KEY object
856 * \return a BIGNUM with the private key (possibly NULL).
857 */
858 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
859
860 /** Sets the private key of a EC_KEY object.
861 * \param key EC_KEY object
862 * \param prv BIGNUM with the private key (note: the EC_KEY object
863 * will use an own copy of the BIGNUM).
864 * \return 1 on success and 0 if an error occurred.
865 */
866 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
867
868 /** Returns the public key of a EC_KEY object.
869 * \param key the EC_KEY object
870 * \return a EC_POINT object with the public key (possibly NULL)
871 */
872 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
873
874 /** Sets the public key of a EC_KEY object.
875 * \param key EC_KEY object
876 * \param pub EC_POINT object with the public key (note: the EC_KEY object
877 * will use an own copy of the EC_POINT object).
878 * \return 1 on success and 0 if an error occurred.
879 */
880 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
881
882 unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
883 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
884 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
885 void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
886
887 #define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
888 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
889 int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg);
890 void *EC_KEY_get_ex_data(const EC_KEY *key, int idx);
891
892 /* wrapper functions for the underlying EC_GROUP object */
893 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
894
895 /** Creates a table of pre-computed multiples of the generator to
896 * accelerate further EC_KEY operations.
897 * \param key EC_KEY object
898 * \param ctx BN_CTX object (optional)
899 * \return 1 on success and 0 if an error occurred.
900 */
901 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
902
903 /** Creates a new ec private (and optional a new public) key.
904 * \param key EC_KEY object
905 * \return 1 on success and 0 if an error occurred.
906 */
907 int EC_KEY_generate_key(EC_KEY *key);
908
909 /** Verifies that a private and/or public key is valid.
910 * \param key the EC_KEY object
911 * \return 1 on success and 0 otherwise.
912 */
913 int EC_KEY_check_key(const EC_KEY *key);
914
915 /** Indicates if an EC_KEY can be used for signing.
916 * \param key the EC_KEY object
917 * \return 1 if can can sign and 0 otherwise.
918 */
919 int EC_KEY_can_sign(const EC_KEY *eckey);
920
921 /** Sets a public key from affine coordinates performing
922 * necessary NIST PKV tests.
923 * \param key the EC_KEY object
924 * \param x public key x coordinate
925 * \param y public key y coordinate
926 * \return 1 on success and 0 otherwise.
927 */
928 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
929 BIGNUM *y);
930
931 /** Encodes an EC_KEY public key to an allocated octet string
932 * \param key key to encode
933 * \param form point conversion form
934 * \param pbuf returns pointer to allocated buffer
935 * \param len length of the memory buffer
936 * \param ctx BN_CTX object (optional)
937 * \return the length of the encoded octet string or 0 if an error occurred
938 */
939
940 size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,
941 unsigned char **pbuf, BN_CTX *ctx);
942
943 /** Decodes a EC_KEY public key from a octet string
944 * \param key key to decode
945 * \param buf memory buffer with the encoded ec point
946 * \param len length of the encoded ec point
947 * \param ctx BN_CTX object (optional)
948 * \return 1 on success and 0 if an error occurred
949 */
950
951 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len,
952 BN_CTX *ctx);
953
954 /** Decodes an EC_KEY private key from an octet string
955 * \param key key to decode
956 * \param buf memory buffer with the encoded private key
957 * \param len length of the encoded key
958 * \return 1 on success and 0 if an error occurred
959 */
960
961 int EC_KEY_oct2priv(EC_KEY *key, unsigned char *buf, size_t len);
962
963 /** Encodes a EC_KEY private key to an octet string
964 * \param key key to encode
965 * \param buf memory buffer for the result. If NULL the function returns
966 * required buffer size.
967 * \param len length of the memory buffer
968 * \return the length of the encoded octet string or 0 if an error occurred
969 */
970
971 size_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len);
972
973 /** Encodes an EC_KEY private key to an allocated octet string
974 * \param key key to encode
975 * \param pbuf returns pointer to allocated buffer
976 * \return the length of the encoded octet string or 0 if an error occurred
977 */
978
979 size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf);
980
981 /********************************************************************/
982 /* de- and encoding functions for SEC1 ECPrivateKey */
983 /********************************************************************/
984
985 /** Decodes a private key from a memory buffer.
986 * \param key a pointer to a EC_KEY object which should be used (or NULL)
987 * \param in pointer to memory with the DER encoded private key
988 * \param len length of the DER encoded private key
989 * \return the decoded private key or NULL if an error occurred.
990 */
991 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
992
993 /** Encodes a private key object and stores the result in a buffer.
994 * \param key the EC_KEY object to encode
995 * \param out the buffer for the result (if NULL the function returns number
996 * of bytes needed).
997 * \return 1 on success and 0 if an error occurred.
998 */
999 int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
1000
1001 /********************************************************************/
1002 /* de- and encoding functions for EC parameters */
1003 /********************************************************************/
1004
1005 /** Decodes ec parameter from a memory buffer.
1006 * \param key a pointer to a EC_KEY object which should be used (or NULL)
1007 * \param in pointer to memory with the DER encoded ec parameters
1008 * \param len length of the DER encoded ec parameters
1009 * \return a EC_KEY object with the decoded parameters or NULL if an error
1010 * occurred.
1011 */
1012 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
1013
1014 /** Encodes ec parameter and stores the result in a buffer.
1015 * \param key the EC_KEY object with ec parameters to encode
1016 * \param out the buffer for the result (if NULL the function returns number
1017 * of bytes needed).
1018 * \return 1 on success and 0 if an error occurred.
1019 */
1020 int i2d_ECParameters(EC_KEY *key, unsigned char **out);
1021
1022 /********************************************************************/
1023 /* de- and encoding functions for EC public key */
1024 /* (octet string, not DER -- hence 'o2i' and 'i2o') */
1025 /********************************************************************/
1026
1027 /** Decodes a ec public key from a octet string.
1028 * \param key a pointer to a EC_KEY object which should be used
1029 * \param in memory buffer with the encoded public key
1030 * \param len length of the encoded public key
1031 * \return EC_KEY object with decoded public key or NULL if an error
1032 * occurred.
1033 */
1034 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
1035
1036 /** Encodes a ec public key in an octet string.
1037 * \param key the EC_KEY object with the public key
1038 * \param out the buffer for the result (if NULL the function returns number
1039 * of bytes needed).
1040 * \return 1 on success and 0 if an error occurred
1041 */
1042 int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
1043
1044 /** Prints out the ec parameters on human readable form.
1045 * \param bp BIO object to which the information is printed
1046 * \param key EC_KEY object
1047 * \return 1 on success and 0 if an error occurred
1048 */
1049 int ECParameters_print(BIO *bp, const EC_KEY *key);
1050
1051 /** Prints out the contents of a EC_KEY object
1052 * \param bp BIO object to which the information is printed
1053 * \param key EC_KEY object
1054 * \param off line offset
1055 * \return 1 on success and 0 if an error occurred
1056 */
1057 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
1058
1059 # ifndef OPENSSL_NO_STDIO
1060 /** Prints out the ec parameters on human readable form.
1061 * \param fp file descriptor to which the information is printed
1062 * \param key EC_KEY object
1063 * \return 1 on success and 0 if an error occurred
1064 */
1065 int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
1066
1067 /** Prints out the contents of a EC_KEY object
1068 * \param fp file descriptor to which the information is printed
1069 * \param key EC_KEY object
1070 * \param off line offset
1071 * \return 1 on success and 0 if an error occurred
1072 */
1073 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
1074
1075 # endif
1076
1077 const EC_KEY_METHOD *EC_KEY_OpenSSL(void);
1078 const EC_KEY_METHOD *EC_KEY_get_default_method(void);
1079 void EC_KEY_set_default_method(const EC_KEY_METHOD *meth);
1080 const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key);
1081 int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth);
1082 EC_KEY *EC_KEY_new_method(ENGINE *engine);
1083
1084 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
1085 const unsigned char *Z, size_t Zlen,
1086 const unsigned char *sinfo, size_t sinfolen,
1087 const EVP_MD *md);
1088
1089 int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
1090 const EC_KEY *ecdh,
1091 void *(*KDF) (const void *in, size_t inlen,
1092 void *out, size_t *outlen));
1093
1094 typedef struct ECDSA_SIG_st ECDSA_SIG;
1095
1096 /** Allocates and initialize a ECDSA_SIG structure
1097 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1098 */
1099 ECDSA_SIG *ECDSA_SIG_new(void);
1100
1101 /** frees a ECDSA_SIG structure
1102 * \param sig pointer to the ECDSA_SIG structure
1103 */
1104 void ECDSA_SIG_free(ECDSA_SIG *sig);
1105
1106 /** DER encode content of ECDSA_SIG object (note: this function modifies *pp
1107 * (*pp += length of the DER encoded signature)).
1108 * \param sig pointer to the ECDSA_SIG object
1109 * \param pp pointer to a unsigned char pointer for the output or NULL
1110 * \return the length of the DER encoded ECDSA_SIG object or 0
1111 */
1112 int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);
1113
1114 /** Decodes a DER encoded ECDSA signature (note: this function changes *pp
1115 * (*pp += len)).
1116 * \param sig pointer to ECDSA_SIG pointer (may be NULL)
1117 * \param pp memory buffer with the DER encoded signature
1118 * \param len length of the buffer
1119 * \return pointer to the decoded ECDSA_SIG structure (or NULL)
1120 */
1121 ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);
1122
1123 /** Accessor for r and s fields of ECDSA_SIG
1124 * \param sig pointer to ECDSA_SIG pointer
1125 * \param pr pointer to BIGNUM pointer for r (may be NULL)
1126 * \param ps pointer to BIGNUM pointer for s (may be NULL)
1127 */
1128 void ECDSA_SIG_get0(BIGNUM **pr, BIGNUM **ps, const ECDSA_SIG *sig);
1129
1130 /** Computes the ECDSA signature of the given hash value using
1131 * the supplied private key and returns the created signature.
1132 * \param dgst pointer to the hash value
1133 * \param dgst_len length of the hash value
1134 * \param eckey EC_KEY object containing a private EC key
1135 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1136 */
1137 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,
1138 EC_KEY *eckey);
1139
1140 /** Computes ECDSA signature of a given hash value using the supplied
1141 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1142 * \param dgst pointer to the hash value to sign
1143 * \param dgstlen length of the hash value
1144 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1145 * \param rp BIGNUM with a pre-computed rp value (optional),
1146 * see ECDSA_sign_setup
1147 * \param eckey EC_KEY object containing a private EC key
1148 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1149 */
1150 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
1151 const BIGNUM *kinv, const BIGNUM *rp,
1152 EC_KEY *eckey);
1153
1154 /** Verifies that the supplied signature is a valid ECDSA
1155 * signature of the supplied hash value using the supplied public key.
1156 * \param dgst pointer to the hash value
1157 * \param dgst_len length of the hash value
1158 * \param sig ECDSA_SIG structure
1159 * \param eckey EC_KEY object containing a public EC key
1160 * \return 1 if the signature is valid, 0 if the signature is invalid
1161 * and -1 on error
1162 */
1163 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
1164 const ECDSA_SIG *sig, EC_KEY *eckey);
1165
1166 /** Precompute parts of the signing operation
1167 * \param eckey EC_KEY object containing a private EC key
1168 * \param ctx BN_CTX object (optional)
1169 * \param kinv BIGNUM pointer for the inverse of k
1170 * \param rp BIGNUM pointer for x coordinate of k * generator
1171 * \return 1 on success and 0 otherwise
1172 */
1173 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);
1174
1175 /** Computes ECDSA signature of a given hash value using the supplied
1176 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1177 * \param type this parameter is ignored
1178 * \param dgst pointer to the hash value to sign
1179 * \param dgstlen length of the hash value
1180 * \param sig memory for the DER encoded created signature
1181 * \param siglen pointer to the length of the returned signature
1182 * \param eckey EC_KEY object containing a private EC key
1183 * \return 1 on success and 0 otherwise
1184 */
1185 int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
1186 unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
1187
1188 /** Computes ECDSA signature of a given hash value using the supplied
1189 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1190 * \param type this parameter is ignored
1191 * \param dgst pointer to the hash value to sign
1192 * \param dgstlen length of the hash value
1193 * \param sig buffer to hold the DER encoded signature
1194 * \param siglen pointer to the length of the returned signature
1195 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1196 * \param rp BIGNUM with a pre-computed rp value (optional),
1197 * see ECDSA_sign_setup
1198 * \param eckey EC_KEY object containing a private EC key
1199 * \return 1 on success and 0 otherwise
1200 */
1201 int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
1202 unsigned char *sig, unsigned int *siglen,
1203 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
1204
1205 /** Verifies that the given signature is valid ECDSA signature
1206 * of the supplied hash value using the specified public key.
1207 * \param type this parameter is ignored
1208 * \param dgst pointer to the hash value
1209 * \param dgstlen length of the hash value
1210 * \param sig pointer to the DER encoded signature
1211 * \param siglen length of the DER encoded signature
1212 * \param eckey EC_KEY object containing a public EC key
1213 * \return 1 if the signature is valid, 0 if the signature is invalid
1214 * and -1 on error
1215 */
1216 int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
1217 const unsigned char *sig, int siglen, EC_KEY *eckey);
1218
1219 /** Returns the maximum length of the DER encoded signature
1220 * \param eckey EC_KEY object
1221 * \return numbers of bytes required for the DER encoded signature
1222 */
1223 int ECDSA_size(const EC_KEY *eckey);
1224
1225 /********************************************************************/
1226 /* EC_KEY_METHOD constructors, destructors, writers and accessors */
1227 /********************************************************************/
1228
1229 EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth);
1230 void EC_KEY_METHOD_free(EC_KEY_METHOD *meth);
1231 void EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth,
1232 int (*init)(EC_KEY *key),
1233 void (*finish)(EC_KEY *key),
1234 int (*copy)(EC_KEY *dest, const EC_KEY *src),
1235 int (*set_group)(EC_KEY *key, const EC_GROUP *grp),
1236 int (*set_private)(EC_KEY *key,
1237 const BIGNUM *priv_key),
1238 int (*set_public)(EC_KEY *key,
1239 const EC_POINT *pub_key));
1240
1241 void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth,
1242 int (*keygen)(EC_KEY *key));
1243
1244 void EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth,
1245 int (*ckey)(unsigned char **psec,
1246 size_t *pseclen,
1247 const EC_POINT *pub_key,
1248 const EC_KEY *ecdh));
1249
1250 void EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth,
1251 int (*sign)(int type, const unsigned char *dgst,
1252 int dlen, unsigned char *sig,
1253 unsigned int *siglen,
1254 const BIGNUM *kinv, const BIGNUM *r,
1255 EC_KEY *eckey),
1256 int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,
1257 BIGNUM **kinvp, BIGNUM **rp),
1258 ECDSA_SIG *(*sign_sig)(const unsigned char *dgst,
1259 int dgst_len,
1260 const BIGNUM *in_kinv,
1261 const BIGNUM *in_r,
1262 EC_KEY *eckey));
1263
1264 void EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth,
1265 int (*verify)(int type, const unsigned
1266 char *dgst, int dgst_len,
1267 const unsigned char *sigbuf,
1268 int sig_len, EC_KEY *eckey),
1269 int (*verify_sig)(const unsigned char *dgst,
1270 int dgst_len,
1271 const ECDSA_SIG *sig,
1272 EC_KEY *eckey));
1273
1274 void EC_KEY_METHOD_get_init(EC_KEY_METHOD *meth,
1275 int (**pinit)(EC_KEY *key),
1276 void (**pfinish)(EC_KEY *key),
1277 int (**pcopy)(EC_KEY *dest, const EC_KEY *src),
1278 int (**pset_group)(EC_KEY *key,
1279 const EC_GROUP *grp),
1280 int (**pset_private)(EC_KEY *key,
1281 const BIGNUM *priv_key),
1282 int (**pset_public)(EC_KEY *key,
1283 const EC_POINT *pub_key));
1284
1285 void EC_KEY_METHOD_get_keygen(EC_KEY_METHOD *meth,
1286 int (**pkeygen)(EC_KEY *key));
1287
1288 void EC_KEY_METHOD_get_compute_key(EC_KEY_METHOD *meth,
1289 int (**pck)(unsigned char **psec,
1290 size_t *pseclen,
1291 const EC_POINT *pub_key,
1292 const EC_KEY *ecdh));
1293
1294 void EC_KEY_METHOD_get_sign(EC_KEY_METHOD *meth,
1295 int (**psign)(int type, const unsigned char *dgst,
1296 int dlen, unsigned char *sig,
1297 unsigned int *siglen,
1298 const BIGNUM *kinv, const BIGNUM *r,
1299 EC_KEY *eckey),
1300 int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,
1301 BIGNUM **kinvp, BIGNUM **rp),
1302 ECDSA_SIG *(**psign_sig)(const unsigned char *dgst,
1303 int dgst_len,
1304 const BIGNUM *in_kinv,
1305 const BIGNUM *in_r,
1306 EC_KEY *eckey));
1307
1308 void EC_KEY_METHOD_get_verify(EC_KEY_METHOD *meth,
1309 int (**pverify)(int type, const unsigned
1310 char *dgst, int dgst_len,
1311 const unsigned char *sigbuf,
1312 int sig_len, EC_KEY *eckey),
1313 int (**pverify_sig)(const unsigned char *dgst,
1314 int dgst_len,
1315 const ECDSA_SIG *sig,
1316 EC_KEY *eckey));
1317
1318 # define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
1319
1320 # ifndef __cplusplus
1321 # if defined(__SUNPRO_C)
1322 # if __SUNPRO_C >= 0x520
1323 # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
1324 # endif
1325 # endif
1326 # endif
1327
1328 # define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
1329 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1330 EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
1331 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
1332
1333 # define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \
1334 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1335 EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
1336 EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)
1337
1338 # define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \
1339 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1340 EVP_PKEY_OP_DERIVE, \
1341 EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)
1342
1343 # define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \
1344 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1345 EVP_PKEY_OP_DERIVE, \
1346 EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)
1347
1348 # define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \
1349 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1350 EVP_PKEY_OP_DERIVE, \
1351 EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)
1352
1353 # define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \
1354 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1355 EVP_PKEY_OP_DERIVE, \
1356 EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)
1357
1358 # define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \
1359 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1360 EVP_PKEY_OP_DERIVE, \
1361 EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)
1362
1363 # define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \
1364 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1365 EVP_PKEY_OP_DERIVE, \
1366 EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)
1367
1368 # define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \
1369 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1370 EVP_PKEY_OP_DERIVE, \
1371 EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)
1372
1373 # define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \
1374 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1375 EVP_PKEY_OP_DERIVE, \
1376 EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)
1377
1378 # define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \
1379 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1380 EVP_PKEY_OP_DERIVE, \
1381 EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)
1382
1383 # define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \
1384 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
1385 EVP_PKEY_OP_DERIVE, \
1386 EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)
1387
1388 # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
1389 # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
1390 # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3)
1391 # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4)
1392 # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5)
1393 # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6)
1394 # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7)
1395 # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8)
1396 # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
1397 # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
1398 /* KDF types */
1399 # define EVP_PKEY_ECDH_KDF_NONE 1
1400 # define EVP_PKEY_ECDH_KDF_X9_62 2
1401
1402 /* BEGIN ERROR CODES */
1403 /*
1404 * The following lines are auto generated by the script mkerr.pl. Any changes
1405 * made after this point may be overwritten when the script is next run.
1406 */
1407 void ERR_load_EC_strings(void);
1408
1409 /* Error codes for the EC functions. */
1410
1411 /* Function codes. */
1412 # define EC_F_BN_TO_FELEM 224
1413 # define EC_F_COMPUTE_WNAF 143
1414 # define EC_F_D2I_ECPARAMETERS 144
1415 # define EC_F_D2I_ECPKPARAMETERS 145
1416 # define EC_F_D2I_ECPRIVATEKEY 146
1417 # define EC_F_DO_EC_KEY_PRINT 221
1418 # define EC_F_ECDH_CMS_DECRYPT 238
1419 # define EC_F_ECDH_CMS_SET_SHARED_INFO 239
1420 # define EC_F_ECDH_COMPUTE_KEY 246
1421 # define EC_F_ECDH_SIMPLE_COMPUTE_KEY 257
1422 # define EC_F_ECDSA_DO_SIGN_EX 251
1423 # define EC_F_ECDSA_DO_VERIFY 252
1424 # define EC_F_ECDSA_SIGN_EX 254
1425 # define EC_F_ECDSA_SIGN_SETUP 248
1426 # define EC_F_ECDSA_VERIFY 253
1427 # define EC_F_ECKEY_PARAM2TYPE 223
1428 # define EC_F_ECKEY_PARAM_DECODE 212
1429 # define EC_F_ECKEY_PRIV_DECODE 213
1430 # define EC_F_ECKEY_PRIV_ENCODE 214
1431 # define EC_F_ECKEY_PUB_DECODE 215
1432 # define EC_F_ECKEY_PUB_ENCODE 216
1433 # define EC_F_ECKEY_TYPE2PARAM 220
1434 # define EC_F_ECPARAMETERS_PRINT 147
1435 # define EC_F_ECPARAMETERS_PRINT_FP 148
1436 # define EC_F_ECPKPARAMETERS_PRINT 149
1437 # define EC_F_ECPKPARAMETERS_PRINT_FP 150
1438 # define EC_F_ECP_NISTZ256_GET_AFFINE 240
1439 # define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243
1440 # define EC_F_ECP_NISTZ256_POINTS_MUL 241
1441 # define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244
1442 # define EC_F_ECP_NISTZ256_WINDOWED_MUL 242
1443 # define EC_F_ECP_NIST_MOD_192 203
1444 # define EC_F_ECP_NIST_MOD_224 204
1445 # define EC_F_ECP_NIST_MOD_256 205
1446 # define EC_F_ECP_NIST_MOD_521 206
1447 # define EC_F_EC_ASN1_GROUP2CURVE 153
1448 # define EC_F_EC_ASN1_GROUP2FIELDID 154
1449 # define EC_F_EC_ASN1_GROUP2PARAMETERS 155
1450 # define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156
1451 # define EC_F_EC_ASN1_PARAMETERS2GROUP 157
1452 # define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158
1453 # define EC_F_EC_EX_DATA_SET_DATA 211
1454 # define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
1455 # define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
1456 # define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
1457 # define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
1458 # define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
1459 # define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
1460 # define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
1461 # define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
1462 # define EC_F_EC_GFP_MONT_FIELD_DECODE 133
1463 # define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
1464 # define EC_F_EC_GFP_MONT_FIELD_MUL 131
1465 # define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
1466 # define EC_F_EC_GFP_MONT_FIELD_SQR 132
1467 # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
1468 # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135
1469 # define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225
1470 # define EC_F_EC_GFP_NISTP224_POINTS_MUL 228
1471 # define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
1472 # define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230
1473 # define EC_F_EC_GFP_NISTP256_POINTS_MUL 231
1474 # define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
1475 # define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233
1476 # define EC_F_EC_GFP_NISTP521_POINTS_MUL 234
1477 # define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
1478 # define EC_F_EC_GFP_NIST_FIELD_MUL 200
1479 # define EC_F_EC_GFP_NIST_FIELD_SQR 201
1480 # define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
1481 # define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
1482 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
1483 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
1484 # define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
1485 # define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
1486 # define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
1487 # define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
1488 # define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
1489 # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
1490 # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
1491 # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
1492 # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
1493 # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
1494 # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
1495 # define EC_F_EC_GROUP_CHECK 170
1496 # define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
1497 # define EC_F_EC_GROUP_COPY 106
1498 # define EC_F_EC_GROUP_GET0_GENERATOR 139
1499 # define EC_F_EC_GROUP_GET_COFACTOR 140
1500 # define EC_F_EC_GROUP_GET_CURVE_GF2M 172
1501 # define EC_F_EC_GROUP_GET_CURVE_GFP 130
1502 # define EC_F_EC_GROUP_GET_DEGREE 173
1503 # define EC_F_EC_GROUP_GET_ECPARAMETERS 261
1504 # define EC_F_EC_GROUP_GET_ECPKPARAMETERS 262
1505 # define EC_F_EC_GROUP_GET_ORDER 141
1506 # define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
1507 # define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
1508 # define EC_F_EC_GROUP_NEW 108
1509 # define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
1510 # define EC_F_EC_GROUP_NEW_FROM_DATA 175
1511 # define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263
1512 # define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264
1513 # define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
1514 # define EC_F_EC_GROUP_SET_CURVE_GF2M 176
1515 # define EC_F_EC_GROUP_SET_CURVE_GFP 109
1516 # define EC_F_EC_GROUP_SET_EXTRA_DATA 110
1517 # define EC_F_EC_GROUP_SET_GENERATOR 111
1518 # define EC_F_EC_KEY_CHECK_KEY 177
1519 # define EC_F_EC_KEY_COPY 178
1520 # define EC_F_EC_KEY_GENERATE_KEY 179
1521 # define EC_F_EC_KEY_NEW 182
1522 # define EC_F_EC_KEY_NEW_METHOD 245
1523 # define EC_F_EC_KEY_OCT2PRIV 255
1524 # define EC_F_EC_KEY_PRINT 180
1525 # define EC_F_EC_KEY_PRINT_FP 181
1526 # define EC_F_EC_KEY_PRIV2OCT 256
1527 # define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229
1528 # define EC_F_EC_KEY_SIMPLE_CHECK_KEY 258
1529 # define EC_F_EC_KEY_SIMPLE_OCT2PRIV 259
1530 # define EC_F_EC_KEY_SIMPLE_PRIV2OCT 260
1531 # define EC_F_EC_POINTS_MAKE_AFFINE 136
1532 # define EC_F_EC_POINT_ADD 112
1533 # define EC_F_EC_POINT_CMP 113
1534 # define EC_F_EC_POINT_COPY 114
1535 # define EC_F_EC_POINT_DBL 115
1536 # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
1537 # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
1538 # define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
1539 # define EC_F_EC_POINT_INVERT 210
1540 # define EC_F_EC_POINT_IS_AT_INFINITY 118
1541 # define EC_F_EC_POINT_IS_ON_CURVE 119
1542 # define EC_F_EC_POINT_MAKE_AFFINE 120
1543 # define EC_F_EC_POINT_MUL 184
1544 # define EC_F_EC_POINT_NEW 121
1545 # define EC_F_EC_POINT_OCT2POINT 122
1546 # define EC_F_EC_POINT_POINT2OCT 123
1547 # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
1548 # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
1549 # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
1550 # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
1551 # define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
1552 # define EC_F_EC_POINT_SET_TO_INFINITY 127
1553 # define EC_F_EC_PRE_COMP_DUP 207
1554 # define EC_F_EC_PRE_COMP_NEW 196
1555 # define EC_F_EC_WNAF_MUL 187
1556 # define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
1557 # define EC_F_I2D_ECPARAMETERS 190
1558 # define EC_F_I2D_ECPKPARAMETERS 191
1559 # define EC_F_I2D_ECPRIVATEKEY 192
1560 # define EC_F_I2O_ECPUBLICKEY 151
1561 # define EC_F_NISTP224_PRE_COMP_NEW 227
1562 # define EC_F_NISTP256_PRE_COMP_NEW 236
1563 # define EC_F_NISTP521_PRE_COMP_NEW 237
1564 # define EC_F_O2I_ECPUBLICKEY 152
1565 # define EC_F_OLD_EC_PRIV_DECODE 222
1566 # define EC_F_OSSL_ECDH_COMPUTE_KEY 247
1567 # define EC_F_OSSL_ECDSA_SIGN_SIG 249
1568 # define EC_F_OSSL_ECDSA_VERIFY_SIG 250
1569 # define EC_F_PKEY_EC_CTRL 197
1570 # define EC_F_PKEY_EC_CTRL_STR 198
1571 # define EC_F_PKEY_EC_DERIVE 217
1572 # define EC_F_PKEY_EC_KEYGEN 199
1573 # define EC_F_PKEY_EC_PARAMGEN 219
1574 # define EC_F_PKEY_EC_SIGN 218
1575
1576 /* Reason codes. */
1577 # define EC_R_ASN1_ERROR 115
1578 # define EC_R_ASN1_UNKNOWN_FIELD 116
1579 # define EC_R_BAD_SIGNATURE 156
1580 # define EC_R_BIGNUM_OUT_OF_RANGE 144
1581 # define EC_R_BUFFER_TOO_SMALL 100
1582 # define EC_R_COORDINATES_OUT_OF_RANGE 146
1583 # define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160
1584 # define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159
1585 # define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
1586 # define EC_R_DECODE_ERROR 142
1587 # define EC_R_DISCRIMINANT_IS_ZERO 118
1588 # define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
1589 # define EC_R_FIELD_TOO_LARGE 143
1590 # define EC_R_GF2M_NOT_SUPPORTED 147
1591 # define EC_R_GROUP2PKPARAMETERS_FAILURE 120
1592 # define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
1593 # define EC_R_INCOMPATIBLE_OBJECTS 101
1594 # define EC_R_INVALID_ARGUMENT 112
1595 # define EC_R_INVALID_COMPRESSED_POINT 110
1596 # define EC_R_INVALID_COMPRESSION_BIT 109
1597 # define EC_R_INVALID_CURVE 141
1598 # define EC_R_INVALID_DIGEST 151
1599 # define EC_R_INVALID_DIGEST_TYPE 138
1600 # define EC_R_INVALID_ENCODING 102
1601 # define EC_R_INVALID_FIELD 103
1602 # define EC_R_INVALID_FORM 104
1603 # define EC_R_INVALID_GROUP_ORDER 122
1604 # define EC_R_INVALID_OUTPUT_LENGTH 161
1605 # define EC_R_INVALID_PENTANOMIAL_BASIS 132
1606 # define EC_R_INVALID_PRIVATE_KEY 123
1607 # define EC_R_INVALID_TRINOMIAL_BASIS 137
1608 # define EC_R_KDF_FAILED 153
1609 # define EC_R_KDF_PARAMETER_ERROR 148
1610 # define EC_R_KEYS_NOT_SET 140
1611 # define EC_R_MISSING_PARAMETERS 124
1612 # define EC_R_MISSING_PRIVATE_KEY 125
1613 # define EC_R_NEED_NEW_SETUP_VALUES 157
1614 # define EC_R_NOT_A_NIST_PRIME 135
1615 # define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136
1616 # define EC_R_NOT_IMPLEMENTED 126
1617 # define EC_R_NOT_INITIALIZED 111
1618 # define EC_R_NO_FIELD_MOD 133
1619 # define EC_R_NO_PARAMETERS_SET 139
1620 # define EC_R_NO_PRIVATE_VALUE 154
1621 # define EC_R_OPERATION_NOT_SUPPORTED 152
1622 # define EC_R_PASSED_NULL_PARAMETER 134
1623 # define EC_R_PEER_KEY_ERROR 149
1624 # define EC_R_PKPARAMETERS2GROUP_FAILURE 127
1625 # define EC_R_POINT_ARITHMETIC_FAILURE 155
1626 # define EC_R_POINT_AT_INFINITY 106
1627 # define EC_R_POINT_IS_NOT_ON_CURVE 107
1628 # define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158
1629 # define EC_R_SHARED_INFO_ERROR 150
1630 # define EC_R_SLOT_FULL 108
1631 # define EC_R_UNDEFINED_GENERATOR 113
1632 # define EC_R_UNDEFINED_ORDER 128
1633 # define EC_R_UNKNOWN_GROUP 129
1634 # define EC_R_UNKNOWN_ORDER 114
1635 # define EC_R_UNSUPPORTED_FIELD 131
1636 # define EC_R_WRONG_CURVE_PARAMETERS 145
1637 # define EC_R_WRONG_ORDER 130
1638
1639 # ifdef __cplusplus
1640 }
1641 # endif
1642 # endif
1643
1644 #endif