2 * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
5 * Licensed under the Apache License 2.0 (the "License"). You may not use
6 * this file except in compliance with the License. You can obtain a copy
7 * in the file LICENSE in the source distribution or at
8 * https://www.openssl.org/source/license.html
15 # include <openssl/macros.h>
16 # ifndef OPENSSL_NO_DEPRECATED_3_0
20 # include <openssl/opensslconf.h>
21 # include <openssl/types.h>
27 /* Values for EVP_PKEY_CTX_set_ec_param_enc() */
28 # define OPENSSL_EC_EXPLICIT_CURVE 0x000
29 # define OPENSSL_EC_NAMED_CURVE 0x001
31 int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX
*ctx
, int nid
);
32 int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX
*ctx
, int param_enc
);
33 int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX
*ctx
, int cofactor_mode
);
34 int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX
*ctx
);
36 int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX
*ctx
, int kdf
);
37 int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX
*ctx
);
39 int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX
*ctx
, const EVP_MD
*md
);
40 int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX
*ctx
, const EVP_MD
**md
);
42 int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX
*ctx
, int len
);
43 int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX
*ctx
, int *len
);
45 int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX
*ctx
, unsigned char *ukm
,
47 # ifndef OPENSSL_NO_DEPRECATED_3_0
49 int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX
*ctx
, unsigned char **ukm
);
52 # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
53 # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
54 # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3)
55 # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4)
56 # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5)
57 # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6)
58 # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7)
59 # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8)
60 # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
61 # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
64 # define EVP_PKEY_ECDH_KDF_NONE 1
65 # define EVP_PKEY_ECDH_KDF_X9_63 2
67 * The old name for EVP_PKEY_ECDH_KDF_X9_63
68 * The ECDH KDF specification has been mistakenly attributed to ANSI X9.62,
69 * it is actually specified in ANSI X9.63.
70 * This identifier is retained for backwards compatibility
72 # define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63
74 /** Enum for the point conversion form as defined in X9.62 (ECDSA)
75 * for the encoding of a elliptic curve point (x,y) */
77 /** the point is encoded as z||x, where the octet z specifies
78 * which solution of the quadratic equation y is */
79 POINT_CONVERSION_COMPRESSED
= 2,
80 /** the point is encoded as z||x||y, where z is the octet 0x04 */
81 POINT_CONVERSION_UNCOMPRESSED
= 4,
82 /** the point is encoded as z||x||y, where the octet z specifies
83 * which solution of the quadratic equation y is */
84 POINT_CONVERSION_HYBRID
= 6
85 } point_conversion_form_t
;
87 # ifndef OPENSSL_NO_EC
88 # include <openssl/asn1.h>
89 # include <openssl/symhacks.h>
90 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
91 # include <openssl/bn.h>
93 # include <openssl/ecerr.h>
95 # ifndef OPENSSL_ECC_MAX_FIELD_BITS
96 # define OPENSSL_ECC_MAX_FIELD_BITS 661
99 # include <openssl/params.h>
100 # ifndef OPENSSL_NO_DEPRECATED_3_0
101 typedef struct ec_method_st EC_METHOD
;
103 typedef struct ec_group_st EC_GROUP
;
104 typedef struct ec_point_st EC_POINT
;
105 typedef struct ecpk_parameters_st ECPKPARAMETERS
;
106 typedef struct ec_parameters_st ECPARAMETERS
;
108 /********************************************************************/
109 /* EC_METHODs for curves over GF(p) */
110 /********************************************************************/
112 # ifndef OPENSSL_NO_DEPRECATED_3_0
113 /** Returns the basic GFp ec methods which provides the basis for the
115 * \return EC_METHOD object
117 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_simple_method(void);
119 /** Returns GFp methods using montgomery multiplication.
120 * \return EC_METHOD object
122 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_mont_method(void);
124 /** Returns GFp methods using optimized methods for NIST recommended curves
125 * \return EC_METHOD object
127 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nist_method(void);
129 # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
130 /** Returns 64-bit optimized methods for nistp224
131 * \return EC_METHOD object
133 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nistp224_method(void);
135 /** Returns 64-bit optimized methods for nistp256
136 * \return EC_METHOD object
138 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nistp256_method(void);
140 /** Returns 64-bit optimized methods for nistp521
141 * \return EC_METHOD object
143 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nistp521_method(void);
144 # endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */
146 # ifndef OPENSSL_NO_EC2M
147 /********************************************************************/
148 /* EC_METHOD for curves over GF(2^m) */
149 /********************************************************************/
151 /** Returns the basic GF2m ec method
152 * \return EC_METHOD object
154 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GF2m_simple_method(void);
158 /********************************************************************/
159 /* EC_GROUP functions */
160 /********************************************************************/
163 * Creates a new EC_GROUP object
164 * \param meth EC_METHOD to use
165 * \return newly created EC_GROUP object or NULL in case of an error.
167 OSSL_DEPRECATEDIN_3_0 EC_GROUP
*EC_GROUP_new(const EC_METHOD
*meth
);
169 /** Clears and frees a EC_GROUP object
170 * \param group EC_GROUP object to be cleared and freed.
172 OSSL_DEPRECATEDIN_3_0
void EC_GROUP_clear_free(EC_GROUP
*group
);
174 /** Returns the EC_METHOD of the EC_GROUP object.
175 * \param group EC_GROUP object
176 * \return EC_METHOD used in this EC_GROUP object.
178 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GROUP_method_of(const EC_GROUP
*group
);
180 /** Returns the field type of the EC_METHOD.
181 * \param meth EC_METHOD object
182 * \return NID of the underlying field type OID.
184 OSSL_DEPRECATEDIN_3_0
int EC_METHOD_get_field_type(const EC_METHOD
*meth
);
185 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
187 /** Frees a EC_GROUP object
188 * \param group EC_GROUP object to be freed.
190 void EC_GROUP_free(EC_GROUP
*group
);
192 /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
193 * \param dst destination EC_GROUP object
194 * \param src source EC_GROUP object
195 * \return 1 on success and 0 if an error occurred.
197 int EC_GROUP_copy(EC_GROUP
*dst
, const EC_GROUP
*src
);
199 /** Creates a new EC_GROUP object and copies the content
200 * form src to the newly created EC_KEY object
201 * \param src source EC_GROUP object
202 * \return newly created EC_GROUP object or NULL in case of an error.
204 EC_GROUP
*EC_GROUP_dup(const EC_GROUP
*src
);
206 /** Sets the generator and its order/cofactor of a EC_GROUP object.
207 * \param group EC_GROUP object
208 * \param generator EC_POINT object with the generator.
209 * \param order the order of the group generated by the generator.
210 * \param cofactor the index of the sub-group generated by the generator
211 * in the group of all points on the elliptic curve.
212 * \return 1 on success and 0 if an error occurred
214 int EC_GROUP_set_generator(EC_GROUP
*group
, const EC_POINT
*generator
,
215 const BIGNUM
*order
, const BIGNUM
*cofactor
);
217 /** Returns the generator of a EC_GROUP object.
218 * \param group EC_GROUP object
219 * \return the currently used generator (possibly NULL).
221 const EC_POINT
*EC_GROUP_get0_generator(const EC_GROUP
*group
);
223 /** Returns the montgomery data for order(Generator)
224 * \param group EC_GROUP object
225 * \return the currently used montgomery data (possibly NULL).
227 BN_MONT_CTX
*EC_GROUP_get_mont_data(const EC_GROUP
*group
);
229 /** Gets the order of a EC_GROUP
230 * \param group EC_GROUP object
231 * \param order BIGNUM to which the order is copied
233 * \return 1 on success and 0 if an error occurred
235 int EC_GROUP_get_order(const EC_GROUP
*group
, BIGNUM
*order
, BN_CTX
*ctx
);
237 /** Gets the order of an EC_GROUP
238 * \param group EC_GROUP object
239 * \return the group order
241 const BIGNUM
*EC_GROUP_get0_order(const EC_GROUP
*group
);
243 /** Gets the number of bits of the order of an EC_GROUP
244 * \param group EC_GROUP object
245 * \return number of bits of group order.
247 int EC_GROUP_order_bits(const EC_GROUP
*group
);
249 /** Gets the cofactor of a EC_GROUP
250 * \param group EC_GROUP object
251 * \param cofactor BIGNUM to which the cofactor is copied
253 * \return 1 on success and 0 if an error occurred
255 int EC_GROUP_get_cofactor(const EC_GROUP
*group
, BIGNUM
*cofactor
,
258 /** Gets the cofactor of an EC_GROUP
259 * \param group EC_GROUP object
260 * \return the group cofactor
262 const BIGNUM
*EC_GROUP_get0_cofactor(const EC_GROUP
*group
);
264 /** Sets the name of a EC_GROUP object
265 * \param group EC_GROUP object
266 * \param nid NID of the curve name OID
268 void EC_GROUP_set_curve_name(EC_GROUP
*group
, int nid
);
270 /** Returns the curve name of a EC_GROUP object
271 * \param group EC_GROUP object
272 * \return NID of the curve name OID or 0 if not set.
274 int EC_GROUP_get_curve_name(const EC_GROUP
*group
);
276 /** Gets the field of an EC_GROUP
277 * \param group EC_GROUP object
278 * \return the group field
280 const BIGNUM
*EC_GROUP_get0_field(const EC_GROUP
*group
);
282 /** Returns the field type of the EC_GROUP.
283 * \param group EC_GROUP object
284 * \return NID of the underlying field type OID.
286 int EC_GROUP_get_field_type(const EC_GROUP
*group
);
288 void EC_GROUP_set_asn1_flag(EC_GROUP
*group
, int flag
);
289 int EC_GROUP_get_asn1_flag(const EC_GROUP
*group
);
291 void EC_GROUP_set_point_conversion_form(EC_GROUP
*group
,
292 point_conversion_form_t form
);
293 point_conversion_form_t
EC_GROUP_get_point_conversion_form(const EC_GROUP
*);
295 unsigned char *EC_GROUP_get0_seed(const EC_GROUP
*x
);
296 size_t EC_GROUP_get_seed_len(const EC_GROUP
*);
297 size_t EC_GROUP_set_seed(EC_GROUP
*, const unsigned char *, size_t len
);
299 /** Sets the parameters of an ec curve defined by y^2 = x^3 + a*x + b (for GFp)
300 * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
301 * \param group EC_GROUP object
302 * \param p BIGNUM with the prime number (GFp) or the polynomial
303 * defining the underlying field (GF2m)
304 * \param a BIGNUM with parameter a of the equation
305 * \param b BIGNUM with parameter b of the equation
306 * \param ctx BN_CTX object (optional)
307 * \return 1 on success and 0 if an error occurred
309 int EC_GROUP_set_curve(EC_GROUP
*group
, const BIGNUM
*p
, const BIGNUM
*a
,
310 const BIGNUM
*b
, BN_CTX
*ctx
);
312 /** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp)
313 * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
314 * \param group EC_GROUP object
315 * \param p BIGNUM with the prime number (GFp) or the polynomial
316 * defining the underlying field (GF2m)
317 * \param a BIGNUM for parameter a of the equation
318 * \param b BIGNUM for parameter b of the equation
319 * \param ctx BN_CTX object (optional)
320 * \return 1 on success and 0 if an error occurred
322 int EC_GROUP_get_curve(const EC_GROUP
*group
, BIGNUM
*p
, BIGNUM
*a
, BIGNUM
*b
,
325 # ifndef OPENSSL_NO_DEPRECATED_3_0
326 /** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve
327 * \param group EC_GROUP object
328 * \param p BIGNUM with the prime number (GFp) or the polynomial
329 * defining the underlying field (GF2m)
330 * \param a BIGNUM with parameter a of the equation
331 * \param b BIGNUM with parameter b of the equation
332 * \param ctx BN_CTX object (optional)
333 * \return 1 on success and 0 if an error occurred
335 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_set_curve_GFp(EC_GROUP
*group
,
341 /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
342 * \param group EC_GROUP object
343 * \param p BIGNUM with the prime number (GFp) or the polynomial
344 * defining the underlying field (GF2m)
345 * \param a BIGNUM for parameter a of the equation
346 * \param b BIGNUM for parameter b of the equation
347 * \param ctx BN_CTX object (optional)
348 * \return 1 on success and 0 if an error occurred
350 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_get_curve_GFp(const EC_GROUP
*group
,
352 BIGNUM
*a
, BIGNUM
*b
,
355 # ifndef OPENSSL_NO_EC2M
356 /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve
357 * \param group EC_GROUP object
358 * \param p BIGNUM with the prime number (GFp) or the polynomial
359 * defining the underlying field (GF2m)
360 * \param a BIGNUM with parameter a of the equation
361 * \param b BIGNUM with parameter b of the equation
362 * \param ctx BN_CTX object (optional)
363 * \return 1 on success and 0 if an error occurred
365 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_set_curve_GF2m(EC_GROUP
*group
,
371 /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
372 * \param group EC_GROUP object
373 * \param p BIGNUM with the prime number (GFp) or the polynomial
374 * defining the underlying field (GF2m)
375 * \param a BIGNUM for parameter a of the equation
376 * \param b BIGNUM for parameter b of the equation
377 * \param ctx BN_CTX object (optional)
378 * \return 1 on success and 0 if an error occurred
380 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_get_curve_GF2m(const EC_GROUP
*group
,
382 BIGNUM
*a
, BIGNUM
*b
,
384 # endif /* OPENSSL_NO_EC2M */
385 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
387 /** Returns the number of bits needed to represent a field element
388 * \param group EC_GROUP object
389 * \return number of bits needed to represent a field element
391 int EC_GROUP_get_degree(const EC_GROUP
*group
);
393 /** Checks whether the parameter in the EC_GROUP define a valid ec group
394 * \param group EC_GROUP object
395 * \param ctx BN_CTX object (optional)
396 * \return 1 if group is a valid ec group and 0 otherwise
398 int EC_GROUP_check(const EC_GROUP
*group
, BN_CTX
*ctx
);
400 /** Checks whether the discriminant of the elliptic curve is zero or not
401 * \param group EC_GROUP object
402 * \param ctx BN_CTX object (optional)
403 * \return 1 if the discriminant is not zero and 0 otherwise
405 int EC_GROUP_check_discriminant(const EC_GROUP
*group
, BN_CTX
*ctx
);
407 /** Compares two EC_GROUP objects
408 * \param a first EC_GROUP object
409 * \param b second EC_GROUP object
410 * \param ctx BN_CTX object (optional)
411 * \return 0 if the groups are equal, 1 if not, or -1 on error
413 int EC_GROUP_cmp(const EC_GROUP
*a
, const EC_GROUP
*b
, BN_CTX
*ctx
);
416 * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after
417 * choosing an appropriate EC_METHOD
420 /** Creates a new EC_GROUP object with the specified parameters defined
421 * over GFp (defined by the equation y^2 = x^3 + a*x + b)
422 * \param p BIGNUM with the prime number
423 * \param a BIGNUM with the parameter a of the equation
424 * \param b BIGNUM with the parameter b of the equation
425 * \param ctx BN_CTX object (optional)
426 * \return newly created EC_GROUP object with the specified parameters
428 EC_GROUP
*EC_GROUP_new_curve_GFp(const BIGNUM
*p
, const BIGNUM
*a
,
429 const BIGNUM
*b
, BN_CTX
*ctx
);
430 # ifndef OPENSSL_NO_EC2M
431 /** Creates a new EC_GROUP object with the specified parameters defined
432 * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
433 * \param p BIGNUM with the polynomial defining the underlying field
434 * \param a BIGNUM with the parameter a of the equation
435 * \param b BIGNUM with the parameter b of the equation
436 * \param ctx BN_CTX object (optional)
437 * \return newly created EC_GROUP object with the specified parameters
439 EC_GROUP
*EC_GROUP_new_curve_GF2m(const BIGNUM
*p
, const BIGNUM
*a
,
440 const BIGNUM
*b
, BN_CTX
*ctx
);
444 * Creates a EC_GROUP object with a curve specified by parameters.
445 * The parameters may be explicit or a named curve,
446 * \param params A list of parameters describing the group.
447 * \param libctx The associated library context or NULL for the default
449 * \param propq A property query string
450 * \return newly created EC_GROUP object with specified parameters or NULL
451 * if an error occurred
453 EC_GROUP
*EC_GROUP_new_from_params(const OSSL_PARAM params
[],
454 OSSL_LIB_CTX
*libctx
, const char *propq
);
457 * Creates a EC_GROUP object with a curve specified by a NID
458 * \param libctx The associated library context or NULL for the default
460 * \param propq A property query string
461 * \param nid NID of the OID of the curve name
462 * \return newly created EC_GROUP object with specified curve or NULL
463 * if an error occurred
465 EC_GROUP
*EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX
*libctx
, const char *propq
,
469 * Creates a EC_GROUP object with a curve specified by a NID. Same as
470 * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always
472 * \param nid NID of the OID of the curve name
473 * \return newly created EC_GROUP object with specified curve or NULL
474 * if an error occurred
476 EC_GROUP
*EC_GROUP_new_by_curve_name(int nid
);
478 /** Creates a new EC_GROUP object from an ECPARAMETERS object
479 * \param params pointer to the ECPARAMETERS object
480 * \return newly created EC_GROUP object with specified curve or NULL
481 * if an error occurred
483 EC_GROUP
*EC_GROUP_new_from_ecparameters(const ECPARAMETERS
*params
);
485 /** Creates an ECPARAMETERS object for the given EC_GROUP object.
486 * \param group pointer to the EC_GROUP object
487 * \param params pointer to an existing ECPARAMETERS object or NULL
488 * \return pointer to the new ECPARAMETERS object or NULL
489 * if an error occurred.
491 ECPARAMETERS
*EC_GROUP_get_ecparameters(const EC_GROUP
*group
,
492 ECPARAMETERS
*params
);
494 /** Creates a new EC_GROUP object from an ECPKPARAMETERS object
495 * \param params pointer to an existing ECPKPARAMETERS object, or NULL
496 * \return newly created EC_GROUP object with specified curve, or NULL
497 * if an error occurred
499 EC_GROUP
*EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS
*params
);
501 /** Creates an ECPKPARAMETERS object for the given EC_GROUP object.
502 * \param group pointer to the EC_GROUP object
503 * \param params pointer to an existing ECPKPARAMETERS object or NULL
504 * \return pointer to the new ECPKPARAMETERS object or NULL
505 * if an error occurred.
507 ECPKPARAMETERS
*EC_GROUP_get_ecpkparameters(const EC_GROUP
*group
,
508 ECPKPARAMETERS
*params
);
510 /********************************************************************/
511 /* handling of internal curves */
512 /********************************************************************/
520 * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all
521 * available curves or zero if a error occurred. In case r is not zero,
522 * nitems EC_builtin_curve structures are filled with the data of the first
523 * nitems internal groups
525 size_t EC_get_builtin_curves(EC_builtin_curve
*r
, size_t nitems
);
527 const char *EC_curve_nid2nist(int nid
);
528 int EC_curve_nist2nid(const char *name
);
529 int EC_GROUP_check_named_curve(const EC_GROUP
*group
, int nist_only
,
532 /********************************************************************/
533 /* EC_POINT functions */
534 /********************************************************************/
536 /** Creates a new EC_POINT object for the specified EC_GROUP
537 * \param group EC_GROUP the underlying EC_GROUP object
538 * \return newly created EC_POINT object or NULL if an error occurred
540 EC_POINT
*EC_POINT_new(const EC_GROUP
*group
);
542 /** Frees a EC_POINT object
543 * \param point EC_POINT object to be freed
545 void EC_POINT_free(EC_POINT
*point
);
547 /** Clears and frees a EC_POINT object
548 * \param point EC_POINT object to be cleared and freed
550 void EC_POINT_clear_free(EC_POINT
*point
);
552 /** Copies EC_POINT object
553 * \param dst destination EC_POINT object
554 * \param src source EC_POINT object
555 * \return 1 on success and 0 if an error occurred
557 int EC_POINT_copy(EC_POINT
*dst
, const EC_POINT
*src
);
559 /** Creates a new EC_POINT object and copies the content of the supplied
561 * \param src source EC_POINT object
562 * \param group underlying the EC_GROUP object
563 * \return newly created EC_POINT object or NULL if an error occurred
565 EC_POINT
*EC_POINT_dup(const EC_POINT
*src
, const EC_GROUP
*group
);
567 /** Sets a point to infinity (neutral element)
568 * \param group underlying EC_GROUP object
569 * \param point EC_POINT to set to infinity
570 * \return 1 on success and 0 if an error occurred
572 int EC_POINT_set_to_infinity(const EC_GROUP
*group
, EC_POINT
*point
);
574 # ifndef OPENSSL_NO_DEPRECATED_3_0
575 /** Returns the EC_METHOD used in EC_POINT object
576 * \param point EC_POINT object
577 * \return the EC_METHOD used
579 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_POINT_method_of(const EC_POINT
*point
);
581 /** Sets the jacobian projective coordinates of a EC_POINT over GFp
582 * \param group underlying EC_GROUP object
583 * \param p EC_POINT object
584 * \param x BIGNUM with the x-coordinate
585 * \param y BIGNUM with the y-coordinate
586 * \param z BIGNUM with the z-coordinate
587 * \param ctx BN_CTX object (optional)
588 * \return 1 on success and 0 if an error occurred
590 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_Jprojective_coordinates_GFp
591 (const EC_GROUP
*group
, EC_POINT
*p
,
592 const BIGNUM
*x
, const BIGNUM
*y
, const BIGNUM
*z
,
595 /** Gets the jacobian projective coordinates of a EC_POINT over GFp
596 * \param group underlying EC_GROUP object
597 * \param p EC_POINT object
598 * \param x BIGNUM for the x-coordinate
599 * \param y BIGNUM for the y-coordinate
600 * \param z BIGNUM for the z-coordinate
601 * \param ctx BN_CTX object (optional)
602 * \return 1 on success and 0 if an error occurred
604 OSSL_DEPRECATEDIN_3_0
int EC_POINT_get_Jprojective_coordinates_GFp
605 (const EC_GROUP
*group
, const EC_POINT
*p
,
606 BIGNUM
*x
, BIGNUM
*y
, BIGNUM
*z
, BN_CTX
*ctx
);
607 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
609 /** Sets the affine coordinates of an EC_POINT
610 * \param group underlying EC_GROUP object
611 * \param p EC_POINT object
612 * \param x BIGNUM with the x-coordinate
613 * \param y BIGNUM with the y-coordinate
614 * \param ctx BN_CTX object (optional)
615 * \return 1 on success and 0 if an error occurred
617 int EC_POINT_set_affine_coordinates(const EC_GROUP
*group
, EC_POINT
*p
,
618 const BIGNUM
*x
, const BIGNUM
*y
,
621 /** Gets the affine coordinates of an EC_POINT.
622 * \param group underlying EC_GROUP object
623 * \param p EC_POINT object
624 * \param x BIGNUM for the x-coordinate
625 * \param y BIGNUM for the y-coordinate
626 * \param ctx BN_CTX object (optional)
627 * \return 1 on success and 0 if an error occurred
629 int EC_POINT_get_affine_coordinates(const EC_GROUP
*group
, const EC_POINT
*p
,
630 BIGNUM
*x
, BIGNUM
*y
, BN_CTX
*ctx
);
632 # ifndef OPENSSL_NO_DEPRECATED_3_0
633 /** Sets the affine coordinates of an EC_POINT. A synonym of
634 * EC_POINT_set_affine_coordinates
635 * \param group underlying EC_GROUP object
636 * \param p EC_POINT object
637 * \param x BIGNUM with the x-coordinate
638 * \param y BIGNUM with the y-coordinate
639 * \param ctx BN_CTX object (optional)
640 * \return 1 on success and 0 if an error occurred
642 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_affine_coordinates_GFp
643 (const EC_GROUP
*group
, EC_POINT
*p
,
644 const BIGNUM
*x
, const BIGNUM
*y
, BN_CTX
*ctx
);
646 /** Gets the affine coordinates of an EC_POINT. A synonym of
647 * EC_POINT_get_affine_coordinates
648 * \param group underlying EC_GROUP object
649 * \param p EC_POINT object
650 * \param x BIGNUM for the x-coordinate
651 * \param y BIGNUM for the y-coordinate
652 * \param ctx BN_CTX object (optional)
653 * \return 1 on success and 0 if an error occurred
655 OSSL_DEPRECATEDIN_3_0
int EC_POINT_get_affine_coordinates_GFp
656 (const EC_GROUP
*group
, const EC_POINT
*p
,
657 BIGNUM
*x
, BIGNUM
*y
, BN_CTX
*ctx
);
658 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
660 /** Sets the x9.62 compressed coordinates of a EC_POINT
661 * \param group underlying EC_GROUP object
662 * \param p EC_POINT object
663 * \param x BIGNUM with x-coordinate
664 * \param y_bit integer with the y-Bit (either 0 or 1)
665 * \param ctx BN_CTX object (optional)
666 * \return 1 on success and 0 if an error occurred
668 int EC_POINT_set_compressed_coordinates(const EC_GROUP
*group
, EC_POINT
*p
,
669 const BIGNUM
*x
, int y_bit
,
672 # ifndef OPENSSL_NO_DEPRECATED_3_0
673 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
674 * EC_POINT_set_compressed_coordinates
675 * \param group underlying EC_GROUP object
676 * \param p EC_POINT object
677 * \param x BIGNUM with x-coordinate
678 * \param y_bit integer with the y-Bit (either 0 or 1)
679 * \param ctx BN_CTX object (optional)
680 * \return 1 on success and 0 if an error occurred
682 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_compressed_coordinates_GFp
683 (const EC_GROUP
*group
, EC_POINT
*p
,
684 const BIGNUM
*x
, int y_bit
, BN_CTX
*ctx
);
685 # ifndef OPENSSL_NO_EC2M
686 /** Sets the affine coordinates of an EC_POINT. A synonym of
687 * EC_POINT_set_affine_coordinates
688 * \param group underlying EC_GROUP object
689 * \param p EC_POINT object
690 * \param x BIGNUM with the x-coordinate
691 * \param y BIGNUM with the y-coordinate
692 * \param ctx BN_CTX object (optional)
693 * \return 1 on success and 0 if an error occurred
695 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_affine_coordinates_GF2m
696 (const EC_GROUP
*group
, EC_POINT
*p
,
697 const BIGNUM
*x
, const BIGNUM
*y
, BN_CTX
*ctx
);
699 /** Gets the affine coordinates of an EC_POINT. A synonym of
700 * EC_POINT_get_affine_coordinates
701 * \param group underlying EC_GROUP object
702 * \param p EC_POINT object
703 * \param x BIGNUM for the x-coordinate
704 * \param y BIGNUM for the y-coordinate
705 * \param ctx BN_CTX object (optional)
706 * \return 1 on success and 0 if an error occurred
708 OSSL_DEPRECATEDIN_3_0
int EC_POINT_get_affine_coordinates_GF2m
709 (const EC_GROUP
*group
, const EC_POINT
*p
,
710 BIGNUM
*x
, BIGNUM
*y
, BN_CTX
*ctx
);
712 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
713 * EC_POINT_set_compressed_coordinates
714 * \param group underlying EC_GROUP object
715 * \param p EC_POINT object
716 * \param x BIGNUM with x-coordinate
717 * \param y_bit integer with the y-Bit (either 0 or 1)
718 * \param ctx BN_CTX object (optional)
719 * \return 1 on success and 0 if an error occurred
721 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_compressed_coordinates_GF2m
722 (const EC_GROUP
*group
, EC_POINT
*p
,
723 const BIGNUM
*x
, int y_bit
, BN_CTX
*ctx
);
725 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
727 /** Encodes a EC_POINT object to a octet string
728 * \param group underlying EC_GROUP object
729 * \param p EC_POINT object
730 * \param form point conversion form
731 * \param buf memory buffer for the result. If NULL the function returns
732 * required buffer size.
733 * \param len length of the memory buffer
734 * \param ctx BN_CTX object (optional)
735 * \return the length of the encoded octet string or 0 if an error occurred
737 size_t EC_POINT_point2oct(const EC_GROUP
*group
, const EC_POINT
*p
,
738 point_conversion_form_t form
,
739 unsigned char *buf
, size_t len
, BN_CTX
*ctx
);
741 /** Decodes a EC_POINT from a octet string
742 * \param group underlying EC_GROUP object
743 * \param p EC_POINT object
744 * \param buf memory buffer with the encoded ec point
745 * \param len length of the encoded ec point
746 * \param ctx BN_CTX object (optional)
747 * \return 1 on success and 0 if an error occurred
749 int EC_POINT_oct2point(const EC_GROUP
*group
, EC_POINT
*p
,
750 const unsigned char *buf
, size_t len
, BN_CTX
*ctx
);
752 /** Encodes an EC_POINT object to an allocated octet string
753 * \param group underlying EC_GROUP object
754 * \param point EC_POINT object
755 * \param form point conversion form
756 * \param pbuf returns pointer to allocated buffer
757 * \param ctx BN_CTX object (optional)
758 * \return the length of the encoded octet string or 0 if an error occurred
760 size_t EC_POINT_point2buf(const EC_GROUP
*group
, const EC_POINT
*point
,
761 point_conversion_form_t form
,
762 unsigned char **pbuf
, BN_CTX
*ctx
);
764 /* other interfaces to point2oct/oct2point: */
765 # ifndef OPENSSL_NO_DEPRECATED_3_0
766 OSSL_DEPRECATEDIN_3_0 BIGNUM
*EC_POINT_point2bn(const EC_GROUP
*,
768 point_conversion_form_t form
,
770 OSSL_DEPRECATEDIN_3_0 EC_POINT
*EC_POINT_bn2point(const EC_GROUP
*,
772 EC_POINT
*, BN_CTX
*);
773 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
775 char *EC_POINT_point2hex(const EC_GROUP
*, const EC_POINT
*,
776 point_conversion_form_t form
, BN_CTX
*);
777 EC_POINT
*EC_POINT_hex2point(const EC_GROUP
*, const char *,
778 EC_POINT
*, BN_CTX
*);
780 /********************************************************************/
781 /* functions for doing EC_POINT arithmetic */
782 /********************************************************************/
784 /** Computes the sum of two EC_POINT
785 * \param group underlying EC_GROUP object
786 * \param r EC_POINT object for the result (r = a + b)
787 * \param a EC_POINT object with the first summand
788 * \param b EC_POINT object with the second summand
789 * \param ctx BN_CTX object (optional)
790 * \return 1 on success and 0 if an error occurred
792 int EC_POINT_add(const EC_GROUP
*group
, EC_POINT
*r
, const EC_POINT
*a
,
793 const EC_POINT
*b
, BN_CTX
*ctx
);
795 /** Computes the double of a EC_POINT
796 * \param group underlying EC_GROUP object
797 * \param r EC_POINT object for the result (r = 2 * a)
798 * \param a EC_POINT object
799 * \param ctx BN_CTX object (optional)
800 * \return 1 on success and 0 if an error occurred
802 int EC_POINT_dbl(const EC_GROUP
*group
, EC_POINT
*r
, const EC_POINT
*a
,
805 /** Computes the inverse of a EC_POINT
806 * \param group underlying EC_GROUP object
807 * \param a EC_POINT object to be inverted (it's used for the result as well)
808 * \param ctx BN_CTX object (optional)
809 * \return 1 on success and 0 if an error occurred
811 int EC_POINT_invert(const EC_GROUP
*group
, EC_POINT
*a
, BN_CTX
*ctx
);
813 /** Checks whether the point is the neutral element of the group
814 * \param group the underlying EC_GROUP object
815 * \param p EC_POINT object
816 * \return 1 if the point is the neutral element and 0 otherwise
818 int EC_POINT_is_at_infinity(const EC_GROUP
*group
, const EC_POINT
*p
);
820 /** Checks whether the point is on the curve
821 * \param group underlying EC_GROUP object
822 * \param point EC_POINT object to check
823 * \param ctx BN_CTX object (optional)
824 * \return 1 if the point is on the curve, 0 if not, or -1 on error
826 int EC_POINT_is_on_curve(const EC_GROUP
*group
, const EC_POINT
*point
,
829 /** Compares two EC_POINTs
830 * \param group underlying EC_GROUP object
831 * \param a first EC_POINT object
832 * \param b second EC_POINT object
833 * \param ctx BN_CTX object (optional)
834 * \return 1 if the points are not equal, 0 if they are, or -1 on error
836 int EC_POINT_cmp(const EC_GROUP
*group
, const EC_POINT
*a
, const EC_POINT
*b
,
839 # ifndef OPENSSL_NO_DEPRECATED_3_0
840 OSSL_DEPRECATEDIN_3_0
int EC_POINT_make_affine(const EC_GROUP
*group
,
841 EC_POINT
*point
, BN_CTX
*ctx
);
842 OSSL_DEPRECATEDIN_3_0
int EC_POINTs_make_affine(const EC_GROUP
*group
, size_t num
,
843 EC_POINT
*points
[], BN_CTX
*ctx
);
845 /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]
846 * \param group underlying EC_GROUP object
847 * \param r EC_POINT object for the result
848 * \param n BIGNUM with the multiplier for the group generator (optional)
849 * \param num number further summands
850 * \param p array of size num of EC_POINT objects
851 * \param m array of size num of BIGNUM objects
852 * \param ctx BN_CTX object (optional)
853 * \return 1 on success and 0 if an error occurred
855 OSSL_DEPRECATEDIN_3_0
int EC_POINTs_mul(const EC_GROUP
*group
, EC_POINT
*r
,
856 const BIGNUM
*n
, size_t num
,
857 const EC_POINT
*p
[], const BIGNUM
*m
[],
859 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
861 /** Computes r = generator * n + q * m
862 * \param group underlying EC_GROUP object
863 * \param r EC_POINT object for the result
864 * \param n BIGNUM with the multiplier for the group generator (optional)
865 * \param q EC_POINT object with the first factor of the second summand
866 * \param m BIGNUM with the second factor of the second summand
867 * \param ctx BN_CTX object (optional)
868 * \return 1 on success and 0 if an error occurred
870 int EC_POINT_mul(const EC_GROUP
*group
, EC_POINT
*r
, const BIGNUM
*n
,
871 const EC_POINT
*q
, const BIGNUM
*m
, BN_CTX
*ctx
);
873 # ifndef OPENSSL_NO_DEPRECATED_3_0
874 /** Stores multiples of generator for faster point multiplication
875 * \param group EC_GROUP object
876 * \param ctx BN_CTX object (optional)
877 * \return 1 on success and 0 if an error occurred
879 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_precompute_mult(EC_GROUP
*group
, BN_CTX
*ctx
);
881 /** Reports whether a precomputation has been done
882 * \param group EC_GROUP object
883 * \return 1 if a pre-computation has been done and 0 otherwise
885 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_have_precompute_mult(const EC_GROUP
*group
);
886 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
888 /********************************************************************/
890 /********************************************************************/
892 DECLARE_ASN1_ITEM(ECPKPARAMETERS
)
893 DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS
)
894 DECLARE_ASN1_ITEM(ECPARAMETERS
)
895 DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS
)
898 * EC_GROUP_get_basis_type() returns the NID of the basis type used to
899 * represent the field elements
901 int EC_GROUP_get_basis_type(const EC_GROUP
*);
902 # ifndef OPENSSL_NO_EC2M
903 int EC_GROUP_get_trinomial_basis(const EC_GROUP
*, unsigned int *k
);
904 int EC_GROUP_get_pentanomial_basis(const EC_GROUP
*, unsigned int *k1
,
905 unsigned int *k2
, unsigned int *k3
);
908 EC_GROUP
*d2i_ECPKParameters(EC_GROUP
**, const unsigned char **in
, long len
);
909 int i2d_ECPKParameters(const EC_GROUP
*, unsigned char **out
);
911 # define d2i_ECPKParameters_bio(bp,x) \
912 ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x)
913 # define i2d_ECPKParameters_bio(bp,x) \
914 ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x)
915 # define d2i_ECPKParameters_fp(fp,x) \
916 (EC_GROUP *)ASN1_d2i_fp(NULL, (char *(*)())d2i_ECPKParameters, (fp), \
917 (unsigned char **)(x))
918 # define i2d_ECPKParameters_fp(fp,x) \
919 ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x))
921 # ifndef OPENSSL_NO_DEPRECATED_3_0
922 OSSL_DEPRECATEDIN_3_0
int ECPKParameters_print(BIO
*bp
, const EC_GROUP
*x
,
924 # ifndef OPENSSL_NO_STDIO
925 OSSL_DEPRECATEDIN_3_0
int ECPKParameters_print_fp(FILE *fp
, const EC_GROUP
*x
,
928 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
930 /********************************************************************/
931 /* EC_KEY functions */
932 /********************************************************************/
934 /* some values for the encoding_flag */
935 # define EC_PKEY_NO_PARAMETERS 0x001
936 # define EC_PKEY_NO_PUBKEY 0x002
938 /* some values for the flags field */
939 # define EC_FLAG_SM2_RANGE 0x0004
940 # define EC_FLAG_COFACTOR_ECDH 0x1000
941 # define EC_FLAG_CHECK_NAMED_GROUP 0x2000
942 # define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000
943 # define EC_FLAG_CHECK_NAMED_GROUP_MASK \
944 (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST)
946 /* Deprecated flags - it was using 0x01..0x02 */
947 # define EC_FLAG_NON_FIPS_ALLOW 0x0000
948 # define EC_FLAG_FIPS_CHECKED 0x0000
950 # ifndef OPENSSL_NO_DEPRECATED_3_0
952 * Creates a new EC_KEY object.
953 * \param ctx The library context for to use for this EC_KEY. May be NULL in
954 * which case the default library context is used.
955 * \return EC_KEY object or NULL if an error occurred.
957 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_ex(OSSL_LIB_CTX
*ctx
, const char *propq
);
960 * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a
961 * NULL library context
962 * \return EC_KEY object or NULL if an error occurred.
964 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new(void);
966 OSSL_DEPRECATEDIN_3_0
int EC_KEY_get_flags(const EC_KEY
*key
);
968 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_flags(EC_KEY
*key
, int flags
);
970 OSSL_DEPRECATEDIN_3_0
void EC_KEY_clear_flags(EC_KEY
*key
, int flags
);
972 OSSL_DEPRECATEDIN_3_0
int EC_KEY_decoded_from_explicit_params(const EC_KEY
*key
);
975 * Creates a new EC_KEY object using a named curve as underlying
977 * \param ctx The library context for to use for this EC_KEY. May be NULL in
978 * which case the default library context is used.
979 * \param propq Any property query string
980 * \param nid NID of the named curve.
981 * \return EC_KEY object or NULL if an error occurred.
983 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX
*ctx
,
988 * Creates a new EC_KEY object using a named curve as underlying
989 * EC_GROUP object. Same as calling EC_KEY_new_by_curve_name_ex with a NULL
990 * library context and property query string.
991 * \param nid NID of the named curve.
992 * \return EC_KEY object or NULL if an error occurred.
994 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_by_curve_name(int nid
);
996 /** Frees a EC_KEY object.
997 * \param key EC_KEY object to be freed.
999 OSSL_DEPRECATEDIN_3_0
void EC_KEY_free(EC_KEY
*key
);
1001 /** Copies a EC_KEY object.
1002 * \param dst destination EC_KEY object
1003 * \param src src EC_KEY object
1004 * \return dst or NULL if an error occurred.
1006 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_copy(EC_KEY
*dst
, const EC_KEY
*src
);
1008 /** Creates a new EC_KEY object and copies the content from src to it.
1009 * \param src the source EC_KEY object
1010 * \return newly created EC_KEY object or NULL if an error occurred.
1012 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_dup(const EC_KEY
*src
);
1014 /** Increases the internal reference count of a EC_KEY object.
1015 * \param key EC_KEY object
1016 * \return 1 on success and 0 if an error occurred.
1018 OSSL_DEPRECATEDIN_3_0
int EC_KEY_up_ref(EC_KEY
*key
);
1020 /** Returns the ENGINE object of a EC_KEY object
1021 * \param eckey EC_KEY object
1022 * \return the ENGINE object (possibly NULL).
1024 OSSL_DEPRECATEDIN_3_0 ENGINE
*EC_KEY_get0_engine(const EC_KEY
*eckey
);
1026 /** Returns the EC_GROUP object of a EC_KEY object
1027 * \param key EC_KEY object
1028 * \return the EC_GROUP object (possibly NULL).
1030 OSSL_DEPRECATEDIN_3_0
const EC_GROUP
*EC_KEY_get0_group(const EC_KEY
*key
);
1032 /** Sets the EC_GROUP of a EC_KEY object.
1033 * \param key EC_KEY object
1034 * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
1035 * object will use an own copy of the EC_GROUP).
1036 * \return 1 on success and 0 if an error occurred.
1038 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_group(EC_KEY
*key
, const EC_GROUP
*group
);
1040 /** Returns the private key of a EC_KEY object.
1041 * \param key EC_KEY object
1042 * \return a BIGNUM with the private key (possibly NULL).
1044 OSSL_DEPRECATEDIN_3_0
const BIGNUM
*EC_KEY_get0_private_key(const EC_KEY
*key
);
1046 /** Sets the private key of a EC_KEY object.
1047 * \param key EC_KEY object
1048 * \param prv BIGNUM with the private key (note: the EC_KEY object
1049 * will use an own copy of the BIGNUM).
1050 * \return 1 on success and 0 if an error occurred.
1052 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_private_key(EC_KEY
*key
, const BIGNUM
*prv
);
1054 /** Returns the public key of a EC_KEY object.
1055 * \param key the EC_KEY object
1056 * \return a EC_POINT object with the public key (possibly NULL)
1058 OSSL_DEPRECATEDIN_3_0
const EC_POINT
*EC_KEY_get0_public_key(const EC_KEY
*key
);
1060 /** Sets the public key of a EC_KEY object.
1061 * \param key EC_KEY object
1062 * \param pub EC_POINT object with the public key (note: the EC_KEY object
1063 * will use an own copy of the EC_POINT object).
1064 * \return 1 on success and 0 if an error occurred.
1066 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_public_key(EC_KEY
*key
, const EC_POINT
*pub
);
1068 OSSL_DEPRECATEDIN_3_0
unsigned EC_KEY_get_enc_flags(const EC_KEY
*key
);
1069 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_enc_flags(EC_KEY
*eckey
, unsigned int flags
);
1070 OSSL_DEPRECATEDIN_3_0 point_conversion_form_t
EC_KEY_get_conv_form(const EC_KEY
*key
);
1071 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_conv_form(EC_KEY
*eckey
,
1072 point_conversion_form_t cform
);
1073 # endif /*OPENSSL_NO_DEPRECATED_3_0 */
1075 # define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
1076 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
1078 # ifndef OPENSSL_NO_DEPRECATED_3_0
1079 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_ex_data(EC_KEY
*key
, int idx
, void *arg
);
1080 OSSL_DEPRECATEDIN_3_0
void *EC_KEY_get_ex_data(const EC_KEY
*key
, int idx
);
1082 /* wrapper functions for the underlying EC_GROUP object */
1083 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_asn1_flag(EC_KEY
*eckey
, int asn1_flag
);
1085 /** Creates a table of pre-computed multiples of the generator to
1086 * accelerate further EC_KEY operations.
1087 * \param key EC_KEY object
1088 * \param ctx BN_CTX object (optional)
1089 * \return 1 on success and 0 if an error occurred.
1091 OSSL_DEPRECATEDIN_3_0
int EC_KEY_precompute_mult(EC_KEY
*key
, BN_CTX
*ctx
);
1093 /** Creates a new ec private (and optional a new public) key.
1094 * \param key EC_KEY object
1095 * \return 1 on success and 0 if an error occurred.
1097 OSSL_DEPRECATEDIN_3_0
int EC_KEY_generate_key(EC_KEY
*key
);
1099 /** Verifies that a private and/or public key is valid.
1100 * \param key the EC_KEY object
1101 * \return 1 on success and 0 otherwise.
1103 OSSL_DEPRECATEDIN_3_0
int EC_KEY_check_key(const EC_KEY
*key
);
1105 /** Indicates if an EC_KEY can be used for signing.
1106 * \param eckey the EC_KEY object
1107 * \return 1 if can can sign and 0 otherwise.
1109 OSSL_DEPRECATEDIN_3_0
int EC_KEY_can_sign(const EC_KEY
*eckey
);
1111 /** Sets a public key from affine coordinates performing
1112 * necessary NIST PKV tests.
1113 * \param key the EC_KEY object
1114 * \param x public key x coordinate
1115 * \param y public key y coordinate
1116 * \return 1 on success and 0 otherwise.
1118 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_public_key_affine_coordinates(EC_KEY
*key
,
1122 /** Encodes an EC_KEY public key to an allocated octet string
1123 * \param key key to encode
1124 * \param form point conversion form
1125 * \param pbuf returns pointer to allocated buffer
1126 * \param ctx BN_CTX object (optional)
1127 * \return the length of the encoded octet string or 0 if an error occurred
1129 OSSL_DEPRECATEDIN_3_0
size_t EC_KEY_key2buf(const EC_KEY
*key
,
1130 point_conversion_form_t form
,
1131 unsigned char **pbuf
, BN_CTX
*ctx
);
1133 /** Decodes a EC_KEY public key from a octet string
1134 * \param key key to decode
1135 * \param buf memory buffer with the encoded ec point
1136 * \param len length of the encoded ec point
1137 * \param ctx BN_CTX object (optional)
1138 * \return 1 on success and 0 if an error occurred
1141 OSSL_DEPRECATEDIN_3_0
int EC_KEY_oct2key(EC_KEY
*key
, const unsigned char *buf
,
1142 size_t len
, BN_CTX
*ctx
);
1144 /** Decodes an EC_KEY private key from an octet string
1145 * \param key key to decode
1146 * \param buf memory buffer with the encoded private key
1147 * \param len length of the encoded key
1148 * \return 1 on success and 0 if an error occurred
1151 OSSL_DEPRECATEDIN_3_0
int EC_KEY_oct2priv(EC_KEY
*key
, const unsigned char *buf
,
1154 /** Encodes a EC_KEY private key to an octet string
1155 * \param key key to encode
1156 * \param buf memory buffer for the result. If NULL the function returns
1157 * required buffer size.
1158 * \param len length of the memory buffer
1159 * \return the length of the encoded octet string or 0 if an error occurred
1162 OSSL_DEPRECATEDIN_3_0
size_t EC_KEY_priv2oct(const EC_KEY
*key
,
1163 unsigned char *buf
, size_t len
);
1165 /** Encodes an EC_KEY private key to an allocated octet string
1166 * \param eckey key to encode
1167 * \param pbuf returns pointer to allocated buffer
1168 * \return the length of the encoded octet string or 0 if an error occurred
1170 OSSL_DEPRECATEDIN_3_0
size_t EC_KEY_priv2buf(const EC_KEY
*eckey
,
1171 unsigned char **pbuf
);
1173 /********************************************************************/
1174 /* de- and encoding functions for SEC1 ECPrivateKey */
1175 /********************************************************************/
1177 /** Decodes a private key from a memory buffer.
1178 * \param key a pointer to a EC_KEY object which should be used (or NULL)
1179 * \param in pointer to memory with the DER encoded private key
1180 * \param len length of the DER encoded private key
1181 * \return the decoded private key or NULL if an error occurred.
1183 OSSL_DEPRECATEDIN_3_0 EC_KEY
*d2i_ECPrivateKey(EC_KEY
**key
,
1184 const unsigned char **in
,
1187 /** Encodes a private key object and stores the result in a buffer.
1188 * \param key the EC_KEY object to encode
1189 * \param out the buffer for the result (if NULL the function returns number
1191 * \return 1 on success and 0 if an error occurred.
1193 OSSL_DEPRECATEDIN_3_0
int i2d_ECPrivateKey(const EC_KEY
*key
,
1194 unsigned char **out
);
1196 /********************************************************************/
1197 /* de- and encoding functions for EC parameters */
1198 /********************************************************************/
1200 /** Decodes ec parameter from a memory buffer.
1201 * \param key a pointer to a EC_KEY object which should be used (or NULL)
1202 * \param in pointer to memory with the DER encoded ec parameters
1203 * \param len length of the DER encoded ec parameters
1204 * \return a EC_KEY object with the decoded parameters or NULL if an error
1207 OSSL_DEPRECATEDIN_3_0 EC_KEY
*d2i_ECParameters(EC_KEY
**key
,
1208 const unsigned char **in
,
1211 /** Encodes ec parameter and stores the result in a buffer.
1212 * \param key the EC_KEY object with ec parameters to encode
1213 * \param out the buffer for the result (if NULL the function returns number
1215 * \return 1 on success and 0 if an error occurred.
1217 OSSL_DEPRECATEDIN_3_0
int i2d_ECParameters(const EC_KEY
*key
,
1218 unsigned char **out
);
1220 /********************************************************************/
1221 /* de- and encoding functions for EC public key */
1222 /* (octet string, not DER -- hence 'o2i' and 'i2o') */
1223 /********************************************************************/
1225 /** Decodes an ec public key from a octet string.
1226 * \param key a pointer to a EC_KEY object which should be used
1227 * \param in memory buffer with the encoded public key
1228 * \param len length of the encoded public key
1229 * \return EC_KEY object with decoded public key or NULL if an error
1232 OSSL_DEPRECATEDIN_3_0 EC_KEY
*o2i_ECPublicKey(EC_KEY
**key
,
1233 const unsigned char **in
, long len
);
1235 /** Encodes an ec public key in an octet string.
1236 * \param key the EC_KEY object with the public key
1237 * \param out the buffer for the result (if NULL the function returns number
1239 * \return 1 on success and 0 if an error occurred
1241 OSSL_DEPRECATEDIN_3_0
int i2o_ECPublicKey(const EC_KEY
*key
, unsigned char **out
);
1243 /** Prints out the ec parameters on human readable form.
1244 * \param bp BIO object to which the information is printed
1245 * \param key EC_KEY object
1246 * \return 1 on success and 0 if an error occurred
1248 OSSL_DEPRECATEDIN_3_0
int ECParameters_print(BIO
*bp
, const EC_KEY
*key
);
1250 /** Prints out the contents of a EC_KEY object
1251 * \param bp BIO object to which the information is printed
1252 * \param key EC_KEY object
1253 * \param off line offset
1254 * \return 1 on success and 0 if an error occurred
1256 OSSL_DEPRECATEDIN_3_0
int EC_KEY_print(BIO
*bp
, const EC_KEY
*key
, int off
);
1258 # ifndef OPENSSL_NO_STDIO
1259 /** Prints out the ec parameters on human readable form.
1260 * \param fp file descriptor to which the information is printed
1261 * \param key EC_KEY object
1262 * \return 1 on success and 0 if an error occurred
1264 OSSL_DEPRECATEDIN_3_0
int ECParameters_print_fp(FILE *fp
, const EC_KEY
*key
);
1266 /** Prints out the contents of a EC_KEY object
1267 * \param fp file descriptor to which the information is printed
1268 * \param key EC_KEY object
1269 * \param off line offset
1270 * \return 1 on success and 0 if an error occurred
1272 OSSL_DEPRECATEDIN_3_0
int EC_KEY_print_fp(FILE *fp
, const EC_KEY
*key
, int off
);
1273 # endif /* OPENSSL_NO_STDIO */
1275 OSSL_DEPRECATEDIN_3_0
const EC_KEY_METHOD
*EC_KEY_OpenSSL(void);
1276 OSSL_DEPRECATEDIN_3_0
const EC_KEY_METHOD
*EC_KEY_get_default_method(void);
1277 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_default_method(const EC_KEY_METHOD
*meth
);
1278 OSSL_DEPRECATEDIN_3_0
const EC_KEY_METHOD
*EC_KEY_get_method(const EC_KEY
*key
);
1279 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_method(EC_KEY
*key
, const EC_KEY_METHOD
*meth
);
1280 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_method(ENGINE
*engine
);
1282 /** The old name for ecdh_KDF_X9_63
1283 * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62,
1284 * it is actually specified in ANSI X9.63.
1285 * This identifier is retained for backwards compatibility
1287 OSSL_DEPRECATEDIN_3_0
int ECDH_KDF_X9_62(unsigned char *out
, size_t outlen
,
1288 const unsigned char *Z
, size_t Zlen
,
1289 const unsigned char *sinfo
,
1290 size_t sinfolen
, const EVP_MD
*md
);
1292 OSSL_DEPRECATEDIN_3_0
int ECDH_compute_key(void *out
, size_t outlen
,
1293 const EC_POINT
*pub_key
,
1295 void *(*KDF
)(const void *in
,
1296 size_t inlen
, void *out
,
1298 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
1300 typedef struct ECDSA_SIG_st ECDSA_SIG
;
1302 /** Allocates and initialize a ECDSA_SIG structure
1303 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1305 ECDSA_SIG
*ECDSA_SIG_new(void);
1307 /** frees a ECDSA_SIG structure
1308 * \param sig pointer to the ECDSA_SIG structure
1310 void ECDSA_SIG_free(ECDSA_SIG
*sig
);
1312 /** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp
1313 * (*pp += length of the DER encoded signature)).
1314 * \param sig pointer to the ECDSA_SIG object
1315 * \param pp pointer to a unsigned char pointer for the output or NULL
1316 * \return the length of the DER encoded ECDSA_SIG object or a negative value
1319 DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG
, ECDSA_SIG
)
1321 /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp
1323 * \param sig pointer to ECDSA_SIG pointer (may be NULL)
1324 * \param pp memory buffer with the DER encoded signature
1325 * \param len length of the buffer
1326 * \return pointer to the decoded ECDSA_SIG structure (or NULL)
1329 /** Accessor for r and s fields of ECDSA_SIG
1330 * \param sig pointer to ECDSA_SIG structure
1331 * \param pr pointer to BIGNUM pointer for r (may be NULL)
1332 * \param ps pointer to BIGNUM pointer for s (may be NULL)
1334 void ECDSA_SIG_get0(const ECDSA_SIG
*sig
, const BIGNUM
**pr
, const BIGNUM
**ps
);
1336 /** Accessor for r field of ECDSA_SIG
1337 * \param sig pointer to ECDSA_SIG structure
1339 const BIGNUM
*ECDSA_SIG_get0_r(const ECDSA_SIG
*sig
);
1341 /** Accessor for s field of ECDSA_SIG
1342 * \param sig pointer to ECDSA_SIG structure
1344 const BIGNUM
*ECDSA_SIG_get0_s(const ECDSA_SIG
*sig
);
1346 /** Setter for r and s fields of ECDSA_SIG
1347 * \param sig pointer to ECDSA_SIG structure
1348 * \param r pointer to BIGNUM for r (may be NULL)
1349 * \param s pointer to BIGNUM for s (may be NULL)
1351 int ECDSA_SIG_set0(ECDSA_SIG
*sig
, BIGNUM
*r
, BIGNUM
*s
);
1353 # ifndef OPENSSL_NO_DEPRECATED_3_0
1354 /** Computes the ECDSA signature of the given hash value using
1355 * the supplied private key and returns the created signature.
1356 * \param dgst pointer to the hash value
1357 * \param dgst_len length of the hash value
1358 * \param eckey EC_KEY object containing a private EC key
1359 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1361 OSSL_DEPRECATEDIN_3_0 ECDSA_SIG
*ECDSA_do_sign(const unsigned char *dgst
,
1362 int dgst_len
, EC_KEY
*eckey
);
1364 /** Computes ECDSA signature of a given hash value using the supplied
1365 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1366 * \param dgst pointer to the hash value to sign
1367 * \param dgstlen length of the hash value
1368 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1369 * \param rp BIGNUM with a pre-computed rp value (optional),
1370 * see ECDSA_sign_setup
1371 * \param eckey EC_KEY object containing a private EC key
1372 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1374 OSSL_DEPRECATEDIN_3_0 ECDSA_SIG
*ECDSA_do_sign_ex(const unsigned char *dgst
,
1375 int dgstlen
, const BIGNUM
*kinv
,
1376 const BIGNUM
*rp
, EC_KEY
*eckey
);
1378 /** Verifies that the supplied signature is a valid ECDSA
1379 * signature of the supplied hash value using the supplied public key.
1380 * \param dgst pointer to the hash value
1381 * \param dgst_len length of the hash value
1382 * \param sig ECDSA_SIG structure
1383 * \param eckey EC_KEY object containing a public EC key
1384 * \return 1 if the signature is valid, 0 if the signature is invalid
1387 OSSL_DEPRECATEDIN_3_0
int ECDSA_do_verify(const unsigned char *dgst
, int dgst_len
,
1388 const ECDSA_SIG
*sig
, EC_KEY
*eckey
);
1390 /** Precompute parts of the signing operation
1391 * \param eckey EC_KEY object containing a private EC key
1392 * \param ctx BN_CTX object (optional)
1393 * \param kinv BIGNUM pointer for the inverse of k
1394 * \param rp BIGNUM pointer for x coordinate of k * generator
1395 * \return 1 on success and 0 otherwise
1397 OSSL_DEPRECATEDIN_3_0
int ECDSA_sign_setup(EC_KEY
*eckey
, BN_CTX
*ctx
,
1398 BIGNUM
**kinv
, BIGNUM
**rp
);
1400 /** Computes ECDSA signature of a given hash value using the supplied
1401 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1402 * \param type this parameter is ignored
1403 * \param dgst pointer to the hash value to sign
1404 * \param dgstlen length of the hash value
1405 * \param sig memory for the DER encoded created signature
1406 * \param siglen pointer to the length of the returned signature
1407 * \param eckey EC_KEY object containing a private EC key
1408 * \return 1 on success and 0 otherwise
1410 OSSL_DEPRECATEDIN_3_0
int ECDSA_sign(int type
, const unsigned char *dgst
,
1411 int dgstlen
, unsigned char *sig
,
1412 unsigned int *siglen
, EC_KEY
*eckey
);
1414 /** Computes ECDSA signature of a given hash value using the supplied
1415 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1416 * \param type this parameter is ignored
1417 * \param dgst pointer to the hash value to sign
1418 * \param dgstlen length of the hash value
1419 * \param sig buffer to hold the DER encoded signature
1420 * \param siglen pointer to the length of the returned signature
1421 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1422 * \param rp BIGNUM with a pre-computed rp value (optional),
1423 * see ECDSA_sign_setup
1424 * \param eckey EC_KEY object containing a private EC key
1425 * \return 1 on success and 0 otherwise
1427 OSSL_DEPRECATEDIN_3_0
int ECDSA_sign_ex(int type
, const unsigned char *dgst
,
1428 int dgstlen
, unsigned char *sig
,
1429 unsigned int *siglen
, const BIGNUM
*kinv
,
1430 const BIGNUM
*rp
, EC_KEY
*eckey
);
1432 /** Verifies that the given signature is valid ECDSA signature
1433 * of the supplied hash value using the specified public key.
1434 * \param type this parameter is ignored
1435 * \param dgst pointer to the hash value
1436 * \param dgstlen length of the hash value
1437 * \param sig pointer to the DER encoded signature
1438 * \param siglen length of the DER encoded signature
1439 * \param eckey EC_KEY object containing a public EC key
1440 * \return 1 if the signature is valid, 0 if the signature is invalid
1443 OSSL_DEPRECATEDIN_3_0
int ECDSA_verify(int type
, const unsigned char *dgst
,
1444 int dgstlen
, const unsigned char *sig
,
1445 int siglen
, EC_KEY
*eckey
);
1447 /** Returns the maximum length of the DER encoded signature
1448 * \param eckey EC_KEY object
1449 * \return numbers of bytes required for the DER encoded signature
1451 OSSL_DEPRECATEDIN_3_0
int ECDSA_size(const EC_KEY
*eckey
);
1453 /********************************************************************/
1454 /* EC_KEY_METHOD constructors, destructors, writers and accessors */
1455 /********************************************************************/
1457 OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD
*EC_KEY_METHOD_new(const EC_KEY_METHOD
*meth
);
1458 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_free(EC_KEY_METHOD
*meth
);
1459 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_init
1460 (EC_KEY_METHOD
*meth
,
1461 int (*init
)(EC_KEY
*key
),
1462 void (*finish
)(EC_KEY
*key
),
1463 int (*copy
)(EC_KEY
*dest
, const EC_KEY
*src
),
1464 int (*set_group
)(EC_KEY
*key
, const EC_GROUP
*grp
),
1465 int (*set_private
)(EC_KEY
*key
, const BIGNUM
*priv_key
),
1466 int (*set_public
)(EC_KEY
*key
, const EC_POINT
*pub_key
));
1468 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD
*meth
,
1469 int (*keygen
)(EC_KEY
*key
));
1471 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_compute_key
1472 (EC_KEY_METHOD
*meth
,
1473 int (*ckey
)(unsigned char **psec
, size_t *pseclen
,
1474 const EC_POINT
*pub_key
, const EC_KEY
*ecdh
));
1476 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_sign
1477 (EC_KEY_METHOD
*meth
,
1478 int (*sign
)(int type
, const unsigned char *dgst
,
1479 int dlen
, unsigned char *sig
,
1480 unsigned int *siglen
,
1481 const BIGNUM
*kinv
, const BIGNUM
*r
,
1483 int (*sign_setup
)(EC_KEY
*eckey
, BN_CTX
*ctx_in
,
1484 BIGNUM
**kinvp
, BIGNUM
**rp
),
1485 ECDSA_SIG
*(*sign_sig
)(const unsigned char *dgst
,
1487 const BIGNUM
*in_kinv
,
1491 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_verify
1492 (EC_KEY_METHOD
*meth
,
1493 int (*verify
)(int type
, const unsigned
1494 char *dgst
, int dgst_len
,
1495 const unsigned char *sigbuf
,
1496 int sig_len
, EC_KEY
*eckey
),
1497 int (*verify_sig
)(const unsigned char *dgst
,
1498 int dgst_len
, const ECDSA_SIG
*sig
,
1501 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_init
1502 (const EC_KEY_METHOD
*meth
,
1503 int (**pinit
)(EC_KEY
*key
),
1504 void (**pfinish
)(EC_KEY
*key
),
1505 int (**pcopy
)(EC_KEY
*dest
, const EC_KEY
*src
),
1506 int (**pset_group
)(EC_KEY
*key
, const EC_GROUP
*grp
),
1507 int (**pset_private
)(EC_KEY
*key
, const BIGNUM
*priv_key
),
1508 int (**pset_public
)(EC_KEY
*key
, const EC_POINT
*pub_key
));
1510 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_keygen
1511 (const EC_KEY_METHOD
*meth
, int (**pkeygen
)(EC_KEY
*key
));
1513 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_compute_key
1514 (const EC_KEY_METHOD
*meth
,
1515 int (**pck
)(unsigned char **psec
,
1517 const EC_POINT
*pub_key
,
1518 const EC_KEY
*ecdh
));
1520 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_sign
1521 (const EC_KEY_METHOD
*meth
,
1522 int (**psign
)(int type
, const unsigned char *dgst
,
1523 int dlen
, unsigned char *sig
,
1524 unsigned int *siglen
,
1525 const BIGNUM
*kinv
, const BIGNUM
*r
,
1527 int (**psign_setup
)(EC_KEY
*eckey
, BN_CTX
*ctx_in
,
1528 BIGNUM
**kinvp
, BIGNUM
**rp
),
1529 ECDSA_SIG
*(**psign_sig
)(const unsigned char *dgst
,
1531 const BIGNUM
*in_kinv
,
1535 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_verify
1536 (const EC_KEY_METHOD
*meth
,
1537 int (**pverify
)(int type
, const unsigned
1538 char *dgst
, int dgst_len
,
1539 const unsigned char *sigbuf
,
1540 int sig_len
, EC_KEY
*eckey
),
1541 int (**pverify_sig
)(const unsigned char *dgst
,
1543 const ECDSA_SIG
*sig
,
1545 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
1547 # define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \
1548 d2i_ECParameters, x)
1550 # ifndef __cplusplus
1551 # if defined(__SUNPRO_C)
1552 # if __SUNPRO_C >= 0x520
1553 # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)