diff options
author | Matt Caswell <matt@openssl.org> | 2019-12-09 11:51:48 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-12-16 14:34:26 +0000 |
commit | e6d06e11e9cea84e41b0b68f63dacb4d4db356cc (patch) | |
tree | 7ac1161781b15b827aebb099ad9a3beda1ae8548 /crypto/evp | |
parent | 39d9123891845f203465dfda181f5c24b45756d1 (diff) |
Ensure EVP_PKEY_set1_DH detects X9.42 keys
OpenSSL supports both PKCS#3 and X9.42 DH keys. By default we use PKCS#3
keys. The function `EVP_PKEY_set1_DH` was assuming that the supplied DH
key was a PKCS#3 key. It should detect what type of key it is and assign
the correct type as appropriate.
Fixes #10592
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10593)
(cherry picked from commit 32c869ffaba67822602ea9fec611272ff8e8db58)
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/p_lib.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 451bc95eae..9f1a485a5b 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -540,7 +540,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; |