summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-05-07 15:31:05 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-05-07 15:31:05 +1000
commit5e77b79a8c47f0801f656cfccfcbaaa3ca1035b4 (patch)
treef93d6603fd386aa19d5536a0a66f5b882aebc7cf /crypto/evp
parent9f2058611f7aec733d4a476f4f28c895d9e5667b (diff)
Remove gen_get_params & gen_gettable_params from keygen operation
EVP_PKEY_CTX_gettable_params() was missing code for the keygen operation. After adding it it was noticed that it is probably not required for this type, so instead the gen_get_params and gen_gettable_params have been remnoved from the provider interface. gen_get_params was only implemented for ec to get the curve name. This seems redundant since normally you would set parameters into the keygen_init() and then generate a key. Normally you would expect to extract data from the key - not the object that we just set up to do the keygen. Added a simple settable and gettable test into a test that does keygen. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11683)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_local.h2
-rw-r--r--crypto/evp/keymgmt_meth.c34
-rw-r--r--crypto/evp/pmeth_gn.c5
-rw-r--r--crypto/evp/pmeth_lib.c11
4 files changed, 5 insertions, 47 deletions
diff --git a/crypto/evp/evp_local.h b/crypto/evp/evp_local.h
index 4c822aa7d3..de7d69a26c 100644
--- a/crypto/evp/evp_local.h
+++ b/crypto/evp/evp_local.h
@@ -86,8 +86,6 @@ struct evp_keymgmt_st {
OSSL_OP_keymgmt_gen_set_template_fn *gen_set_template;
OSSL_OP_keymgmt_gen_set_params_fn *gen_set_params;
OSSL_OP_keymgmt_gen_settable_params_fn *gen_settable_params;
- OSSL_OP_keymgmt_gen_get_params_fn *gen_get_params;
- OSSL_OP_keymgmt_gen_gettable_params_fn *gen_gettable_params;
OSSL_OP_keymgmt_gen_fn *gen;
OSSL_OP_keymgmt_gen_cleanup_fn *gen_cleanup;
diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c
index 172dd21a71..b75d02f136 100644
--- a/crypto/evp/keymgmt_meth.c
+++ b/crypto/evp/keymgmt_meth.c
@@ -39,7 +39,7 @@ static void *keymgmt_from_dispatch(int name_id,
{
EVP_KEYMGMT *keymgmt = NULL;
int setparamfncnt = 0, getparamfncnt = 0;
- int setgenparamfncnt = 0, getgenparamfncnt = 0;
+ int setgenparamfncnt = 0;
int importfncnt = 0, exportfncnt = 0;
if ((keymgmt = keymgmt_new()) == NULL) {
@@ -77,20 +77,6 @@ static void *keymgmt_from_dispatch(int name_id,
OSSL_get_OP_keymgmt_gen_settable_params(fns);
}
break;
- case OSSL_FUNC_KEYMGMT_GEN_GET_PARAMS:
- if (keymgmt->gen_get_params == NULL) {
- getgenparamfncnt++;
- keymgmt->gen_get_params =
- OSSL_get_OP_keymgmt_gen_get_params(fns);
- }
- break;
- case OSSL_FUNC_KEYMGMT_GEN_GETTABLE_PARAMS:
- if (keymgmt->gen_gettable_params == NULL) {
- getgenparamfncnt++;
- keymgmt->gen_gettable_params =
- OSSL_get_OP_keymgmt_gen_gettable_params(fns);
- }
- break;
case OSSL_FUNC_KEYMGMT_GEN:
if (keymgmt->gen == NULL)
keymgmt->gen = OSSL_get_OP_keymgmt_gen(fns);
@@ -186,7 +172,6 @@ static void *keymgmt_from_dispatch(int name_id,
|| (getparamfncnt != 0 && getparamfncnt != 2)
|| (setparamfncnt != 0 && setparamfncnt != 2)
|| (setgenparamfncnt != 0 && setgenparamfncnt != 2)
- || (getgenparamfncnt != 0 && getgenparamfncnt != 2)
|| (importfncnt != 0 && importfncnt != 2)
|| (exportfncnt != 0 && exportfncnt != 2)
|| (keymgmt->gen != NULL
@@ -342,23 +327,6 @@ const OSSL_PARAM *evp_keymgmt_gen_settable_params(const EVP_KEYMGMT *keymgmt)
return keymgmt->gen_settable_params(provctx);
}
-int evp_keymgmt_gen_get_params(const EVP_KEYMGMT *keymgmt, void *genctx,
- OSSL_PARAM params[])
-{
- if (keymgmt->gen_get_params == NULL)
- return 0;
- return keymgmt->gen_get_params(genctx, params);
-}
-
-const OSSL_PARAM *evp_keymgmt_gen_gettable_params(const EVP_KEYMGMT *keymgmt)
-{
- void *provctx = ossl_provider_ctx(EVP_KEYMGMT_provider(keymgmt));
-
- if (keymgmt->gen_gettable_params == NULL)
- return NULL;
- return keymgmt->gen_gettable_params(provctx);
-}
-
void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx,
OSSL_CALLBACK *cb, void *cbarg)
{
diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c
index dc1dad86ba..a775d2bee7 100644
--- a/crypto/evp/pmeth_gn.c
+++ b/crypto/evp/pmeth_gn.c
@@ -210,8 +210,9 @@ int EVP_PKEY_gen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
{
char curve_name[OSSL_MAX_NAME_SIZE] = "";
- if (EVP_PKEY_CTX_get_ec_paramgen_curve_name(ctx, curve_name,
- sizeof(curve_name)) < 1
+ if (!EVP_PKEY_get_utf8_string_param(*ppkey, OSSL_PKEY_PARAM_EC_NAME,
+ curve_name, sizeof(curve_name),
+ NULL)
|| strcmp(curve_name, "SM2") != 0)
goto end;
}
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index e262e87319..3476d83ea6 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -613,12 +613,6 @@ int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params)
&& ctx->op.ciph.cipher->get_ctx_params != NULL)
return ctx->op.ciph.cipher->get_ctx_params(ctx->op.ciph.ciphprovctx,
params);
- if (EVP_PKEY_CTX_IS_GEN_OP(ctx)
- && ctx->op.keymgmt.genctx != NULL
- && ctx->keymgmt != NULL
- && ctx->keymgmt->gen_get_params != NULL)
- return evp_keymgmt_gen_get_params(ctx->keymgmt, ctx->op.keymgmt.genctx,
- params);
return 0;
}
@@ -632,12 +626,10 @@ const OSSL_PARAM *EVP_PKEY_CTX_gettable_params(EVP_PKEY_CTX *ctx)
&& ctx->op.sig.signature != NULL
&& ctx->op.sig.signature->gettable_ctx_params != NULL)
return ctx->op.sig.signature->gettable_ctx_params();
-
if (EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx)
&& ctx->op.ciph.cipher != NULL
&& ctx->op.ciph.cipher->gettable_ctx_params != NULL)
return ctx->op.ciph.cipher->gettable_ctx_params();
-
return NULL;
}
@@ -656,8 +648,7 @@ const OSSL_PARAM *EVP_PKEY_CTX_settable_params(EVP_PKEY_CTX *ctx)
&& ctx->op.ciph.cipher->settable_ctx_params != NULL)
return ctx->op.ciph.cipher->settable_ctx_params();
if (EVP_PKEY_CTX_IS_GEN_OP(ctx)
- && ctx->keymgmt != NULL
- && ctx->keymgmt->gen_settable_params != NULL)
+ && ctx->keymgmt != NULL)
return evp_keymgmt_gen_settable_params(ctx->keymgmt);
return NULL;