diff options
Diffstat (limited to 'contrib/libfido2/examples/info.c')
| -rw-r--r-- | contrib/libfido2/examples/info.c | 101 |
1 files changed, 95 insertions, 6 deletions
diff --git a/contrib/libfido2/examples/info.c b/contrib/libfido2/examples/info.c index 72b786a8bd83..a10a50cffb37 100644 --- a/contrib/libfido2/examples/info.c +++ b/contrib/libfido2/examples/info.c @@ -1,7 +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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <fido.h> @@ -104,6 +105,25 @@ print_opt_array(const char *label, char * const *name, const bool *value, } /* + * Auxiliary function to print (char *, uint64_t) pairs on stdout. + */ +static void +print_cert_array(const char *label, char * const *name, const uint64_t *value, + size_t len) +{ + if (len == 0) + return; + + printf("%s: ", label); + + for (size_t i = 0; i < len; i++) + printf("%s%s %llu", i > 0 ? ", " : "", name[i], + (unsigned long long)value[i]); + + printf("\n"); +} + +/* * Auxiliary function to print a list of supported COSE algorithms on stdout. */ static void @@ -120,15 +140,18 @@ print_algorithms(const fido_cbor_info_t *ci) for (size_t i = 0; i < len; i++) { cose = type = "unknown"; switch (fido_cbor_info_algorithm_cose(ci, i)) { - case COSE_EDDSA: - cose = "eddsa"; - break; case COSE_ES256: cose = "es256"; break; + case COSE_ES384: + cose = "es384"; + break; case COSE_RS256: cose = "rs256"; break; + case COSE_EDDSA: + cose = "eddsa"; + break; } if (fido_cbor_info_algorithm_type(ci, i) != NULL) type = fido_cbor_info_algorithm_type(ci, i); @@ -183,6 +206,51 @@ print_maxcredidlen(uint64_t 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 the authenticator's estimated number of + * remaining resident credentials. + */ +static void +print_rk_remaining(int64_t rk_remaining) +{ + printf("remaining rk(s): "); + + if (rk_remaining == -1) + printf("undefined\n"); + else + printf("%d\n", (int)rk_remaining); +} + +/* + * Auxiliary function to print the minimum pin length observed by the + * authenticator. + */ +static void +print_minpinlen(uint64_t minpinlen) +{ + printf("minpinlen: %d\n", (int)minpinlen); +} + +/* + * Auxiliary function to print the authenticator's preferred (platform) + * UV attempts. + */ +static void +print_uv_attempts(uint64_t uv_attempts) +{ + printf("platform uv attempt(s): %d\n", (int)uv_attempts); +} + +/* * Auxiliary function to print an authenticator's firmware version on stdout. */ static void @@ -255,6 +323,14 @@ getinfo(const char *path) fido_cbor_info_options_value_ptr(ci), fido_cbor_info_options_len(ci)); + /* print certifications */ + print_cert_array("certifications", fido_cbor_info_certs_name_ptr(ci), + fido_cbor_info_certs_value_ptr(ci), + fido_cbor_info_certs_len(ci)); + + /* print firmware version */ + print_fwversion(fido_cbor_info_fwversion(ci)); + /* print maximum message size */ print_maxmsgsiz(fido_cbor_info_maxmsgsiz(ci)); @@ -264,13 +340,26 @@ getinfo(const char *path) /* print maximum length of a credential ID */ print_maxcredidlen(fido_cbor_info_maxcredidlen(ci)); - /* print firmware version */ - print_fwversion(fido_cbor_info_fwversion(ci)); + /* print maximum length of largeBlob array */ + print_maxlargeblob(fido_cbor_info_maxlargeblob(ci)); + + /* print number of remaining resident credentials */ + print_rk_remaining(fido_cbor_info_rk_remaining(ci)); + + /* print minimum pin length */ + print_minpinlen(fido_cbor_info_minpinlen(ci)); /* print supported pin protocols */ print_byte_array("pin protocols", fido_cbor_info_protocols_ptr(ci), fido_cbor_info_protocols_len(ci)); + /* print whether a new pin is required */ + printf("pin change required: %s\n", + fido_cbor_info_new_pin_required(ci) ? "true" : "false"); + + /* print platform uv attempts */ + print_uv_attempts(fido_cbor_info_uv_attempts(ci)); + fido_cbor_info_free(&ci); end: if ((r = fido_dev_close(dev)) != FIDO_OK) |
