Keep the provided peer EVP_PKEY in the EVP_PKEY_CTX too

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26976)

(cherry picked from commit 2656922feb)
This commit is contained in:
Tomas Mraz 2025-03-04 18:43:18 +01:00
parent 6fdf39cc7d
commit 18a17538cf

View file

@ -430,7 +430,13 @@ int EVP_PKEY_derive_set_peer_ex(EVP_PKEY_CTX *ctx, EVP_PKEY *peer,
*/
if (provkey == NULL)
goto legacy;
return ctx->op.kex.exchange->set_peer(ctx->op.kex.algctx, provkey);
ret = ctx->op.kex.exchange->set_peer(ctx->op.kex.algctx, provkey);
if (ret <= 0)
return ret;
EVP_PKEY_free(ctx->peerkey);
ctx->peerkey = peer;
EVP_PKEY_up_ref(peer);
return 1;
legacy:
#ifdef FIPS_MODULE