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