Skip to content

Commit

Permalink
bio: support non-preview command
Browse files Browse the repository at this point in the history
If the bioEnroll option ID is present in the authenticatorGetInfo
response, use the aunthenticatorBioEnrollment (0x09) command instead of
the preview command (0x40).
  • Loading branch information
LDVG committed Nov 21, 2023
1 parent 2b51136 commit dfe62a7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
11 changes: 10 additions & 1 deletion src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ bio_prepare_hmac(uint8_t cmd, cbor_item_t **argv, size_t argc,
return (ok);
}

static uint8_t
bio_get_cmd(const fido_dev_t *dev)
{
if (dev->flags & (FIDO_DEV_BIO_SET|FIDO_DEV_BIO_UNSET))
return (CTAP_CBOR_BIO_ENROLL);

return (CTAP_CBOR_BIO_ENROLL_PRE);
}

static int
bio_tx(fido_dev_t *dev, uint8_t subcmd, cbor_item_t **sub_argv, size_t sub_argc,
const char *pin, const fido_blob_t *token, int *ms)
Expand All @@ -66,7 +75,7 @@ bio_tx(fido_dev_t *dev, uint8_t subcmd, cbor_item_t **sub_argv, size_t sub_argc,
fido_blob_t *ecdh = NULL;
fido_blob_t f;
fido_blob_t hmac;
const uint8_t cmd = CTAP_CBOR_BIO_ENROLL_PRE;
const uint8_t cmd = bio_get_cmd(dev);
int r = FIDO_ERR_INTERNAL;

memset(&f, 0, sizeof(f));
Expand Down
3 changes: 3 additions & 0 deletions src/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ fido_dev_set_option_flags(fido_dev_t *dev, const fido_cbor_info_t *info)
} else if (strcmp(ptr[i], "pinUvAuthToken") == 0) {
if (val[i])
dev->flags |= FIDO_DEV_TOKEN_PERMS;
} else if (strcmp(ptr[i], "bioEnroll") == 0) {
dev->flags |= val[i] ?
FIDO_DEV_BIO_SET : FIDO_DEV_BIO_UNSET;
}
}

Expand Down
24 changes: 13 additions & 11 deletions src/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,19 @@ uint32_t uniform_random(uint32_t);
#endif

/* internal device capability flags */
#define FIDO_DEV_PIN_SET 0x001
#define FIDO_DEV_PIN_UNSET 0x002
#define FIDO_DEV_CRED_PROT 0x004
#define FIDO_DEV_CREDMAN 0x008
#define FIDO_DEV_PIN_PROTOCOL1 0x010
#define FIDO_DEV_PIN_PROTOCOL2 0x020
#define FIDO_DEV_UV_SET 0x040
#define FIDO_DEV_UV_UNSET 0x080
#define FIDO_DEV_TOKEN_PERMS 0x100
#define FIDO_DEV_WINHELLO 0x200
#define FIDO_DEV_CREDMAN_PRE 0x400
#define FIDO_DEV_PIN_SET 0x0001
#define FIDO_DEV_PIN_UNSET 0x0002
#define FIDO_DEV_CRED_PROT 0x0004
#define FIDO_DEV_CREDMAN 0x0008
#define FIDO_DEV_PIN_PROTOCOL1 0x0010
#define FIDO_DEV_PIN_PROTOCOL2 0x0020
#define FIDO_DEV_UV_SET 0x0040
#define FIDO_DEV_UV_UNSET 0x0080
#define FIDO_DEV_TOKEN_PERMS 0x0100
#define FIDO_DEV_WINHELLO 0x0200
#define FIDO_DEV_CREDMAN_PRE 0x0400
#define FIDO_DEV_BIO_SET 0x0800
#define FIDO_DEV_BIO_UNSET 0x1000

/* miscellanea */
#define FIDO_DUMMY_CLIENTDATA ""
Expand Down
1 change: 1 addition & 0 deletions src/fido/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define CTAP_CBOR_CLIENT_PIN 0x06
#define CTAP_CBOR_RESET 0x07
#define CTAP_CBOR_NEXT_ASSERT 0x08
#define CTAP_CBOR_BIO_ENROLL 0x09
#define CTAP_CBOR_CRED_MGMT 0x0a
#define CTAP_CBOR_LARGEBLOB 0x0c
#define CTAP_CBOR_CONFIG 0x0d
Expand Down
1 change: 1 addition & 0 deletions src/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ encode_uv_permission(uint8_t cmd)
case CTAP_CBOR_ASSERT:
return (cbor_build_uint8(CTAP21_UV_TOKEN_PERM_ASSERT));
case CTAP_CBOR_BIO_ENROLL_PRE:
case CTAP_CBOR_BIO_ENROLL:
return (cbor_build_uint8(CTAP21_UV_TOKEN_PERM_BIO));
case CTAP_CBOR_CONFIG:
return (cbor_build_uint8(CTAP21_UV_TOKEN_PERM_CONFIG));
Expand Down

0 comments on commit dfe62a7

Please sign in to comment.