summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/ssh-keygen.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2020-01-25 00:03:36 +0000
committerdjm <djm@openbsd.org>2020-01-25 00:03:36 +0000
commit44e54ccb31e3bda5c68b2bc2df1c3b4d67797ec2 (patch)
tree0f950be0912e4b8b69547ba02a3f898f9df352c3 /usr.bin/ssh/ssh-keygen.c
parenttweak proctitle to include sshd arguments, as these are frequently (diff)
downloadwireguard-openbsd-44e54ccb31e3bda5c68b2bc2df1c3b4d67797ec2.tar.xz
wireguard-openbsd-44e54ccb31e3bda5c68b2bc2df1c3b4d67797ec2.zip
expose PKCS#11 key labels/X.509 subjects as comments
Extract the key label or X.509 subject string when PKCS#11 keys are retrieved from the token and plumb this through to places where it may be used as a comment. based on https://github.com/openssh/openssh-portable/pull/138 by Danielle Church feedback and ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh-keygen.c')
-rw-r--r--usr.bin/ssh/ssh-keygen.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index 5987a72889c..edbbe51c988 100644
--- a/usr.bin/ssh/ssh-keygen.c
+++ b/usr.bin/ssh/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.391 2020/01/24 05:33:01 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.392 2020/01/25 00:03:36 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -811,13 +811,13 @@ do_download(struct passwd *pw)
int i, nkeys;
enum sshkey_fp_rep rep;
int fptype;
- char *fp, *ra;
+ char *fp, *ra, **comments = NULL;
fptype = print_bubblebabble ? SSH_DIGEST_SHA1 : fingerprint_hash;
rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_DEFAULT;
pkcs11_init(1);
- nkeys = pkcs11_add_provider(pkcs11provider, NULL, &keys);
+ nkeys = pkcs11_add_provider(pkcs11provider, NULL, &keys, &comments);
if (nkeys <= 0)
fatal("cannot read public key from pkcs11");
for (i = 0; i < nkeys; i++) {
@@ -835,10 +835,13 @@ do_download(struct passwd *pw)
free(fp);
} else {
(void) sshkey_write(keys[i], stdout); /* XXX check */
- fprintf(stdout, "\n");
+ fprintf(stdout, "%s%s\n",
+ *(comments[i]) == '\0' ? "" : " ", comments[i]);
}
+ free(comments[i]);
sshkey_free(keys[i]);
}
+ free(comments);
free(keys);
pkcs11_terminate();
exit(0);
@@ -1683,7 +1686,8 @@ load_pkcs11_key(char *path)
fatal("Couldn't load CA public key \"%s\": %s",
path, ssh_err(r));
- nkeys = pkcs11_add_provider(pkcs11provider, identity_passphrase, &keys);
+ nkeys = pkcs11_add_provider(pkcs11provider, identity_passphrase,
+ &keys, NULL);
debug3("%s: %d keys", __func__, nkeys);
if (nkeys <= 0)
fatal("cannot read public key from pkcs11");