diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 8e6682fff4322e6f2738ab9657ed2f97233d5f86..99d6063e3ed40762642c373a47618e2dd6ce0be8 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -569,7 +569,9 @@ EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey) int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) { - int ret = EVP_PKEY_assign_DH(pkey, key); + int type = DH_get0_q(key) == NULL ? EVP_PKEY_DH : EVP_PKEY_DHX; + int ret = EVP_PKEY_assign(pkey, type, key); + if (ret) DH_up_ref(key); return ret;