Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add CLI flag to force FIDO2 #735

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions man/fido2-assert.1
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ By default,
.Nm
will use FIDO2 if supported by the authenticator, and fallback to
U2F otherwise.
.It Fl 2
Obtain an assertion using only FIDO2.
By default,
.Nm
will use FIDO2 if supported by the authenticator, and fallback to
U2F otherwise.
.It Fl v
If obtaining an assertion, prompt the user for a PIN and request
user verification from the authenticator.
Expand Down
6 changes: 6 additions & 0 deletions man/fido2-cred.1
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ By default,
.Nm
will use FIDO2 if supported by the authenticator, and fallback to
U2F otherwise.
.It Fl 2
Create a FIDO2 credential.
By default,
.Nm
will use FIDO2 if supported by the authenticator, and fallback to
U2F otherwise.
.It Fl v
If making a credential, request user verification.
If verifying a credential, check whether the user verification bit
Expand Down
12 changes: 10 additions & 2 deletions tools/assert_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ assert_get(int argc, char **argv)

opt.up = opt.uv = opt.pin = FIDO_OPT_OMIT;

while ((ch = getopt(argc, argv, "bdhi:o:prt:uvw")) != -1) {
while ((ch = getopt(argc, argv, "bdhi:o:prt:u2vw")) != -1) {
switch (ch) {
case 'b':
flags |= FLAG_LARGEBLOB;
Expand Down Expand Up @@ -255,6 +255,9 @@ assert_get(int argc, char **argv)
case 'u':
flags |= FLAG_U2F;
break;
case '2':
flags |= FLAG_FIDO2;
break;
case 'v':
/* -v implies both pin and uv for historical reasons */
opt.pin = FIDO_OPT_TRUE;
Expand Down Expand Up @@ -282,8 +285,13 @@ assert_get(int argc, char **argv)
assert = prepare_assert(in_f, flags, &opt);

dev = open_dev(argv[0]);
if (flags & FLAG_U2F)
if (flags & FLAG_U2F) {
fido_dev_force_u2f(dev);
if (flags & FLAG_DEBUG) fprintf(stderr, "Forcing U2F (CTAP1).\n");
} else if (flags & FLAG_FIDO2) {
fido_dev_force_fido2(dev);
if (flags & FLAG_DEBUG) fprintf(stderr, "Forcing FIDO2 (CTAP2).\n");
}

if (opt.pin == FIDO_OPT_TRUE) {
r = snprintf(prompt, sizeof(prompt), "Enter PIN for %s: ",
Expand Down
12 changes: 10 additions & 2 deletions tools/cred_make.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ cred_make(int argc, char **argv)
int ch;
int r;

while ((ch = getopt(argc, argv, "bc:dhi:o:qruvw")) != -1) {
while ((ch = getopt(argc, argv, "bc:dhi:o:qru2vw")) != -1) {
switch (ch) {
case 'b':
flags |= FLAG_LARGEBLOB;
Expand Down Expand Up @@ -184,6 +184,9 @@ cred_make(int argc, char **argv)
case 'u':
flags |= FLAG_U2F;
break;
case '2':
flags |= FLAG_FIDO2;
break;
case 'v':
flags |= FLAG_UV;
break;
Expand Down Expand Up @@ -212,8 +215,13 @@ cred_make(int argc, char **argv)
cred = prepare_cred(in_f, type, flags);

dev = open_dev(argv[0]);
if (flags & FLAG_U2F)
if (flags & FLAG_U2F) {
fido_dev_force_u2f(dev);
if (flags & FLAG_DEBUG) fprintf(stderr, "Forcing U2F (CTAP1).\n");
} else if (flags & FLAG_FIDO2) {
fido_dev_force_fido2(dev);
if (flags & FLAG_DEBUG) fprintf(stderr, "Forcing FIDO2 (CTAP2).\n");
}

if (cred_protect > 0) {
r = fido_cred_set_prot(cred, cred_protect);
Expand Down
1 change: 1 addition & 0 deletions tools/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct blob {
#define FLAG_UP 0x040
#define FLAG_LARGEBLOB 0x080
#define FLAG_CD 0x100
#define FLAG_FIDO2 0x200

#define PINBUF_LEN 256

Expand Down
2 changes: 1 addition & 1 deletion tools/fido2-assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void
usage(void)
{
fprintf(stderr,
"usage: fido2-assert -G [-bdhpruvw] [-t option] [-i input_file] [-o output_file] device\n"
"usage: fido2-assert -G [-bdhpru2vw] [-t option] [-i input_file] [-o output_file] device\n"
" fido2-assert -V [-dhpv] [-i input_file] key_file [type]\n"
);

Expand Down
2 changes: 1 addition & 1 deletion tools/fido2-cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void
usage(void)
{
fprintf(stderr,
"usage: fido2-cred -M [-bdhqruvw] [-c cred_protect] [-i input_file] [-o output_file] device [type]\n"
"usage: fido2-cred -M [-bdhqru2vw] [-c cred_protect] [-i input_file] [-o output_file] device [type]\n"
" fido2-cred -V [-dhv] [-c cred_protect] [-i input_file] [-o output_file] [type]\n"
);

Expand Down