mirror of https://github.com/openssl/openssl.git
Fix d2i_PrivateKey_ex() to work as documented
d2i_PrivateKey(), and thereby d2i_PrivateKey_ex(), is documented to return keys of the type given as first argument |type|, unconditionally. Most specifically, the manual says this: > An error occurs if the decoded key does not match type. However, when faced of a PKCS#8 wrapped key, |type| was ignored, which may lead to unexpected results. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11787)
This commit is contained in:
parent
885a2a399d
commit
b2952366dd
|
|
@ -58,6 +58,8 @@ EVP_PKEY *d2i_PrivateKey_ex(int type, EVP_PKEY **a, const unsigned char **pp,
|
|||
goto err;
|
||||
EVP_PKEY_free(ret);
|
||||
ret = tmp;
|
||||
if (EVP_PKEY_type(type) != EVP_PKEY_base_id(ret))
|
||||
goto err;
|
||||
} else {
|
||||
ASN1err(0, ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
|
|
|
|||
Loading…
Reference in New Issue