Skip to content

Commit

Permalink
Add fido_cbor_info_{maxcredcntlst,maxcredidlen}
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed May 11, 2020
1 parent 7240413 commit f003d76
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 7 deletions.
26 changes: 26 additions & 0 deletions examples/info.c
Expand Up @@ -130,6 +130,26 @@ print_maxmsgsiz(uint64_t maxmsgsiz)
printf("maxmsgsiz: %d\n", (int)maxmsgsiz);
}

/*
* Auxiliary function to print an authenticator's maximum number of credentials
* in a credential list on stdout.
*/
static void
print_maxcredcntlst(uint64_t maxcredcntlst)
{
printf("maxcredcntlst: %d\n", (int)maxcredcntlst);
}

/*
* Auxiliary function to print an authenticator's maximal credential ID length
* on stdout.
*/
static void
print_maxcredidlen(uint64_t maxcredidlen)
{
printf("maxcredlen: %d\n", (int)maxcredidlen);
}

/*
* Auxiliary function to print an authenticator's firmware version on stdout.
*/
Expand Down Expand Up @@ -199,6 +219,12 @@ getinfo(const char *path)
/* print maximum message size */
print_maxmsgsiz(fido_cbor_info_maxmsgsiz(ci));

/* print maximum number of credentials allowed in credential lists */
print_maxcredcntlst(fido_cbor_info_maxcredcntlst(ci));

/* print maximum length of a credential ID */
print_maxcredidlen(fido_cbor_info_maxcredidlen(ci));

/* print firmware version */
print_fwversion(fido_cbor_info_fwversion(ci));

Expand Down
2 changes: 2 additions & 0 deletions fuzz/export.gnu
Expand Up @@ -76,6 +76,8 @@
fido_cbor_info_extensions_ptr;
fido_cbor_info_free;
fido_cbor_info_maxmsgsiz;
fido_cbor_info_maxcredcntlst;
fido_cbor_info_maxcredidlen;
fido_cbor_info_fwversion;
fido_cbor_info_new;
fido_cbor_info_options_len;
Expand Down
6 changes: 6 additions & 0 deletions fuzz/fuzz_mgmt.c
Expand Up @@ -207,6 +207,12 @@ dev_get_cbor_info(struct param *p)
n = fido_cbor_info_maxmsgsiz(ci);
consume(&n, sizeof(n));

n = fido_cbor_info_maxcredcntlst(ci);
consume(&n, sizeof(n));

n = fido_cbor_info_maxcredidlen(ci);
consume(&n, sizeof(n));

n = fido_cbor_info_fwversion(ci);
consume(&n, sizeof(n));

Expand Down
2 changes: 2 additions & 0 deletions man/CMakeLists.txt
Expand Up @@ -101,6 +101,8 @@ list(APPEND MAN_ALIAS
fido_cbor_info_new fido_cbor_info_extensions_ptr
fido_cbor_info_new fido_cbor_info_free
fido_cbor_info_new fido_cbor_info_maxmsgsiz
fido_cbor_info_new fido_cbor_info_maxcredcntlst;
fido_cbor_info_new fido_cbor_info_maxcredidlen;
fido_cbor_info_new fido_cbor_info_fwversion
fido_cbor_info_new fido_cbor_info_options_len
fido_cbor_info_new fido_cbor_info_options_name_ptr
Expand Down
18 changes: 18 additions & 0 deletions man/fido_cbor_info_new.3
Expand Up @@ -21,6 +21,8 @@
.Nm fido_cbor_info_versions_len ,
.Nm fido_cbor_info_options_len ,
.Nm fido_cbor_info_maxmsgsiz ,
.Nm fido_cbor_info_maxcredcntlst ,
.Nm fido_cbor_info_maxcredidlen ,
.Nm fido_cbor_info_fwversion
.Nd FIDO 2 CBOR Info API
.Sh SYNOPSIS
Expand Down Expand Up @@ -56,6 +58,10 @@
.Ft uint64_t
.Fn fido_cbor_info_maxmsgsiz "const fido_cbor_info_t *ci"
.Ft uint64_t
.Fn fido_cbor_info_maxcredcntlst "const fido_cbor_info_t *ci"
.Ft uint64_t
.Fn fido_cbor_info_maxcredidlen "const fido_cbor_info_t *ci"
.Ft uint64_t
.Fn fido_cbor_info_fwversion "const fido_cbor_info_t *ci"
.Sh DESCRIPTION
The
Expand Down Expand Up @@ -131,6 +137,18 @@ function returns the maximum message size attribute of
.Fa ci .
.Pp
The
.Fn fido_cbor_info_maxcredcntlst
function returns the maximum supported number of credentials in
a single credential ID list as reported in
.Fa ci .
.Pp
The
.Fn fido_cbor_info_maxcredidlen
function returns the maximum supported length of a credential ID
as reported in
.Fa ci .
.Pp
The
.Fn fido_cbor_info_fwversion
function returns the firmware version attribute of
.Fa ci .
Expand Down
2 changes: 2 additions & 0 deletions src/export.gnu
Expand Up @@ -76,6 +76,8 @@
fido_cbor_info_extensions_ptr;
fido_cbor_info_free;
fido_cbor_info_maxmsgsiz;
fido_cbor_info_maxcredcntlst;
fido_cbor_info_maxcredidlen;
fido_cbor_info_fwversion;
fido_cbor_info_new;
fido_cbor_info_options_len;
Expand Down
2 changes: 2 additions & 0 deletions src/export.llvm
Expand Up @@ -74,6 +74,8 @@ _fido_cbor_info_extensions_len
_fido_cbor_info_extensions_ptr
_fido_cbor_info_free
_fido_cbor_info_maxmsgsiz
_fido_cbor_info_maxcredcntlst
_fido_cbor_info_maxcredidlen
_fido_cbor_info_fwversion
_fido_cbor_info_new
_fido_cbor_info_options_len
Expand Down
2 changes: 2 additions & 0 deletions src/export.msvc
Expand Up @@ -75,6 +75,8 @@ fido_cbor_info_extensions_len
fido_cbor_info_extensions_ptr
fido_cbor_info_free
fido_cbor_info_maxmsgsiz
fido_cbor_info_maxcredcntlst
fido_cbor_info_maxcredidlen
fido_cbor_info_fwversion
fido_cbor_info_new
fido_cbor_info_options_len
Expand Down
2 changes: 2 additions & 0 deletions src/fido.h
Expand Up @@ -178,6 +178,8 @@ uint8_t fido_dev_flags(const fido_dev_t *);
int16_t fido_dev_info_vendor(const fido_dev_info_t *);
int16_t fido_dev_info_product(const fido_dev_info_t *);
uint64_t fido_cbor_info_maxmsgsiz(const fido_cbor_info_t *);
uint64_t fido_cbor_info_maxcredcntlst(const fido_cbor_info_t *ci);
uint64_t fido_cbor_info_maxcredidlen(const fido_cbor_info_t *);
uint64_t fido_cbor_info_fwversion(const fido_cbor_info_t *);

bool fido_dev_is_fido2(const fido_dev_t *);
Expand Down
16 changes: 9 additions & 7 deletions src/fido/types.h
Expand Up @@ -175,13 +175,15 @@ typedef struct fido_byte_array {
} fido_byte_array_t;

typedef struct fido_cbor_info {
fido_str_array_t versions; /* supported versions: fido2|u2f */
fido_str_array_t extensions; /* list of supported extensions */
unsigned char aaguid[16]; /* aaguid */
fido_opt_array_t options; /* list of supported options */
uint64_t maxmsgsiz; /* maximum message size */
fido_byte_array_t protocols; /* supported pin protocols */
uint64_t fwversion; /* firmware version */
fido_str_array_t versions; /* supported versions: fido2|u2f */
fido_str_array_t extensions; /* list of supported extensions */
unsigned char aaguid[16]; /* aaguid */
fido_opt_array_t options; /* list of supported options */
uint64_t maxmsgsiz; /* maximum message size */
fido_byte_array_t protocols; /* supported pin protocols */
uint64_t maxcredcntlst; /* max number of credentials in list */
uint64_t maxcredidlen; /* max credential ID length */
uint64_t fwversion; /* firmware version */
} fido_cbor_info_t;

typedef struct fido_dev_info {
Expand Down
16 changes: 16 additions & 0 deletions src/info.c
Expand Up @@ -217,6 +217,10 @@ parse_reply_element(const cbor_item_t *key, const cbor_item_t *val, void *arg)
return (cbor_decode_uint64(val, &ci->maxmsgsiz));
case 6: /* pinProtocols */
return (decode_protocols(val, &ci->protocols));
case 7: /* maxCredentialCountInList */
return (cbor_decode_uint64(val, &ci->maxcredcntlst));
case 8: /* maxCredentialIdLength */
return (cbor_decode_uint64(val, &ci->maxcredidlen));
case 14: /* fwVersion */
return (cbor_decode_uint64(val, &ci->fwversion));
default: /* ignore */
Expand Down Expand Up @@ -398,6 +402,18 @@ fido_cbor_info_maxmsgsiz(const fido_cbor_info_t *ci)
return (ci->maxmsgsiz);
}

uint64_t
fido_cbor_info_maxcredcntlst(const fido_cbor_info_t *ci)
{
return (ci->maxcredcntlst);
}

uint64_t
fido_cbor_info_maxcredidlen(const fido_cbor_info_t *ci)
{
return (ci->maxcredidlen);
}

uint64_t
fido_cbor_info_fwversion(const fido_cbor_info_t *ci)
{
Expand Down
18 changes: 18 additions & 0 deletions tools/token.c
Expand Up @@ -111,6 +111,18 @@ print_maxmsgsiz(uint64_t maxmsgsiz)
printf("maxmsgsiz: %d\n", (int)maxmsgsiz);
}

static void
print_maxcredcntlst(uint64_t maxcredcntlst)
{
printf("maxcredcntlst: %d\n", (int)maxcredcntlst);
}

static void
print_maxcredidlen(uint64_t maxcredidlen)
{
printf("maxcredlen: %d\n", (int)maxcredidlen);
}

static void
print_fwversion(uint64_t fwversion)
{
Expand Down Expand Up @@ -202,6 +214,12 @@ token_info(int argc, char **argv, char *path)
/* print maximum message size */
print_maxmsgsiz(fido_cbor_info_maxmsgsiz(ci));

/* print maximum number of credentials allowed in credential lists */
print_maxcredcntlst(fido_cbor_info_maxcredcntlst(ci));

/* print maximum length of a credential ID */
print_maxcredidlen(fido_cbor_info_maxcredidlen(ci));

/* print firmware version */
print_fwversion(fido_cbor_info_fwversion(ci));

Expand Down

0 comments on commit f003d76

Please sign in to comment.