mirror of
https://github.com/openssl/openssl.git
synced 2024-11-21 01:15:20 +08:00
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 <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11914)
This commit is contained in:
parent
9d2d857f13
commit
11a1b341f3
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 <openssl/rsa.h>
|
||||
|
||||
@ -154,10 +156,6 @@ EVP_PKEY_CTX_set1_id, EVP_PKEY_CTX_get1_id, EVP_PKEY_CTX_get1_id_len
|
||||
|
||||
#include <openssl/ec.h>
|
||||
|
||||
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<EVP_PKEY_new_raw_private_key(3)> 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<EVP_PKEY_new_raw_private_key(3)> function.
|
||||
|
||||
EVP_PKEY_CTX_set_group_name() sets the group name to I<name> 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<ctx>, and writes it to the location that I<name> points at, as long
|
||||
as its size I<namelen> 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<ctx>.
|
||||
@ -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<name> for EC
|
||||
parameter generation.
|
||||
Use EVP_PKEY_CTX_set_group_name() (described above) to set the curve name to
|
||||
I<name> 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<nid> rather than a
|
||||
name string.
|
||||
EVP_PKEY_CTX_set_group_name(), but is specific to EC and uses a I<nid> 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<ctx>, and writes it to the location that I<name> points at, as long
|
||||
as its size I<namelen> 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<ctx>.
|
||||
|
||||
The EVP_PKEY_CTX_set_ec_param_enc() macro sets the EC parameter encoding to
|
||||
I<param_enc> 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
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ The following Import/Export types are available for the built-in EC algorithm:
|
||||
|
||||
=over 4
|
||||
|
||||
=item "curve-name" (B<OSSL_PKEY_PARAM_EC_NAME>) <utf8 string>
|
||||
=item "group-name" (B<OSSL_PKEY_PARAM_GROUP_NAME>) <utf8 string>
|
||||
|
||||
The EC curve name.
|
||||
The curve name.
|
||||
|
||||
=item "use-cofactor-flag" (B<OSSL_PKEY_PARAM_USE_COFACTOR_ECDH>) <integer>
|
||||
|
||||
@ -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<EVP_PKEY> 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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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) \
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user