From c9f78b2124054fb56885a7280fe440fb98d66aa5 Mon Sep 17 00:00:00 2001 From: pedro martelletto Date: Fri, 22 Apr 2022 15:33:19 +0200 Subject: [PATCH] info: add fido_cbor_info_maxlargeblob() add fido_cbor_info_maxlargeblob(), a function to retrieve the maximum size of an authenticator's serialized largeBlob array. --- examples/info.c | 15 ++++++++++++++- fuzz/export.gnu | 3 ++- fuzz/fuzz_mgmt.c | 5 ++++- man/CMakeLists.txt | 3 ++- man/fido_cbor_info_new.3 | 13 +++++++++++-- src/export.gnu | 3 ++- src/export.llvm | 3 ++- src/export.msvc | 3 ++- src/fido.h | 3 ++- src/fido/types.h | 25 +++++++++++++------------ src/info.c | 8 ++++++++ tools/token.c | 9 +++++++++ 12 files changed, 71 insertions(+), 22 deletions(-) diff --git a/examples/info.c b/examples/info.c index 72b786a8..1098580e 100644 --- a/examples/info.c +++ b/examples/info.c @@ -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. */ @@ -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. */ @@ -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)); diff --git a/fuzz/export.gnu b/fuzz/export.gnu index 92a0f931..0ce72434 100644 --- a/fuzz/export.gnu +++ b/fuzz/export.gnu @@ -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; diff --git a/fuzz/fuzz_mgmt.c b/fuzz/fuzz_mgmt.c index 7c28979f..41077e23 100644 --- a/fuzz/fuzz_mgmt.c +++ b/fuzz/fuzz_mgmt.c @@ -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. */ @@ -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)); diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index 8952071c..910ee684 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -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 diff --git a/man/fido_cbor_info_new.3 b/man/fido_cbor_info_new.3 index 86f2a887..45c143f5 100644 --- a/man/fido_cbor_info_new.3 +++ b/man/fido_cbor_info_new.3 @@ -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 @@ -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 @@ -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 @@ -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 . diff --git a/src/export.gnu b/src/export.gnu index 0a8d46a2..8fc94af3 100644 --- a/src/export.gnu +++ b/src/export.gnu @@ -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; diff --git a/src/export.llvm b/src/export.llvm index 80507346..df9a667f 100644 --- a/src/export.llvm +++ b/src/export.llvm @@ -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 diff --git a/src/export.msvc b/src/export.msvc index 14602164..a9082152 100644 --- a/src/export.msvc +++ b/src/export.msvc @@ -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 diff --git a/src/fido.h b/src/fido.h index 52cbb114..63d6de87 100644 --- a/src/fido.h +++ b/src/fido.h @@ -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 *); diff --git a/src/fido/types.h b/src/fido/types.h index 8b5c24f9..593a6a6b 100644 --- a/src/fido/types.h +++ b/src/fido/types.h @@ -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. */ @@ -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 { diff --git a/src/info.c b/src/info.c index 167a1d30..ea26f222 100644 --- a/src/info.c +++ b/src/info.c @@ -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 */ @@ -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) { diff --git a/tools/token.c b/tools/token.c index 3d165623..9124e7b7 100644 --- a/tools/token.c +++ b/tools/token.c @@ -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) { @@ -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));