summaryrefslogtreecommitdiffstats
path: root/apps/storeutl.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-07-30 10:09:43 +0200
committerRichard Levitte <levitte@openssl.org>2020-08-20 12:37:35 +0200
commit2274d22d39fd65b83c9c969cba86c8f03b3e0bec (patch)
treedd86a9ea759bc5d2d1bd541afe0d28a929018e6d /apps/storeutl.c
parent6cc1dfca88c565ddacd9ea9aa8261ef9c0c37335 (diff)
STORE: Distinguish public keys from private keys
While public keys and private keys use the same type (EVP_PKEY), just with different contents, callers still need to distinguish between the two to be able to know what functions to call with them (for example, to be able to choose between EVP_PKEY_print_private() and EVP_PKEY_print_public()). The OSSL_STORE backend knows what it loaded, so it has the capacity to inform. Note that the same as usual still applies, that a private key EVP_PKEY contains the public parts, but not necessarily the other way around. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12673)
Diffstat (limited to 'apps/storeutl.c')
-rw-r--r--apps/storeutl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/apps/storeutl.c b/apps/storeutl.c
index 66fd423ab0..3d9498dc46 100644
--- a/apps/storeutl.c
+++ b/apps/storeutl.c
@@ -450,6 +450,13 @@ static int process(const char *uri, const UI_METHOD *uimeth, PW_CB_DATA *uidata,
PEM_write_bio_Parameters(out,
OSSL_STORE_INFO_get0_PARAMS(info));
break;
+ case OSSL_STORE_INFO_PUBKEY:
+ if (text)
+ EVP_PKEY_print_public(out, OSSL_STORE_INFO_get0_PUBKEY(info),
+ 0, NULL);
+ if (!noout)
+ PEM_write_bio_PUBKEY(out, OSSL_STORE_INFO_get0_PUBKEY(info));
+ break;
case OSSL_STORE_INFO_PKEY:
if (text)
EVP_PKEY_print_private(out, OSSL_STORE_INFO_get0_PKEY(info),