Fix d2i_PrivateKey_ex() to work as documented
authorRichard Levitte <levitte@openssl.org>
Mon, 11 May 2020 07:14:11 +0000 (09:14 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 12 May 2020 04:48:47 +0000 (06:48 +0200)
commitb2952366dd0248bf35c83e1736cd203033a22378
treea057c8393fcee475d54a6fa0165511b4bb518a19
parent885a2a399dcf25860f471e59af43db2917c39335
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)
crypto/asn1/d2i_pr.c