Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16725)
if (evp_pkey_ctx_is_legacy(ctx))
goto legacy;
+ if (ctx->pkey == NULL) {
+ ERR_clear_last_mark();
+ ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
+ goto err;
+ }
+
/*
* Try to derive the supported asym cipher from |ctx->keymgmt|.
*/
evp_pkey_ctx_free_old_ops(ctx);
ctx->operation = operation;
+ if (ctx->pkey == NULL) {
+ ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
+ goto err;
+ }
+
/*
* Try to derive the supported kem from |ctx->keymgmt|.
*/
if (evp_pkey_ctx_is_legacy(locpctx))
goto legacy;
+ if (locpctx->pkey == NULL) {
+ ERR_clear_last_mark();
+ ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
+ goto err;
+ }
+
/*
* Try to derive the supported signature from |locpctx->keymgmt|.
*/
if (evp_pkey_ctx_is_legacy(ctx))
goto legacy;
+ if (ctx->pkey == NULL) {
+ ERR_clear_last_mark();
+ ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
+ goto err;
+ }
+
/*
* Try to derive the supported signature from |ctx->keymgmt|.
*/