From 11a1b341f3bc6a0afe75f9432f623026624fb720 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 19 May 2020 15:24:25 +0100 Subject: [PATCH] Make EVP_PKEY_CTX_[get|set]_ec_paramgen_curve_name more generic We rename these function to EVP_PKEY_CTX_get_group_name and EVP_PKEY_CTX_set_group_name so that they can be used for other algorithms other than EC. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/11914) --- crypto/ec/ec_ameth.c | 2 +- crypto/ec/ec_backend.c | 2 +- crypto/ec/ec_ctrl.c | 44 +------------------- crypto/evp/evp_lib.c | 40 ++++++++++++++++++ crypto/evp/p_lib.c | 2 +- crypto/evp/pmeth_gn.c | 2 +- crypto/evp/pmeth_lib.c | 4 +- doc/man3/EVP_PKEY_CTX_ctrl.pod | 38 ++++++++++------- doc/man3/EVP_PKEY_gettable_params.pod | 2 +- doc/man7/EVP_PKEY-EC.pod | 8 ++-- include/openssl/core_names.h | 2 +- include/openssl/ec.h | 4 -- include/openssl/evp.h | 3 ++ providers/fips/self_test_data.inc | 4 +- providers/implementations/keymgmt/ec_kmgmt.c | 8 ++-- test/acvp_test.c | 8 ++-- test/evp_pkey_provided_test.c | 6 +-- util/libcrypto.num | 4 +- 18 files changed, 92 insertions(+), 91 deletions(-) diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 6ccaef3815..bde8458274 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -611,7 +611,7 @@ int ecparams_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl) if ((curve_name = OBJ_nid2sn(curve_nid)) == NULL) return 0; - if (!OSSL_PARAM_BLD_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME, curve_name, 0)) + if (!OSSL_PARAM_BLD_push_utf8_string(tmpl, OSSL_PKEY_PARAM_GROUP_NAME, curve_name, 0)) return 0; } diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c index fb6497b084..b12a9411d2 100644 --- a/crypto/ec/ec_backend.c +++ b/crypto/ec/ec_backend.c @@ -173,7 +173,7 @@ int ec_key_domparams_fromdata(EC_KEY *ec, const OSSL_PARAM params[]) if (ec == NULL) return 0; - param_ec_name = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_EC_NAME); + param_ec_name = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_GROUP_NAME); if (param_ec_name == NULL) { /* explicit parameters */ diff --git a/crypto/ec/ec_ctrl.c b/crypto/ec/ec_ctrl.c index 9e12b9a159..b47d7b606c 100644 --- a/crypto/ec/ec_ctrl.c +++ b/crypto/ec/ec_ctrl.c @@ -421,48 +421,6 @@ int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **pukm) return (int)ukmlen; } -int EVP_PKEY_CTX_set_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx, - const char *name) -{ - OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END }; - OSSL_PARAM *p = params; - - if (ctx == NULL || !EVP_PKEY_CTX_IS_GEN_OP(ctx)) { - ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED); - /* Uses the same return values as EVP_PKEY_CTX_ctrl */ - return -2; - } - - if (name == NULL) - return -1; - - *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_EC_NAME, - (char *)name, 0); - return EVP_PKEY_CTX_set_params(ctx, params); -} - -int EVP_PKEY_CTX_get_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx, - char *name, size_t namelen) -{ - OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END }; - OSSL_PARAM *p = params; - - if (ctx == NULL || !EVP_PKEY_CTX_IS_GEN_OP(ctx)) { - ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED); - /* Uses the same return values as EVP_PKEY_CTX_ctrl */ - return -2; - } - - if (name == NULL) - return -1; - - *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_EC_NAME, - name, namelen); - if (!EVP_PKEY_CTX_get_params(ctx, params)) - return -1; - return 1; -} - #ifndef FIPS_MODULE int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid) { @@ -483,6 +441,6 @@ int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid) EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL); - return EVP_PKEY_CTX_set_ec_paramgen_curve_name(ctx, OBJ_nid2sn(nid)); + return EVP_PKEY_CTX_set_group_name(ctx, OBJ_nid2sn(nid)); } #endif diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 229485102a..00d6b27177 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -940,3 +940,43 @@ int EVP_hex2ctrl(int (*cb)(void *ctx, int cmd, void *buf, size_t buflen), OPENSSL_free(bin); return rv; } + +int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name) +{ + OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END }; + OSSL_PARAM *p = params; + + if (ctx == NULL || !EVP_PKEY_CTX_IS_GEN_OP(ctx)) { + ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED); + /* Uses the same return values as EVP_PKEY_CTX_ctrl */ + return -2; + } + + if (name == NULL) + return -1; + + *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, + (char *)name, 0); + return EVP_PKEY_CTX_set_params(ctx, params); +} + +int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen) +{ + OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END }; + OSSL_PARAM *p = params; + + if (ctx == NULL || !EVP_PKEY_CTX_IS_GEN_OP(ctx)) { + ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED); + /* Uses the same return values as EVP_PKEY_CTX_ctrl */ + return -2; + } + + if (name == NULL) + return -1; + + *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, + name, namelen); + if (!EVP_PKEY_CTX_get_params(ctx, params)) + return -1; + return 1; +} diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 0b067c8a8c..4dc1e0a5b2 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1000,7 +1000,7 @@ static int get_ec_curve_name_cb(const OSSL_PARAM params[], void *arg) { const OSSL_PARAM *p = NULL; - if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_EC_NAME)) != NULL) + if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_GROUP_NAME)) != NULL) return OSSL_PARAM_get_utf8_string(p, arg, 0); /* If there is no curve name, this is not an EC key */ diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c index 411f270b49..1ab309329d 100644 --- a/crypto/evp/pmeth_gn.c +++ b/crypto/evp/pmeth_gn.c @@ -228,7 +228,7 @@ int EVP_PKEY_gen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey) { char curve_name[OSSL_MAX_NAME_SIZE] = ""; - if (!EVP_PKEY_get_utf8_string_param(*ppkey, OSSL_PKEY_PARAM_EC_NAME, + if (!EVP_PKEY_get_utf8_string_param(*ppkey, OSSL_PKEY_PARAM_GROUP_NAME, curve_name, sizeof(curve_name), NULL) || strcmp(curve_name, "SM2") != 0) diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index dd6556c891..4c1c01c703 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -605,7 +605,6 @@ int EVP_PKEY_CTX_set_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params) return 0; } -#ifndef FIPS_MODULE int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params) { if (EVP_PKEY_CTX_IS_DERIVE_OP(ctx) @@ -629,6 +628,7 @@ int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params) return 0; } +#ifndef FIPS_MODULE const OSSL_PARAM *EVP_PKEY_CTX_gettable_params(EVP_PKEY_CTX *ctx) { if (EVP_PKEY_CTX_IS_DERIVE_OP(ctx) @@ -1064,7 +1064,7 @@ static int legacy_ctrl_str_to_param(EVP_PKEY_CTX *ctx, const char *name, # endif # ifndef OPENSSL_NO_EC else if (strcmp(name, "ec_paramgen_curve") == 0) - name = OSSL_PKEY_PARAM_EC_NAME; + name = OSSL_PKEY_PARAM_GROUP_NAME; else if (strcmp(name, "ecdh_cofactor_mode") == 0) name = OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE; else if (strcmp(name, "ecdh_kdf_md") == 0) diff --git a/doc/man3/EVP_PKEY_CTX_ctrl.pod b/doc/man3/EVP_PKEY_CTX_ctrl.pod index db91f01038..1e836fc30e 100644 --- a/doc/man3/EVP_PKEY_CTX_ctrl.pod +++ b/doc/man3/EVP_PKEY_CTX_ctrl.pod @@ -9,6 +9,8 @@ EVP_PKEY_CTX_md, EVP_PKEY_CTX_set_signature_md, EVP_PKEY_CTX_get_signature_md, EVP_PKEY_CTX_set_mac_key, +EVP_PKEY_CTX_set_group_name, +EVP_PKEY_CTX_get_group_name, EVP_PKEY_CTX_set_rsa_padding, EVP_PKEY_CTX_get_rsa_padding, EVP_PKEY_CTX_set_rsa_pss_saltlen, @@ -53,8 +55,6 @@ EVP_PKEY_CTX_set_dh_kdf_outlen, EVP_PKEY_CTX_get_dh_kdf_outlen, EVP_PKEY_CTX_set0_dh_kdf_ukm, EVP_PKEY_CTX_get0_dh_kdf_ukm, -EVP_PKEY_CTX_set_ec_paramgen_curve_name, -EVP_PKEY_CTX_get_ec_paramgen_curve_name, EVP_PKEY_CTX_set_ec_paramgen_curve_nid, EVP_PKEY_CTX_set_ec_param_enc, EVP_PKEY_CTX_set_ecdh_cofactor_mode, @@ -88,6 +88,8 @@ EVP_PKEY_CTX_set1_id, EVP_PKEY_CTX_get1_id, EVP_PKEY_CTX_get1_id_len int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, int len); + int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name); + int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); #include @@ -154,10 +156,6 @@ EVP_PKEY_CTX_set1_id, EVP_PKEY_CTX_get1_id, EVP_PKEY_CTX_get1_id_len #include - int EVP_PKEY_CTX_set_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx, - const char *name); - int EVP_PKEY_CTX_get_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx, - char *name, size_t namelen); int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc); int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int cofactor_mode); @@ -221,6 +219,15 @@ L or similar functions instead of this macro. The EVP_PKEY_CTX_set_mac_key() macro can be used with any of the algorithms supported by the L function. +EVP_PKEY_CTX_set_group_name() sets the group name to I for parameter and +key generation. For example for EC keys this will set the curve name and for +DH keys it will set the name of the finite field group. + +EVP_PKEY_CTX_get_group_name() finds the group name that's currently +set with I, and writes it to the location that I points at, as long +as its size I is large enough to store that name, including a +terminating NUL byte. + =head2 RSA parameters The EVP_PKEY_CTX_set_rsa_padding() function sets the RSA padding mode for I. @@ -524,23 +531,21 @@ by the library and should not be freed by the caller. =head2 EC parameters -EVP_PKEY_CTX_set_ec_paramgen_curve_name() sets the EC curve to I for EC -parameter generation. +Use EVP_PKEY_CTX_set_group_name() (described above) to set the curve name to +I for parameter and key generation. EVP_PKEY_CTX_set_ec_paramgen_curve_nid() does the same as -EVP_PKEY_CTX_set_ec_paramgen_curve_name(), but uses a I rather than a -name string. +EVP_PKEY_CTX_set_group_name(), but is specific to EC and uses a I rather +than a name string. -For EC parameter generation, one of EVP_PKEY_CTX_set_ec_paramgen_curve_name() +For EC parameter generation, one of EVP_PKEY_CTX_set_group_name() or EVP_PKEY_CTX_set_ec_paramgen_curve_nid() must be called or an error occurs because there is no default curve. These function can also be called to set the curve explicitly when generating an EC key. -EVP_PKEY_CTX_get_ec_paramgen_curve_name() finds the curve name that's currently -set with I, and writes it to the location that I points at, as long -as its size I is large enough to store that name, including a -terminating NUL byte. +EVP_PKEY_CTX_get_group_name() (described above) can be used to obtain the curve +name that's currently set with I. The EVP_PKEY_CTX_set_ec_param_enc() macro sets the EC parameter encoding to I when generating EC parameters or an EC key. The encoding can be @@ -642,7 +647,8 @@ From OpenSSL 3.0 they are functions. EVP_PKEY_CTX_get_rsa_oaep_md_name(), EVP_PKEY_CTX_get_rsa_mgf1_md_name(), EVP_PKEY_CTX_set_rsa_mgf1_md_name(), EVP_PKEY_CTX_set_rsa_oaep_md_name(), EVP_PKEY_CTX_set_dsa_paramgen_md_props(), EVP_PKEY_CTX_set_dsa_paramgen_gindex(), -EVP_PKEY_CTX_set_dsa_paramgen_type() and EVP_PKEY_CTX_set_dsa_paramgen_seed() +EVP_PKEY_CTX_set_dsa_paramgen_type(), EVP_PKEY_CTX_set_dsa_paramgen_seed(), +EVP_PKEY_CTX_set_group_name() and EVP_PKEY_CTX_get_group_name() were added in OpenSSL 3.0. The EVP_PKEY_CTX_set1_id(), EVP_PKEY_CTX_get1_id() and diff --git a/doc/man3/EVP_PKEY_gettable_params.pod b/doc/man3/EVP_PKEY_gettable_params.pod index 87d25c7b99..8f6854a568 100644 --- a/doc/man3/EVP_PKEY_gettable_params.pod +++ b/doc/man3/EVP_PKEY_gettable_params.pod @@ -72,7 +72,7 @@ value. * is an EC key. */ - if (!EVP_PKEY_get_utf8_string_param(key, OSSL_PKEY_PARAM_EC_NAME, + if (!EVP_PKEY_get_utf8_string_param(key, OSSL_PKEY_PARAM_GROUP_NAME, curve_name, sizeof(curve_name), &len)) { /* Error */ } diff --git a/doc/man7/EVP_PKEY-EC.pod b/doc/man7/EVP_PKEY-EC.pod index 85e633ceed..ea25d5dc02 100644 --- a/doc/man7/EVP_PKEY-EC.pod +++ b/doc/man7/EVP_PKEY-EC.pod @@ -16,9 +16,9 @@ The following Import/Export types are available for the built-in EC algorithm: =over 4 -=item "curve-name" (B) +=item "group-name" (B) -The EC curve name. +The curve name. =item "use-cofactor-flag" (B) @@ -63,7 +63,7 @@ calling: EVP_PKEY_keygen_init(gctx); - params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_EC_NAME, + params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, "P-256", 0); params[1] = OSSL_PARAM_construct_end(); EVP_PKEY_CTX_set_params(gctx, params); @@ -90,7 +90,7 @@ An B EC CDH (Cofactor Diffie-Hellman) key can be generated with a EVP_PKEY_keygen_init(gctx); - params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_EC_NAME, + params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, "K-571", 0); /* * This curve has a cofactor that is not 1 - so setting CDH mode changes diff --git a/include/openssl/core_names.h b/include/openssl/core_names.h index 96b9d7e684..9d99bc486f 100644 --- a/include/openssl/core_names.h +++ b/include/openssl/core_names.h @@ -195,6 +195,7 @@ extern "C" { #define OSSL_PKEY_PARAM_MGF1_DIGEST "mgf1-digest" #define OSSL_PKEY_PARAM_MGF1_PROPERTIES "mgf1-properties" #define OSSL_PKEY_PARAM_TLS_ENCODED_PT "tls-encoded-pt" +#define OSSL_PKEY_PARAM_GROUP_NAME "group-name" /* Diffie-Hellman/DSA public/private key */ #define OSSL_PKEY_PARAM_PUB_KEY "pub" @@ -222,7 +223,6 @@ extern "C" { #define OSSL_PKEY_PARAM_DH_PRIV_LEN "priv_len" /* Elliptic Curve Domain Parameters */ -#define OSSL_PKEY_PARAM_EC_NAME "curve-name" #define OSSL_PKEY_PARAM_EC_PUB_X "qx" #define OSSL_PKEY_PARAM_EC_PUB_Y "qy" diff --git a/include/openssl/ec.h b/include/openssl/ec.h index 90e109b61e..1302e27bb0 100644 --- a/include/openssl/ec.h +++ b/include/openssl/ec.h @@ -1450,10 +1450,6 @@ DEPRECATEDIN_3_0(void EC_KEY_METHOD_get_verify # endif # endif -int EVP_PKEY_CTX_set_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx, - const char *name); -int EVP_PKEY_CTX_get_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx, - char *name, size_t namelen); int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); # define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \ diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 9ce2f5e2ac..2b39d613b0 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -1886,6 +1886,9 @@ int EVP_str2ctrl(int (*cb)(void *ctx, int cmd, void *buf, size_t buflen), int EVP_hex2ctrl(int (*cb)(void *ctx, int cmd, void *buf, size_t buflen), void *ctx, int cmd, const char *hex); +int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name); +int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); + # ifdef __cplusplus } # endif diff --git a/providers/fips/self_test_data.inc b/providers/fips/self_test_data.inc index 431e52467c..674806edb2 100644 --- a/providers/fips/self_test_data.inc +++ b/providers/fips/self_test_data.inc @@ -739,7 +739,7 @@ static const unsigned char ecdh_peer_pub[] = { }; static const ST_KAT_PARAM ecdh_group[] = { - ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_EC_NAME, ecdh_curve_name), + ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecdh_curve_name), ST_KAT_PARAM_END() }; static const ST_KAT_PARAM ecdh_host_key[] = { @@ -1015,7 +1015,7 @@ static const unsigned char ecd_pub[] = { }; static const ST_KAT_PARAM ecdsa_key[] = { - ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_EC_NAME, ecd_curve_name), + ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecd_curve_name), ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecd_pub), ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_priv), ST_KAT_PARAM_END() diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index d926ec2bd2..0b006047d5 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -89,7 +89,7 @@ int domparams_to_params(const EC_KEY *ec, OSSL_PARAM_BLD *tmpl, if ((curve_name = ec_curve_nid2name(curve_nid)) == NULL) return 0; if (!ossl_param_build_set_utf8_string(tmpl, params, - OSSL_PKEY_PARAM_EC_NAME, + OSSL_PKEY_PARAM_GROUP_NAME, curve_name)) return 0; @@ -412,7 +412,7 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, /* IMEXPORT = IMPORT + EXPORT */ # define EC_IMEXPORTABLE_DOM_PARAMETERS \ - OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_NAME, NULL, 0) + OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0) # define EC_IMEXPORTABLE_PUBLIC_KEY \ OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0) # define EC_IMEXPORTABLE_PRIVATE_KEY \ @@ -699,7 +699,7 @@ static int ec_gen_set_params(void *genctx, const OSSL_PARAM params[]) if (!OSSL_PARAM_get_int(p, &gctx->ecdh_mode)) return 0; } - if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_EC_NAME)) + if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_GROUP_NAME)) != NULL) { const char *curve_name = NULL; int ret = 0; @@ -733,7 +733,7 @@ static int ec_gen_set_params(void *genctx, const OSSL_PARAM params[]) static const OSSL_PARAM *ec_gen_settable_params(void *provctx) { static OSSL_PARAM settable[] = { - OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_NAME, NULL, 0), + OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0), OSSL_PARAM_int(OSSL_PKEY_PARAM_USE_COFACTOR_ECDH, NULL), OSSL_PARAM_END }; diff --git a/test/acvp_test.c b/test/acvp_test.c index 0e3e117133..b7db04079c 100644 --- a/test/acvp_test.c +++ b/test/acvp_test.c @@ -120,8 +120,7 @@ static int ecdsa_keygen_test(int id) if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", NULL)) || !TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0) - || !TEST_true(EVP_PKEY_CTX_set_ec_paramgen_curve_name(ctx, - tst->curve_name)) + || !TEST_true(EVP_PKEY_CTX_set_group_name(ctx, tst->curve_name)) || !TEST_int_gt(EVP_PKEY_keygen(ctx, &pkey), 0) || !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_PRIV_KEY, &priv, &priv_len)) @@ -156,7 +155,7 @@ static int ecdsa_create_pkey(EVP_PKEY **pkey, const char *curve_name, if (!TEST_ptr(bld = OSSL_PARAM_BLD_new()) || (curve_name != NULL && !TEST_true(OSSL_PARAM_BLD_push_utf8_string( - bld, OSSL_PKEY_PARAM_EC_NAME, curve_name, 0) > 0)) + bld, OSSL_PKEY_PARAM_GROUP_NAME, curve_name, 0) > 0)) || !TEST_true(OSSL_PARAM_BLD_push_octet_string(bld, OSSL_PKEY_PARAM_PUB_KEY, pub, pub_len) > 0) @@ -252,8 +251,7 @@ static int ecdsa_siggen_test(int id) if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", NULL)) || !TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0) - || !TEST_true(EVP_PKEY_CTX_set_ec_paramgen_curve_name(ctx, - tst->curve_name)) + || !TEST_true(EVP_PKEY_CTX_set_group_name(ctx, tst->curve_name)) || !TEST_int_gt(EVP_PKEY_keygen(ctx, &pkey), 0)) goto err; diff --git a/test/evp_pkey_provided_test.c b/test/evp_pkey_provided_test.c index ffb56cb3ee..f842999615 100644 --- a/test/evp_pkey_provided_test.c +++ b/test/evp_pkey_provided_test.c @@ -928,7 +928,7 @@ static int test_fromdata_ec(void) sizeof(ec_priv_keydata), NULL))) goto err; - if (OSSL_PARAM_BLD_push_utf8_string(bld, OSSL_PKEY_PARAM_EC_NAME, + if (OSSL_PARAM_BLD_push_utf8_string(bld, OSSL_PKEY_PARAM_GROUP_NAME, curve, 0) <= 0) goto err; if (OSSL_PARAM_BLD_push_octet_string(bld, OSSL_PKEY_PARAM_PUB_KEY, @@ -955,12 +955,12 @@ static int test_fromdata_ec(void) goto err; if (!TEST_ptr(gettable = EVP_PKEY_gettable_params(pk)) - || !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_EC_NAME)) + || !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_GROUP_NAME)) || !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_PUB_KEY)) || !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_PRIV_KEY))) goto err; - if (!EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_EC_NAME, + if (!EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_GROUP_NAME, out_curve_name, sizeof(out_curve_name), &len) || !TEST_str_eq(out_curve_name, curve) diff --git a/util/libcrypto.num b/util/libcrypto.num index a92dccef61..38cc5700d7 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -5048,8 +5048,8 @@ CTLOG_new_from_base64_with_libctx ? 3_0_0 EXIST::FUNCTION:CT CTLOG_STORE_new_with_libctx ? 3_0_0 EXIST::FUNCTION:CT EVP_PKEY_set_ex_data ? 3_0_0 EXIST::FUNCTION: EVP_PKEY_get_ex_data ? 3_0_0 EXIST::FUNCTION: -EVP_PKEY_CTX_set_ec_paramgen_curve_name ? 3_0_0 EXIST::FUNCTION:EC -EVP_PKEY_CTX_get_ec_paramgen_curve_name ? 3_0_0 EXIST::FUNCTION:EC +EVP_PKEY_CTX_set_group_name ? 3_0_0 EXIST::FUNCTION: +EVP_PKEY_CTX_get_group_name ? 3_0_0 EXIST::FUNCTION: EVP_PKEY_CTX_set_ec_paramgen_curve_nid ? 3_0_0 EXIST::FUNCTION:EC d2i_PrivateKey_ex ? 3_0_0 EXIST::FUNCTION: d2i_AutoPrivateKey_ex ? 3_0_0 EXIST::FUNCTION: -- 2.25.1