diff options
author | 2019-11-12 22:36:44 +0000 | |
---|---|---|
committer | 2019-11-12 22:36:44 +0000 | |
commit | 5d2c7279e0a3c17e67d61ed65b485f15beafc4cd (patch) | |
tree | 07c312e80c9e628011a2bf5603c4ad2db8b55eca | |
parent | pass SSH_ASKPASS_PROMPT hint to y/n key confirm too (diff) | |
download | wireguard-openbsd-5d2c7279e0a3c17e67d61ed65b485f15beafc4cd.tar.xz wireguard-openbsd-5d2c7279e0a3c17e67d61ed65b485f15beafc4cd.zip |
security keys typically need to be tapped/touched in order to perform
a signature operation. Notify the user when this is expected via
the TTY (if available) or $SSH_ASKPASS if we can.
ok markus@
-rw-r--r-- | usr.bin/ssh/ssh-agent.c | 13 | ||||
-rw-r--r-- | usr.bin/ssh/ssh-keygen.c | 14 | ||||
-rw-r--r-- | usr.bin/ssh/sshconnect2.c | 17 |
3 files changed, 38 insertions, 6 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index c7fbc94cf5d..cd9d9997cef 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.240 2019/11/12 19:33:08 markus Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.241 2019/11/12 22:36:44 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -274,9 +274,10 @@ provider_sign(const char *provider, struct sshkey *key, { int status, pair[2], r = SSH_ERR_INTERNAL_ERROR; pid_t pid; - char *helper, *verbosity = NULL; + char *helper, *verbosity = NULL, *fp = NULL; struct sshbuf *kbuf, *req, *resp; u_char version; + struct notifier_ctx *notifier = NULL; debug3("%s: start for provider %s", __func__, provider); @@ -329,10 +330,17 @@ provider_sign(const char *provider, struct sshkey *key, error("%s: send: %s", __func__, ssh_err(r)); goto out; } + if ((fp = sshkey_fingerprint(key, SSH_FP_HASH_DEFAULT, + SSH_FP_DEFAULT)) == NULL) + fatal("%s: sshkey_fingerprint failed", __func__); + notifier = notify_start(0, + "Confirm user presence for key %s %s", sshkey_type(key), fp); if ((r = ssh_msg_recv(pair[0], resp)) != 0) { error("%s: receive: %s", __func__, ssh_err(r)); goto out; } + notify_complete(notifier); + notifier = NULL; if ((r = sshbuf_get_u8(resp, &version)) != 0) { error("%s: parse version: %s", __func__, ssh_err(r)); goto out; @@ -360,6 +368,7 @@ provider_sign(const char *provider, struct sshkey *key, if (errno != EINTR) fatal("%s: waitpid: %s", __func__, ssh_err(r)); } + notify_complete(notifier); if (!WIFEXITED(status)) { error("%s: helper %s exited abnormally", __func__, helper); if (r == 0) diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c index dd143dfddc2..11b2c95b51c 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.362 2019/11/12 19:33:08 markus Exp $ */ +/* $OpenBSD: ssh-keygen.c,v 1.363 2019/11/12 22:36:44 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -2487,8 +2487,7 @@ sign_one(struct sshkey *signkey, const char *filename, int fd, { struct sshbuf *sigbuf = NULL, *abuf = NULL; int r = SSH_ERR_INTERNAL_ERROR, wfd = -1, oerrno; - char *wfile = NULL; - char *asig = NULL; + char *wfile = NULL, *asig = NULL, *fp = NULL; if (!quiet) { if (fd == STDIN_FILENO) @@ -2496,6 +2495,15 @@ sign_one(struct sshkey *signkey, const char *filename, int fd, else fprintf(stderr, "Signing file %s\n", filename); } + if (signer == NULL && sshkey_is_sk(signkey) && + (signkey->sk_flags & SSH_SK_USER_PRESENCE_REQD)) { + if ((fp = sshkey_fingerprint(signkey, fingerprint_hash, + SSH_FP_DEFAULT)) == NULL) + fatal("%s: sshkey_fingerprint failed", __func__); + fprintf(stderr, "Confirm user presence for key %s %s\n", + sshkey_type(signkey), fp); + free(fp); + } if ((r = sshsig_sign_fd(signkey, NULL, sk_provider, fd, sig_namespace, &sigbuf, signer, signer_ctx)) != 0) { error("Signing %s failed: %s", filename, ssh_err(r)); diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 668062761fa..66ec335284d 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/sshconnect2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect2.c,v 1.311 2019/11/12 19:33:08 markus Exp $ */ +/* $OpenBSD: sshconnect2.c,v 1.312 2019/11/12 22:36:44 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2008 Damien Miller. All rights reserved. @@ -67,6 +67,7 @@ #include "ssherr.h" #include "utf8.h" #include "ssh-sk.h" +#include "sk-api.h" #ifdef GSSAPI #include "ssh-gss.h" @@ -1141,6 +1142,8 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp, { struct sshkey *sign_key = NULL, *prv = NULL; int r = SSH_ERR_INTERNAL_ERROR; + struct notifier_ctx *notifier = NULL; + char *fp = NULL; *sigp = NULL; *lenp = 0; @@ -1169,12 +1172,24 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp, goto out; } sign_key = prv; + if (sshkey_is_sk(sign_key) && + (sign_key->sk_flags & SSH_SK_USER_PRESENCE_REQD)) { + /* XXX match batch mode should just skip these keys? */ + if ((fp = sshkey_fingerprint(sign_key, + options.fingerprint_hash, SSH_FP_DEFAULT)) == NULL) + fatal("%s: sshkey_fingerprint", __func__); + notifier = notify_start(options.batch_mode, + "Confirm user presence for key %s %s", + sshkey_type(sign_key), fp); + free(fp); + } } if ((r = sshkey_sign(sign_key, sigp, lenp, data, datalen, alg, options.sk_provider, compat)) != 0) { debug("%s: sshkey_sign: %s", __func__, ssh_err(r)); goto out; } + notify_complete(notifier); /* * PKCS#11 tokens may not support all signature algorithms, * so check what we get back. |