Avoid erroneous legacy code path when provided
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27075)
(cherry picked from commit 27b88364e4
)
This commit is contained in:
parent
8b431eed9a
commit
f16561eead
3 changed files with 11 additions and 3 deletions
|
@ -2895,11 +2895,15 @@ static int evp_pkey_ctx_setget_params_to_ctrl(EVP_PKEY_CTX *pctx,
|
||||||
|
|
||||||
int evp_pkey_ctx_set_params_to_ctrl(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params)
|
int evp_pkey_ctx_set_params_to_ctrl(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params)
|
||||||
{
|
{
|
||||||
|
if (ctx->keymgmt != NULL)
|
||||||
|
return 0;
|
||||||
return evp_pkey_ctx_setget_params_to_ctrl(ctx, SET, (OSSL_PARAM *)params);
|
return evp_pkey_ctx_setget_params_to_ctrl(ctx, SET, (OSSL_PARAM *)params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int evp_pkey_ctx_get_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params)
|
int evp_pkey_ctx_get_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params)
|
||||||
{
|
{
|
||||||
|
if (ctx->keymgmt != NULL)
|
||||||
|
return 0;
|
||||||
return evp_pkey_ctx_setget_params_to_ctrl(ctx, GET, params);
|
return evp_pkey_ctx_setget_params_to_ctrl(ctx, GET, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -695,8 +695,9 @@ int EVP_PKEY_CTX_set_params(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params)
|
||||||
ctx->op.encap.kem->set_ctx_params(ctx->op.encap.algctx,
|
ctx->op.encap.kem->set_ctx_params(ctx->op.encap.algctx,
|
||||||
params);
|
params);
|
||||||
break;
|
break;
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
case EVP_PKEY_STATE_UNKNOWN:
|
case EVP_PKEY_STATE_UNKNOWN:
|
||||||
|
break;
|
||||||
|
#ifndef FIPS_MODULE
|
||||||
case EVP_PKEY_STATE_LEGACY:
|
case EVP_PKEY_STATE_LEGACY:
|
||||||
return evp_pkey_ctx_set_params_to_ctrl(ctx, params);
|
return evp_pkey_ctx_set_params_to_ctrl(ctx, params);
|
||||||
#endif
|
#endif
|
||||||
|
@ -733,8 +734,9 @@ int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params)
|
||||||
ctx->op.encap.kem->get_ctx_params(ctx->op.encap.algctx,
|
ctx->op.encap.kem->get_ctx_params(ctx->op.encap.algctx,
|
||||||
params);
|
params);
|
||||||
break;
|
break;
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
case EVP_PKEY_STATE_UNKNOWN:
|
case EVP_PKEY_STATE_UNKNOWN:
|
||||||
|
break;
|
||||||
|
#ifndef FIPS_MODULE
|
||||||
case EVP_PKEY_STATE_LEGACY:
|
case EVP_PKEY_STATE_LEGACY:
|
||||||
return evp_pkey_ctx_get_params_to_ctrl(ctx, params);
|
return evp_pkey_ctx_get_params_to_ctrl(ctx, params);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -721,7 +721,9 @@ static EVP_PKEY *make_key_fromdata(char *keytype, OSSL_PARAM *params)
|
||||||
|
|
||||||
if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, keytype, testpropq)))
|
if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, keytype, testpropq)))
|
||||||
goto err;
|
goto err;
|
||||||
if (!TEST_int_gt(EVP_PKEY_fromdata_init(pctx), 0)
|
/* Check that premature EVP_PKEY_CTX_set_params() fails gracefully */
|
||||||
|
if (!TEST_int_eq(EVP_PKEY_CTX_set_params(pctx, params), 0)
|
||||||
|
|| !TEST_int_gt(EVP_PKEY_fromdata_init(pctx), 0)
|
||||||
|| !TEST_int_gt(EVP_PKEY_fromdata(pctx, &tmp_pkey, EVP_PKEY_KEYPAIR,
|
|| !TEST_int_gt(EVP_PKEY_fromdata(pctx, &tmp_pkey, EVP_PKEY_KEYPAIR,
|
||||||
params), 0))
|
params), 0))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue