summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/ssh-keygen.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2020-02-07 03:27:54 +0000
committerdjm <djm@openbsd.org>2020-02-07 03:27:54 +0000
commit2f4a28af3657e24aee64941ccc8f9cd205ba62e5 (patch)
tree8832065942f555ae124339c5956a6a089238d75d /usr.bin/ssh/ssh-keygen.c
parentRemove backward compatibility for obsolete -H flag. (diff)
downloadwireguard-openbsd-2f4a28af3657e24aee64941ccc8f9cd205ba62e5.tar.xz
wireguard-openbsd-2f4a28af3657e24aee64941ccc8f9cd205ba62e5.zip
fix two PIN entry bugs on FIDO keygen: 1) it would allow more than the
intended number of prompts (3) and 2) it would SEGV too many incorrect PINs were entered; based on patch by Gabriel Kihlman
Diffstat (limited to 'usr.bin/ssh/ssh-keygen.c')
-rw-r--r--usr.bin/ssh/ssh-keygen.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index 73a96d62733..86b2308d8d5 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.397 2020/02/06 22:30:54 naddy Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.398 2020/02/07 03:27:54 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -3563,7 +3563,7 @@ main(int argc, char **argv)
passphrase = NULL;
if ((attest = sshbuf_new()) == NULL)
fatal("sshbuf_new failed");
- for (i = 0 ; i < 3; i++) {
+ for (i = 0 ; ; i++) {
fflush(stdout);
r = sshsk_enroll(type, sk_provider, sk_device,
sk_application == NULL ? "ssh:" : sk_application,
@@ -3573,15 +3573,21 @@ main(int argc, char **argv)
break;
if (r != SSH_ERR_KEY_WRONG_PASSPHRASE)
fatal("Key enrollment failed: %s", ssh_err(r));
- if (passphrase != NULL)
+ else if (i > 0)
+ error("PIN incorrect");
+ if (passphrase != NULL) {
freezero(passphrase, strlen(passphrase));
+ passphrase = NULL;
+ }
+ if (i >= 3)
+ fatal("Too many incorrect PINs");
passphrase = read_passphrase("Enter PIN for "
"authenticator: ", RP_ALLOW_STDIN);
}
- if (passphrase != NULL)
+ if (passphrase != NULL) {
freezero(passphrase, strlen(passphrase));
- if (i > 3)
- fatal("Too many incorrect PINs");
+ passphrase = NULL;
+ }
break;
default:
if ((r = sshkey_generate(type, bits, &private)) != 0)