Skip to content

Commit

Permalink
info: add fido_cbor_info_maxlargeblob()
Browse files Browse the repository at this point in the history
add fido_cbor_info_maxlargeblob(), a function to retrieve the
maximum size of an authenticator's serialized largeBlob array.
  • Loading branch information
martelletto committed Apr 25, 2022
1 parent 961c919 commit c9f78b2
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 22 deletions.
15 changes: 14 additions & 1 deletion examples/info.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Yubico AB. All rights reserved.
* Copyright (c) 2018-2022 Yubico AB. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
Expand Down Expand Up @@ -182,6 +182,16 @@ print_maxcredidlen(uint64_t maxcredidlen)
printf("maxcredlen: %d\n", (int)maxcredidlen);
}

/*
* Auxiliary function to print the maximum size of an authenticator's
* serialized largeBlob array.
*/
static void
print_maxlargeblob(uint64_t maxlargeblob)
{
printf("maxlargeblob: %d\n", (int)maxlargeblob);
}

/*
* Auxiliary function to print an authenticator's firmware version on stdout.
*/
Expand Down Expand Up @@ -264,6 +274,9 @@ getinfo(const char *path)
/* print maximum length of a credential ID */
print_maxcredidlen(fido_cbor_info_maxcredidlen(ci));

/* print maximum length of largeBlob array */
print_maxlargeblob(fido_cbor_info_maxlargeblob(ci));

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

Expand Down
3 changes: 2 additions & 1 deletion fuzz/export.gnu
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@
fido_cbor_info_extensions_len;
fido_cbor_info_extensions_ptr;
fido_cbor_info_free;
fido_cbor_info_maxmsgsiz;
fido_cbor_info_maxcredbloblen;
fido_cbor_info_maxcredcntlst;
fido_cbor_info_maxcredidlen;
fido_cbor_info_maxlargeblob;
fido_cbor_info_maxmsgsiz;
fido_cbor_info_fwversion;
fido_cbor_info_new;
fido_cbor_info_options_len;
Expand Down
5 changes: 4 additions & 1 deletion fuzz/fuzz_mgmt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Yubico AB. All rights reserved.
* Copyright (c) 2019-2022 Yubico AB. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
Expand Down Expand Up @@ -288,6 +288,9 @@ dev_get_cbor_info(const struct param *p)
n = fido_cbor_info_maxcredidlen(ci);
consume(&n, sizeof(n));

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

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

Expand Down
3 changes: 2 additions & 1 deletion man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ list(APPEND MAN_ALIAS
fido_cbor_info_new fido_cbor_info_extensions_len
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_maxcredbloblen
fido_cbor_info_new fido_cbor_info_maxcredcntlst
fido_cbor_info_new fido_cbor_info_maxcredidlen
fido_cbor_info_new fido_cbor_info_maxlargeblob
fido_cbor_info_new fido_cbor_info_maxmsgsiz
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
13 changes: 11 additions & 2 deletions man/fido_cbor_info_new.3
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.\" Copyright (c) 2018 Yubico AB. All rights reserved.
.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved.
.\" Use of this source code is governed by a BSD-style
.\" license that can be found in the LICENSE file.
.\"
.Dd $Mdocdate: May 24 2018 $
.Dd $Mdocdate: April 22 2022 $
.Dt FIDO_CBOR_INFO_NEW 3
.Os
.Sh NAME
Expand All @@ -29,6 +29,7 @@
.Nm fido_cbor_info_maxcredbloblen ,
.Nm fido_cbor_info_maxcredcntlst ,
.Nm fido_cbor_info_maxcredidlen ,
.Nm fido_cbor_info_maxlargeblob ,
.Nm fido_cbor_info_fwversion
.Nd FIDO2 CBOR Info API
.Sh SYNOPSIS
Expand Down Expand Up @@ -80,6 +81,8 @@
.Ft uint64_t
.Fn fido_cbor_info_maxcredidlen "const fido_cbor_info_t *ci"
.Ft uint64_t
.Fn fido_cbor_info_maxlargeblob "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 @@ -201,6 +204,12 @@ as reported in
.Fa ci .
.Pp
The
.Fn fido_cbor_info_maxlargeblob
function returns the maximum length in bytes of an authenticator's
serialized largeBlob array as reported in
.Fa ci .
.Pp
The
.Fn fido_cbor_info_fwversion
function returns the firmware version attribute of
.Fa ci .
Expand Down
3 changes: 2 additions & 1 deletion src/export.gnu
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@
fido_cbor_info_extensions_len;
fido_cbor_info_extensions_ptr;
fido_cbor_info_free;
fido_cbor_info_maxmsgsiz;
fido_cbor_info_maxcredbloblen;
fido_cbor_info_maxcredcntlst;
fido_cbor_info_maxcredidlen;
fido_cbor_info_maxlargeblob;
fido_cbor_info_maxmsgsiz;
fido_cbor_info_fwversion;
fido_cbor_info_new;
fido_cbor_info_options_len;
Expand Down
3 changes: 2 additions & 1 deletion src/export.llvm
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ _fido_cbor_info_algorithm_type
_fido_cbor_info_extensions_len
_fido_cbor_info_extensions_ptr
_fido_cbor_info_free
_fido_cbor_info_maxmsgsiz
_fido_cbor_info_maxcredbloblen
_fido_cbor_info_maxcredcntlst
_fido_cbor_info_maxcredidlen
_fido_cbor_info_maxlargeblob
_fido_cbor_info_maxmsgsiz
_fido_cbor_info_fwversion
_fido_cbor_info_new
_fido_cbor_info_options_len
Expand Down
3 changes: 2 additions & 1 deletion src/export.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ fido_cbor_info_algorithm_type
fido_cbor_info_extensions_len
fido_cbor_info_extensions_ptr
fido_cbor_info_free
fido_cbor_info_maxmsgsiz
fido_cbor_info_maxcredbloblen
fido_cbor_info_maxcredcntlst
fido_cbor_info_maxcredidlen
fido_cbor_info_maxlargeblob
fido_cbor_info_maxmsgsiz
fido_cbor_info_fwversion
fido_cbor_info_new
fido_cbor_info_options_len
Expand Down
3 changes: 2 additions & 1 deletion src/fido.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ uint8_t fido_dev_build(const fido_dev_t *);
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_maxcredbloblen(const fido_cbor_info_t *);
uint64_t fido_cbor_info_maxcredcntlst(const fido_cbor_info_t *);
uint64_t fido_cbor_info_maxcredidlen(const fido_cbor_info_t *);
uint64_t fido_cbor_info_maxlargeblob(const fido_cbor_info_t *);
uint64_t fido_cbor_info_maxmsgsiz(const fido_cbor_info_t *);
uint64_t fido_cbor_info_fwversion(const fido_cbor_info_t *);

bool fido_dev_has_pin(const fido_dev_t *);
Expand Down
25 changes: 13 additions & 12 deletions src/fido/types.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Yubico AB. All rights reserved.
* Copyright (c) 2018-2022 Yubico AB. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
Expand Down Expand Up @@ -220,18 +220,19 @@ typedef struct fido_algo_array {
} fido_algo_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 */
fido_str_array_t transports; /* list of supported transports */
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 */
fido_algo_array_t algorithms; /* list of supported algorithms */
uint64_t maxcredcntlst; /* max number of credentials in list */
uint64_t maxcredidlen; /* max credential ID length */
uint64_t fwversion; /* firmware version */
fido_str_array_t versions; /* supported versions: fido2|u2f */
fido_str_array_t extensions; /* list of supported extensions */
fido_str_array_t transports; /* list of supported transports */
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 */
fido_algo_array_t algorithms; /* list of supported algorithms */
uint64_t maxcredcntlst; /* max credentials in list */
uint64_t maxcredidlen; /* max credential ID length */
uint64_t fwversion; /* firmware version */
uint64_t maxcredbloblen; /* max credBlob length */
uint64_t maxlargeblob; /* max largeBlob array length */
} fido_cbor_info_t;

typedef struct fido_dev_info {
Expand Down
8 changes: 8 additions & 0 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ parse_reply_element(const cbor_item_t *key, const cbor_item_t *val, void *arg)
return (decode_string_array(val, &ci->transports));
case 10: /* algorithms */
return (decode_algorithms(val, &ci->algorithms));
case 11: /* maxSerializedLargeBlobArray */
return (cbor_decode_uint64(val, &ci->maxlargeblob));
case 14: /* fwVersion */
return (cbor_decode_uint64(val, &ci->fwversion));
case 15: /* maxCredBlobLen */
Expand Down Expand Up @@ -461,6 +463,12 @@ fido_cbor_info_maxcredidlen(const fido_cbor_info_t *ci)
return (ci->maxcredidlen);
}

uint64_t
fido_cbor_info_maxlargeblob(const fido_cbor_info_t *ci)
{
return (ci->maxlargeblob);
}

uint64_t
fido_cbor_info_fwversion(const fido_cbor_info_t *ci)
{
Expand Down
9 changes: 9 additions & 0 deletions tools/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ print_maxcredidlen(uint64_t maxcredidlen)
printf("maxcredlen: %d\n", (int)maxcredidlen);
}

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

static void
print_fwversion(uint64_t fwversion)
{
Expand Down Expand Up @@ -259,6 +265,9 @@ token_info(int argc, char **argv, char *path)
/* print maximum length of a credential ID */
print_maxcredidlen(fido_cbor_info_maxcredidlen(ci));

/* print maximum length of serialized largeBlob array */
print_maxlargeblob(fido_cbor_info_maxlargeblob(ci));

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

Expand Down

0 comments on commit c9f78b2

Please sign in to comment.