summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKinichiro Inoguchi <inoguchi@cvs.openbsd.org>2019-11-20 10:46:18 +0000
committerKinichiro Inoguchi <inoguchi@cvs.openbsd.org>2019-11-20 10:46:18 +0000
commit08a7503c365bea2e478d27c355886f889c0cb804 (patch)
treebb223322102e870f527637c867d4fb556a27d312 /lib
parentaedef8c31f276919dc2a0ee64b819536621e6cab (diff)
Fix rsa key output format
This fixes openssl(1) rsa -text output format ok tb@
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/rsa/rsa_ameth.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libcrypto/rsa/rsa_ameth.c b/lib/libcrypto/rsa/rsa_ameth.c
index 255ccb4d131..d373d7c1327 100644
--- a/lib/libcrypto/rsa/rsa_ameth.c
+++ b/lib/libcrypto/rsa/rsa_ameth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_ameth.c,v 1.23 2019/11/02 14:35:48 jsing Exp $ */
+/* $OpenBSD: rsa_ameth.c,v 1.24 2019/11/20 10:46:17 inoguchi Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@@ -449,10 +449,17 @@ pkey_rsa_print(BIO *bp, const EVP_PKEY *pkey, int off, int priv)
if (BIO_printf(bp, "%s ", pkey_is_pss(pkey) ? "RSA-PSS" : "RSA") <= 0)
goto err;
- if (BIO_printf(bp, "Public-Key: (%d bit)\n", mod_len) <= 0)
- goto err;
- str = "Modulus:";
- s = "Exponent:";
+ if (priv && x->d != NULL) {
+ if (BIO_printf(bp, "Private-Key: (%d bit)\n", mod_len) <= 0)
+ goto err;
+ str = "modulus:";
+ s = "publicExponent:";
+ } else {
+ if (BIO_printf(bp, "Public-Key: (%d bit)\n", mod_len) <= 0)
+ goto err;
+ str = "Modulus:";
+ s = "Exponent:";
+ }
if (!ASN1_bn_print(bp, str, x->n, m, off))
goto err;
if (!ASN1_bn_print(bp, s, x->e, m, off))