summaryrefslogtreecommitdiff
path: root/sshsig.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 /sshsig.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 'sshsig.c')
-rw-r--r--sshsig.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sshsig.c b/sshsig.c
index 15f9cead6..658b8c852 100644
--- a/sshsig.c
+++ b/sshsig.c
@@ -151,7 +151,7 @@ done:
151 151
152static int 152static int
153sshsig_wrap_sign(struct sshkey *key, const char *hashalg, 153sshsig_wrap_sign(struct sshkey *key, const char *hashalg,
154 const char *sk_provider, const struct sshbuf *h_message, 154 const char *sk_provider, const char *sk_pin, const struct sshbuf *h_message,
155 const char *sig_namespace, struct sshbuf **out, 155 const char *sig_namespace, struct sshbuf **out,
156 sshsig_signer *signer, void *signer_ctx) 156 sshsig_signer *signer, void *signer_ctx)
157{ 157{
@@ -185,14 +185,14 @@ sshsig_wrap_sign(struct sshkey *key, const char *hashalg,
185 if (signer != NULL) { 185 if (signer != NULL) {
186 if ((r = signer(key, &sig, &slen, 186 if ((r = signer(key, &sig, &slen,
187 sshbuf_ptr(tosign), sshbuf_len(tosign), 187 sshbuf_ptr(tosign), sshbuf_len(tosign),
188 sign_alg, sk_provider, 0, signer_ctx)) != 0) { 188 sign_alg, sk_provider, sk_pin, 0, signer_ctx)) != 0) {
189 error("Couldn't sign message: %s", ssh_err(r)); 189 error("Couldn't sign message: %s", ssh_err(r));
190 goto done; 190 goto done;
191 } 191 }
192 } else { 192 } else {
193 if ((r = sshkey_sign(key, &sig, &slen, 193 if ((r = sshkey_sign(key, &sig, &slen,
194 sshbuf_ptr(tosign), sshbuf_len(tosign), 194 sshbuf_ptr(tosign), sshbuf_len(tosign),
195 sign_alg, sk_provider, 0)) != 0) { 195 sign_alg, sk_provider, sk_pin, 0)) != 0) {
196 error("Couldn't sign message: %s", ssh_err(r)); 196 error("Couldn't sign message: %s", ssh_err(r));
197 goto done; 197 goto done;
198 } 198 }
@@ -430,7 +430,8 @@ hash_buffer(const struct sshbuf *m, const char *hashalg, struct sshbuf **bp)
430} 430}
431 431
432int 432int
433sshsig_signb(struct sshkey *key, const char *hashalg, const char *sk_provider, 433sshsig_signb(struct sshkey *key, const char *hashalg,
434 const char *sk_provider, const char *sk_pin,
434 const struct sshbuf *message, const char *sig_namespace, 435 const struct sshbuf *message, const char *sig_namespace,
435 struct sshbuf **out, sshsig_signer *signer, void *signer_ctx) 436 struct sshbuf **out, sshsig_signer *signer, void *signer_ctx)
436{ 437{
@@ -445,7 +446,7 @@ sshsig_signb(struct sshkey *key, const char *hashalg, const char *sk_provider,
445 error("%s: hash_buffer failed: %s", __func__, ssh_err(r)); 446 error("%s: hash_buffer failed: %s", __func__, ssh_err(r));
446 goto out; 447 goto out;
447 } 448 }
448 if ((r = sshsig_wrap_sign(key, hashalg, sk_provider, b, 449 if ((r = sshsig_wrap_sign(key, hashalg, sk_provider, sk_pin, b,
449 sig_namespace, out, signer, signer_ctx)) != 0) 450 sig_namespace, out, signer, signer_ctx)) != 0)
450 goto out; 451 goto out;
451 /* success */ 452 /* success */
@@ -558,7 +559,8 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp)
558} 559}
559 560
560int 561int
561sshsig_sign_fd(struct sshkey *key, const char *hashalg, const char *sk_provider, 562sshsig_sign_fd(struct sshkey *key, const char *hashalg,
563 const char *sk_provider, const char *sk_pin,
562 int fd, const char *sig_namespace, struct sshbuf **out, 564 int fd, const char *sig_namespace, struct sshbuf **out,
563 sshsig_signer *signer, void *signer_ctx) 565 sshsig_signer *signer, void *signer_ctx)
564{ 566{
@@ -573,7 +575,7 @@ sshsig_sign_fd(struct sshkey *key, const char *hashalg, const char *sk_provider,
573 error("%s: hash_file failed: %s", __func__, ssh_err(r)); 575 error("%s: hash_file failed: %s", __func__, ssh_err(r));
574 return r; 576 return r;
575 } 577 }
576 if ((r = sshsig_wrap_sign(key, hashalg, sk_provider, b, 578 if ((r = sshsig_wrap_sign(key, hashalg, sk_provider, sk_pin, b,
577 sig_namespace, out, signer, signer_ctx)) != 0) 579 sig_namespace, out, signer, signer_ctx)) != 0)
578 goto out; 580 goto out;
579 /* success */ 581 /* success */