2 * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 * ECDH/ECDSA low level APIs are deprecated for public use, but still ok for
14 #include "internal/deprecated.h"
16 #include "e_os.h" /* strcasecmp */
18 #include <openssl/core_dispatch.h>
19 #include <openssl/core_names.h>
20 #include <openssl/bn.h>
21 #include <openssl/err.h>
22 #include <openssl/objects.h>
23 #include "crypto/bn.h"
24 #include "crypto/ec.h"
25 #include "prov/implementations.h"
26 #include "prov/providercommon.h"
27 #include "prov/providercommonerr.h"
28 #include "prov/provider_ctx.h"
29 #include "internal/param_build_set.h"
30 #include "crypto/sm2.h"
32 static OSSL_FUNC_keymgmt_new_fn ec_newdata
;
33 static OSSL_FUNC_keymgmt_gen_init_fn ec_gen_init
;
34 static OSSL_FUNC_keymgmt_gen_set_template_fn ec_gen_set_template
;
35 static OSSL_FUNC_keymgmt_gen_set_params_fn ec_gen_set_params
;
36 static OSSL_FUNC_keymgmt_gen_settable_params_fn ec_gen_settable_params
;
37 static OSSL_FUNC_keymgmt_gen_fn ec_gen
;
38 static OSSL_FUNC_keymgmt_gen_cleanup_fn ec_gen_cleanup
;
39 static OSSL_FUNC_keymgmt_load_fn ec_load
;
40 static OSSL_FUNC_keymgmt_free_fn ec_freedata
;
41 static OSSL_FUNC_keymgmt_get_params_fn ec_get_params
;
42 static OSSL_FUNC_keymgmt_gettable_params_fn ec_gettable_params
;
43 static OSSL_FUNC_keymgmt_set_params_fn ec_set_params
;
44 static OSSL_FUNC_keymgmt_settable_params_fn ec_settable_params
;
45 static OSSL_FUNC_keymgmt_has_fn ec_has
;
46 static OSSL_FUNC_keymgmt_match_fn ec_match
;
47 static OSSL_FUNC_keymgmt_validate_fn ec_validate
;
48 static OSSL_FUNC_keymgmt_import_fn ec_import
;
49 static OSSL_FUNC_keymgmt_import_types_fn ec_import_types
;
50 static OSSL_FUNC_keymgmt_export_fn ec_export
;
51 static OSSL_FUNC_keymgmt_export_types_fn ec_export_types
;
52 static OSSL_FUNC_keymgmt_query_operation_name_fn ec_query_operation_name
;
53 #ifndef OPENSSL_NO_SM2
54 static OSSL_FUNC_keymgmt_gen_fn sm2_gen
;
55 static OSSL_FUNC_keymgmt_get_params_fn sm2_get_params
;
56 static OSSL_FUNC_keymgmt_gettable_params_fn sm2_gettable_params
;
57 static OSSL_FUNC_keymgmt_settable_params_fn sm2_settable_params
;
58 static OSSL_FUNC_keymgmt_import_fn sm2_import
;
59 static OSSL_FUNC_keymgmt_query_operation_name_fn sm2_query_operation_name
;
62 #define EC_DEFAULT_MD "SHA256"
63 #define EC_POSSIBLE_SELECTIONS \
64 (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS)
65 #define SM2_DEFAULT_MD "SM3"
68 const char *ec_query_operation_name(int operation_id
)
70 switch (operation_id
) {
73 case OSSL_OP_SIGNATURE
:
79 #ifndef OPENSSL_NO_SM2
81 const char *sm2_query_operation_name(int operation_id
)
83 switch (operation_id
) {
84 case OSSL_OP_SIGNATURE
:
92 int domparams_to_params(const EC_KEY
*ec
, OSSL_PARAM_BLD
*tmpl
,
101 ecg
= EC_KEY_get0_group(ec
);
105 curve_nid
= EC_GROUP_get_curve_name(ecg
);
107 if (curve_nid
== NID_undef
) {
108 /* TODO(3.0): should we support explicit parameters curves? */
112 const char *curve_name
= NULL
;
114 if ((curve_name
= ec_curve_nid2name(curve_nid
)) == NULL
)
116 if (!ossl_param_build_set_utf8_string(tmpl
, params
,
117 OSSL_PKEY_PARAM_GROUP_NAME
,
127 * Callers of key_to_params MUST make sure that domparams_to_params is also
130 * This function only exports the bare keypair, domain parameters and other
131 * parameters are exported separately.
134 int key_to_params(const EC_KEY
*eckey
, OSSL_PARAM_BLD
*tmpl
,
135 OSSL_PARAM params
[], int include_private
,
136 unsigned char **pub_key
)
138 BIGNUM
*x
= NULL
, *y
= NULL
;
139 const BIGNUM
*priv_key
= NULL
;
140 const EC_POINT
*pub_point
= NULL
;
141 const EC_GROUP
*ecg
= NULL
;
142 size_t pub_key_len
= 0;
144 BN_CTX
*bnctx
= NULL
;
147 || (ecg
= EC_KEY_get0_group(eckey
)) == NULL
)
150 priv_key
= EC_KEY_get0_private_key(eckey
);
151 pub_point
= EC_KEY_get0_public_key(eckey
);
153 if (pub_point
!= NULL
) {
154 OSSL_PARAM
*p
= NULL
, *px
= NULL
, *py
= NULL
;
156 * EC_POINT_point2buf() can generate random numbers in some
157 * implementations so we need to ensure we use the correct libctx.
159 bnctx
= BN_CTX_new_ex(ec_key_get_libctx(eckey
));
164 /* If we are doing a get then check first before decoding the point */
166 p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_PUB_KEY
);
167 px
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_EC_PUB_X
);
168 py
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_EC_PUB_Y
);
171 if (p
!= NULL
|| tmpl
!= NULL
) {
172 /* convert pub_point to a octet string according to the SECG standard */
173 if ((pub_key_len
= EC_POINT_point2buf(ecg
, pub_point
,
174 POINT_CONVERSION_COMPRESSED
,
175 pub_key
, bnctx
)) == 0
176 || !ossl_param_build_set_octet_string(tmpl
, p
,
177 OSSL_PKEY_PARAM_PUB_KEY
,
178 *pub_key
, pub_key_len
))
181 if (px
!= NULL
|| py
!= NULL
) {
183 x
= BN_CTX_get(bnctx
);
185 y
= BN_CTX_get(bnctx
);
187 if (!EC_POINT_get_affine_coordinates(ecg
, pub_point
, x
, y
, bnctx
))
190 && !ossl_param_build_set_bn(tmpl
, px
,
191 OSSL_PKEY_PARAM_EC_PUB_X
, x
))
194 && !ossl_param_build_set_bn(tmpl
, py
,
195 OSSL_PKEY_PARAM_EC_PUB_Y
, y
))
200 if (priv_key
!= NULL
&& include_private
) {
205 * Key import/export should never leak the bit length of the secret
208 * For this reason, on export we use padded BIGNUMs with fixed length.
210 * When importing we also should make sure that, even if short lived,
211 * the newly created BIGNUM is marked with the BN_FLG_CONSTTIME flag as
212 * soon as possible, so that any processing of this BIGNUM might opt for
213 * constant time implementations in the backend.
215 * Setting the BN_FLG_CONSTTIME flag alone is never enough, we also have
216 * to preallocate the BIGNUM internal buffer to a fixed public size big
217 * enough that operations performed during the processing never trigger
218 * a realloc which would leak the size of the scalar through memory
224 * The order of the large prime subgroup of the curve is our choice for
225 * a fixed public size, as that is generally the upper bound for
226 * generating a private key in EC cryptosystems and should fit all valid
229 * For padding on export we just use the bit length of the order
230 * converted to bytes (rounding up).
232 * For preallocating the BIGNUM storage we look at the number of "words"
233 * required for the internal representation of the order, and we
234 * preallocate 2 extra "words" in case any of the subsequent processing
235 * might temporarily overflow the order length.
237 ecbits
= EC_GROUP_order_bits(ecg
);
240 sz
= (ecbits
+ 7 ) / 8;
242 if (!ossl_param_build_set_bn_pad(tmpl
, params
,
243 OSSL_PKEY_PARAM_PRIV_KEY
,
254 int otherparams_to_params(const EC_KEY
*ec
, OSSL_PARAM_BLD
*tmpl
,
257 int ecdh_cofactor_mode
= 0;
263 (EC_KEY_get_flags(ec
) & EC_FLAG_COFACTOR_ECDH
) ? 1 : 0;
264 return ossl_param_build_set_int(tmpl
, params
,
265 OSSL_PKEY_PARAM_USE_COFACTOR_ECDH
,
270 void *ec_newdata(void *provctx
)
272 if (!ossl_prov_is_running())
274 return EC_KEY_new_with_libctx(PROV_LIBRARY_CONTEXT_OF(provctx
), NULL
);
278 void ec_freedata(void *keydata
)
280 EC_KEY_free(keydata
);
284 int ec_has(void *keydata
, int selection
)
286 EC_KEY
*ec
= keydata
;
289 if (ossl_prov_is_running() && ec
!= NULL
) {
290 if ((selection
& EC_POSSIBLE_SELECTIONS
) != 0)
293 if ((selection
& OSSL_KEYMGMT_SELECT_PUBLIC_KEY
) != 0)
294 ok
= ok
&& (EC_KEY_get0_public_key(ec
) != NULL
);
295 if ((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
) != 0)
296 ok
= ok
&& (EC_KEY_get0_private_key(ec
) != NULL
);
297 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) != 0)
298 ok
= ok
&& (EC_KEY_get0_group(ec
) != NULL
);
300 * We consider OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS to always be
301 * available, so no extra check is needed other than the previous one
302 * against EC_POSSIBLE_SELECTIONS.
308 static int ec_match(const void *keydata1
, const void *keydata2
, int selection
)
310 const EC_KEY
*ec1
= keydata1
;
311 const EC_KEY
*ec2
= keydata2
;
312 const EC_GROUP
*group_a
= EC_KEY_get0_group(ec1
);
313 const EC_GROUP
*group_b
= EC_KEY_get0_group(ec2
);
314 BN_CTX
*ctx
= BN_CTX_new_ex(ec_key_get_libctx(ec1
));
317 if (!ossl_prov_is_running())
320 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) != 0)
321 ok
= ok
&& group_a
!= NULL
&& group_b
!= NULL
322 && EC_GROUP_cmp(group_a
, group_b
, ctx
) == 0;
323 if ((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
) != 0) {
324 const BIGNUM
*pa
= EC_KEY_get0_private_key(ec1
);
325 const BIGNUM
*pb
= EC_KEY_get0_private_key(ec2
);
327 ok
= ok
&& BN_cmp(pa
, pb
) == 0;
329 if ((selection
& OSSL_KEYMGMT_SELECT_PUBLIC_KEY
) != 0) {
330 const EC_POINT
*pa
= EC_KEY_get0_public_key(ec1
);
331 const EC_POINT
*pb
= EC_KEY_get0_public_key(ec2
);
333 ok
= ok
&& EC_POINT_cmp(group_b
, pa
, pb
, ctx
) == 0;
340 int common_import(void *keydata
, int selection
, const OSSL_PARAM params
[],
343 EC_KEY
*ec
= keydata
;
344 const EC_GROUP
*ecg
= NULL
;
347 if (!ossl_prov_is_running() || ec
== NULL
)
351 * In this implementation, we can export/import only keydata in the
352 * following combinations:
353 * - domain parameters (+optional other params)
354 * - public key with associated domain parameters (+optional other params)
355 * - private key with associated public key and domain parameters
356 * (+optional other params)
359 * - domain parameters must always be requested
360 * - private key must be requested alongside public key
361 * - other parameters are always optional
363 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) == 0)
365 if ((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
) != 0
366 && (selection
& OSSL_KEYMGMT_SELECT_PUBLIC_KEY
) == 0)
369 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) != 0)
370 ok
= ok
&& ec_group_fromdata(ec
, params
);
373 * sm2_curve: import the keys or domparams only on SM2 Curve
374 * !sm2_curve: import the keys or domparams only not on SM2 Curve
376 if ((ecg
= EC_KEY_get0_group(ec
)) == NULL
377 || (sm2_curve
^ (EC_GROUP_get_curve_name(ecg
) == NID_sm2
)))
380 if ((selection
& OSSL_KEYMGMT_SELECT_KEYPAIR
) != 0) {
381 int include_private
=
382 selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
? 1 : 0;
384 ok
= ok
&& ec_key_fromdata(ec
, params
, include_private
);
386 if ((selection
& OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS
) != 0)
387 ok
= ok
&& ec_key_otherparams_fromdata(ec
, params
);
393 int ec_import(void *keydata
, int selection
, const OSSL_PARAM params
[])
395 return common_import(keydata
, selection
, params
, 0);
398 #ifndef OPENSSL_NO_SM2
400 int sm2_import(void *keydata
, int selection
, const OSSL_PARAM params
[])
402 return common_import(keydata
, selection
, params
, 1);
407 int ec_export(void *keydata
, int selection
, OSSL_CALLBACK
*param_cb
,
410 EC_KEY
*ec
= keydata
;
411 OSSL_PARAM_BLD
*tmpl
= NULL
;
412 OSSL_PARAM
*params
= NULL
;
413 unsigned char *pub_key
= NULL
, *genbuf
= NULL
;
414 BN_CTX
*bnctx
= NULL
;
417 if (!ossl_prov_is_running() || ec
== NULL
)
421 * In this implementation, we can export/import only keydata in the
422 * following combinations:
423 * - domain parameters (+optional other params)
424 * - public key with associated domain parameters (+optional other params)
425 * - private key with associated public key and domain parameters
426 * (+optional other params)
429 * - domain parameters must always be requested
430 * - private key must be requested alongside public key
431 * - other parameters are always optional
433 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) == 0)
435 if ((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
) != 0
436 && (selection
& OSSL_KEYMGMT_SELECT_PUBLIC_KEY
) == 0)
438 if ((selection
& OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS
) != 0
439 && (selection
& OSSL_KEYMGMT_SELECT_KEYPAIR
) == 0)
442 tmpl
= OSSL_PARAM_BLD_new();
446 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) != 0) {
447 bnctx
= BN_CTX_new_ex(ec_key_get_libctx(ec
));
453 ok
= ok
&& ec_group_todata(EC_KEY_get0_group(ec
), tmpl
, NULL
,
454 ec_key_get_libctx(ec
), ec_key_get0_propq(ec
),
458 if ((selection
& OSSL_KEYMGMT_SELECT_KEYPAIR
) != 0) {
459 int include_private
=
460 selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
? 1 : 0;
462 ok
= ok
&& key_to_params(ec
, tmpl
, NULL
, include_private
, &pub_key
);
464 if ((selection
& OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS
) != 0)
465 ok
= ok
&& otherparams_to_params(ec
, tmpl
, NULL
);
467 if (ok
&& (params
= OSSL_PARAM_BLD_to_param(tmpl
)) != NULL
)
468 ok
= param_cb(params
, cbarg
);
470 OSSL_PARAM_BLD_free_params(params
);
471 OSSL_PARAM_BLD_free(tmpl
);
472 OPENSSL_free(pub_key
);
473 OPENSSL_free(genbuf
);
479 /* IMEXPORT = IMPORT + EXPORT */
481 # define EC_IMEXPORTABLE_DOM_PARAMETERS \
482 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0), \
483 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_ENCODING, NULL, 0), \
484 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_FIELD_TYPE, NULL, 0), \
485 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_P, NULL, 0), \
486 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_A, NULL, 0), \
487 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_B, NULL, 0), \
488 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_GENERATOR, NULL, 0), \
489 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_ORDER, NULL, 0), \
490 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_COFACTOR, NULL, 0), \
491 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_SEED, NULL, 0)
493 # define EC_IMEXPORTABLE_PUBLIC_KEY \
494 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0)
495 # define EC_IMEXPORTABLE_PRIVATE_KEY \
496 OSSL_PARAM_BN(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0)
497 # define EC_IMEXPORTABLE_OTHER_PARAMETERS \
498 OSSL_PARAM_int(OSSL_PKEY_PARAM_USE_COFACTOR_ECDH, NULL)
501 * Include all the possible combinations of OSSL_PARAM arrays for
502 * ec_imexport_types().
504 * They are in a separate file as it is ~100 lines of unreadable and
505 * uninteresting machine generated stuff.
507 * TODO(3.0): the generated list looks quite ugly, as to cover all possible
508 * combinations of the bits in `selection`, it also includes combinations that
509 * are not really useful: we might want to consider alternatives to this
512 #include "ec_kmgmt_imexport.inc"
515 const OSSL_PARAM
*ec_imexport_types(int selection
)
519 if ((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
) != 0)
521 if ((selection
& OSSL_KEYMGMT_SELECT_PUBLIC_KEY
) != 0)
523 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) != 0)
525 if ((selection
& OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS
) != 0)
527 return ec_types
[type_select
];
531 const OSSL_PARAM
*ec_import_types(int selection
)
533 return ec_imexport_types(selection
);
537 const OSSL_PARAM
*ec_export_types(int selection
)
539 return ec_imexport_types(selection
);
542 static int ec_get_ecm_params(const EC_GROUP
*group
, OSSL_PARAM params
[])
544 #ifdef OPENSSL_NO_EC2M
548 unsigned int k1
= 0, k2
= 0, k3
= 0;
550 const char *basis_name
= NULL
;
551 int fid
= EC_GROUP_get_field_type(group
);
553 if (fid
!= NID_X9_62_characteristic_two_field
)
556 basis_nid
= EC_GROUP_get_basis_type(group
);
557 if (basis_nid
== NID_X9_62_tpBasis
)
558 basis_name
= SN_X9_62_tpBasis
;
559 else if (basis_nid
== NID_X9_62_ppBasis
)
560 basis_name
= SN_X9_62_ppBasis
;
564 m
= EC_GROUP_get_degree(group
);
565 if (!ossl_param_build_set_int(NULL
, params
, OSSL_PKEY_PARAM_EC_CHAR2_M
, m
)
566 || !ossl_param_build_set_utf8_string(NULL
, params
,
567 OSSL_PKEY_PARAM_EC_CHAR2_TYPE
,
571 if (basis_nid
== NID_X9_62_tpBasis
) {
572 if (!EC_GROUP_get_trinomial_basis(group
, &k1
)
573 || !ossl_param_build_set_int(NULL
, params
,
574 OSSL_PKEY_PARAM_EC_CHAR2_TP_BASIS
,
578 if (!EC_GROUP_get_pentanomial_basis(group
, &k1
, &k2
, &k3
)
579 || !ossl_param_build_set_int(NULL
, params
,
580 OSSL_PKEY_PARAM_EC_CHAR2_PP_K1
, (int)k1
)
581 || !ossl_param_build_set_int(NULL
, params
,
582 OSSL_PKEY_PARAM_EC_CHAR2_PP_K2
, (int)k2
)
583 || !ossl_param_build_set_int(NULL
, params
,
584 OSSL_PKEY_PARAM_EC_CHAR2_PP_K3
, (int)k3
))
590 #endif /* OPENSSL_NO_EC2M */
594 int ec_get_params(void *key
, OSSL_PARAM params
[])
598 const EC_GROUP
*ecg
= NULL
;
600 unsigned char *pub_key
= NULL
, *genbuf
= NULL
;
603 BN_CTX
*bnctx
= NULL
;
605 ecg
= EC_KEY_get0_group(eck
);
609 libctx
= ec_key_get_libctx(eck
);
610 propq
= ec_key_get0_propq(eck
);
612 bnctx
= BN_CTX_new_ex(libctx
);
617 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_MAX_SIZE
)) != NULL
618 && !OSSL_PARAM_set_int(p
, ECDSA_size(eck
)))
620 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_BITS
)) != NULL
621 && !OSSL_PARAM_set_int(p
, EC_GROUP_order_bits(ecg
)))
623 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_SECURITY_BITS
)) != NULL
) {
624 int ecbits
, sec_bits
;
626 ecbits
= EC_GROUP_order_bits(ecg
);
629 * The following estimates are based on the values published
630 * in Table 2 of "NIST Special Publication 800-57 Part 1 Revision 4"
631 * at http://dx.doi.org/10.6028/NIST.SP.800-57pt1r4 .
633 * Note that the above reference explicitly categorizes algorithms in a
634 * discrete set of values {80, 112, 128, 192, 256}, and that it is
635 * relevant only for NIST approved Elliptic Curves, while OpenSSL
636 * applies the same logic also to other curves.
638 * Classifications produced by other standardazing bodies might differ,
639 * so the results provided for "bits of security" by this provider are
640 * to be considered merely indicative, and it is the users'
641 * responsibility to compare these values against the normative
642 * references that may be relevant for their intent and purposes.
646 else if (ecbits
>= 384)
648 else if (ecbits
>= 256)
650 else if (ecbits
>= 224)
652 else if (ecbits
>= 160)
655 sec_bits
= ecbits
/ 2;
657 if (!OSSL_PARAM_set_int(p
, sec_bits
))
661 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_DEFAULT_DIGEST
)) != NULL
662 && !OSSL_PARAM_set_utf8_string(p
, EC_DEFAULT_MD
))
665 p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH
);
667 int ecdh_cofactor_mode
= 0;
670 (EC_KEY_get_flags(eck
) & EC_FLAG_COFACTOR_ECDH
) ? 1 : 0;
672 if (!OSSL_PARAM_set_int(p
, ecdh_cofactor_mode
))
675 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_TLS_ENCODED_PT
)) != NULL
) {
676 p
->return_size
= EC_POINT_point2oct(EC_KEY_get0_group(key
),
677 EC_KEY_get0_public_key(key
),
678 POINT_CONVERSION_UNCOMPRESSED
,
679 p
->data
, p
->return_size
, bnctx
);
680 if (p
->return_size
== 0)
684 ret
= ec_get_ecm_params(ecg
, params
)
685 && ec_group_todata(ecg
, NULL
, params
, libctx
, propq
, bnctx
, &genbuf
)
686 && key_to_params(eck
, NULL
, params
, 1, &pub_key
)
687 && otherparams_to_params(eck
, NULL
, params
);
689 OPENSSL_free(genbuf
);
690 OPENSSL_free(pub_key
);
696 #ifndef OPENSSL_NO_EC2M
697 # define EC2M_GETTABLE_DOM_PARAMS \
698 OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_CHAR2_M, NULL), \
699 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_CHAR2_TYPE, NULL, 0), \
700 OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_CHAR2_TP_BASIS, NULL), \
701 OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_CHAR2_PP_K1, NULL), \
702 OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_CHAR2_PP_K2, NULL), \
703 OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_CHAR2_PP_K3, NULL),
705 # define EC2M_GETTABLE_DOM_PARAMS
708 static const OSSL_PARAM ec_known_gettable_params
[] = {
709 OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS
, NULL
),
710 OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS
, NULL
),
711 OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE
, NULL
),
712 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_TLS_ENCODED_PT
, NULL
, 0),
713 EC_IMEXPORTABLE_DOM_PARAMETERS
,
714 EC2M_GETTABLE_DOM_PARAMS
715 EC_IMEXPORTABLE_PUBLIC_KEY
,
716 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_PUB_X
, NULL
, 0),
717 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_PUB_Y
, NULL
, 0),
718 EC_IMEXPORTABLE_PRIVATE_KEY
,
719 EC_IMEXPORTABLE_OTHER_PARAMETERS
,
724 const OSSL_PARAM
*ec_gettable_params(void *provctx
)
726 return ec_known_gettable_params
;
729 static const OSSL_PARAM ec_known_settable_params
[] = {
730 OSSL_PARAM_int(OSSL_PKEY_PARAM_USE_COFACTOR_ECDH
, NULL
),
731 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_TLS_ENCODED_PT
, NULL
, 0),
736 const OSSL_PARAM
*ec_settable_params(void *provctx
)
738 return ec_known_settable_params
;
742 int ec_set_params(void *key
, const OSSL_PARAM params
[])
747 p
= OSSL_PARAM_locate_const(params
, OSSL_PKEY_PARAM_TLS_ENCODED_PT
);
749 BN_CTX
*ctx
= BN_CTX_new_ex(ec_key_get_libctx(key
));
753 || p
->data_type
!= OSSL_PARAM_OCTET_STRING
754 || !EC_KEY_oct2key(key
, p
->data
, p
->data_size
, ctx
))
761 return ec_key_otherparams_fromdata(eck
, params
);
764 #ifndef OPENSSL_NO_SM2
766 int sm2_get_params(void *key
, OSSL_PARAM params
[])
770 const EC_GROUP
*ecg
= NULL
;
772 unsigned char *pub_key
= NULL
;
774 ecg
= EC_KEY_get0_group(eck
);
778 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_MAX_SIZE
)) != NULL
779 && !OSSL_PARAM_set_int(p
, ECDSA_size(eck
)))
781 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_BITS
)) != NULL
782 && !OSSL_PARAM_set_int(p
, EC_GROUP_order_bits(ecg
)))
786 * I dropped the support of OSSL_PKEY_PARAM_SECURITY_BITS since
787 * I didn't find definition of SM2 security bits so far. This could
788 * be supported if the definition is clear in the future.
791 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_DEFAULT_DIGEST
)) != NULL
792 && !OSSL_PARAM_set_utf8_string(p
, SM2_DEFAULT_MD
))
795 if ((p
= OSSL_PARAM_locate(params
, OSSL_PKEY_PARAM_TLS_ENCODED_PT
)) != NULL
) {
796 BN_CTX
*ctx
= BN_CTX_new_ex(ec_key_get_libctx(key
));
800 p
->return_size
= EC_POINT_point2oct(EC_KEY_get0_group(key
),
801 EC_KEY_get0_public_key(key
),
802 POINT_CONVERSION_UNCOMPRESSED
,
803 p
->data
, p
->return_size
, ctx
);
805 if (p
->return_size
== 0)
809 ret
= domparams_to_params(eck
, NULL
, params
)
810 && key_to_params(eck
, NULL
, params
, 1, &pub_key
);
811 OPENSSL_free(pub_key
);
815 static const OSSL_PARAM sm2_known_gettable_params
[] = {
816 OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS
, NULL
),
817 OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE
, NULL
),
818 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_TLS_ENCODED_PT
, NULL
, 0),
819 EC_IMEXPORTABLE_DOM_PARAMETERS
,
820 EC_IMEXPORTABLE_PUBLIC_KEY
,
821 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_PUB_X
, NULL
, 0),
822 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_PUB_Y
, NULL
, 0),
823 EC_IMEXPORTABLE_PRIVATE_KEY
,
828 const OSSL_PARAM
*sm2_gettable_params(ossl_unused
void *provctx
)
830 return sm2_known_gettable_params
;
833 static const OSSL_PARAM sm2_known_settable_params
[] = {
834 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_TLS_ENCODED_PT
, NULL
, 0),
839 const OSSL_PARAM
*sm2_settable_params(ossl_unused
void *provctx
)
841 return sm2_known_settable_params
;
846 int ec_validate(void *keydata
, int selection
)
848 EC_KEY
*eck
= keydata
;
850 BN_CTX
*ctx
= BN_CTX_new_ex(ec_key_get_libctx(eck
));
852 if (!ossl_prov_is_running() || ctx
== NULL
)
855 if ((selection
& EC_POSSIBLE_SELECTIONS
) != 0)
858 if ((selection
& OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
) != 0)
859 ok
= ok
&& EC_GROUP_check(EC_KEY_get0_group(eck
), ctx
);
861 if ((selection
& OSSL_KEYMGMT_SELECT_PUBLIC_KEY
) != 0)
862 ok
= ok
&& ec_key_public_check(eck
, ctx
);
864 if ((selection
& OSSL_KEYMGMT_SELECT_PRIVATE_KEY
) != 0)
865 ok
= ok
&& ec_key_private_check(eck
);
867 if ((selection
& OSSL_KEYMGMT_SELECT_KEYPAIR
) == OSSL_KEYMGMT_SELECT_KEYPAIR
)
868 ok
= ok
&& ec_key_pairwise_check(eck
, ctx
);
879 BIGNUM
*p
, *a
, *b
, *order
, *cofactor
;
880 unsigned char *gen
, *seed
;
881 size_t gen_len
, seed_len
;
887 static void *ec_gen_init(void *provctx
, int selection
)
889 OPENSSL_CTX
*libctx
= PROV_LIBRARY_CONTEXT_OF(provctx
);
890 struct ec_gen_ctx
*gctx
= NULL
;
892 if (!ossl_prov_is_running() || (selection
& (EC_POSSIBLE_SELECTIONS
)) == 0)
895 if ((gctx
= OPENSSL_zalloc(sizeof(*gctx
))) != NULL
) {
896 gctx
->libctx
= libctx
;
897 gctx
->selection
= selection
;
903 static int ec_gen_set_group(void *genctx
, const EC_GROUP
*src
)
905 struct ec_gen_ctx
*gctx
= genctx
;
908 group
= EC_GROUP_dup(src
);
910 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_CURVE
);
913 EC_GROUP_free(gctx
->gen_group
);
914 gctx
->gen_group
= group
;
918 static int ec_gen_set_template(void *genctx
, void *templ
)
920 struct ec_gen_ctx
*gctx
= genctx
;
922 const EC_GROUP
*ec_group
;
924 if (!ossl_prov_is_running() || gctx
== NULL
|| ec
== NULL
)
926 if ((ec_group
= EC_KEY_get0_group(ec
)) == NULL
)
928 return ec_gen_set_group(gctx
, ec_group
);
931 #define COPY_INT_PARAM(params, key, val) \
932 p = OSSL_PARAM_locate_const(params, key); \
933 if (p != NULL && !OSSL_PARAM_get_int(p, &val)) \
936 #define COPY_UTF8_PARAM(params, key, val) \
937 p = OSSL_PARAM_locate_const(params, key); \
939 if (p->data_type != OSSL_PARAM_UTF8_STRING) \
942 val = OPENSSL_strdup(p->data); \
947 #define COPY_OCTET_PARAM(params, key, val, len) \
948 p = OSSL_PARAM_locate_const(params, key); \
950 if (p->data_type != OSSL_PARAM_OCTET_STRING) \
953 len = p->data_size; \
954 val = OPENSSL_memdup(p->data, p->data_size); \
959 #define COPY_BN_PARAM(params, key, bn) \
960 p = OSSL_PARAM_locate_const(params, key); \
964 if (bn == NULL || !OSSL_PARAM_get_BN(p, &bn)) \
968 static int ec_gen_set_params(void *genctx
, const OSSL_PARAM params
[])
971 struct ec_gen_ctx
*gctx
= genctx
;
973 EC_GROUP
*group
= NULL
;
975 COPY_INT_PARAM(params
, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH
, gctx
->ecdh_mode
);
977 COPY_UTF8_PARAM(params
, OSSL_PKEY_PARAM_GROUP_NAME
, gctx
->group_name
);
978 COPY_UTF8_PARAM(params
, OSSL_PKEY_PARAM_EC_FIELD_TYPE
, gctx
->field_type
);
979 COPY_UTF8_PARAM(params
, OSSL_PKEY_PARAM_EC_ENCODING
, gctx
->encoding
);
981 COPY_BN_PARAM(params
, OSSL_PKEY_PARAM_EC_P
, gctx
->p
);
982 COPY_BN_PARAM(params
, OSSL_PKEY_PARAM_EC_A
, gctx
->a
);
983 COPY_BN_PARAM(params
, OSSL_PKEY_PARAM_EC_B
, gctx
->b
);
984 COPY_BN_PARAM(params
, OSSL_PKEY_PARAM_EC_ORDER
, gctx
->order
);
985 COPY_BN_PARAM(params
, OSSL_PKEY_PARAM_EC_COFACTOR
, gctx
->cofactor
);
987 COPY_OCTET_PARAM(params
, OSSL_PKEY_PARAM_EC_SEED
, gctx
->seed
, gctx
->seed_len
);
988 COPY_OCTET_PARAM(params
, OSSL_PKEY_PARAM_EC_GENERATOR
, gctx
->gen
,
993 EC_GROUP_free(group
);
997 static int ec_gen_set_group_from_params(struct ec_gen_ctx
*gctx
)
1000 OSSL_PARAM_BLD
*bld
;
1001 OSSL_PARAM
*params
= NULL
;
1002 EC_GROUP
*group
= NULL
;
1004 bld
= OSSL_PARAM_BLD_new();
1008 if (gctx
->encoding
!= NULL
1009 && !OSSL_PARAM_BLD_push_utf8_string(bld
, OSSL_PKEY_PARAM_EC_ENCODING
,
1013 if (gctx
->group_name
!= NULL
) {
1014 if (!OSSL_PARAM_BLD_push_utf8_string(bld
, OSSL_PKEY_PARAM_GROUP_NAME
,
1015 gctx
->group_name
, 0))
1017 /* Ignore any other parameters if there is a group name */
1019 } else if (gctx
->field_type
!= NULL
) {
1020 if (!OSSL_PARAM_BLD_push_utf8_string(bld
, OSSL_PKEY_PARAM_EC_FIELD_TYPE
,
1021 gctx
->field_type
, 0))
1029 || gctx
->order
== NULL
1030 || !OSSL_PARAM_BLD_push_BN(bld
, OSSL_PKEY_PARAM_EC_P
, gctx
->p
)
1031 || !OSSL_PARAM_BLD_push_BN(bld
, OSSL_PKEY_PARAM_EC_A
, gctx
->a
)
1032 || !OSSL_PARAM_BLD_push_BN(bld
, OSSL_PKEY_PARAM_EC_B
, gctx
->b
)
1033 || !OSSL_PARAM_BLD_push_BN(bld
, OSSL_PKEY_PARAM_EC_ORDER
, gctx
->order
))
1036 if (gctx
->cofactor
!= NULL
1037 && !OSSL_PARAM_BLD_push_BN(bld
, OSSL_PKEY_PARAM_EC_COFACTOR
,
1041 if (gctx
->seed
!= NULL
1042 && !OSSL_PARAM_BLD_push_octet_string(bld
, OSSL_PKEY_PARAM_EC_SEED
,
1043 gctx
->seed
, gctx
->seed_len
))
1046 if (gctx
->gen
== NULL
1047 || !OSSL_PARAM_BLD_push_octet_string(bld
, OSSL_PKEY_PARAM_EC_GENERATOR
,
1048 gctx
->gen
, gctx
->gen_len
))
1051 params
= OSSL_PARAM_BLD_to_param(bld
);
1054 group
= EC_GROUP_new_from_params(params
, gctx
->libctx
, NULL
);
1058 EC_GROUP_free(gctx
->gen_group
);
1059 gctx
->gen_group
= group
;
1063 OSSL_PARAM_BLD_free_params(params
);
1064 OSSL_PARAM_BLD_free(bld
);
1068 static const OSSL_PARAM
*ec_gen_settable_params(void *provctx
)
1070 static OSSL_PARAM settable
[] = {
1071 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME
, NULL
, 0),
1072 OSSL_PARAM_int(OSSL_PKEY_PARAM_USE_COFACTOR_ECDH
, NULL
),
1073 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_ENCODING
, NULL
, 0),
1074 OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_FIELD_TYPE
, NULL
, 0),
1075 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_P
, NULL
, 0),
1076 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_A
, NULL
, 0),
1077 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_B
, NULL
, 0),
1078 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_GENERATOR
, NULL
, 0),
1079 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_ORDER
, NULL
, 0),
1080 OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_COFACTOR
, NULL
, 0),
1081 OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_SEED
, NULL
, 0),
1088 static int ec_gen_assign_group(EC_KEY
*ec
, EC_GROUP
*group
)
1090 if (group
== NULL
) {
1091 ERR_raise(ERR_LIB_PROV
, PROV_R_NO_PARAMETERS_SET
);
1094 return EC_KEY_set_group(ec
, group
) > 0;
1098 * The callback arguments (osslcb & cbarg) are not used by EC_KEY generation
1100 static void *ec_gen(void *genctx
, OSSL_CALLBACK
*osslcb
, void *cbarg
)
1102 struct ec_gen_ctx
*gctx
= genctx
;
1106 if (!ossl_prov_is_running()
1108 || (ec
= EC_KEY_new_with_libctx(gctx
->libctx
, NULL
)) == NULL
)
1111 if (gctx
->gen_group
== NULL
) {
1112 if (!ec_gen_set_group_from_params(gctx
))
1115 if (gctx
->encoding
) {
1116 int flags
= ec_encoding_name2id(gctx
->encoding
);
1119 EC_GROUP_set_asn1_flag(gctx
->gen_group
, flags
);
1123 /* We must always assign a group, no matter what */
1124 ret
= ec_gen_assign_group(ec
, gctx
->gen_group
);
1126 /* Whether you want it or not, you get a keypair, not just one half */
1127 if ((gctx
->selection
& OSSL_KEYMGMT_SELECT_KEYPAIR
) != 0)
1128 ret
= ret
&& EC_KEY_generate_key(ec
);
1130 if (gctx
->ecdh_mode
!= -1)
1131 ret
= ret
&& ec_set_ecdh_cofactor_mode(ec
, gctx
->ecdh_mode
);
1136 /* Something went wrong, throw the key away */
1141 #ifndef OPENSSL_NO_SM2
1143 * The callback arguments (osslcb & cbarg) are not used by EC_KEY generation
1145 static void *sm2_gen(void *genctx
, OSSL_CALLBACK
*osslcb
, void *cbarg
)
1147 struct ec_gen_ctx
*gctx
= genctx
;
1152 || (ec
= EC_KEY_new_with_libctx(gctx
->libctx
, NULL
)) == NULL
)
1155 if (gctx
->gen_group
== NULL
) {
1156 if (!ec_gen_set_group_from_params(gctx
))
1159 if (gctx
->encoding
) {
1160 int flags
= ec_encoding_name2id(gctx
->encoding
);
1163 EC_GROUP_set_asn1_flag(gctx
->gen_group
, flags
);
1167 /* We must always assign a group, no matter what */
1168 ret
= ec_gen_assign_group(ec
, gctx
->gen_group
);
1170 /* Whether you want it or not, you get a keypair, not just one half */
1171 if ((gctx
->selection
& OSSL_KEYMGMT_SELECT_KEYPAIR
) != 0) {
1173 * For SM2, we need a new flag to indicate the 'generate' function
1174 * to use a new range
1176 EC_KEY_set_flags(ec
, EC_FLAG_SM2_RANGE
);
1177 ret
= ret
&& EC_KEY_generate_key(ec
);
1183 /* Something went wrong, throw the key away */
1189 static void ec_gen_cleanup(void *genctx
)
1191 struct ec_gen_ctx
*gctx
= genctx
;
1196 EC_GROUP_free(gctx
->gen_group
);
1200 BN_free(gctx
->order
);
1201 BN_free(gctx
->cofactor
);
1202 OPENSSL_free(gctx
->group_name
);
1203 OPENSSL_free(gctx
->field_type
);;
1204 OPENSSL_free(gctx
->encoding
);
1205 OPENSSL_free(gctx
->seed
);
1206 OPENSSL_free(gctx
->gen
);
1210 void *ec_load(const void *reference
, size_t reference_sz
)
1214 if (ossl_prov_is_running() && reference_sz
== sizeof(ec
)) {
1215 /* The contents of the reference is the address to our object */
1216 ec
= *(EC_KEY
**)reference
;
1217 /* We grabbed, so we detach it */
1218 *(EC_KEY
**)reference
= NULL
;
1224 const OSSL_DISPATCH ec_keymgmt_functions
[] = {
1225 { OSSL_FUNC_KEYMGMT_NEW
, (void (*)(void))ec_newdata
},
1226 { OSSL_FUNC_KEYMGMT_GEN_INIT
, (void (*)(void))ec_gen_init
},
1227 { OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE
,
1228 (void (*)(void))ec_gen_set_template
},
1229 { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS
, (void (*)(void))ec_gen_set_params
},
1230 { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS
,
1231 (void (*)(void))ec_gen_settable_params
},
1232 { OSSL_FUNC_KEYMGMT_GEN
, (void (*)(void))ec_gen
},
1233 { OSSL_FUNC_KEYMGMT_GEN_CLEANUP
, (void (*)(void))ec_gen_cleanup
},
1234 { OSSL_FUNC_KEYMGMT_LOAD
, (void (*)(void))ec_load
},
1235 { OSSL_FUNC_KEYMGMT_FREE
, (void (*)(void))ec_freedata
},
1236 { OSSL_FUNC_KEYMGMT_GET_PARAMS
, (void (*) (void))ec_get_params
},
1237 { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS
, (void (*) (void))ec_gettable_params
},
1238 { OSSL_FUNC_KEYMGMT_SET_PARAMS
, (void (*) (void))ec_set_params
},
1239 { OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS
, (void (*) (void))ec_settable_params
},
1240 { OSSL_FUNC_KEYMGMT_HAS
, (void (*)(void))ec_has
},
1241 { OSSL_FUNC_KEYMGMT_MATCH
, (void (*)(void))ec_match
},
1242 { OSSL_FUNC_KEYMGMT_VALIDATE
, (void (*)(void))ec_validate
},
1243 { OSSL_FUNC_KEYMGMT_IMPORT
, (void (*)(void))ec_import
},
1244 { OSSL_FUNC_KEYMGMT_IMPORT_TYPES
, (void (*)(void))ec_import_types
},
1245 { OSSL_FUNC_KEYMGMT_EXPORT
, (void (*)(void))ec_export
},
1246 { OSSL_FUNC_KEYMGMT_EXPORT_TYPES
, (void (*)(void))ec_export_types
},
1247 { OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME
,
1248 (void (*)(void))ec_query_operation_name
},
1252 #ifndef OPENSSL_NO_SM2
1253 const OSSL_DISPATCH sm2_keymgmt_functions
[] = {
1254 { OSSL_FUNC_KEYMGMT_NEW
, (void (*)(void))ec_newdata
},
1255 { OSSL_FUNC_KEYMGMT_GEN_INIT
, (void (*)(void))ec_gen_init
},
1256 { OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE
,
1257 (void (*)(void))ec_gen_set_template
},
1258 { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS
, (void (*)(void))ec_gen_set_params
},
1259 { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS
,
1260 (void (*)(void))ec_gen_settable_params
},
1261 { OSSL_FUNC_KEYMGMT_GEN
, (void (*)(void))sm2_gen
},
1262 { OSSL_FUNC_KEYMGMT_GEN_CLEANUP
, (void (*)(void))ec_gen_cleanup
},
1263 { OSSL_FUNC_KEYMGMT_FREE
, (void (*)(void))ec_freedata
},
1264 { OSSL_FUNC_KEYMGMT_GET_PARAMS
, (void (*) (void))sm2_get_params
},
1265 { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS
, (void (*) (void))sm2_gettable_params
},
1266 { OSSL_FUNC_KEYMGMT_SET_PARAMS
, (void (*) (void))ec_set_params
},
1267 { OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS
, (void (*) (void))sm2_settable_params
},
1268 { OSSL_FUNC_KEYMGMT_HAS
, (void (*)(void))ec_has
},
1269 { OSSL_FUNC_KEYMGMT_MATCH
, (void (*)(void))ec_match
},
1270 { OSSL_FUNC_KEYMGMT_VALIDATE
, (void (*)(void))ec_validate
},
1271 { OSSL_FUNC_KEYMGMT_IMPORT
, (void (*)(void))sm2_import
},
1272 { OSSL_FUNC_KEYMGMT_IMPORT_TYPES
, (void (*)(void))ec_import_types
},
1273 { OSSL_FUNC_KEYMGMT_EXPORT
, (void (*)(void))ec_export
},
1274 { OSSL_FUNC_KEYMGMT_EXPORT_TYPES
, (void (*)(void))ec_export_types
},
1275 { OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME
,
1276 (void (*)(void))sm2_query_operation_name
},