2 * Copyright 2002-2020 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 int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX
*ctx
, unsigned char **ukm
);
49 # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
50 # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
51 # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3)
52 # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4)
53 # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5)
54 # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6)
55 # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7)
56 # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8)
57 # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
58 # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
61 # define EVP_PKEY_ECDH_KDF_NONE 1
62 # define EVP_PKEY_ECDH_KDF_X9_63 2
64 * The old name for EVP_PKEY_ECDH_KDF_X9_63
65 * The ECDH KDF specification has been mistakenly attributed to ANSI X9.62,
66 * it is actually specified in ANSI X9.63.
67 * This identifier is retained for backwards compatibility
69 # define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63
71 /** Enum for the point conversion form as defined in X9.62 (ECDSA)
72 * for the encoding of a elliptic curve point (x,y) */
74 /** the point is encoded as z||x, where the octet z specifies
75 * which solution of the quadratic equation y is */
76 POINT_CONVERSION_COMPRESSED
= 2,
77 /** the point is encoded as z||x||y, where z is the octet 0x04 */
78 POINT_CONVERSION_UNCOMPRESSED
= 4,
79 /** the point is encoded as z||x||y, where the octet z specifies
80 * which solution of the quadratic equation y is */
81 POINT_CONVERSION_HYBRID
= 6
82 } point_conversion_form_t
;
84 # ifndef OPENSSL_NO_EC
85 # include <openssl/asn1.h>
86 # include <openssl/symhacks.h>
87 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
88 # include <openssl/bn.h>
90 # include <openssl/ecerr.h>
92 # ifndef OPENSSL_ECC_MAX_FIELD_BITS
93 # define OPENSSL_ECC_MAX_FIELD_BITS 661
96 # include <openssl/params.h>
97 # ifndef OPENSSL_NO_DEPRECATED_3_0
98 typedef struct ec_method_st EC_METHOD
;
100 typedef struct ec_group_st EC_GROUP
;
101 typedef struct ec_point_st EC_POINT
;
102 typedef struct ecpk_parameters_st ECPKPARAMETERS
;
103 typedef struct ec_parameters_st ECPARAMETERS
;
105 /********************************************************************/
106 /* EC_METHODs for curves over GF(p) */
107 /********************************************************************/
109 # ifndef OPENSSL_NO_DEPRECATED_3_0
110 /** Returns the basic GFp ec methods which provides the basis for the
112 * \return EC_METHOD object
114 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_simple_method(void);
116 /** Returns GFp methods using montgomery multiplication.
117 * \return EC_METHOD object
119 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_mont_method(void);
121 /** Returns GFp methods using optimized methods for NIST recommended curves
122 * \return EC_METHOD object
124 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nist_method(void);
126 # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
127 /** Returns 64-bit optimized methods for nistp224
128 * \return EC_METHOD object
130 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nistp224_method(void);
132 /** Returns 64-bit optimized methods for nistp256
133 * \return EC_METHOD object
135 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nistp256_method(void);
137 /** Returns 64-bit optimized methods for nistp521
138 * \return EC_METHOD object
140 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GFp_nistp521_method(void);
141 # endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */
143 # ifndef OPENSSL_NO_EC2M
144 /********************************************************************/
145 /* EC_METHOD for curves over GF(2^m) */
146 /********************************************************************/
148 /** Returns the basic GF2m ec method
149 * \return EC_METHOD object
151 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GF2m_simple_method(void);
155 /********************************************************************/
156 /* EC_GROUP functions */
157 /********************************************************************/
160 * Creates a new EC_GROUP object
161 * \param meth EC_METHOD to use
162 * \return newly created EC_GROUP object or NULL in case of an error.
164 OSSL_DEPRECATEDIN_3_0 EC_GROUP
*EC_GROUP_new(const EC_METHOD
*meth
);
166 /** Clears and frees a EC_GROUP object
167 * \param group EC_GROUP object to be cleared and freed.
169 OSSL_DEPRECATEDIN_3_0
void EC_GROUP_clear_free(EC_GROUP
*group
);
171 /** Returns the EC_METHOD of the EC_GROUP object.
172 * \param group EC_GROUP object
173 * \return EC_METHOD used in this EC_GROUP object.
175 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_GROUP_method_of(const EC_GROUP
*group
);
177 /** Returns the field type of the EC_METHOD.
178 * \param meth EC_METHOD object
179 * \return NID of the underlying field type OID.
181 OSSL_DEPRECATEDIN_3_0
int EC_METHOD_get_field_type(const EC_METHOD
*meth
);
182 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
184 /** Frees a EC_GROUP object
185 * \param group EC_GROUP object to be freed.
187 void EC_GROUP_free(EC_GROUP
*group
);
189 /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
190 * \param dst destination EC_GROUP object
191 * \param src source EC_GROUP object
192 * \return 1 on success and 0 if an error occurred.
194 int EC_GROUP_copy(EC_GROUP
*dst
, const EC_GROUP
*src
);
196 /** Creates a new EC_GROUP object and copies the content
197 * form src to the newly created EC_KEY object
198 * \param src source EC_GROUP object
199 * \return newly created EC_GROUP object or NULL in case of an error.
201 EC_GROUP
*EC_GROUP_dup(const EC_GROUP
*src
);
203 /** Sets the generator and its order/cofactor of a EC_GROUP object.
204 * \param group EC_GROUP object
205 * \param generator EC_POINT object with the generator.
206 * \param order the order of the group generated by the generator.
207 * \param cofactor the index of the sub-group generated by the generator
208 * in the group of all points on the elliptic curve.
209 * \return 1 on success and 0 if an error occurred
211 int EC_GROUP_set_generator(EC_GROUP
*group
, const EC_POINT
*generator
,
212 const BIGNUM
*order
, const BIGNUM
*cofactor
);
214 /** Returns the generator of a EC_GROUP object.
215 * \param group EC_GROUP object
216 * \return the currently used generator (possibly NULL).
218 const EC_POINT
*EC_GROUP_get0_generator(const EC_GROUP
*group
);
220 /** Returns the montgomery data for order(Generator)
221 * \param group EC_GROUP object
222 * \return the currently used montgomery data (possibly NULL).
224 BN_MONT_CTX
*EC_GROUP_get_mont_data(const EC_GROUP
*group
);
226 /** Gets the order of a EC_GROUP
227 * \param group EC_GROUP object
228 * \param order BIGNUM to which the order is copied
230 * \return 1 on success and 0 if an error occurred
232 int EC_GROUP_get_order(const EC_GROUP
*group
, BIGNUM
*order
, BN_CTX
*ctx
);
234 /** Gets the order of an EC_GROUP
235 * \param group EC_GROUP object
236 * \return the group order
238 const BIGNUM
*EC_GROUP_get0_order(const EC_GROUP
*group
);
240 /** Gets the number of bits of the order of an EC_GROUP
241 * \param group EC_GROUP object
242 * \return number of bits of group order.
244 int EC_GROUP_order_bits(const EC_GROUP
*group
);
246 /** Gets the cofactor of a EC_GROUP
247 * \param group EC_GROUP object
248 * \param cofactor BIGNUM to which the cofactor is copied
250 * \return 1 on success and 0 if an error occurred
252 int EC_GROUP_get_cofactor(const EC_GROUP
*group
, BIGNUM
*cofactor
,
255 /** Gets the cofactor of an EC_GROUP
256 * \param group EC_GROUP object
257 * \return the group cofactor
259 const BIGNUM
*EC_GROUP_get0_cofactor(const EC_GROUP
*group
);
261 /** Sets the name of a EC_GROUP object
262 * \param group EC_GROUP object
263 * \param nid NID of the curve name OID
265 void EC_GROUP_set_curve_name(EC_GROUP
*group
, int nid
);
267 /** Returns the curve name of a EC_GROUP object
268 * \param group EC_GROUP object
269 * \return NID of the curve name OID or 0 if not set.
271 int EC_GROUP_get_curve_name(const EC_GROUP
*group
);
273 /** Gets the field of an EC_GROUP
274 * \param group EC_GROUP object
275 * \return the group field
277 const BIGNUM
*EC_GROUP_get0_field(const EC_GROUP
*group
);
279 /** Returns the field type of the EC_GROUP.
280 * \param group EC_GROUP object
281 * \return NID of the underlying field type OID.
283 int EC_GROUP_get_field_type(const EC_GROUP
*group
);
285 void EC_GROUP_set_asn1_flag(EC_GROUP
*group
, int flag
);
286 int EC_GROUP_get_asn1_flag(const EC_GROUP
*group
);
288 void EC_GROUP_set_point_conversion_form(EC_GROUP
*group
,
289 point_conversion_form_t form
);
290 point_conversion_form_t
EC_GROUP_get_point_conversion_form(const EC_GROUP
*);
292 unsigned char *EC_GROUP_get0_seed(const EC_GROUP
*x
);
293 size_t EC_GROUP_get_seed_len(const EC_GROUP
*);
294 size_t EC_GROUP_set_seed(EC_GROUP
*, const unsigned char *, size_t len
);
296 /** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp)
297 * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
298 * \param group EC_GROUP object
299 * \param p BIGNUM with the prime number (GFp) or the polynomial
300 * defining the underlying field (GF2m)
301 * \param a BIGNUM with parameter a of the equation
302 * \param b BIGNUM with parameter b of the equation
303 * \param ctx BN_CTX object (optional)
304 * \return 1 on success and 0 if an error occurred
306 int EC_GROUP_set_curve(EC_GROUP
*group
, const BIGNUM
*p
, const BIGNUM
*a
,
307 const BIGNUM
*b
, BN_CTX
*ctx
);
309 /** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp)
310 * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
311 * \param group EC_GROUP object
312 * \param p BIGNUM with the prime number (GFp) or the polynomial
313 * defining the underlying field (GF2m)
314 * \param a BIGNUM for parameter a of the equation
315 * \param b BIGNUM for parameter b of the equation
316 * \param ctx BN_CTX object (optional)
317 * \return 1 on success and 0 if an error occurred
319 int EC_GROUP_get_curve(const EC_GROUP
*group
, BIGNUM
*p
, BIGNUM
*a
, BIGNUM
*b
,
322 # ifndef OPENSSL_NO_DEPRECATED_3_0
323 /** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve
324 * \param group EC_GROUP object
325 * \param p BIGNUM with the prime number (GFp) or the polynomial
326 * defining the underlying field (GF2m)
327 * \param a BIGNUM with parameter a of the equation
328 * \param b BIGNUM with parameter b of the equation
329 * \param ctx BN_CTX object (optional)
330 * \return 1 on success and 0 if an error occurred
332 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_set_curve_GFp(EC_GROUP
*group
,
338 /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
339 * \param group EC_GROUP object
340 * \param p BIGNUM with the prime number (GFp) or the polynomial
341 * defining the underlying field (GF2m)
342 * \param a BIGNUM for parameter a of the equation
343 * \param b BIGNUM for parameter b of the equation
344 * \param ctx BN_CTX object (optional)
345 * \return 1 on success and 0 if an error occurred
347 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_get_curve_GFp(const EC_GROUP
*group
,
349 BIGNUM
*a
, BIGNUM
*b
,
352 # ifndef OPENSSL_NO_EC2M
353 /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve
354 * \param group EC_GROUP object
355 * \param p BIGNUM with the prime number (GFp) or the polynomial
356 * defining the underlying field (GF2m)
357 * \param a BIGNUM with parameter a of the equation
358 * \param b BIGNUM with parameter b of the equation
359 * \param ctx BN_CTX object (optional)
360 * \return 1 on success and 0 if an error occurred
362 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_set_curve_GF2m(EC_GROUP
*group
,
368 /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
369 * \param group EC_GROUP object
370 * \param p BIGNUM with the prime number (GFp) or the polynomial
371 * defining the underlying field (GF2m)
372 * \param a BIGNUM for parameter a of the equation
373 * \param b BIGNUM for parameter b of the equation
374 * \param ctx BN_CTX object (optional)
375 * \return 1 on success and 0 if an error occurred
377 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_get_curve_GF2m(const EC_GROUP
*group
,
379 BIGNUM
*a
, BIGNUM
*b
,
381 # endif /* OPENSSL_NO_EC2M */
382 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
384 /** Returns the number of bits needed to represent a field element
385 * \param group EC_GROUP object
386 * \return number of bits needed to represent a field element
388 int EC_GROUP_get_degree(const EC_GROUP
*group
);
390 /** Checks whether the parameter in the EC_GROUP define a valid ec group
391 * \param group EC_GROUP object
392 * \param ctx BN_CTX object (optional)
393 * \return 1 if group is a valid ec group and 0 otherwise
395 int EC_GROUP_check(const EC_GROUP
*group
, BN_CTX
*ctx
);
397 /** Checks whether the discriminant of the elliptic curve is zero or not
398 * \param group EC_GROUP object
399 * \param ctx BN_CTX object (optional)
400 * \return 1 if the discriminant is not zero and 0 otherwise
402 int EC_GROUP_check_discriminant(const EC_GROUP
*group
, BN_CTX
*ctx
);
404 /** Compares two EC_GROUP objects
405 * \param a first EC_GROUP object
406 * \param b second EC_GROUP object
407 * \param ctx BN_CTX object (optional)
408 * \return 0 if the groups are equal, 1 if not, or -1 on error
410 int EC_GROUP_cmp(const EC_GROUP
*a
, const EC_GROUP
*b
, BN_CTX
*ctx
);
413 * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after
414 * choosing an appropriate EC_METHOD
417 /** Creates a new EC_GROUP object with the specified parameters defined
418 * over GFp (defined by the equation y^2 = x^3 + a*x + b)
419 * \param p BIGNUM with the prime number
420 * \param a BIGNUM with the parameter a of the equation
421 * \param b BIGNUM with the parameter b of the equation
422 * \param ctx BN_CTX object (optional)
423 * \return newly created EC_GROUP object with the specified parameters
425 EC_GROUP
*EC_GROUP_new_curve_GFp(const BIGNUM
*p
, const BIGNUM
*a
,
426 const BIGNUM
*b
, BN_CTX
*ctx
);
427 # ifndef OPENSSL_NO_EC2M
428 /** Creates a new EC_GROUP object with the specified parameters defined
429 * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
430 * \param p BIGNUM with the polynomial defining the underlying field
431 * \param a BIGNUM with the parameter a of the equation
432 * \param b BIGNUM with the parameter b of the equation
433 * \param ctx BN_CTX object (optional)
434 * \return newly created EC_GROUP object with the specified parameters
436 EC_GROUP
*EC_GROUP_new_curve_GF2m(const BIGNUM
*p
, const BIGNUM
*a
,
437 const BIGNUM
*b
, BN_CTX
*ctx
);
441 * Creates a EC_GROUP object with a curve specified by parameters.
442 * The parameters may be explicit or a named curve,
443 * \param params A list of parameters describing the group.
444 * \param libctx The associated library context or NULL for the default
446 * \param propq A property query string
447 * \return newly created EC_GROUP object with specified parameters or NULL
448 * if an error occurred
450 EC_GROUP
*EC_GROUP_new_from_params(const OSSL_PARAM params
[],
451 OSSL_LIB_CTX
*libctx
, const char *propq
);
454 * Creates a EC_GROUP object with a curve specified by a NID
455 * \param libctx The associated library context or NULL for the default
457 * \param propq A property query string
458 * \param nid NID of the OID of the curve name
459 * \return newly created EC_GROUP object with specified curve or NULL
460 * if an error occurred
462 EC_GROUP
*EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX
*libctx
, const char *propq
,
466 * Creates a EC_GROUP object with a curve specified by a NID. Same as
467 * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always
469 * \param nid NID of the OID of the curve name
470 * \return newly created EC_GROUP object with specified curve or NULL
471 * if an error occurred
473 EC_GROUP
*EC_GROUP_new_by_curve_name(int nid
);
475 /** Creates a new EC_GROUP object from an ECPARAMETERS object
476 * \param params pointer to the ECPARAMETERS object
477 * \return newly created EC_GROUP object with specified curve or NULL
478 * if an error occurred
480 EC_GROUP
*EC_GROUP_new_from_ecparameters(const ECPARAMETERS
*params
);
482 /** Creates an ECPARAMETERS object for the given EC_GROUP object.
483 * \param group pointer to the EC_GROUP object
484 * \param params pointer to an existing ECPARAMETERS object or NULL
485 * \return pointer to the new ECPARAMETERS object or NULL
486 * if an error occurred.
488 ECPARAMETERS
*EC_GROUP_get_ecparameters(const EC_GROUP
*group
,
489 ECPARAMETERS
*params
);
491 /** Creates a new EC_GROUP object from an ECPKPARAMETERS object
492 * \param params pointer to an existing ECPKPARAMETERS object, or NULL
493 * \return newly created EC_GROUP object with specified curve, or NULL
494 * if an error occurred
496 EC_GROUP
*EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS
*params
);
498 /** Creates an ECPKPARAMETERS object for the given EC_GROUP object.
499 * \param group pointer to the EC_GROUP object
500 * \param params pointer to an existing ECPKPARAMETERS object or NULL
501 * \return pointer to the new ECPKPARAMETERS object or NULL
502 * if an error occurred.
504 ECPKPARAMETERS
*EC_GROUP_get_ecpkparameters(const EC_GROUP
*group
,
505 ECPKPARAMETERS
*params
);
507 /********************************************************************/
508 /* handling of internal curves */
509 /********************************************************************/
517 * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all
518 * available curves or zero if a error occurred. In case r is not zero,
519 * nitems EC_builtin_curve structures are filled with the data of the first
520 * nitems internal groups
522 size_t EC_get_builtin_curves(EC_builtin_curve
*r
, size_t nitems
);
524 const char *EC_curve_nid2nist(int nid
);
525 int EC_curve_nist2nid(const char *name
);
526 int EC_GROUP_check_named_curve(const EC_GROUP
*group
, int nist_only
,
529 /********************************************************************/
530 /* EC_POINT functions */
531 /********************************************************************/
533 /** Creates a new EC_POINT object for the specified EC_GROUP
534 * \param group EC_GROUP the underlying EC_GROUP object
535 * \return newly created EC_POINT object or NULL if an error occurred
537 EC_POINT
*EC_POINT_new(const EC_GROUP
*group
);
539 /** Frees a EC_POINT object
540 * \param point EC_POINT object to be freed
542 void EC_POINT_free(EC_POINT
*point
);
544 /** Clears and frees a EC_POINT object
545 * \param point EC_POINT object to be cleared and freed
547 void EC_POINT_clear_free(EC_POINT
*point
);
549 /** Copies EC_POINT object
550 * \param dst destination EC_POINT object
551 * \param src source EC_POINT object
552 * \return 1 on success and 0 if an error occurred
554 int EC_POINT_copy(EC_POINT
*dst
, const EC_POINT
*src
);
556 /** Creates a new EC_POINT object and copies the content of the supplied
558 * \param src source EC_POINT object
559 * \param group underlying the EC_GROUP object
560 * \return newly created EC_POINT object or NULL if an error occurred
562 EC_POINT
*EC_POINT_dup(const EC_POINT
*src
, const EC_GROUP
*group
);
564 /** Sets a point to infinity (neutral element)
565 * \param group underlying EC_GROUP object
566 * \param point EC_POINT to set to infinity
567 * \return 1 on success and 0 if an error occurred
569 int EC_POINT_set_to_infinity(const EC_GROUP
*group
, EC_POINT
*point
);
571 # ifndef OPENSSL_NO_DEPRECATED_3_0
572 /** Returns the EC_METHOD used in EC_POINT object
573 * \param point EC_POINT object
574 * \return the EC_METHOD used
576 OSSL_DEPRECATEDIN_3_0
const EC_METHOD
*EC_POINT_method_of(const EC_POINT
*point
);
578 /** Sets the jacobian projective coordinates of a EC_POINT over GFp
579 * \param group underlying EC_GROUP object
580 * \param p EC_POINT object
581 * \param x BIGNUM with the x-coordinate
582 * \param y BIGNUM with the y-coordinate
583 * \param z BIGNUM with the z-coordinate
584 * \param ctx BN_CTX object (optional)
585 * \return 1 on success and 0 if an error occurred
587 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_Jprojective_coordinates_GFp
588 (const EC_GROUP
*group
, EC_POINT
*p
,
589 const BIGNUM
*x
, const BIGNUM
*y
, const BIGNUM
*z
,
592 /** Gets the jacobian projective coordinates of a EC_POINT over GFp
593 * \param group underlying EC_GROUP object
594 * \param p EC_POINT object
595 * \param x BIGNUM for the x-coordinate
596 * \param y BIGNUM for the y-coordinate
597 * \param z BIGNUM for the z-coordinate
598 * \param ctx BN_CTX object (optional)
599 * \return 1 on success and 0 if an error occurred
601 OSSL_DEPRECATEDIN_3_0
int EC_POINT_get_Jprojective_coordinates_GFp
602 (const EC_GROUP
*group
, const EC_POINT
*p
,
603 BIGNUM
*x
, BIGNUM
*y
, BIGNUM
*z
, BN_CTX
*ctx
);
604 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
606 /** Sets the affine coordinates of an EC_POINT
607 * \param group underlying EC_GROUP object
608 * \param p EC_POINT object
609 * \param x BIGNUM with the x-coordinate
610 * \param y BIGNUM with the y-coordinate
611 * \param ctx BN_CTX object (optional)
612 * \return 1 on success and 0 if an error occurred
614 int EC_POINT_set_affine_coordinates(const EC_GROUP
*group
, EC_POINT
*p
,
615 const BIGNUM
*x
, const BIGNUM
*y
,
618 /** Gets the affine coordinates of an EC_POINT.
619 * \param group underlying EC_GROUP object
620 * \param p EC_POINT object
621 * \param x BIGNUM for the x-coordinate
622 * \param y BIGNUM for the y-coordinate
623 * \param ctx BN_CTX object (optional)
624 * \return 1 on success and 0 if an error occurred
626 int EC_POINT_get_affine_coordinates(const EC_GROUP
*group
, const EC_POINT
*p
,
627 BIGNUM
*x
, BIGNUM
*y
, BN_CTX
*ctx
);
629 # ifndef OPENSSL_NO_DEPRECATED_3_0
630 /** Sets the affine coordinates of an EC_POINT. A synonym of
631 * EC_POINT_set_affine_coordinates
632 * \param group underlying EC_GROUP object
633 * \param p EC_POINT object
634 * \param x BIGNUM with the x-coordinate
635 * \param y BIGNUM with the y-coordinate
636 * \param ctx BN_CTX object (optional)
637 * \return 1 on success and 0 if an error occurred
639 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_affine_coordinates_GFp
640 (const EC_GROUP
*group
, EC_POINT
*p
,
641 const BIGNUM
*x
, const BIGNUM
*y
, BN_CTX
*ctx
);
643 /** Gets the affine coordinates of an EC_POINT. A synonym of
644 * EC_POINT_get_affine_coordinates
645 * \param group underlying EC_GROUP object
646 * \param p EC_POINT object
647 * \param x BIGNUM for the x-coordinate
648 * \param y BIGNUM for the y-coordinate
649 * \param ctx BN_CTX object (optional)
650 * \return 1 on success and 0 if an error occurred
652 OSSL_DEPRECATEDIN_3_0
int EC_POINT_get_affine_coordinates_GFp
653 (const EC_GROUP
*group
, const EC_POINT
*p
,
654 BIGNUM
*x
, BIGNUM
*y
, BN_CTX
*ctx
);
655 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
657 /** Sets the x9.62 compressed coordinates of a EC_POINT
658 * \param group underlying EC_GROUP object
659 * \param p EC_POINT object
660 * \param x BIGNUM with x-coordinate
661 * \param y_bit integer with the y-Bit (either 0 or 1)
662 * \param ctx BN_CTX object (optional)
663 * \return 1 on success and 0 if an error occurred
665 int EC_POINT_set_compressed_coordinates(const EC_GROUP
*group
, EC_POINT
*p
,
666 const BIGNUM
*x
, int y_bit
,
669 # ifndef OPENSSL_NO_DEPRECATED_3_0
670 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
671 * EC_POINT_set_compressed_coordinates
672 * \param group underlying EC_GROUP object
673 * \param p EC_POINT object
674 * \param x BIGNUM with x-coordinate
675 * \param y_bit integer with the y-Bit (either 0 or 1)
676 * \param ctx BN_CTX object (optional)
677 * \return 1 on success and 0 if an error occurred
679 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_compressed_coordinates_GFp
680 (const EC_GROUP
*group
, EC_POINT
*p
,
681 const BIGNUM
*x
, int y_bit
, BN_CTX
*ctx
);
682 # ifndef OPENSSL_NO_EC2M
683 /** Sets the affine coordinates of an EC_POINT. A synonym of
684 * EC_POINT_set_affine_coordinates
685 * \param group underlying EC_GROUP object
686 * \param p EC_POINT object
687 * \param x BIGNUM with the x-coordinate
688 * \param y BIGNUM with the y-coordinate
689 * \param ctx BN_CTX object (optional)
690 * \return 1 on success and 0 if an error occurred
692 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_affine_coordinates_GF2m
693 (const EC_GROUP
*group
, EC_POINT
*p
,
694 const BIGNUM
*x
, const BIGNUM
*y
, BN_CTX
*ctx
);
696 /** Gets the affine coordinates of an EC_POINT. A synonym of
697 * EC_POINT_get_affine_coordinates
698 * \param group underlying EC_GROUP object
699 * \param p EC_POINT object
700 * \param x BIGNUM for the x-coordinate
701 * \param y BIGNUM for the y-coordinate
702 * \param ctx BN_CTX object (optional)
703 * \return 1 on success and 0 if an error occurred
705 OSSL_DEPRECATEDIN_3_0
int EC_POINT_get_affine_coordinates_GF2m
706 (const EC_GROUP
*group
, const EC_POINT
*p
,
707 BIGNUM
*x
, BIGNUM
*y
, BN_CTX
*ctx
);
709 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
710 * EC_POINT_set_compressed_coordinates
711 * \param group underlying EC_GROUP object
712 * \param p EC_POINT object
713 * \param x BIGNUM with x-coordinate
714 * \param y_bit integer with the y-Bit (either 0 or 1)
715 * \param ctx BN_CTX object (optional)
716 * \return 1 on success and 0 if an error occurred
718 OSSL_DEPRECATEDIN_3_0
int EC_POINT_set_compressed_coordinates_GF2m
719 (const EC_GROUP
*group
, EC_POINT
*p
,
720 const BIGNUM
*x
, int y_bit
, BN_CTX
*ctx
);
722 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
724 /** Encodes a EC_POINT object to a octet string
725 * \param group underlying EC_GROUP object
726 * \param p EC_POINT object
727 * \param form point conversion form
728 * \param buf memory buffer for the result. If NULL the function returns
729 * required buffer size.
730 * \param len length of the memory buffer
731 * \param ctx BN_CTX object (optional)
732 * \return the length of the encoded octet string or 0 if an error occurred
734 size_t EC_POINT_point2oct(const EC_GROUP
*group
, const EC_POINT
*p
,
735 point_conversion_form_t form
,
736 unsigned char *buf
, size_t len
, BN_CTX
*ctx
);
738 /** Decodes a EC_POINT from a octet string
739 * \param group underlying EC_GROUP object
740 * \param p EC_POINT object
741 * \param buf memory buffer with the encoded ec point
742 * \param len length of the encoded ec point
743 * \param ctx BN_CTX object (optional)
744 * \return 1 on success and 0 if an error occurred
746 int EC_POINT_oct2point(const EC_GROUP
*group
, EC_POINT
*p
,
747 const unsigned char *buf
, size_t len
, BN_CTX
*ctx
);
749 /** Encodes an EC_POINT object to an allocated octet string
750 * \param group underlying EC_GROUP object
751 * \param point EC_POINT object
752 * \param form point conversion form
753 * \param pbuf returns pointer to allocated buffer
754 * \param ctx BN_CTX object (optional)
755 * \return the length of the encoded octet string or 0 if an error occurred
757 size_t EC_POINT_point2buf(const EC_GROUP
*group
, const EC_POINT
*point
,
758 point_conversion_form_t form
,
759 unsigned char **pbuf
, BN_CTX
*ctx
);
761 /* other interfaces to point2oct/oct2point: */
762 # ifndef OPENSSL_NO_DEPRECATED_3_0
763 OSSL_DEPRECATEDIN_3_0 BIGNUM
*EC_POINT_point2bn(const EC_GROUP
*,
765 point_conversion_form_t form
,
767 OSSL_DEPRECATEDIN_3_0 EC_POINT
*EC_POINT_bn2point(const EC_GROUP
*,
769 EC_POINT
*, BN_CTX
*);
770 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
772 char *EC_POINT_point2hex(const EC_GROUP
*, const EC_POINT
*,
773 point_conversion_form_t form
, BN_CTX
*);
774 EC_POINT
*EC_POINT_hex2point(const EC_GROUP
*, const char *,
775 EC_POINT
*, BN_CTX
*);
777 /********************************************************************/
778 /* functions for doing EC_POINT arithmetic */
779 /********************************************************************/
781 /** Computes the sum of two EC_POINT
782 * \param group underlying EC_GROUP object
783 * \param r EC_POINT object for the result (r = a + b)
784 * \param a EC_POINT object with the first summand
785 * \param b EC_POINT object with the second summand
786 * \param ctx BN_CTX object (optional)
787 * \return 1 on success and 0 if an error occurred
789 int EC_POINT_add(const EC_GROUP
*group
, EC_POINT
*r
, const EC_POINT
*a
,
790 const EC_POINT
*b
, BN_CTX
*ctx
);
792 /** Computes the double of a EC_POINT
793 * \param group underlying EC_GROUP object
794 * \param r EC_POINT object for the result (r = 2 * a)
795 * \param a EC_POINT object
796 * \param ctx BN_CTX object (optional)
797 * \return 1 on success and 0 if an error occurred
799 int EC_POINT_dbl(const EC_GROUP
*group
, EC_POINT
*r
, const EC_POINT
*a
,
802 /** Computes the inverse of a EC_POINT
803 * \param group underlying EC_GROUP object
804 * \param a EC_POINT object to be inverted (it's used for the result as well)
805 * \param ctx BN_CTX object (optional)
806 * \return 1 on success and 0 if an error occurred
808 int EC_POINT_invert(const EC_GROUP
*group
, EC_POINT
*a
, BN_CTX
*ctx
);
810 /** Checks whether the point is the neutral element of the group
811 * \param group the underlying EC_GROUP object
812 * \param p EC_POINT object
813 * \return 1 if the point is the neutral element and 0 otherwise
815 int EC_POINT_is_at_infinity(const EC_GROUP
*group
, const EC_POINT
*p
);
817 /** Checks whether the point is on the curve
818 * \param group underlying EC_GROUP object
819 * \param point EC_POINT object to check
820 * \param ctx BN_CTX object (optional)
821 * \return 1 if the point is on the curve, 0 if not, or -1 on error
823 int EC_POINT_is_on_curve(const EC_GROUP
*group
, const EC_POINT
*point
,
826 /** Compares two EC_POINTs
827 * \param group underlying EC_GROUP object
828 * \param a first EC_POINT object
829 * \param b second EC_POINT object
830 * \param ctx BN_CTX object (optional)
831 * \return 1 if the points are not equal, 0 if they are, or -1 on error
833 int EC_POINT_cmp(const EC_GROUP
*group
, const EC_POINT
*a
, const EC_POINT
*b
,
836 # ifndef OPENSSL_NO_DEPRECATED_3_0
837 OSSL_DEPRECATEDIN_3_0
int EC_POINT_make_affine(const EC_GROUP
*group
,
838 EC_POINT
*point
, BN_CTX
*ctx
);
839 OSSL_DEPRECATEDIN_3_0
int EC_POINTs_make_affine(const EC_GROUP
*group
, size_t num
,
840 EC_POINT
*points
[], BN_CTX
*ctx
);
842 /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]
843 * \param group underlying EC_GROUP object
844 * \param r EC_POINT object for the result
845 * \param n BIGNUM with the multiplier for the group generator (optional)
846 * \param num number further summands
847 * \param p array of size num of EC_POINT objects
848 * \param m array of size num of BIGNUM objects
849 * \param ctx BN_CTX object (optional)
850 * \return 1 on success and 0 if an error occurred
852 OSSL_DEPRECATEDIN_3_0
int EC_POINTs_mul(const EC_GROUP
*group
, EC_POINT
*r
,
853 const BIGNUM
*n
, size_t num
,
854 const EC_POINT
*p
[], const BIGNUM
*m
[],
856 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
858 /** Computes r = generator * n + q * m
859 * \param group underlying EC_GROUP object
860 * \param r EC_POINT object for the result
861 * \param n BIGNUM with the multiplier for the group generator (optional)
862 * \param q EC_POINT object with the first factor of the second summand
863 * \param m BIGNUM with the second factor of the second summand
864 * \param ctx BN_CTX object (optional)
865 * \return 1 on success and 0 if an error occurred
867 int EC_POINT_mul(const EC_GROUP
*group
, EC_POINT
*r
, const BIGNUM
*n
,
868 const EC_POINT
*q
, const BIGNUM
*m
, BN_CTX
*ctx
);
870 # ifndef OPENSSL_NO_DEPRECATED_3_0
871 /** Stores multiples of generator for faster point multiplication
872 * \param group EC_GROUP object
873 * \param ctx BN_CTX object (optional)
874 * \return 1 on success and 0 if an error occurred
876 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_precompute_mult(EC_GROUP
*group
, BN_CTX
*ctx
);
878 /** Reports whether a precomputation has been done
879 * \param group EC_GROUP object
880 * \return 1 if a pre-computation has been done and 0 otherwise
882 OSSL_DEPRECATEDIN_3_0
int EC_GROUP_have_precompute_mult(const EC_GROUP
*group
);
883 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
885 /********************************************************************/
887 /********************************************************************/
889 DECLARE_ASN1_ITEM(ECPKPARAMETERS
)
890 DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS
)
891 DECLARE_ASN1_ITEM(ECPARAMETERS
)
892 DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS
)
895 * EC_GROUP_get_basis_type() returns the NID of the basis type used to
896 * represent the field elements
898 int EC_GROUP_get_basis_type(const EC_GROUP
*);
899 # ifndef OPENSSL_NO_EC2M
900 int EC_GROUP_get_trinomial_basis(const EC_GROUP
*, unsigned int *k
);
901 int EC_GROUP_get_pentanomial_basis(const EC_GROUP
*, unsigned int *k1
,
902 unsigned int *k2
, unsigned int *k3
);
905 EC_GROUP
*d2i_ECPKParameters(EC_GROUP
**, const unsigned char **in
, long len
);
906 int i2d_ECPKParameters(const EC_GROUP
*, unsigned char **out
);
908 # define d2i_ECPKParameters_bio(bp,x) \
909 ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x)
910 # define i2d_ECPKParameters_bio(bp,x) \
911 ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x)
912 # define d2i_ECPKParameters_fp(fp,x) \
913 (EC_GROUP *)ASN1_d2i_fp(NULL, (char *(*)())d2i_ECPKParameters, (fp), \
914 (unsigned char **)(x))
915 # define i2d_ECPKParameters_fp(fp,x) \
916 ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x))
918 # ifndef OPENSSL_NO_DEPRECATED_3_0
919 OSSL_DEPRECATEDIN_3_0
int ECPKParameters_print(BIO
*bp
, const EC_GROUP
*x
,
921 # ifndef OPENSSL_NO_STDIO
922 OSSL_DEPRECATEDIN_3_0
int ECPKParameters_print_fp(FILE *fp
, const EC_GROUP
*x
,
925 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
927 /********************************************************************/
928 /* EC_KEY functions */
929 /********************************************************************/
931 /* some values for the encoding_flag */
932 # define EC_PKEY_NO_PARAMETERS 0x001
933 # define EC_PKEY_NO_PUBKEY 0x002
935 /* some values for the flags field */
936 # define EC_FLAG_SM2_RANGE 0x0004
937 # define EC_FLAG_COFACTOR_ECDH 0x1000
938 # define EC_FLAG_CHECK_NAMED_GROUP 0x2000
939 # define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000
940 # define EC_FLAG_CHECK_NAMED_GROUP_MASK \
941 (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST)
943 /* Deprecated flags - it was using 0x01..0x02 */
944 # define EC_FLAG_NON_FIPS_ALLOW 0x0000
945 # define EC_FLAG_FIPS_CHECKED 0x0000
947 # ifndef OPENSSL_NO_DEPRECATED_3_0
949 * Creates a new EC_KEY object.
950 * \param ctx The library context for to use for this EC_KEY. May be NULL in
951 * which case the default library context is used.
952 * \return EC_KEY object or NULL if an error occurred.
954 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_ex(OSSL_LIB_CTX
*ctx
, const char *propq
);
957 * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a
958 * NULL library context
959 * \return EC_KEY object or NULL if an error occurred.
961 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new(void);
963 OSSL_DEPRECATEDIN_3_0
int EC_KEY_get_flags(const EC_KEY
*key
);
965 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_flags(EC_KEY
*key
, int flags
);
967 OSSL_DEPRECATEDIN_3_0
void EC_KEY_clear_flags(EC_KEY
*key
, int flags
);
969 OSSL_DEPRECATEDIN_3_0
int EC_KEY_decoded_from_explicit_params(const EC_KEY
*key
);
972 * Creates a new EC_KEY object using a named curve as underlying
974 * \param ctx The library context for to use for this EC_KEY. May be NULL in
975 * which case the default library context is used.
976 * \param propq Any property query string
977 * \param nid NID of the named curve.
978 * \return EC_KEY object or NULL if an error occurred.
980 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX
*ctx
,
985 * Creates a new EC_KEY object using a named curve as underlying
986 * EC_GROUP object. Same as calling EC_KEY_new_by_curve_name_ex with a NULL
987 * library context and property query string.
988 * \param nid NID of the named curve.
989 * \return EC_KEY object or NULL if an error occurred.
991 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_by_curve_name(int nid
);
993 /** Frees a EC_KEY object.
994 * \param key EC_KEY object to be freed.
996 OSSL_DEPRECATEDIN_3_0
void EC_KEY_free(EC_KEY
*key
);
998 /** Copies a EC_KEY object.
999 * \param dst destination EC_KEY object
1000 * \param src src EC_KEY object
1001 * \return dst or NULL if an error occurred.
1003 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_copy(EC_KEY
*dst
, const EC_KEY
*src
);
1005 /** Creates a new EC_KEY object and copies the content from src to it.
1006 * \param src the source EC_KEY object
1007 * \return newly created EC_KEY object or NULL if an error occurred.
1009 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_dup(const EC_KEY
*src
);
1011 /** Increases the internal reference count of a EC_KEY object.
1012 * \param key EC_KEY object
1013 * \return 1 on success and 0 if an error occurred.
1015 OSSL_DEPRECATEDIN_3_0
int EC_KEY_up_ref(EC_KEY
*key
);
1017 /** Returns the ENGINE object of a EC_KEY object
1018 * \param eckey EC_KEY object
1019 * \return the ENGINE object (possibly NULL).
1021 OSSL_DEPRECATEDIN_3_0 ENGINE
*EC_KEY_get0_engine(const EC_KEY
*eckey
);
1023 /** Returns the EC_GROUP object of a EC_KEY object
1024 * \param key EC_KEY object
1025 * \return the EC_GROUP object (possibly NULL).
1027 OSSL_DEPRECATEDIN_3_0
const EC_GROUP
*EC_KEY_get0_group(const EC_KEY
*key
);
1029 /** Sets the EC_GROUP of a EC_KEY object.
1030 * \param key EC_KEY object
1031 * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
1032 * object will use an own copy of the EC_GROUP).
1033 * \return 1 on success and 0 if an error occurred.
1035 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_group(EC_KEY
*key
, const EC_GROUP
*group
);
1037 /** Returns the private key of a EC_KEY object.
1038 * \param key EC_KEY object
1039 * \return a BIGNUM with the private key (possibly NULL).
1041 OSSL_DEPRECATEDIN_3_0
const BIGNUM
*EC_KEY_get0_private_key(const EC_KEY
*key
);
1043 /** Sets the private key of a EC_KEY object.
1044 * \param key EC_KEY object
1045 * \param prv BIGNUM with the private key (note: the EC_KEY object
1046 * will use an own copy of the BIGNUM).
1047 * \return 1 on success and 0 if an error occurred.
1049 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_private_key(EC_KEY
*key
, const BIGNUM
*prv
);
1051 /** Returns the public key of a EC_KEY object.
1052 * \param key the EC_KEY object
1053 * \return a EC_POINT object with the public key (possibly NULL)
1055 OSSL_DEPRECATEDIN_3_0
const EC_POINT
*EC_KEY_get0_public_key(const EC_KEY
*key
);
1057 /** Sets the public key of a EC_KEY object.
1058 * \param key EC_KEY object
1059 * \param pub EC_POINT object with the public key (note: the EC_KEY object
1060 * will use an own copy of the EC_POINT object).
1061 * \return 1 on success and 0 if an error occurred.
1063 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_public_key(EC_KEY
*key
, const EC_POINT
*pub
);
1065 OSSL_DEPRECATEDIN_3_0
unsigned EC_KEY_get_enc_flags(const EC_KEY
*key
);
1066 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_enc_flags(EC_KEY
*eckey
, unsigned int flags
);
1067 OSSL_DEPRECATEDIN_3_0 point_conversion_form_t
EC_KEY_get_conv_form(const EC_KEY
*key
);
1068 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_conv_form(EC_KEY
*eckey
,
1069 point_conversion_form_t cform
);
1070 # endif /*OPENSSL_NO_DEPRECATED_3_0 */
1072 # define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
1073 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
1075 # ifndef OPENSSL_NO_DEPRECATED_3_0
1076 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_ex_data(EC_KEY
*key
, int idx
, void *arg
);
1077 OSSL_DEPRECATEDIN_3_0
void *EC_KEY_get_ex_data(const EC_KEY
*key
, int idx
);
1079 /* wrapper functions for the underlying EC_GROUP object */
1080 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_asn1_flag(EC_KEY
*eckey
, int asn1_flag
);
1082 /** Creates a table of pre-computed multiples of the generator to
1083 * accelerate further EC_KEY operations.
1084 * \param key EC_KEY object
1085 * \param ctx BN_CTX object (optional)
1086 * \return 1 on success and 0 if an error occurred.
1088 OSSL_DEPRECATEDIN_3_0
int EC_KEY_precompute_mult(EC_KEY
*key
, BN_CTX
*ctx
);
1090 /** Creates a new ec private (and optional a new public) key.
1091 * \param key EC_KEY object
1092 * \return 1 on success and 0 if an error occurred.
1094 OSSL_DEPRECATEDIN_3_0
int EC_KEY_generate_key(EC_KEY
*key
);
1096 /** Verifies that a private and/or public key is valid.
1097 * \param key the EC_KEY object
1098 * \return 1 on success and 0 otherwise.
1100 OSSL_DEPRECATEDIN_3_0
int EC_KEY_check_key(const EC_KEY
*key
);
1102 /** Indicates if an EC_KEY can be used for signing.
1103 * \param eckey the EC_KEY object
1104 * \return 1 if can can sign and 0 otherwise.
1106 OSSL_DEPRECATEDIN_3_0
int EC_KEY_can_sign(const EC_KEY
*eckey
);
1108 /** Sets a public key from affine coordinates performing
1109 * necessary NIST PKV tests.
1110 * \param key the EC_KEY object
1111 * \param x public key x coordinate
1112 * \param y public key y coordinate
1113 * \return 1 on success and 0 otherwise.
1115 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_public_key_affine_coordinates(EC_KEY
*key
,
1119 /** Encodes an EC_KEY public key to an allocated octet string
1120 * \param key key to encode
1121 * \param form point conversion form
1122 * \param pbuf returns pointer to allocated buffer
1123 * \param ctx BN_CTX object (optional)
1124 * \return the length of the encoded octet string or 0 if an error occurred
1126 OSSL_DEPRECATEDIN_3_0
size_t EC_KEY_key2buf(const EC_KEY
*key
,
1127 point_conversion_form_t form
,
1128 unsigned char **pbuf
, BN_CTX
*ctx
);
1130 /** Decodes a EC_KEY public key from a octet string
1131 * \param key key to decode
1132 * \param buf memory buffer with the encoded ec point
1133 * \param len length of the encoded ec point
1134 * \param ctx BN_CTX object (optional)
1135 * \return 1 on success and 0 if an error occurred
1138 OSSL_DEPRECATEDIN_3_0
int EC_KEY_oct2key(EC_KEY
*key
, const unsigned char *buf
,
1139 size_t len
, BN_CTX
*ctx
);
1141 /** Decodes an EC_KEY private key from an octet string
1142 * \param key key to decode
1143 * \param buf memory buffer with the encoded private key
1144 * \param len length of the encoded key
1145 * \return 1 on success and 0 if an error occurred
1148 OSSL_DEPRECATEDIN_3_0
int EC_KEY_oct2priv(EC_KEY
*key
, const unsigned char *buf
,
1151 /** Encodes a EC_KEY private key to an octet string
1152 * \param key key to encode
1153 * \param buf memory buffer for the result. If NULL the function returns
1154 * required buffer size.
1155 * \param len length of the memory buffer
1156 * \return the length of the encoded octet string or 0 if an error occurred
1159 OSSL_DEPRECATEDIN_3_0
size_t EC_KEY_priv2oct(const EC_KEY
*key
,
1160 unsigned char *buf
, size_t len
);
1162 /** Encodes an EC_KEY private key to an allocated octet string
1163 * \param eckey key to encode
1164 * \param pbuf returns pointer to allocated buffer
1165 * \return the length of the encoded octet string or 0 if an error occurred
1167 OSSL_DEPRECATEDIN_3_0
size_t EC_KEY_priv2buf(const EC_KEY
*eckey
,
1168 unsigned char **pbuf
);
1170 /********************************************************************/
1171 /* de- and encoding functions for SEC1 ECPrivateKey */
1172 /********************************************************************/
1174 /** Decodes a private key from a memory buffer.
1175 * \param key a pointer to a EC_KEY object which should be used (or NULL)
1176 * \param in pointer to memory with the DER encoded private key
1177 * \param len length of the DER encoded private key
1178 * \return the decoded private key or NULL if an error occurred.
1180 OSSL_DEPRECATEDIN_3_0 EC_KEY
*d2i_ECPrivateKey(EC_KEY
**key
,
1181 const unsigned char **in
,
1184 /** Encodes a private key object and stores the result in a buffer.
1185 * \param key the EC_KEY object to encode
1186 * \param out the buffer for the result (if NULL the function returns number
1188 * \return 1 on success and 0 if an error occurred.
1190 OSSL_DEPRECATEDIN_3_0
int i2d_ECPrivateKey(const EC_KEY
*key
,
1191 unsigned char **out
);
1193 /********************************************************************/
1194 /* de- and encoding functions for EC parameters */
1195 /********************************************************************/
1197 /** Decodes ec parameter from a memory buffer.
1198 * \param key a pointer to a EC_KEY object which should be used (or NULL)
1199 * \param in pointer to memory with the DER encoded ec parameters
1200 * \param len length of the DER encoded ec parameters
1201 * \return a EC_KEY object with the decoded parameters or NULL if an error
1204 OSSL_DEPRECATEDIN_3_0 EC_KEY
*d2i_ECParameters(EC_KEY
**key
,
1205 const unsigned char **in
,
1208 /** Encodes ec parameter and stores the result in a buffer.
1209 * \param key the EC_KEY object with ec parameters to encode
1210 * \param out the buffer for the result (if NULL the function returns number
1212 * \return 1 on success and 0 if an error occurred.
1214 OSSL_DEPRECATEDIN_3_0
int i2d_ECParameters(const EC_KEY
*key
,
1215 unsigned char **out
);
1217 /********************************************************************/
1218 /* de- and encoding functions for EC public key */
1219 /* (octet string, not DER -- hence 'o2i' and 'i2o') */
1220 /********************************************************************/
1222 /** Decodes a ec public key from a octet string.
1223 * \param key a pointer to a EC_KEY object which should be used
1224 * \param in memory buffer with the encoded public key
1225 * \param len length of the encoded public key
1226 * \return EC_KEY object with decoded public key or NULL if an error
1229 OSSL_DEPRECATEDIN_3_0 EC_KEY
*o2i_ECPublicKey(EC_KEY
**key
,
1230 const unsigned char **in
, long len
);
1232 /** Encodes a ec public key in an octet string.
1233 * \param key the EC_KEY object with the public key
1234 * \param out the buffer for the result (if NULL the function returns number
1236 * \return 1 on success and 0 if an error occurred
1238 OSSL_DEPRECATEDIN_3_0
int i2o_ECPublicKey(const EC_KEY
*key
, unsigned char **out
);
1240 /** Prints out the ec parameters on human readable form.
1241 * \param bp BIO object to which the information is printed
1242 * \param key EC_KEY object
1243 * \return 1 on success and 0 if an error occurred
1245 OSSL_DEPRECATEDIN_3_0
int ECParameters_print(BIO
*bp
, const EC_KEY
*key
);
1247 /** Prints out the contents of a EC_KEY object
1248 * \param bp BIO object to which the information is printed
1249 * \param key EC_KEY object
1250 * \param off line offset
1251 * \return 1 on success and 0 if an error occurred
1253 OSSL_DEPRECATEDIN_3_0
int EC_KEY_print(BIO
*bp
, const EC_KEY
*key
, int off
);
1255 # ifndef OPENSSL_NO_STDIO
1256 /** Prints out the ec parameters on human readable form.
1257 * \param fp file descriptor to which the information is printed
1258 * \param key EC_KEY object
1259 * \return 1 on success and 0 if an error occurred
1261 OSSL_DEPRECATEDIN_3_0
int ECParameters_print_fp(FILE *fp
, const EC_KEY
*key
);
1263 /** Prints out the contents of a EC_KEY object
1264 * \param fp file descriptor to which the information is printed
1265 * \param key EC_KEY object
1266 * \param off line offset
1267 * \return 1 on success and 0 if an error occurred
1269 OSSL_DEPRECATEDIN_3_0
int EC_KEY_print_fp(FILE *fp
, const EC_KEY
*key
, int off
);
1270 # endif /* OPENSSL_NO_STDIO */
1272 OSSL_DEPRECATEDIN_3_0
const EC_KEY_METHOD
*EC_KEY_OpenSSL(void);
1273 OSSL_DEPRECATEDIN_3_0
const EC_KEY_METHOD
*EC_KEY_get_default_method(void);
1274 OSSL_DEPRECATEDIN_3_0
void EC_KEY_set_default_method(const EC_KEY_METHOD
*meth
);
1275 OSSL_DEPRECATEDIN_3_0
const EC_KEY_METHOD
*EC_KEY_get_method(const EC_KEY
*key
);
1276 OSSL_DEPRECATEDIN_3_0
int EC_KEY_set_method(EC_KEY
*key
, const EC_KEY_METHOD
*meth
);
1277 OSSL_DEPRECATEDIN_3_0 EC_KEY
*EC_KEY_new_method(ENGINE
*engine
);
1279 /** The old name for ecdh_KDF_X9_63
1280 * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62,
1281 * it is actually specified in ANSI X9.63.
1282 * This identifier is retained for backwards compatibility
1284 OSSL_DEPRECATEDIN_3_0
int ECDH_KDF_X9_62(unsigned char *out
, size_t outlen
,
1285 const unsigned char *Z
, size_t Zlen
,
1286 const unsigned char *sinfo
,
1287 size_t sinfolen
, const EVP_MD
*md
);
1289 OSSL_DEPRECATEDIN_3_0
int ECDH_compute_key(void *out
, size_t outlen
,
1290 const EC_POINT
*pub_key
,
1292 void *(*KDF
)(const void *in
,
1293 size_t inlen
, void *out
,
1295 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
1297 typedef struct ECDSA_SIG_st ECDSA_SIG
;
1299 /** Allocates and initialize a ECDSA_SIG structure
1300 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1302 ECDSA_SIG
*ECDSA_SIG_new(void);
1304 /** frees a ECDSA_SIG structure
1305 * \param sig pointer to the ECDSA_SIG structure
1307 void ECDSA_SIG_free(ECDSA_SIG
*sig
);
1309 /** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp
1310 * (*pp += length of the DER encoded signature)).
1311 * \param sig pointer to the ECDSA_SIG object
1312 * \param pp pointer to a unsigned char pointer for the output or NULL
1313 * \return the length of the DER encoded ECDSA_SIG object or a negative value
1316 DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG
, ECDSA_SIG
)
1318 /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp
1320 * \param sig pointer to ECDSA_SIG pointer (may be NULL)
1321 * \param pp memory buffer with the DER encoded signature
1322 * \param len length of the buffer
1323 * \return pointer to the decoded ECDSA_SIG structure (or NULL)
1326 /** Accessor for r and s fields of ECDSA_SIG
1327 * \param sig pointer to ECDSA_SIG structure
1328 * \param pr pointer to BIGNUM pointer for r (may be NULL)
1329 * \param ps pointer to BIGNUM pointer for s (may be NULL)
1331 void ECDSA_SIG_get0(const ECDSA_SIG
*sig
, const BIGNUM
**pr
, const BIGNUM
**ps
);
1333 /** Accessor for r field of ECDSA_SIG
1334 * \param sig pointer to ECDSA_SIG structure
1336 const BIGNUM
*ECDSA_SIG_get0_r(const ECDSA_SIG
*sig
);
1338 /** Accessor for s field of ECDSA_SIG
1339 * \param sig pointer to ECDSA_SIG structure
1341 const BIGNUM
*ECDSA_SIG_get0_s(const ECDSA_SIG
*sig
);
1343 /** Setter for r and s fields of ECDSA_SIG
1344 * \param sig pointer to ECDSA_SIG structure
1345 * \param r pointer to BIGNUM for r (may be NULL)
1346 * \param s pointer to BIGNUM for s (may be NULL)
1348 int ECDSA_SIG_set0(ECDSA_SIG
*sig
, BIGNUM
*r
, BIGNUM
*s
);
1350 # ifndef OPENSSL_NO_DEPRECATED_3_0
1351 /** Computes the ECDSA signature of the given hash value using
1352 * the supplied private key and returns the created signature.
1353 * \param dgst pointer to the hash value
1354 * \param dgst_len length of the hash value
1355 * \param eckey EC_KEY object containing a private EC key
1356 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1358 OSSL_DEPRECATEDIN_3_0 ECDSA_SIG
*ECDSA_do_sign(const unsigned char *dgst
,
1359 int dgst_len
, EC_KEY
*eckey
);
1361 /** Computes ECDSA signature of a given hash value using the supplied
1362 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1363 * \param dgst pointer to the hash value to sign
1364 * \param dgstlen length of the hash value
1365 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1366 * \param rp BIGNUM with a pre-computed rp value (optional),
1367 * see ECDSA_sign_setup
1368 * \param eckey EC_KEY object containing a private EC key
1369 * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
1371 OSSL_DEPRECATEDIN_3_0 ECDSA_SIG
*ECDSA_do_sign_ex(const unsigned char *dgst
,
1372 int dgstlen
, const BIGNUM
*kinv
,
1373 const BIGNUM
*rp
, EC_KEY
*eckey
);
1375 /** Verifies that the supplied signature is a valid ECDSA
1376 * signature of the supplied hash value using the supplied public key.
1377 * \param dgst pointer to the hash value
1378 * \param dgst_len length of the hash value
1379 * \param sig ECDSA_SIG structure
1380 * \param eckey EC_KEY object containing a public EC key
1381 * \return 1 if the signature is valid, 0 if the signature is invalid
1384 OSSL_DEPRECATEDIN_3_0
int ECDSA_do_verify(const unsigned char *dgst
, int dgst_len
,
1385 const ECDSA_SIG
*sig
, EC_KEY
*eckey
);
1387 /** Precompute parts of the signing operation
1388 * \param eckey EC_KEY object containing a private EC key
1389 * \param ctx BN_CTX object (optional)
1390 * \param kinv BIGNUM pointer for the inverse of k
1391 * \param rp BIGNUM pointer for x coordinate of k * generator
1392 * \return 1 on success and 0 otherwise
1394 OSSL_DEPRECATEDIN_3_0
int ECDSA_sign_setup(EC_KEY
*eckey
, BN_CTX
*ctx
,
1395 BIGNUM
**kinv
, BIGNUM
**rp
);
1397 /** Computes ECDSA signature of a given hash value using the supplied
1398 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1399 * \param type this parameter is ignored
1400 * \param dgst pointer to the hash value to sign
1401 * \param dgstlen length of the hash value
1402 * \param sig memory for the DER encoded created signature
1403 * \param siglen pointer to the length of the returned signature
1404 * \param eckey EC_KEY object containing a private EC key
1405 * \return 1 on success and 0 otherwise
1407 OSSL_DEPRECATEDIN_3_0
int ECDSA_sign(int type
, const unsigned char *dgst
,
1408 int dgstlen
, unsigned char *sig
,
1409 unsigned int *siglen
, EC_KEY
*eckey
);
1411 /** Computes ECDSA signature of a given hash value using the supplied
1412 * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
1413 * \param type this parameter is ignored
1414 * \param dgst pointer to the hash value to sign
1415 * \param dgstlen length of the hash value
1416 * \param sig buffer to hold the DER encoded signature
1417 * \param siglen pointer to the length of the returned signature
1418 * \param kinv BIGNUM with a pre-computed inverse k (optional)
1419 * \param rp BIGNUM with a pre-computed rp value (optional),
1420 * see ECDSA_sign_setup
1421 * \param eckey EC_KEY object containing a private EC key
1422 * \return 1 on success and 0 otherwise
1424 OSSL_DEPRECATEDIN_3_0
int ECDSA_sign_ex(int type
, const unsigned char *dgst
,
1425 int dgstlen
, unsigned char *sig
,
1426 unsigned int *siglen
, const BIGNUM
*kinv
,
1427 const BIGNUM
*rp
, EC_KEY
*eckey
);
1429 /** Verifies that the given signature is valid ECDSA signature
1430 * of the supplied hash value using the specified public key.
1431 * \param type this parameter is ignored
1432 * \param dgst pointer to the hash value
1433 * \param dgstlen length of the hash value
1434 * \param sig pointer to the DER encoded signature
1435 * \param siglen length of the DER encoded signature
1436 * \param eckey EC_KEY object containing a public EC key
1437 * \return 1 if the signature is valid, 0 if the signature is invalid
1440 OSSL_DEPRECATEDIN_3_0
int ECDSA_verify(int type
, const unsigned char *dgst
,
1441 int dgstlen
, const unsigned char *sig
,
1442 int siglen
, EC_KEY
*eckey
);
1444 /** Returns the maximum length of the DER encoded signature
1445 * \param eckey EC_KEY object
1446 * \return numbers of bytes required for the DER encoded signature
1448 OSSL_DEPRECATEDIN_3_0
int ECDSA_size(const EC_KEY
*eckey
);
1450 /********************************************************************/
1451 /* EC_KEY_METHOD constructors, destructors, writers and accessors */
1452 /********************************************************************/
1454 OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD
*EC_KEY_METHOD_new(const EC_KEY_METHOD
*meth
);
1455 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_free(EC_KEY_METHOD
*meth
);
1456 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_init
1457 (EC_KEY_METHOD
*meth
,
1458 int (*init
)(EC_KEY
*key
),
1459 void (*finish
)(EC_KEY
*key
),
1460 int (*copy
)(EC_KEY
*dest
, const EC_KEY
*src
),
1461 int (*set_group
)(EC_KEY
*key
, const EC_GROUP
*grp
),
1462 int (*set_private
)(EC_KEY
*key
, const BIGNUM
*priv_key
),
1463 int (*set_public
)(EC_KEY
*key
, const EC_POINT
*pub_key
));
1465 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD
*meth
,
1466 int (*keygen
)(EC_KEY
*key
));
1468 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_compute_key
1469 (EC_KEY_METHOD
*meth
,
1470 int (*ckey
)(unsigned char **psec
, size_t *pseclen
,
1471 const EC_POINT
*pub_key
, const EC_KEY
*ecdh
));
1473 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_sign
1474 (EC_KEY_METHOD
*meth
,
1475 int (*sign
)(int type
, const unsigned char *dgst
,
1476 int dlen
, unsigned char *sig
,
1477 unsigned int *siglen
,
1478 const BIGNUM
*kinv
, const BIGNUM
*r
,
1480 int (*sign_setup
)(EC_KEY
*eckey
, BN_CTX
*ctx_in
,
1481 BIGNUM
**kinvp
, BIGNUM
**rp
),
1482 ECDSA_SIG
*(*sign_sig
)(const unsigned char *dgst
,
1484 const BIGNUM
*in_kinv
,
1488 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_set_verify
1489 (EC_KEY_METHOD
*meth
,
1490 int (*verify
)(int type
, const unsigned
1491 char *dgst
, int dgst_len
,
1492 const unsigned char *sigbuf
,
1493 int sig_len
, EC_KEY
*eckey
),
1494 int (*verify_sig
)(const unsigned char *dgst
,
1495 int dgst_len
, const ECDSA_SIG
*sig
,
1498 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_init
1499 (const EC_KEY_METHOD
*meth
,
1500 int (**pinit
)(EC_KEY
*key
),
1501 void (**pfinish
)(EC_KEY
*key
),
1502 int (**pcopy
)(EC_KEY
*dest
, const EC_KEY
*src
),
1503 int (**pset_group
)(EC_KEY
*key
, const EC_GROUP
*grp
),
1504 int (**pset_private
)(EC_KEY
*key
, const BIGNUM
*priv_key
),
1505 int (**pset_public
)(EC_KEY
*key
, const EC_POINT
*pub_key
));
1507 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_keygen
1508 (const EC_KEY_METHOD
*meth
, int (**pkeygen
)(EC_KEY
*key
));
1510 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_compute_key
1511 (const EC_KEY_METHOD
*meth
,
1512 int (**pck
)(unsigned char **psec
,
1514 const EC_POINT
*pub_key
,
1515 const EC_KEY
*ecdh
));
1517 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_sign
1518 (const EC_KEY_METHOD
*meth
,
1519 int (**psign
)(int type
, const unsigned char *dgst
,
1520 int dlen
, unsigned char *sig
,
1521 unsigned int *siglen
,
1522 const BIGNUM
*kinv
, const BIGNUM
*r
,
1524 int (**psign_setup
)(EC_KEY
*eckey
, BN_CTX
*ctx_in
,
1525 BIGNUM
**kinvp
, BIGNUM
**rp
),
1526 ECDSA_SIG
*(**psign_sig
)(const unsigned char *dgst
,
1528 const BIGNUM
*in_kinv
,
1532 OSSL_DEPRECATEDIN_3_0
void EC_KEY_METHOD_get_verify
1533 (const EC_KEY_METHOD
*meth
,
1534 int (**pverify
)(int type
, const unsigned
1535 char *dgst
, int dgst_len
,
1536 const unsigned char *sigbuf
,
1537 int sig_len
, EC_KEY
*eckey
),
1538 int (**pverify_sig
)(const unsigned char *dgst
,
1540 const ECDSA_SIG
*sig
,
1542 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
1544 # define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \
1545 d2i_ECParameters, x)
1547 # ifndef __cplusplus
1548 # if defined(__SUNPRO_C)
1549 # if __SUNPRO_C >= 0x520
1550 # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)