PEM: Make PEM_write_bio_PrivateKey_traditional() handle provider-native keys
authorRichard Levitte <levitte@openssl.org>
Thu, 27 Aug 2020 08:07:09 +0000 (10:07 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 8 Sep 2020 14:45:11 +0000 (16:45 +0200)
commit4ce1025a8ac37d255f569147116dd776f9267cce
treeb89c84f89e808f6cfd6be703bf33e323507f5587
parent924663c36d47066d5307937da77fed7e872730c7
PEM: Make PEM_write_bio_PrivateKey_traditional() handle provider-native keys

PEM_write_bio_PrivateKey_traditional() didn't handle provider-native
keys very well.  Originally, it would simply use the corresponding
encoder, which is likely to output modern PEM (not "traditional").

PEM_write_bio_PrivateKey_traditional() is now changed to try and get a
legacy copy of the input EVP_PKEY, and use that copy for traditional
output, if it has such support.

Internally, evp_pkey_copy_downgraded() is added, to be used when
evp_pkey_downgrade() is too intrusive for what it's needed for.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12738)
crypto/evp/p_lib.c
crypto/pem/pem_pkey.c
doc/internal/man3/evp_pkey_export_to_provider.pod
include/crypto/evp.h