From 600ae3309934717b40f3a8f30104f26d08b69791 Mon Sep 17 00:00:00 2001 From: naddy Date: Tue, 31 May 2022 14:05:12 +0000 Subject: [PATCH] ssh-keygen: implement "verify-required" certificate option This was already documented when support for user-verified FIDO keys was added, but the ssh-keygen(1) code was missing. ok djm@ --- usr.bin/ssh/ssh-keygen.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c index 30d956020b9..5faa1ceffa4 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.452 2022/05/09 03:09:53 djm Exp $ */ +/* $OpenBSD: ssh-keygen.c,v 1.453 2022/05/31 14:05:12 naddy Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1994 Tatu Ylonen , Espoo, Finland @@ -121,6 +121,7 @@ static u_int64_t cert_valid_to = ~0ULL; #define CERTOPT_PTY (1<<3) #define CERTOPT_USER_RC (1<<4) #define CERTOPT_NO_REQUIRE_USER_PRESENCE (1<<5) +#define CERTOPT_REQUIRE_VERIFY (1<<6) #define CERTOPT_DEFAULT (CERTOPT_X_FWD|CERTOPT_AGENT_FWD| \ CERTOPT_PORT_FWD|CERTOPT_PTY|CERTOPT_USER_RC) static u_int32_t certflags_flags = CERTOPT_DEFAULT; @@ -1649,6 +1650,8 @@ finalise_cert_exts(void) cert_ext_add("force-command", certflags_command, 1); if (certflags_src_addr != NULL) cert_ext_add("source-address", certflags_src_addr, 1); + if ((certflags_flags & CERTOPT_REQUIRE_VERIFY) != 0) + cert_ext_add("verify-required", NULL, 1); /* extensions */ if ((certflags_flags & CERTOPT_X_FWD) != 0) cert_ext_add("permit-X11-forwarding", NULL, 0); @@ -1970,6 +1973,10 @@ add_cert_option(char *opt) certflags_flags &= ~CERTOPT_NO_REQUIRE_USER_PRESENCE; else if (strcasecmp(opt, "no-touch-required") == 0) certflags_flags |= CERTOPT_NO_REQUIRE_USER_PRESENCE; + else if (strcasecmp(opt, "no-verify-required") == 0) + certflags_flags &= ~CERTOPT_REQUIRE_VERIFY; + else if (strcasecmp(opt, "verify-required") == 0) + certflags_flags |= CERTOPT_REQUIRE_VERIFY; else if (strncasecmp(opt, "force-command=", 14) == 0) { val = opt + 14; if (*val == '\0') @@ -2028,6 +2035,9 @@ show_options(struct sshbuf *optbuf, int in_critical) fatal_fr(r, "parse critical"); printf(" %s\n", arg); free(arg); + } else if (in_critical && + strcmp(name, "verify-required") == 0) { + printf("\n"); } else if (sshbuf_len(option) > 0) { hex = sshbuf_dtob16(option); printf(" UNKNOWN OPTION: %s (len %zu)\n", -- 2.20.1