Propagate selection all the way on key export
authorSimo Sorce <simo@redhat.com>
Thu, 10 Nov 2022 15:46:32 +0000 (10:46 -0500)
committerTomas Mraz <tomas@openssl.org>
Tue, 15 Nov 2022 11:04:12 +0000 (12:04 +0100)
commit98642df4ba886818900ab7e6b23703544e6addd4
treec2779bfde9324683c67718fc0ede90a607a55b94
parent93e1271eedfe3af0a1c1b14d26899d2c8bde98e9
Propagate selection all the way on key export

EVP_PKEY_eq() is used to check, among other things, if a certificate
public key corresponds to a private key. When the private key belongs to
a provider that does not allow to export private keys this currently
fails as the internal functions used to import/export keys ignored the
selection given (which specifies that only the public key needs to be
considered) and instead tries to export everything.

This patch allows to propagate the selection all the way down including
adding it in the cache so that a following operation actually looking
for other selection parameters does not mistakenly pick up an export
containing only partial information.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19648)
crypto/evp/keymgmt_lib.c
crypto/evp/p_lib.c
include/crypto/evp.h