[openssh-commits] [openssh] 04/05: upstream: security keys typically need to be tapped/touched in

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Nov 13 10:15:55 AEDT 2019


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit e44bb61824e36d0d181a08489c16c378c486a974
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Tue Nov 12 22:36:44 2019 +0000

    upstream: 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@
    
    OpenBSD-Commit-ID: 0ef90a99a85d4a2a07217a58efb4df8444818609
---
 ssh-agent.c   | 13 +++++++++++--
 ssh-keygen.c  | 14 +++++++++++---
 sshconnect2.c | 17 ++++++++++++++++-
 3 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/ssh-agent.c b/ssh-agent.c
index dd9f85ae..eb17b18b 100644
--- a/ssh-agent.c
+++ b/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 at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -289,9 +289,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);
 
@@ -344,10 +345,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;
@@ -375,6 +383,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/ssh-keygen.c b/ssh-keygen.c
index 7b8dce7d..46d642e1 100644
--- a/ssh-keygen.c
+++ b/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 at cs.hut.fi>
  * Copyright (c) 1994 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -2506,8 +2506,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)
@@ -2515,6 +2514,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/sshconnect2.c b/sshconnect2.c
index 4e5cddf1..c8db626d 100644
--- a/sshconnect2.c
+++ b/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.
@@ -73,6 +73,7 @@
 #include "ssherr.h"
 #include "utf8.h"
 #include "ssh-sk.h"
+#include "sk-api.h"
 
 #ifdef GSSAPI
 #include "ssh-gss.h"
@@ -1149,6 +1150,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;
@@ -1177,12 +1180,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.

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list