EVP: Have EVP_PKCS82PKEY_ex() pass a correct selection to OSSL_DECODER

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15934)
This commit is contained in:
Richard Levitte 2021-06-28 07:08:51 +02:00
parent 398f8fe1c4
commit 69e14a546d

View File

@ -70,6 +70,7 @@ EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx,
const unsigned char *p8_data = NULL;
unsigned char *encoded_data = NULL;
int encoded_len;
int selection;
size_t len;
OSSL_DECODER_CTX *dctx = NULL;
@ -79,8 +80,9 @@ EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx,
p8_data = encoded_data;
len = encoded_len;
selection = EVP_PKEY_KEYPAIR | EVP_PKEY_KEY_PARAMETERS;
dctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, "DER", "PrivateKeyInfo",
EVP_PKEY_NONE, 0, libctx, propq);
NULL, selection, libctx, propq);
if (dctx == NULL
|| !OSSL_DECODER_from_data(dctx, &p8_data, &len))
/* try legacy */