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