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