From 4af85af128274707eff411ecefdb6180a9275e7d Mon Sep 17 00:00:00 2001 From: inoguchi <> Date: Wed, 20 Nov 2019 10:46:17 +0000 Subject: Fix rsa key output format This fixes openssl(1) rsa -text output format ok tb@ --- src/lib/libcrypto/rsa/rsa_ameth.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c index 255ccb4d13..d373d7c132 100644 --- a/src/lib/libcrypto/rsa/rsa_ameth.c +++ b/src/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)) -- cgit v1.2.3-55-g6feb