3 * Originally written by Bodo Moeller for the OpenSSL project.
\r
6 * \file crypto/ec/ec.h Include file for the OpenSSL EC functions
\r
7 * \author Originally written by Bodo Moeller for the OpenSSL project
\r
9 /* ====================================================================
\r
10 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
\r
12 * Redistribution and use in source and binary forms, with or without
\r
13 * modification, are permitted provided that the following conditions
\r
16 * 1. Redistributions of source code must retain the above copyright
\r
17 * notice, this list of conditions and the following disclaimer.
\r
19 * 2. Redistributions in binary form must reproduce the above copyright
\r
20 * notice, this list of conditions and the following disclaimer in
\r
21 * the documentation and/or other materials provided with the
\r
24 * 3. All advertising materials mentioning features or use of this
\r
25 * software must display the following acknowledgment:
\r
26 * "This product includes software developed by the OpenSSL Project
\r
27 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
\r
29 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
\r
30 * endorse or promote products derived from this software without
\r
31 * prior written permission. For written permission, please contact
\r
32 * openssl-core@openssl.org.
\r
34 * 5. Products derived from this software may not be called "OpenSSL"
\r
35 * nor may "OpenSSL" appear in their names without prior written
\r
36 * permission of the OpenSSL Project.
\r
38 * 6. Redistributions of any form whatsoever must retain the following
\r
40 * "This product includes software developed by the OpenSSL Project
\r
41 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
\r
43 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
\r
44 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
46 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
\r
47 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
\r
49 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
52 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
\r
54 * OF THE POSSIBILITY OF SUCH DAMAGE.
\r
55 * ====================================================================
\r
57 * This product includes cryptographic software written by Eric Young
\r
58 * (eay@cryptsoft.com). This product includes software written by Tim
\r
59 * Hudson (tjh@cryptsoft.com).
\r
62 /* ====================================================================
\r
63 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
\r
65 * Portions of the attached software ("Contribution") are developed by
\r
66 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
\r
68 * The Contribution is licensed pursuant to the OpenSSL open source
\r
69 * license provided above.
\r
71 * The elliptic curve binary polynomial software is originally written by
\r
72 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
\r
79 #include <openssl/opensslconf.h>
\r
81 #ifdef OPENSSL_NO_EC
\r
82 #error EC is disabled.
\r
85 #include <openssl/asn1.h>
\r
86 #include <openssl/symhacks.h>
\r
87 #ifndef OPENSSL_NO_DEPRECATED
\r
88 #include <openssl/bn.h>
\r
93 #elif defined(__SUNPRO_C)
\r
94 # if __SUNPRO_C >= 0x520
\r
95 # pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
\r
100 #ifndef OPENSSL_ECC_MAX_FIELD_BITS
\r
101 # define OPENSSL_ECC_MAX_FIELD_BITS 661
\r
104 /** Enum for the point conversion form as defined in X9.62 (ECDSA)
\r
105 * for the encoding of a elliptic curve point (x,y) */
\r
107 /** the point is encoded as z||x, where the octet z specifies
\r
108 * which solution of the quadratic equation y is */
\r
109 POINT_CONVERSION_COMPRESSED = 2,
\r
110 /** the point is encoded as z||x||y, where z is the octet 0x02 */
\r
111 POINT_CONVERSION_UNCOMPRESSED = 4,
\r
112 /** the point is encoded as z||x||y, where the octet z specifies
\r
113 * which solution of the quadratic equation y is */
\r
114 POINT_CONVERSION_HYBRID = 6
\r
115 } point_conversion_form_t;
\r
118 typedef struct ec_method_st EC_METHOD;
\r
120 typedef struct ec_group_st
\r
123 -- field definition
\r
124 -- curve coefficients
\r
125 -- optional generator with associated information (order, cofactor)
\r
126 -- optional extra data (precomputed table for fast computation of multiples of generator)
\r
131 typedef struct ec_point_st EC_POINT;
\r
134 /********************************************************************/
\r
135 /* EC_METHODs for curves over GF(p) */
\r
136 /********************************************************************/
\r
138 /** Returns the basic GFp ec methods which provides the basis for the
\r
139 * optimized methods.
\r
140 * \return EC_METHOD object
\r
142 const EC_METHOD *EC_GFp_simple_method(void);
\r
144 /** Returns GFp methods using montgomery multiplication.
\r
145 * \return EC_METHOD object
\r
147 const EC_METHOD *EC_GFp_mont_method(void);
\r
149 /** Returns GFp methods using optimized methods for NIST recommended curves
\r
150 * \return EC_METHOD object
\r
152 const EC_METHOD *EC_GFp_nist_method(void);
\r
155 /********************************************************************/
\r
156 /* EC_METHOD for curves over GF(2^m) */
\r
157 /********************************************************************/
\r
159 /** Returns the basic GF2m ec method
\r
160 * \return EC_METHOD object
\r
162 const EC_METHOD *EC_GF2m_simple_method(void);
\r
165 /********************************************************************/
\r
166 /* EC_GROUP functions */
\r
167 /********************************************************************/
\r
169 /** Creates a new EC_GROUP object
\r
170 * \param meth EC_METHOD to use
\r
171 * \return newly created EC_GROUP object or NULL in case of an error.
\r
173 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
\r
175 /** Frees a EC_GROUP object
\r
176 * \param group EC_GROUP object to be freed.
\r
178 void EC_GROUP_free(EC_GROUP *group);
\r
180 /** Clears and frees a EC_GROUP object
\r
181 * \param group EC_GROUP object to be cleared and freed.
\r
183 void EC_GROUP_clear_free(EC_GROUP *group);
\r
185 /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
\r
186 * \param dst destination EC_GROUP object
\r
187 * \param src source EC_GROUP object
\r
188 * \return 1 on success and 0 if an error occurred.
\r
190 int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
\r
192 /** Creates a new EC_GROUP object and copies the copies the content
\r
193 * form src to the newly created EC_KEY object
\r
194 * \param src source EC_GROUP object
\r
195 * \return newly created EC_GROUP object or NULL in case of an error.
\r
197 EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
\r
199 /** Returns the EC_METHOD of the EC_GROUP object.
\r
200 * \param group EC_GROUP object
\r
201 * \return EC_METHOD used in this EC_GROUP object.
\r
203 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
\r
205 /** Returns the field type of the EC_METHOD.
\r
206 * \param meth EC_METHOD object
\r
207 * \return NID of the underlying field type OID.
\r
209 int EC_METHOD_get_field_type(const EC_METHOD *meth);
\r
211 /** Sets the generator and it's order/cofactor of a EC_GROUP object.
\r
212 * \param group EC_GROUP object
\r
213 * \param generator EC_POINT object with the generator.
\r
214 * \param order the order of the group generated by the generator.
\r
215 * \param cofactor the index of the sub-group generated by the generator
\r
216 * in the group of all points on the elliptic curve.
\r
217 * \return 1 on success and 0 if an error occured
\r
219 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
\r
221 /** Returns the generator of a EC_GROUP object.
\r
222 * \param group EC_GROUP object
\r
223 * \return the currently used generator (possibly NULL).
\r
225 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
\r
227 /** Gets the order of a EC_GROUP
\r
228 * \param group EC_GROUP object
\r
229 * \param order BIGNUM to which the order is copied
\r
230 * \param ctx BN_CTX object (optional)
\r
231 * \return 1 on success and 0 if an error occured
\r
233 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
\r
235 /** Gets the cofactor of a EC_GROUP
\r
236 * \param group EC_GROUP object
\r
237 * \param cofactor BIGNUM to which the cofactor is copied
\r
238 * \param ctx BN_CTX object (optional)
\r
239 * \return 1 on success and 0 if an error occured
\r
241 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
\r
243 /** Sets the name of a EC_GROUP object
\r
244 * \param group EC_GROUP object
\r
245 * \param nid NID of the curve name OID
\r
247 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
\r
249 /** Returns the curve name of a EC_GROUP object
\r
250 * \param group EC_GROUP object
\r
251 * \return NID of the curve name OID or 0 if not set.
\r
253 int EC_GROUP_get_curve_name(const EC_GROUP *group);
\r
255 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
\r
256 int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
\r
258 void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
\r
259 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
\r
261 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *);
\r
262 size_t EC_GROUP_get_seed_len(const EC_GROUP *);
\r
263 size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
\r
265 /** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
\r
266 * \param group EC_GROUP object
\r
267 * \param p BIGNUM with the prime number
\r
268 * \param a BIGNUM with parameter a of the equation
\r
269 * \param b BIGNUM with parameter b of the equation
\r
270 * \param ctx BN_CTX object (optional)
\r
271 * \return 1 on success and 0 if an error occured
\r
273 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
\r
275 /** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
\r
276 * \param group EC_GROUP object
\r
277 * \param p BIGNUM for the prime number
\r
278 * \param a BIGNUM for parameter a of the equation
\r
279 * \param b BIGNUM for parameter b of the equation
\r
280 * \param ctx BN_CTX object (optional)
\r
281 * \return 1 on success and 0 if an error occured
\r
283 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
\r
285 /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
\r
286 * \param group EC_GROUP object
\r
287 * \param p BIGNUM with the polynomial defining the underlying field
\r
288 * \param a BIGNUM with parameter a of the equation
\r
289 * \param b BIGNUM with parameter b of the equation
\r
290 * \param ctx BN_CTX object (optional)
\r
291 * \return 1 on success and 0 if an error occured
\r
293 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
\r
295 /** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
\r
296 * \param group EC_GROUP object
\r
297 * \param p BIGNUM for the polynomial defining the underlying field
\r
298 * \param a BIGNUM for parameter a of the equation
\r
299 * \param b BIGNUM for parameter b of the equation
\r
300 * \param ctx BN_CTX object (optional)
\r
301 * \return 1 on success and 0 if an error occured
\r
303 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
\r
305 /** Returns the number of bits needed to represent a field element
\r
306 * \param group EC_GROUP object
\r
307 * \return number of bits needed to represent a field element
\r
309 int EC_GROUP_get_degree(const EC_GROUP *group);
\r
311 /** Checks whether the parameter in the EC_GROUP define a valid ec group
\r
312 * \param group EC_GROUP object
\r
313 * \param ctx BN_CTX object (optional)
\r
314 * \return 1 if group is a valid ec group and 0 otherwise
\r
316 int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
\r
318 /** Checks whether the discriminant of the elliptic curve is zero or not
\r
319 * \param group EC_GROUP object
\r
320 * \param ctx BN_CTX object (optional)
\r
321 * \return 1 if the discriminant is not zero and 0 otherwise
\r
323 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
\r
325 /** Compares two EC_GROUP objects
\r
326 * \param a first EC_GROUP object
\r
327 * \param b second EC_GROUP object
\r
328 * \param ctx BN_CTX object (optional)
\r
329 * \return 0 if both groups are equal and 1 otherwise
\r
331 int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
\r
333 /* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
\r
334 * after choosing an appropriate EC_METHOD */
\r
336 /** Creates a new EC_GROUP object with the specified parameters defined
\r
337 * over GFp (defined by the equation y^2 = x^3 + a*x + b)
\r
338 * \param p BIGNUM with the prime number
\r
339 * \param a BIGNUM with the parameter a of the equation
\r
340 * \param b BIGNUM with the parameter b of the equation
\r
341 * \param ctx BN_CTX object (optional)
\r
342 * \return newly created EC_GROUP object with the specified parameters
\r
344 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
\r
346 /** Creates a new EC_GROUP object with the specified parameters defined
\r
347 * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
\r
348 * \param p BIGNUM with the polynomial defining the underlying field
\r
349 * \param a BIGNUM with the parameter a of the equation
\r
350 * \param b BIGNUM with the parameter b of the equation
\r
351 * \param ctx BN_CTX object (optional)
\r
352 * \return newly created EC_GROUP object with the specified parameters
\r
354 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
\r
356 /** Creates a EC_GROUP object with a curve specified by a NID
\r
357 * \param nid NID of the OID of the curve name
\r
358 * \return newly created EC_GROUP object with specified curve or NULL
\r
359 * if an error occurred
\r
361 EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
\r
364 /********************************************************************/
\r
365 /* handling of internal curves */
\r
366 /********************************************************************/
\r
370 const char *comment;
\r
371 } EC_builtin_curve;
\r
373 /* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
\r
374 * of all available curves or zero if a error occurred.
\r
375 * In case r ist not zero nitems EC_builtin_curve structures
\r
376 * are filled with the data of the first nitems internal groups */
\r
377 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
\r
380 /********************************************************************/
\r
381 /* EC_POINT functions */
\r
382 /********************************************************************/
\r
384 /** Creates a new EC_POINT object for the specified EC_GROUP
\r
385 * \param group EC_GROUP the underlying EC_GROUP object
\r
386 * \return newly created EC_POINT object or NULL if an error occurred
\r
388 EC_POINT *EC_POINT_new(const EC_GROUP *group);
\r
390 /** Frees a EC_POINT object
\r
391 * \param point EC_POINT object to be freed
\r
393 void EC_POINT_free(EC_POINT *point);
\r
395 /** Clears and frees a EC_POINT object
\r
396 * \param point EC_POINT object to be cleared and freed
\r
398 void EC_POINT_clear_free(EC_POINT *point);
\r
400 /** Copies EC_POINT object
\r
401 * \param dst destination EC_POINT object
\r
402 * \param src source EC_POINT object
\r
403 * \return 1 on success and 0 if an error occured
\r
405 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
\r
407 /** Creates a new EC_POINT object and copies the content of the supplied
\r
409 * \param src source EC_POINT object
\r
410 * \param group underlying the EC_GROUP object
\r
411 * \return newly created EC_POINT object or NULL if an error occurred
\r
413 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
\r
415 /** Returns the EC_METHOD used in EC_POINT object
\r
416 * \param point EC_POINT object
\r
417 * \return the EC_METHOD used
\r
419 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
\r
421 /** Sets a point to infinity (neutral element)
\r
422 * \param group underlying EC_GROUP object
\r
423 * \param point EC_POINT to set to infinity
\r
424 * \return 1 on success and 0 if an error occured
\r
426 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
\r
428 /** Sets the jacobian projective coordinates of a EC_POINT over GFp
\r
429 * \param group underlying EC_GROUP object
\r
430 * \param p EC_POINT object
\r
431 * \param x BIGNUM with the x-coordinate
\r
432 * \param y BIGNUM with the y-coordinate
\r
433 * \param z BIGNUM with the z-coordinate
\r
434 * \param ctx BN_CTX object (optional)
\r
435 * \return 1 on success and 0 if an error occured
\r
437 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
\r
438 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
\r
440 /** Gets the jacobian projective coordinates of a EC_POINT over GFp
\r
441 * \param group underlying EC_GROUP object
\r
442 * \param p EC_POINT object
\r
443 * \param x BIGNUM for the x-coordinate
\r
444 * \param y BIGNUM for the y-coordinate
\r
445 * \param z BIGNUM for the z-coordinate
\r
446 * \param ctx BN_CTX object (optional)
\r
447 * \return 1 on success and 0 if an error occured
\r
449 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
\r
450 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
\r
452 /** Sets the affine coordinates of a EC_POINT over GFp
\r
453 * \param group underlying EC_GROUP object
\r
454 * \param p EC_POINT object
\r
455 * \param x BIGNUM with the x-coordinate
\r
456 * \param y BIGNUM with the y-coordinate
\r
457 * \param ctx BN_CTX object (optional)
\r
458 * \return 1 on success and 0 if an error occured
\r
460 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
\r
461 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
\r
463 /** Gets the affine coordinates of a EC_POINT over GFp
\r
464 * \param group underlying EC_GROUP object
\r
465 * \param p EC_POINT object
\r
466 * \param x BIGNUM for the x-coordinate
\r
467 * \param y BIGNUM for the y-coordinate
\r
468 * \param ctx BN_CTX object (optional)
\r
469 * \return 1 on success and 0 if an error occured
\r
471 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
\r
472 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
\r
474 /** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
\r
475 * \param group underlying EC_GROUP object
\r
476 * \param p EC_POINT object
\r
477 * \param x BIGNUM with x-coordinate
\r
478 * \param y_bit integer with the y-Bit (either 0 or 1)
\r
479 * \param ctx BN_CTX object (optional)
\r
480 * \return 1 on success and 0 if an error occured
\r
482 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
\r
483 const BIGNUM *x, int y_bit, BN_CTX *ctx);
\r
485 /** Sets the affine coordinates of a EC_POINT over GF2m
\r
486 * \param group underlying EC_GROUP object
\r
487 * \param p EC_POINT object
\r
488 * \param x BIGNUM with the x-coordinate
\r
489 * \param y BIGNUM with the y-coordinate
\r
490 * \param ctx BN_CTX object (optional)
\r
491 * \return 1 on success and 0 if an error occured
\r
493 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
\r
494 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
\r
496 /** Gets the affine coordinates of a EC_POINT over GF2m
\r
497 * \param group underlying EC_GROUP object
\r
498 * \param p EC_POINT object
\r
499 * \param x BIGNUM for the x-coordinate
\r
500 * \param y BIGNUM for the y-coordinate
\r
501 * \param ctx BN_CTX object (optional)
\r
502 * \return 1 on success and 0 if an error occured
\r
504 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
\r
505 const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
\r
507 /** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
\r
508 * \param group underlying EC_GROUP object
\r
509 * \param p EC_POINT object
\r
510 * \param x BIGNUM with x-coordinate
\r
511 * \param y_bit integer with the y-Bit (either 0 or 1)
\r
512 * \param ctx BN_CTX object (optional)
\r
513 * \return 1 on success and 0 if an error occured
\r
515 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
\r
516 const BIGNUM *x, int y_bit, BN_CTX *ctx);
\r
518 /** Encodes a EC_POINT object to a octet string
\r
519 * \param group underlying EC_GROUP object
\r
520 * \param p EC_POINT object
\r
521 * \param form point conversion form
\r
522 * \param buf memory buffer for the result. If NULL the function returns
\r
523 * required buffer size.
\r
524 * \param len length of the memory buffer
\r
525 * \param ctx BN_CTX object (optional)
\r
526 * \return the length of the encoded octet string or 0 if an error occurred
\r
528 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
\r
529 point_conversion_form_t form,
\r
530 unsigned char *buf, size_t len, BN_CTX *ctx);
\r
532 /** Decodes a EC_POINT from a octet string
\r
533 * \param group underlying EC_GROUP object
\r
534 * \param p EC_POINT object
\r
535 * \param buf memory buffer with the encoded ec point
\r
536 * \param len length of the encoded ec point
\r
537 * \param ctx BN_CTX object (optional)
\r
538 * \return 1 on success and 0 if an error occured
\r
540 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
\r
541 const unsigned char *buf, size_t len, BN_CTX *ctx);
\r
543 /* other interfaces to point2oct/oct2point: */
\r
544 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
\r
545 point_conversion_form_t form, BIGNUM *, BN_CTX *);
\r
546 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
\r
547 EC_POINT *, BN_CTX *);
\r
548 char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
\r
549 point_conversion_form_t form, BN_CTX *);
\r
550 EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
\r
551 EC_POINT *, BN_CTX *);
\r
554 /********************************************************************/
\r
555 /* functions for doing EC_POINT arithmetic */
\r
556 /********************************************************************/
\r
558 /** Computes the sum of two EC_POINT
\r
559 * \param group underlying EC_GROUP object
\r
560 * \param r EC_POINT object for the result (r = a + b)
\r
561 * \param a EC_POINT object with the first summand
\r
562 * \param b EC_POINT object with the second summand
\r
563 * \param ctx BN_CTX object (optional)
\r
564 * \return 1 on success and 0 if an error occured
\r
566 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
\r
568 /** Computes the double of a EC_POINT
\r
569 * \param group underlying EC_GROUP object
\r
570 * \param r EC_POINT object for the result (r = 2 * a)
\r
571 * \param a EC_POINT object
\r
572 * \param ctx BN_CTX object (optional)
\r
573 * \return 1 on success and 0 if an error occured
\r
575 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
\r
577 /** Computes the inverse of a EC_POINT
\r
578 * \param group underlying EC_GROUP object
\r
579 * \param a EC_POINT object to be inverted (it's used for the result as well)
\r
580 * \param ctx BN_CTX object (optional)
\r
581 * \return 1 on success and 0 if an error occured
\r
583 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
\r
585 /** Checks whether the point is the neutral element of the group
\r
586 * \param group the underlying EC_GROUP object
\r
587 * \param p EC_POINT object
\r
588 * \return 1 if the point is the neutral element and 0 otherwise
\r
590 int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
\r
592 /** Checks whether the point is on the curve
\r
593 * \param group underlying EC_GROUP object
\r
594 * \param point EC_POINT object to check
\r
595 * \param ctx BN_CTX object (optional)
\r
596 * \return 1 if point if on the curve and 0 otherwise
\r
598 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
\r
600 /** Compares two EC_POINTs
\r
601 * \param group underlying EC_GROUP object
\r
602 * \param a first EC_POINT object
\r
603 * \param b second EC_POINT object
\r
604 * \param ctx BN_CTX object (optional)
\r
605 * \return 0 if both points are equal and a value != 0 otherwise
\r
607 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
\r
609 int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
\r
610 int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
\r
612 /** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
\r
613 * \param group underlying EC_GROUP object
\r
614 * \param r EC_POINT object for the result
\r
615 * \param n BIGNUM with the multiplier for the group generator (optional)
\r
616 * \param num number futher summands
\r
617 * \param p array of size num of EC_POINT objects
\r
618 * \param m array of size num of BIGNUM objects
\r
619 * \param ctx BN_CTX object (optional)
\r
620 * \return 1 on success and 0 if an error occured
\r
622 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);
\r
624 /** Computes r = generator * n + q * m
\r
625 * \param group underlying EC_GROUP object
\r
626 * \param r EC_POINT object for the result
\r
627 * \param n BIGNUM with the multiplier for the group generator (optional)
\r
628 * \param q EC_POINT object with the first factor of the second summand
\r
629 * \param m BIGNUM with the second factor of the second summand
\r
630 * \param ctx BN_CTX object (optional)
\r
631 * \return 1 on success and 0 if an error occured
\r
633 int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
\r
635 /** Stores multiples of generator for faster point multiplication
\r
636 * \param group EC_GROUP object
\r
637 * \param ctx BN_CTX object (optional)
\r
638 * \return 1 on success and 0 if an error occured
\r
640 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
\r
642 /** Reports whether a precomputation has been done
\r
643 * \param group EC_GROUP object
\r
644 * \return 1 if a pre-computation has been done and 0 otherwise
\r
646 int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
\r
649 /********************************************************************/
\r
651 /********************************************************************/
\r
653 /* EC_GROUP_get_basis_type() returns the NID of the basis type
\r
654 * used to represent the field elements */
\r
655 int EC_GROUP_get_basis_type(const EC_GROUP *);
\r
656 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
\r
657 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
\r
658 unsigned int *k2, unsigned int *k3);
\r
660 #define OPENSSL_EC_NAMED_CURVE 0x001
\r
662 typedef struct ecpk_parameters_st ECPKPARAMETERS;
\r
664 EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
\r
665 int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
\r
667 #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
\r
668 #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
\r
669 #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
\r
670 (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
\r
671 #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
\r
672 (unsigned char *)(x))
\r
674 #ifndef OPENSSL_NO_BIO
\r
675 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
\r
677 #ifndef OPENSSL_NO_FP_API
\r
678 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
\r
682 /********************************************************************/
\r
683 /* EC_KEY functions */
\r
684 /********************************************************************/
\r
686 typedef struct ec_key_st EC_KEY;
\r
688 /* some values for the encoding_flag */
\r
689 #define EC_PKEY_NO_PARAMETERS 0x001
\r
690 #define EC_PKEY_NO_PUBKEY 0x002
\r
692 /** Creates a new EC_KEY object.
\r
693 * \return EC_KEY object or NULL if an error occurred.
\r
695 EC_KEY *EC_KEY_new(void);
\r
697 /** Creates a new EC_KEY object using a named curve as underlying
\r
699 * \param nid NID of the named curve.
\r
700 * \return EC_KEY object or NULL if an error occurred.
\r
702 EC_KEY *EC_KEY_new_by_curve_name(int nid);
\r
704 /** Frees a EC_KEY object.
\r
705 * \param key EC_KEY object to be freed.
\r
707 void EC_KEY_free(EC_KEY *key);
\r
709 /** Copies a EC_KEY object.
\r
710 * \param dst destination EC_KEY object
\r
711 * \param src src EC_KEY object
\r
712 * \return dst or NULL if an error occurred.
\r
714 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
\r
716 /** Creates a new EC_KEY object and copies the content from src to it.
\r
717 * \param src the source EC_KEY object
\r
718 * \return newly created EC_KEY object or NULL if an error occurred.
\r
720 EC_KEY *EC_KEY_dup(const EC_KEY *src);
\r
722 /** Increases the internal reference count of a EC_KEY object.
\r
723 * \param key EC_KEY object
\r
724 * \return 1 on success and 0 if an error occurred.
\r
726 int EC_KEY_up_ref(EC_KEY *key);
\r
728 /** Returns the EC_GROUP object of a EC_KEY object
\r
729 * \param key EC_KEY object
\r
730 * \return the EC_GROUP object (possibly NULL).
\r
732 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
\r
734 /** Sets the EC_GROUP of a EC_KEY object.
\r
735 * \param key EC_KEY object
\r
736 * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
\r
737 * object will use an own copy of the EC_GROUP).
\r
738 * \return 1 on success and 0 if an error occurred.
\r
740 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
\r
742 /** Returns the private key of a EC_KEY object.
\r
743 * \param key EC_KEY object
\r
744 * \return a BIGNUM with the private key (possibly NULL).
\r
746 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
\r
748 /** Sets the private key of a EC_KEY object.
\r
749 * \param key EC_KEY object
\r
750 * \param prv BIGNUM with the private key (note: the EC_KEY object
\r
751 * will use an own copy of the BIGNUM).
\r
752 * \return 1 on success and 0 if an error occurred.
\r
754 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
\r
756 /** Returns the public key of a EC_KEY object.
\r
757 * \param key the EC_KEY object
\r
758 * \return a EC_POINT object with the public key (possibly NULL)
\r
760 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
\r
762 /** Sets the public key of a EC_KEY object.
\r
763 * \param key EC_KEY object
\r
764 * \param pub EC_POINT object with the public key (note: the EC_KEY object
\r
765 * will use an own copy of the EC_POINT object).
\r
766 * \return 1 on success and 0 if an error occurred.
\r
768 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
\r
770 unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
\r
771 void EC_KEY_set_enc_flags(EC_KEY *, unsigned int);
\r
772 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *);
\r
773 void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
\r
774 /* functions to set/get method specific data */
\r
775 void *EC_KEY_get_key_method_data(EC_KEY *,
\r
776 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
\r
777 void EC_KEY_insert_key_method_data(EC_KEY *, void *data,
\r
778 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
\r
779 /* wrapper functions for the underlying EC_GROUP object */
\r
780 void EC_KEY_set_asn1_flag(EC_KEY *, int);
\r
782 /** Creates a table of pre-computed multiples of the generator to
\r
783 * accelerate further EC_KEY operations.
\r
784 * \param key EC_KEY object
\r
785 * \param ctx BN_CTX object (optional)
\r
786 * \return 1 on success and 0 if an error occurred.
\r
788 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
\r
790 /** Creates a new ec private (and optional a new public) key.
\r
791 * \param key EC_KEY object
\r
792 * \return 1 on success and 0 if an error occurred.
\r
794 int EC_KEY_generate_key(EC_KEY *key);
\r
796 /** Verifies that a private and/or public key is valid.
\r
797 * \param key the EC_KEY object
\r
798 * \return 1 on success and 0 otherwise.
\r
800 int EC_KEY_check_key(const EC_KEY *key);
\r
803 /********************************************************************/
\r
804 /* de- and encoding functions for SEC1 ECPrivateKey */
\r
805 /********************************************************************/
\r
807 /** Decodes a private key from a memory buffer.
\r
808 * \param key a pointer to a EC_KEY object which should be used (or NULL)
\r
809 * \param in pointer to memory with the DER encoded private key
\r
810 * \param len length of the DER encoded private key
\r
811 * \return the decoded private key or NULL if an error occurred.
\r
813 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
\r
815 /** Encodes a private key object and stores the result in a buffer.
\r
816 * \param key the EC_KEY object to encode
\r
817 * \param out the buffer for the result (if NULL the function returns number
\r
818 * of bytes needed).
\r
819 * \return 1 on success and 0 if an error occurred.
\r
821 int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
\r
824 /********************************************************************/
\r
825 /* de- and encoding functions for EC parameters */
\r
826 /********************************************************************/
\r
828 /** Decodes ec parameter from a memory buffer.
\r
829 * \param key a pointer to a EC_KEY object which should be used (or NULL)
\r
830 * \param in pointer to memory with the DER encoded ec parameters
\r
831 * \param len length of the DER encoded ec parameters
\r
832 * \return a EC_KEY object with the decoded parameters or NULL if an error
\r
835 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
\r
837 /** Encodes ec parameter and stores the result in a buffer.
\r
838 * \param key the EC_KEY object with ec paramters to encode
\r
839 * \param out the buffer for the result (if NULL the function returns number
\r
840 * of bytes needed).
\r
841 * \return 1 on success and 0 if an error occurred.
\r
843 int i2d_ECParameters(EC_KEY *key, unsigned char **out);
\r
846 /********************************************************************/
\r
847 /* de- and encoding functions for EC public key */
\r
848 /* (octet string, not DER -- hence 'o2i' and 'i2o') */
\r
849 /********************************************************************/
\r
851 /** Decodes a ec public key from a octet string.
\r
852 * \param key a pointer to a EC_KEY object which should be used
\r
853 * \param in memory buffer with the encoded public key
\r
854 * \param len length of the encoded public key
\r
855 * \return EC_KEY object with decoded public key or NULL if an error
\r
858 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
\r
860 /** Encodes a ec public key in an octet string.
\r
861 * \param key the EC_KEY object with the public key
\r
862 * \param out the buffer for the result (if NULL the function returns number
\r
863 * of bytes needed).
\r
864 * \return 1 on success and 0 if an error occurred
\r
866 int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
\r
868 #ifndef OPENSSL_NO_BIO
\r
869 /** Prints out the ec parameters on human readable form.
\r
870 * \param bp BIO object to which the information is printed
\r
871 * \param key EC_KEY object
\r
872 * \return 1 on success and 0 if an error occurred
\r
874 int ECParameters_print(BIO *bp, const EC_KEY *key);
\r
876 /** Prints out the contents of a EC_KEY object
\r
877 * \param bp BIO object to which the information is printed
\r
878 * \param key EC_KEY object
\r
879 * \param off line offset
\r
880 * \return 1 on success and 0 if an error occurred
\r
882 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
\r
885 #ifndef OPENSSL_NO_FP_API
\r
886 /** Prints out the ec parameters on human readable form.
\r
887 * \param fp file descriptor to which the information is printed
\r
888 * \param key EC_KEY object
\r
889 * \return 1 on success and 0 if an error occurred
\r
891 int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
\r
893 /** Prints out the contents of a EC_KEY object
\r
894 * \param fp file descriptor to which the information is printed
\r
895 * \param key EC_KEY object
\r
896 * \param off line offset
\r
897 * \return 1 on success and 0 if an error occurred
\r
899 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
\r
903 #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
\r
905 #ifndef __cplusplus
\r
906 #if defined(__SUNPRO_C)
\r
907 # if __SUNPRO_C >= 0x520
\r
908 # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
\r
913 #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
\r
914 EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
\r
915 EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
\r
918 #define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
\r
920 /* BEGIN ERROR CODES */
\r
921 /* The following lines are auto generated by the script mkerr.pl. Any changes
\r
922 * made after this point may be overwritten when the script is next run.
\r
924 void ERR_load_EC_strings(void);
\r
926 /* Error codes for the EC functions. */
\r
928 /* Function codes. */
\r
929 #define EC_F_COMPUTE_WNAF 143
\r
930 #define EC_F_D2I_ECPARAMETERS 144
\r
931 #define EC_F_D2I_ECPKPARAMETERS 145
\r
932 #define EC_F_D2I_ECPRIVATEKEY 146
\r
933 #define EC_F_DO_EC_KEY_PRINT 221
\r
934 #define EC_F_ECKEY_PARAM2TYPE 223
\r
935 #define EC_F_ECKEY_PARAM_DECODE 212
\r
936 #define EC_F_ECKEY_PRIV_DECODE 213
\r
937 #define EC_F_ECKEY_PRIV_ENCODE 214
\r
938 #define EC_F_ECKEY_PUB_DECODE 215
\r
939 #define EC_F_ECKEY_PUB_ENCODE 216
\r
940 #define EC_F_ECKEY_TYPE2PARAM 220
\r
941 #define EC_F_ECPARAMETERS_PRINT 147
\r
942 #define EC_F_ECPARAMETERS_PRINT_FP 148
\r
943 #define EC_F_ECPKPARAMETERS_PRINT 149
\r
944 #define EC_F_ECPKPARAMETERS_PRINT_FP 150
\r
945 #define EC_F_ECP_NIST_MOD_192 203
\r
946 #define EC_F_ECP_NIST_MOD_224 204
\r
947 #define EC_F_ECP_NIST_MOD_256 205
\r
948 #define EC_F_ECP_NIST_MOD_521 206
\r
949 #define EC_F_EC_ASN1_GROUP2CURVE 153
\r
950 #define EC_F_EC_ASN1_GROUP2FIELDID 154
\r
951 #define EC_F_EC_ASN1_GROUP2PARAMETERS 155
\r
952 #define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156
\r
953 #define EC_F_EC_ASN1_PARAMETERS2GROUP 157
\r
954 #define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158
\r
955 #define EC_F_EC_EX_DATA_SET_DATA 211
\r
956 #define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
\r
957 #define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
\r
958 #define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
\r
959 #define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
\r
960 #define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
\r
961 #define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
\r
962 #define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
\r
963 #define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
\r
964 #define EC_F_EC_GFP_MONT_FIELD_DECODE 133
\r
965 #define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
\r
966 #define EC_F_EC_GFP_MONT_FIELD_MUL 131
\r
967 #define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
\r
968 #define EC_F_EC_GFP_MONT_FIELD_SQR 132
\r
969 #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
\r
970 #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135
\r
971 #define EC_F_EC_GFP_NIST_FIELD_MUL 200
\r
972 #define EC_F_EC_GFP_NIST_FIELD_SQR 201
\r
973 #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
\r
974 #define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
\r
975 #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
\r
976 #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
\r
977 #define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
\r
978 #define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
\r
979 #define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
\r
980 #define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
\r
981 #define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
\r
982 #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
\r
983 #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
\r
984 #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
\r
985 #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
\r
986 #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
\r
987 #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
\r
988 #define EC_F_EC_GROUP_CHECK 170
\r
989 #define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
\r
990 #define EC_F_EC_GROUP_COPY 106
\r
991 #define EC_F_EC_GROUP_GET0_GENERATOR 139
\r
992 #define EC_F_EC_GROUP_GET_COFACTOR 140
\r
993 #define EC_F_EC_GROUP_GET_CURVE_GF2M 172
\r
994 #define EC_F_EC_GROUP_GET_CURVE_GFP 130
\r
995 #define EC_F_EC_GROUP_GET_DEGREE 173
\r
996 #define EC_F_EC_GROUP_GET_ORDER 141
\r
997 #define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
\r
998 #define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
\r
999 #define EC_F_EC_GROUP_NEW 108
\r
1000 #define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
\r
1001 #define EC_F_EC_GROUP_NEW_FROM_DATA 175
\r
1002 #define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
\r
1003 #define EC_F_EC_GROUP_SET_CURVE_GF2M 176
\r
1004 #define EC_F_EC_GROUP_SET_CURVE_GFP 109
\r
1005 #define EC_F_EC_GROUP_SET_EXTRA_DATA 110
\r
1006 #define EC_F_EC_GROUP_SET_GENERATOR 111
\r
1007 #define EC_F_EC_KEY_CHECK_KEY 177
\r
1008 #define EC_F_EC_KEY_COPY 178
\r
1009 #define EC_F_EC_KEY_GENERATE_KEY 179
\r
1010 #define EC_F_EC_KEY_NEW 182
\r
1011 #define EC_F_EC_KEY_PRINT 180
\r
1012 #define EC_F_EC_KEY_PRINT_FP 181
\r
1013 #define EC_F_EC_POINTS_MAKE_AFFINE 136
\r
1014 #define EC_F_EC_POINT_ADD 112
\r
1015 #define EC_F_EC_POINT_CMP 113
\r
1016 #define EC_F_EC_POINT_COPY 114
\r
1017 #define EC_F_EC_POINT_DBL 115
\r
1018 #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
\r
1019 #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
\r
1020 #define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
\r
1021 #define EC_F_EC_POINT_INVERT 210
\r
1022 #define EC_F_EC_POINT_IS_AT_INFINITY 118
\r
1023 #define EC_F_EC_POINT_IS_ON_CURVE 119
\r
1024 #define EC_F_EC_POINT_MAKE_AFFINE 120
\r
1025 #define EC_F_EC_POINT_MUL 184
\r
1026 #define EC_F_EC_POINT_NEW 121
\r
1027 #define EC_F_EC_POINT_OCT2POINT 122
\r
1028 #define EC_F_EC_POINT_POINT2OCT 123
\r
1029 #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
\r
1030 #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
\r
1031 #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
\r
1032 #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
\r
1033 #define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
\r
1034 #define EC_F_EC_POINT_SET_TO_INFINITY 127
\r
1035 #define EC_F_EC_PRE_COMP_DUP 207
\r
1036 #define EC_F_EC_PRE_COMP_NEW 196
\r
1037 #define EC_F_EC_WNAF_MUL 187
\r
1038 #define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
\r
1039 #define EC_F_I2D_ECPARAMETERS 190
\r
1040 #define EC_F_I2D_ECPKPARAMETERS 191
\r
1041 #define EC_F_I2D_ECPRIVATEKEY 192
\r
1042 #define EC_F_I2O_ECPUBLICKEY 151
\r
1043 #define EC_F_O2I_ECPUBLICKEY 152
\r
1044 #define EC_F_OLD_EC_PRIV_DECODE 222
\r
1045 #define EC_F_PKEY_EC_CTRL 197
\r
1046 #define EC_F_PKEY_EC_CTRL_STR 198
\r
1047 #define EC_F_PKEY_EC_DERIVE 217
\r
1048 #define EC_F_PKEY_EC_KEYGEN 199
\r
1049 #define EC_F_PKEY_EC_PARAMGEN 219
\r
1050 #define EC_F_PKEY_EC_SIGN 218
\r
1052 /* Reason codes. */
\r
1053 #define EC_R_ASN1_ERROR 115
\r
1054 #define EC_R_ASN1_UNKNOWN_FIELD 116
\r
1055 #define EC_R_BUFFER_TOO_SMALL 100
\r
1056 #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
\r
1057 #define EC_R_DECODE_ERROR 142
\r
1058 #define EC_R_DISCRIMINANT_IS_ZERO 118
\r
1059 #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
\r
1060 #define EC_R_FIELD_TOO_LARGE 143
\r
1061 #define EC_R_GROUP2PKPARAMETERS_FAILURE 120
\r
1062 #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
\r
1063 #define EC_R_INCOMPATIBLE_OBJECTS 101
\r
1064 #define EC_R_INVALID_ARGUMENT 112
\r
1065 #define EC_R_INVALID_COMPRESSED_POINT 110
\r
1066 #define EC_R_INVALID_COMPRESSION_BIT 109
\r
1067 #define EC_R_INVALID_CURVE 141
\r
1068 #define EC_R_INVALID_DIGEST_TYPE 138
\r
1069 #define EC_R_INVALID_ENCODING 102
\r
1070 #define EC_R_INVALID_FIELD 103
\r
1071 #define EC_R_INVALID_FORM 104
\r
1072 #define EC_R_INVALID_GROUP_ORDER 122
\r
1073 #define EC_R_INVALID_PENTANOMIAL_BASIS 132
\r
1074 #define EC_R_INVALID_PRIVATE_KEY 123
\r
1075 #define EC_R_INVALID_TRINOMIAL_BASIS 137
\r
1076 #define EC_R_KEYS_NOT_SET 140
\r
1077 #define EC_R_MISSING_PARAMETERS 124
\r
1078 #define EC_R_MISSING_PRIVATE_KEY 125
\r
1079 #define EC_R_NOT_A_NIST_PRIME 135
\r
1080 #define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136
\r
1081 #define EC_R_NOT_IMPLEMENTED 126
\r
1082 #define EC_R_NOT_INITIALIZED 111
\r
1083 #define EC_R_NO_FIELD_MOD 133
\r
1084 #define EC_R_NO_PARAMETERS_SET 139
\r
1085 #define EC_R_PASSED_NULL_PARAMETER 134
\r
1086 #define EC_R_PKPARAMETERS2GROUP_FAILURE 127
\r
1087 #define EC_R_POINT_AT_INFINITY 106
\r
1088 #define EC_R_POINT_IS_NOT_ON_CURVE 107
\r
1089 #define EC_R_SLOT_FULL 108
\r
1090 #define EC_R_UNDEFINED_GENERATOR 113
\r
1091 #define EC_R_UNDEFINED_ORDER 128
\r
1092 #define EC_R_UNKNOWN_GROUP 129
\r
1093 #define EC_R_UNKNOWN_ORDER 114
\r
1094 #define EC_R_UNSUPPORTED_FIELD 131
\r
1095 #define EC_R_WRONG_ORDER 130
\r
1097 #ifdef __cplusplus
\r