diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2019-04-13 15:52:47 +0200 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2020-09-09 18:32:10 +0200 |
commit | 10203a34725ec75136b03d64fd2126b321419ac1 (patch) | |
tree | 74fe59f88ef556a8bcadd7673bac64f092c7057b /apps/rsa.c | |
parent | 8ae40cf57d2138af92a3479e23f35037ae8c5c30 (diff) |
Support writing RSA keys using the traditional format again
Fixes: #6855
Reviewed-by: Richard Levitte <levitte@openssl.org>
GH: #8743
Diffstat (limited to 'apps/rsa.c')
-rw-r--r-- | apps/rsa.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/rsa.c b/apps/rsa.c index 0464729f71..fdee96d570 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -31,7 +31,7 @@ typedef enum OPTION_choice { /* Do not change the order here; see case statements below */ OPT_PVK_NONE, OPT_PVK_WEAK, OPT_PVK_STRONG, OPT_NOOUT, OPT_TEXT, OPT_MODULUS, OPT_CHECK, OPT_CIPHER, - OPT_PROV_ENUM + OPT_PROV_ENUM, OPT_TRADITIONAL } OPTION_CHOICE; const OPTIONS rsa_options[] = { @@ -59,6 +59,8 @@ const OPTIONS rsa_options[] = { {"noout", OPT_NOOUT, '-', "Don't print key out"}, {"text", OPT_TEXT, '-', "Print the key in text"}, {"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"}, + {"traditional", OPT_TRADITIONAL, '-', + "Use traditional format for private keys"}, #if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) OPT_SECTION("PVK"), @@ -88,6 +90,7 @@ int rsa_main(int argc, char **argv) int pvk_encr = 2; #endif OPTION_CHOICE o; + int traditional = 0; prog = opt_init(argc, argv, rsa_options); while ((o = opt_next()) != OPT_EOF) { @@ -163,6 +166,9 @@ int rsa_main(int argc, char **argv) if (!opt_provider(o)) goto end; break; + case OPT_TRADITIONAL: + traditional = 1; + break; } } argc = opt_num_rest(); @@ -280,8 +286,13 @@ int rsa_main(int argc, char **argv) i = PEM_write_bio_RSA_PUBKEY(out, rsa); } else { assert(private); - i = PEM_write_bio_RSAPrivateKey(out, rsa, - enc, NULL, 0, NULL, passout); + if (traditional) { + i = PEM_write_bio_PrivateKey_traditional(out, pkey, enc, NULL, 0, + NULL, passout); + } else { + i = PEM_write_bio_PrivateKey(out, pkey, + enc, NULL, 0, NULL, passout); + } } #ifndef OPENSSL_NO_DSA } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { |