summaryrefslogtreecommitdiff
path: root/sshconnect2.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-08-27 01:06:18 +0000
committerDamien Miller <djm@mindrot.org>2020-08-27 11:28:36 +1000
commit9b8ad93824c682ce841f53f3b5762cef4e7cc4dc (patch)
treed4523956d4623b19bf5904d1b92afeb2307f69d3 /sshconnect2.c
parent1196d7f49d4fbc90f37e550de3056561613b0960 (diff)
upstream: support for user-verified FIDO keys
FIDO2 supports a notion of "user verification" where the user is required to demonstrate their identity to the token before particular operations (e.g. signing). Typically this is done by authenticating themselves using a PIN that has been set on the token. This adds support for generating and using user verified keys where the verification happens via PIN (other options might be added in the future, but none are in common use now). Practically, this adds another key generation option "verify-required" that yields a key that requires a PIN before each authentication. feedback markus@ and Pedro Martelletto; ok markus@ OpenBSD-Commit-ID: 57fd461e4366f87c47502c5614ec08573e6d6a15
Diffstat (limited to 'sshconnect2.c')
-rw-r--r--sshconnect2.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/sshconnect2.c b/sshconnect2.c
index 74946da0d..347e348c6 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.324 2020/06/27 13:39:09 bket Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.325 2020/08/27 01:06:18 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Damien Miller. All rights reserved. 4 * Copyright (c) 2008 Damien Miller. All rights reserved.
@@ -1175,7 +1175,7 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
1175 struct sshkey *sign_key = NULL, *prv = NULL; 1175 struct sshkey *sign_key = NULL, *prv = NULL;
1176 int r = SSH_ERR_INTERNAL_ERROR; 1176 int r = SSH_ERR_INTERNAL_ERROR;
1177 struct notifier_ctx *notifier = NULL; 1177 struct notifier_ctx *notifier = NULL;
1178 char *fp = NULL; 1178 char *fp = NULL, *pin = NULL, *prompt = NULL;
1179 1179
1180 *sigp = NULL; 1180 *sigp = NULL;
1181 *lenp = 0; 1181 *lenp = 0;
@@ -1204,20 +1204,28 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
1204 goto out; 1204 goto out;
1205 } 1205 }
1206 sign_key = prv; 1206 sign_key = prv;
1207 if (sshkey_is_sk(sign_key) && 1207 if (sshkey_is_sk(sign_key)) {
1208 (sign_key->sk_flags & SSH_SK_USER_PRESENCE_REQD)) { 1208 if ((sign_key->sk_flags &
1209 /* XXX match batch mode should just skip these keys? */ 1209 SSH_SK_USER_VERIFICATION_REQD)) {
1210 if ((fp = sshkey_fingerprint(sign_key, 1210 xasprintf(&prompt, "Enter PIN for %s key %s: ",
1211 options.fingerprint_hash, SSH_FP_DEFAULT)) == NULL) 1211 sshkey_type(sign_key), id->filename);
1212 fatal("%s: sshkey_fingerprint", __func__); 1212 pin = read_passphrase(prompt, 0);
1213 notifier = notify_start(options.batch_mode, 1213 }
1214 "Confirm user presence for key %s %s", 1214 if ((sign_key->sk_flags & SSH_SK_USER_PRESENCE_REQD)) {
1215 sshkey_type(sign_key), fp); 1215 /* XXX should batch mode just skip these? */
1216 free(fp); 1216 if ((fp = sshkey_fingerprint(sign_key,
1217 options.fingerprint_hash,
1218 SSH_FP_DEFAULT)) == NULL)
1219 fatal("%s: fingerprint", __func__);
1220 notifier = notify_start(options.batch_mode,
1221 "Confirm user presence for key %s %s",
1222 sshkey_type(sign_key), fp);
1223 free(fp);
1224 }
1217 } 1225 }
1218 } 1226 }
1219 if ((r = sshkey_sign(sign_key, sigp, lenp, data, datalen, 1227 if ((r = sshkey_sign(sign_key, sigp, lenp, data, datalen,
1220 alg, options.sk_provider, compat)) != 0) { 1228 alg, options.sk_provider, pin, compat)) != 0) {
1221 debug("%s: sshkey_sign: %s", __func__, ssh_err(r)); 1229 debug("%s: sshkey_sign: %s", __func__, ssh_err(r));
1222 goto out; 1230 goto out;
1223 } 1231 }
@@ -1232,6 +1240,9 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
1232 /* success */ 1240 /* success */
1233 r = 0; 1241 r = 0;
1234 out: 1242 out:
1243 free(prompt);
1244 if (pin != NULL)
1245 freezero(pin, strlen(pin));
1235 notify_complete(notifier); 1246 notify_complete(notifier);
1236 sshkey_free(prv); 1247 sshkey_free(prv);
1237 return r; 1248 return r;