diff options
author | Ed Maste <emaste@FreeBSD.org> | 2023-04-26 16:40:13 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2023-04-26 16:40:13 +0000 |
commit | fdfa06d7d381e83be6a8c5e39a5bd7af714ac656 (patch) | |
tree | 54d32c05b0d6396408ff0d599d771fb9e7cdd60c | |
parent | cd0b1b947d7afe02b6deaa176ae6767f25818f1b (diff) |
Vendor import of libfido2 0.12.0vendor/libfido2/1.12.0
193 files changed, 4057 insertions, 711 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f10727d40e9..dc31cc0d4806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # 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 # detect AppleClang; needs to come before project() cmake_policy(SET CMP0025 NEW) @@ -28,7 +29,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_COLOR_MAKEFILE OFF) set(CMAKE_VERBOSE_MAKEFILE ON) set(FIDO_MAJOR "1") -set(FIDO_MINOR "11") +set(FIDO_MINOR "12") set(FIDO_PATCH "0") set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH}) @@ -67,7 +68,7 @@ if(NOT MSVC) if(APPLE) set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DARWIN_C_SOURCE") set(FIDO_CFLAGS "${FIDO_CFLAGS} -D__STDC_WANT_LIB_EXT1__=1") - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR MINGW OR CYGWIN) set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_GNU_SOURCE") set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DEFAULT_SOURCE") elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR @@ -277,16 +278,21 @@ else() add_compile_options(-Wwrite-strings) add_compile_options(-Wmissing-prototypes) add_compile_options(-Wbad-function-cast) + add_compile_options(-Wimplicit-fallthrough) add_compile_options(-pedantic) add_compile_options(-pedantic-errors) + set(EXTRA_CFLAGS "-Wconversion -Wsign-conversion") + if(WIN32) add_compile_options(-Wno-type-limits) add_compile_options(-Wno-cast-function-type) endif() + if(HAVE_SHORTEN_64_TO_32) add_compile_options(-Wshorten-64-to-32) endif() + if(HAVE_STACK_PROTECTOR_ALL) add_compile_options(-fstack-protector-all) endif() @@ -301,6 +307,8 @@ else() if(LIBFUZZER) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link") + else() + set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wframe-larger-than=2047") endif() endif() @@ -22,3 +22,5 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +SPDX-License-Identifier: BSD-2-Clause @@ -1,3 +1,25 @@ +* Version 1.12.0 (2022-09-22) + ** Support for COSE_ES384. + ** Support for hidraw(4) on FreeBSD; gh#597. + ** Improved support for FIDO 2.1 authenticators. + ** New API calls: + - es384_pk_free; + - es384_pk_from_EC_KEY; + - es384_pk_from_EVP_PKEY; + - es384_pk_from_ptr; + - es384_pk_new; + - es384_pk_to_EVP_PKEY; + - fido_cbor_info_certs_len; + - fido_cbor_info_certs_name_ptr; + - fido_cbor_info_certs_value_ptr; + - fido_cbor_info_maxrpid_minpinlen; + - fido_cbor_info_minpinlen; + - fido_cbor_info_new_pin_required; + - fido_cbor_info_rk_remaining; + - fido_cbor_info_uv_attempts; + - fido_cbor_info_uv_modality. + ** Documentation and reliability fixes. + * Version 1.11.0 (2022-05-03) ** Experimental PCSC support; enable with -DUSE_PCSC. ** Improved OpenSSL 3.0 compatibility. diff --git a/README.adoc b/README.adoc index c9cdafb5fea8..6d6a96eb1712 100644 --- a/README.adoc +++ b/README.adoc @@ -38,7 +38,7 @@ is also available. === Releases -The current release of *libfido2* is 1.11.0. Signed release tarballs are +The current release of *libfido2* is 1.12.0. Signed release tarballs are available at Yubico's https://developers.yubico.com/libfido2/Releases[release page]. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e558b620fd6e..f013df4e71ec 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright (c) 2018 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 list(APPEND COMPAT_SOURCES ../openbsd-compat/clock_gettime.c diff --git a/examples/README.adoc b/examples/README.adoc index 44ee52743a0d..6853757acad1 100644 --- a/examples/README.adoc +++ b/examples/README.adoc @@ -48,8 +48,8 @@ The following examples are provided: Configures <pin> as the new PIN of <device>. If [oldpin] is provided, the device's PIN is changed from [oldpin] to <pin>. -- cred [-t ecdsa|rsa|eddsa] [-k pubkey] [-ei cred_id] [-P pin] [-T seconds] - [-b blobkey] [-hruv] <device> +- cred [-t es256|es384|rs256|eddsa] [-k pubkey] [-ei cred_id] [-P pin] + [-T seconds] [-b blobkey] [-hruv] <device> Creates a new credential on <device> and verify that the credential was signed by the authenticator. The device's attestation certificate @@ -66,8 +66,8 @@ The following examples are provided: option -b is specified, the credential's "largeBlob" key is stored in <blobkey>. -- assert [-t ecdsa|rsa|eddsa] [-a cred_id] [-h hmac_secret] [-s hmac_salt] - [-P pin] [-T seconds] [-b blobkey] [-puv] <pubkey> <device> +- assert [-t es256|es384|rs256|eddsa] [-a cred_id] [-h hmac_secret] [-P pin] + [-s hmac_salt] [-T seconds] [-b blobkey] [-puv] <pubkey> <device> Asks <device> for a FIDO2 assertion corresponding to [cred_id], which may be omitted for resident keys. The obtained assertion diff --git a/examples/assert.c b/examples/assert.c index 8b0dbd9f6eb2..32ba97b2fca3 100644 --- a/examples/assert.c +++ b/examples/assert.c @@ -1,11 +1,13 @@ /* - * Copyright (c) 2018-2021 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> #include <fido/es256.h> +#include <fido/es384.h> #include <fido/rs256.h> #include <fido/eddsa.h> @@ -30,9 +32,9 @@ static const unsigned char cd[32] = { static void usage(void) { - fprintf(stderr, "usage: assert [-t ecdsa|rsa|eddsa] [-a cred_id] " - "[-h hmac_secret] [-s hmac_salt] [-P pin] [-T seconds] " - "[-b blobkey] [-puv] <pubkey> <device>\n"); + fprintf(stderr, "usage: assert [-t es256|es384|rs256|eddsa] " + "[-a cred_id] [-h hmac_secret] [-s hmac_salt] [-P pin] " + "[-T seconds] [-b blobkey] [-puv] <pubkey> <device>\n"); exit(EXIT_FAILURE); } @@ -46,6 +48,7 @@ verify_assert(int type, const unsigned char *authdata_ptr, size_t authdata_len, RSA *rsa = NULL; EVP_PKEY *eddsa = NULL; es256_pk_t *es256_pk = NULL; + es384_pk_t *es384_pk = NULL; rs256_pk_t *rs256_pk = NULL; eddsa_pk_t *eddsa_pk = NULL; void *pk; @@ -68,6 +71,21 @@ verify_assert(int type, const unsigned char *authdata_ptr, size_t authdata_len, ec = NULL; break; + case COSE_ES384: + if ((ec = read_ec_pubkey(key)) == NULL) + errx(1, "read_ec_pubkey"); + + if ((es384_pk = es384_pk_new()) == NULL) + errx(1, "es384_pk_new"); + + if (es384_pk_from_EC_KEY(es384_pk, ec) != FIDO_OK) + errx(1, "es384_pk_from_EC_KEY"); + + pk = es384_pk; + EC_KEY_free(ec); + ec = NULL; + + break; case COSE_RS256: if ((rsa = read_rsa_pubkey(key)) == NULL) errx(1, "read_rsa_pubkey"); @@ -147,6 +165,7 @@ verify_assert(int type, const unsigned char *authdata_ptr, size_t authdata_len, errx(1, "fido_assert_verify: %s (0x%x)", fido_strerr(r), r); es256_pk_free(&es256_pk); + es384_pk_free(&es384_pk); rs256_pk_free(&rs256_pk); eddsa_pk_free(&eddsa_pk); @@ -219,9 +238,11 @@ main(int argc, char **argv) body = NULL; break; case 't': - if (strcmp(optarg, "ecdsa") == 0) + if (strcmp(optarg, "es256") == 0) type = COSE_ES256; - else if (strcmp(optarg, "rsa") == 0) + else if (strcmp(optarg, "es384") == 0) + type = COSE_ES384; + else if (strcmp(optarg, "rs256") == 0) type = COSE_RS256; else if (strcmp(optarg, "eddsa") == 0) type = COSE_EDDSA; diff --git a/examples/cred.c b/examples/cred.c index 4a9d8bf4b25a..576900d97786 100644 --- a/examples/cred.c +++ b/examples/cred.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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 <errno.h> @@ -34,7 +35,7 @@ static const unsigned char user_id[32] = { static void usage(void) { - fprintf(stderr, "usage: cred [-t ecdsa|rsa|eddsa] [-k pubkey] " + fprintf(stderr, "usage: cred [-t es256|es384|rs256|eddsa] [-k pubkey] " "[-ei cred_id] [-P pin] [-T seconds] [-b blobkey] [-hruv] " "<device>\n"); exit(EXIT_FAILURE); @@ -107,15 +108,23 @@ out: if (key_out != NULL) { /* extract the credential pubkey */ if (type == COSE_ES256) { - if (write_ec_pubkey(key_out, fido_cred_pubkey_ptr(cred), + if (write_es256_pubkey(key_out, + fido_cred_pubkey_ptr(cred), fido_cred_pubkey_len(cred)) < 0) - errx(1, "write_ec_pubkey"); + errx(1, "write_es256_pubkey"); + } else if (type == COSE_ES384) { + if (write_es384_pubkey(key_out, + fido_cred_pubkey_ptr(cred), + fido_cred_pubkey_len(cred)) < 0) + errx(1, "write_es384_pubkey"); } else if (type == COSE_RS256) { - if (write_rsa_pubkey(key_out, fido_cred_pubkey_ptr(cred), + if (write_rs256_pubkey(key_out, + fido_cred_pubkey_ptr(cred), fido_cred_pubkey_len(cred)) < 0) - errx(1, "write_rsa_pubkey"); + errx(1, "write_rs256_pubkey"); } else if (type == COSE_EDDSA) { - if (write_eddsa_pubkey(key_out, fido_cred_pubkey_ptr(cred), + if (write_eddsa_pubkey(key_out, + fido_cred_pubkey_ptr(cred), fido_cred_pubkey_len(cred)) < 0) errx(1, "write_eddsa_pubkey"); } @@ -193,9 +202,11 @@ main(int argc, char **argv) rk = true; break; case 't': - if (strcmp(optarg, "ecdsa") == 0) + if (strcmp(optarg, "es256") == 0) type = COSE_ES256; - else if (strcmp(optarg, "rsa") == 0) + else if (strcmp(optarg, "es384") == 0) + type = COSE_ES384; + else if (strcmp(optarg, "rs256") == 0) type = COSE_RS256; else if (strcmp(optarg, "eddsa") == 0) type = COSE_EDDSA; diff --git a/examples/extern.h b/examples/extern.h index 5633b23d2003..5cffd7fbf882 100644 --- a/examples/extern.h +++ b/examples/extern.h @@ -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 */ #ifndef _EXTERN_H_ @@ -18,8 +19,9 @@ EVP_PKEY *read_eddsa_pubkey(const char *); int base10(const char *, long long *); int read_blob(const char *, unsigned char **, size_t *); int write_blob(const char *, const unsigned char *, size_t); -int write_ec_pubkey(const char *, const void *, size_t); -int write_rsa_pubkey(const char *, const void *, size_t); +int write_es256_pubkey(const char *, const void *, size_t); +int write_es384_pubkey(const char *, const void *, size_t); +int write_rs256_pubkey(const char *, const void *, size_t); int write_eddsa_pubkey(const char *, const void *, size_t); #endif /* _EXTERN_H_ */ diff --git a/examples/info.c b/examples/info.c index 1098580eec6f..a10a50cffb37 100644 --- a/examples/info.c +++ b/examples/info.c @@ -2,6 +2,7 @@ * 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); @@ -193,6 +216,41 @@ print_maxlargeblob(uint64_t 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 @@ -265,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)); @@ -277,13 +343,23 @@ getinfo(const char *path) /* print maximum length of largeBlob array */ print_maxlargeblob(fido_cbor_info_maxlargeblob(ci)); - /* print firmware version */ - print_fwversion(fido_cbor_info_fwversion(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) diff --git a/examples/manifest.c b/examples/manifest.c index d38166a9fea9..c2b3bf19137b 100644 --- a/examples/manifest.c +++ b/examples/manifest.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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> diff --git a/examples/reset.c b/examples/reset.c index b429d05f0fe4..767a162b6f63 100644 --- a/examples/reset.c +++ b/examples/reset.c @@ -2,6 +2,7 @@ * Copyright (c) 2018-2021 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 */ /* diff --git a/examples/retries.c b/examples/retries.c index b96118b1e154..a0610fe13903 100644 --- a/examples/retries.c +++ b/examples/retries.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ /* @@ -35,7 +36,7 @@ main(int argc, char **argv) errx(1, "fido_open: %s (0x%x)", fido_strerr(r), r); if ((r = fido_dev_get_retry_count(dev, &n)) != FIDO_OK) - errx(1, "fido_get_retries: %s (0x%x)", fido_strerr(r), r); + errx(1, "fido_dev_get_retry_count: %s (0x%x)", fido_strerr(r), r); if ((r = fido_dev_close(dev)) != FIDO_OK) errx(1, "fido_close: %s (0x%x)", fido_strerr(r), r); diff --git a/examples/select.c b/examples/select.c index 05f6a331fd4c..008eb2e99b8f 100644 --- a/examples/select.c +++ b/examples/select.c @@ -2,6 +2,7 @@ * Copyright (c) 2020-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 <errno.h> diff --git a/examples/setpin.c b/examples/setpin.c index 7fa0dcc764f3..72e08e4b9088 100644 --- a/examples/setpin.c +++ b/examples/setpin.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ /* diff --git a/examples/util.c b/examples/util.c index 8b360af21c7a..0c0c77a94001 100644 --- a/examples/util.c +++ b/examples/util.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 <sys/types.h> @@ -13,6 +14,7 @@ #include <fido.h> #include <fido/es256.h> +#include <fido/es384.h> #include <fido/rs256.h> #include <fido/eddsa.h> @@ -158,7 +160,7 @@ fail: } int -write_ec_pubkey(const char *path, const void *ptr, size_t len) +write_es256_pubkey(const char *path, const void *ptr, size_t len) { FILE *fp = NULL; EVP_PKEY *pkey = NULL; @@ -214,6 +216,63 @@ fail: return (ok); } +int +write_es384_pubkey(const char *path, const void *ptr, size_t len) +{ + FILE *fp = NULL; + EVP_PKEY *pkey = NULL; + es384_pk_t *pk = NULL; + int fd = -1; + int ok = -1; + + if ((pk = es384_pk_new()) == NULL) { + warnx("es384_pk_new"); + goto fail; + } + + if (es384_pk_from_ptr(pk, ptr, len) != FIDO_OK) { + warnx("es384_pk_from_ptr"); + goto fail; + } + + if ((fd = open(path, O_WRONLY | O_CREAT, 0644)) < 0) { + warn("open %s", path); + goto fail; + } + + if ((fp = fdopen(fd, "w")) == NULL) { + warn("fdopen"); + goto fail; + } + fd = -1; /* owned by fp now */ + + if ((pkey = es384_pk_to_EVP_PKEY(pk)) == NULL) { + warnx("es384_pk_to_EVP_PKEY"); + goto fail; + } + + if (PEM_write_PUBKEY(fp, pkey) == 0) { + warnx("PEM_write_PUBKEY"); + goto fail; + } + + ok = 0; +fail: + es384_pk_free(&pk); + + if (fp != NULL) { + fclose(fp); + } + if (fd != -1) { + close(fd); + } + if (pkey != NULL) { + EVP_PKEY_free(pkey); + } + + return (ok); +} + RSA * read_rsa_pubkey(const char *path) { @@ -247,7 +306,7 @@ fail: } int -write_rsa_pubkey(const char *path, const void *ptr, size_t len) +write_rs256_pubkey(const char *path, const void *ptr, size_t len) { FILE *fp = NULL; EVP_PKEY *pkey = NULL; diff --git a/fuzz/CMakeLists.txt b/fuzz/CMakeLists.txt index 4b6fdfbfca4f..52355c1ab6b0 100644 --- a/fuzz/CMakeLists.txt +++ b/fuzz/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright (c) 2019 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 list(APPEND COMPAT_SOURCES ../openbsd-compat/strlcpy.c diff --git a/fuzz/Dockerfile b/fuzz/Dockerfile index a899df2c3ddd..0c99f2c95aaf 100644 --- a/fuzz/Dockerfile +++ b/fuzz/Dockerfile @@ -1,16 +1,16 @@ # 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. +# SPDX-License-Identifier: BSD-2-Clause -FROM ubuntu:focal -ENV DEBIAN_FRONTEND=noninteractive -ENV CC=clang-14 -ENV CXX=clang++-14 -RUN apt-get update -RUN apt-get install -y cmake git libssl-dev libudev-dev make pkg-config -RUN apt-get install -y libpcsclite-dev zlib1g-dev software-properties-common +FROM alpine:latest +ENV CC=clang +ENV CXX=clang++ +RUN apk -q update +RUN apk add build-base clang clang-analyzer cmake compiler-rt coreutils +RUN apk add eudev-dev git linux-headers llvm openssl-dev pcsc-lite-dev +RUN apk add sudo tar zlib-dev RUN git clone --branch v0.9.0 --depth=1 https://github.com/PJK/libcbor RUN git clone --depth=1 https://github.com/yubico/libfido2 WORKDIR /libfido2 -RUN ./.actions/setup_clang "${CC}" RUN ./fuzz/build-coverage /libcbor /libfido2 diff --git a/fuzz/Makefile b/fuzz/Makefile index 6abf59c3e69d..857c89ee0742 100644 --- a/fuzz/Makefile +++ b/fuzz/Makefile @@ -1,11 +1,12 @@ # 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. +# SPDX-License-Identifier: BSD-2-Clause -IMAGE := libfido2-coverage:1.11.2 +IMAGE := libfido2-coverage:1.12.2 RUNNER := libfido2-runner -PROFDATA := llvm-profdata-14 -COV := llvm-cov-14 +PROFDATA := llvm-profdata +COV := llvm-cov TARGETS := fuzz_assert fuzz_bio fuzz_cred fuzz_credman fuzz_hid \ fuzz_largeblob fuzz_netlink fuzz_mgmt fuzz_pcsc CORPORA := $(foreach f,${TARGETS},${f}/corpus) @@ -75,8 +76,15 @@ ${CORPORA}: -mkdir -p $@ gsutil -q -m rsync -d -r ${REMOTE}/libFuzzer/libfido2_$(@:/corpus=) $@ -corpus.tgz: ${CORPORA} +fetch-oss-fuzz: ${CORPORA} + find ${TARGETS} -type f -size +8192c -print0 | xargs -0 rm + +fetch-franz: + ssh franz tar -C corpus -cf- . | tar -xf- + +corpus.tgz: tar zcf $@ ${TARGETS} .PHONY: build run sync corpus ${TARGETS} ${CORPORA} .PHONY: report.tgz summary.txt functions.txt +.PHONY: fetch-oss-fuzz fetch-franz corpus.tgz diff --git a/fuzz/README b/fuzz/README index 28fc7f8f51b2..2e88db74975e 100644 --- a/fuzz/README +++ b/fuzz/README @@ -10,6 +10,13 @@ libFuzzer is better suited for bespoke fuzzers; see fuzz_cred.c, fuzz_credman.c, fuzz_assert.c, fuzz_hid.c, and fuzz_mgmt.c for examples. To build these harnesses, use -DFUZZ=ON -DLIBFUZZER=ON. +If -DFUZZ=ON is enabled, symbols listed in wrapped.sym are wrapped in the +resulting shared object. The wrapper functions simulate failure according to a +deterministic RNG and probabilities defined in wrap.c. Harnesses wishing to +use this functionality should call prng_init() with a seed obtained from the +corpus. To mutate only the seed part of a libFuzzer harness's corpora, +use '-reduce_inputs=0 --fido-mutate=seed'. + To run under ASAN/MSAN/UBSAN, libfido2 needs to be linked against flavours of libcbor and OpenSSL built with the respective sanitiser. In order to keep memory utilisation at a manageable level, you can either enforce limits at diff --git a/fuzz/build-coverage b/fuzz/build-coverage index e0e90da02b5d..8c989fc0cb6d 100755 --- a/fuzz/build-coverage +++ b/fuzz/build-coverage @@ -3,6 +3,7 @@ # Copyright (c) 2019 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 LIBCBOR="$1" LIBFIDO2="$2" diff --git a/fuzz/clock.c b/fuzz/clock.c index 23803c2ee3e5..bd758ea1a497 100644 --- a/fuzz/clock.c +++ b/fuzz/clock.c @@ -2,6 +2,7 @@ * Copyright (c) 2021 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 <stdint.h> diff --git a/fuzz/dummy.h b/fuzz/dummy.h index b0225440e5da..fc4bfc5ada4b 100644 --- a/fuzz/dummy.h +++ b/fuzz/dummy.h @@ -2,6 +2,7 @@ * Copyright (c) 2020-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 */ #ifndef _DUMMY_H diff --git a/fuzz/export.gnu b/fuzz/export.gnu index 0ce72434fbd8..f0fb840dd686 100644 --- a/fuzz/export.gnu +++ b/fuzz/export.gnu @@ -11,6 +11,12 @@ es256_pk_from_ptr; es256_pk_new; es256_pk_to_EVP_PKEY; + es384_pk_free; + es384_pk_from_EC_KEY; + es384_pk_from_EVP_PKEY; + es384_pk_from_ptr; + es384_pk_new; + es384_pk_to_EVP_PKEY; fido_assert_allow_cred; fido_assert_authdata_len; fido_assert_authdata_ptr; @@ -82,23 +88,32 @@ fido_cbor_info_algorithm_cose; fido_cbor_info_algorithm_count; fido_cbor_info_algorithm_type; + fido_cbor_info_certs_len; + fido_cbor_info_certs_name_ptr; + fido_cbor_info_certs_value_ptr; fido_cbor_info_extensions_len; fido_cbor_info_extensions_ptr; fido_cbor_info_free; + fido_cbor_info_fwversion; 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_maxrpid_minpinlen; + fido_cbor_info_minpinlen; fido_cbor_info_new; + fido_cbor_info_new_pin_required; fido_cbor_info_options_len; fido_cbor_info_options_name_ptr; fido_cbor_info_options_value_ptr; fido_cbor_info_protocols_len; fido_cbor_info_protocols_ptr; + fido_cbor_info_rk_remaining; fido_cbor_info_transports_len; fido_cbor_info_transports_ptr; + fido_cbor_info_uv_attempts; + fido_cbor_info_uv_modality; fido_cbor_info_versions_len; fido_cbor_info_versions_ptr; fido_cred_attstmt_len; @@ -257,6 +272,7 @@ prng_init; prng_up; fuzz_clock_reset; + fuzz_save_corpus; set_netlink_io_functions; set_pcsc_parameters; set_pcsc_io_functions; diff --git a/fuzz/functions.txt b/fuzz/functions.txt index 9c1a03cffb0b..da7f058d6c00 100644 --- a/fuzz/functions.txt +++ b/fuzz/functions.txt @@ -5,20 +5,20 @@ aes256_cbc_enc 4 0 100.00% 4 0 100.00% aes256_cbc_dec 4 0 100.00% 4 0 100.00% aes256_gcm_enc 1 0 100.00% 3 0 100.00% aes256_gcm_dec 1 0 100.00% 3 0 100.00% -aes256.c:aes256_cbc_fips 26 2 92.31% 42 7 83.33% +aes256.c:aes256_cbc_fips 26 1 96.15% 42 4 90.48% aes256.c:aes256_cbc 29 1 96.55% 36 3 91.67% aes256.c:aes256_cbc_proto1 1 0 100.00% 5 0 100.00% aes256.c:aes256_gcm 52 1 98.08% 60 4 93.33% -------------------------------------------------------------------------------------------------------- -TOTAL 118 4 96.61% 157 14 91.08% +TOTAL 118 3 97.46% 157 11 92.99% File '/libfido2/src/assert.c': Name Regions Miss Cover Lines Miss Cover ----------------------------------------------------------------------------------------------------------------- fido_dev_get_assert 40 0 100.00% 35 0 100.00% fido_check_flags 13 0 100.00% 15 0 100.00% -fido_get_signed_hash 36 0 100.00% 46 0 100.00% -fido_assert_verify 48 4 91.67% 67 7 89.55% +fido_get_signed_hash 20 1 95.00% 34 3 91.18% +fido_assert_verify 50 4 92.00% 70 7 90.00% fido_assert_set_clientdata 12 12 0.00% 11 11 0.00% fido_assert_set_clientdata_hash 8 0 100.00% 6 0 100.00% fido_assert_set_hmac_salt 10 0 100.00% 6 0 100.00% @@ -62,17 +62,20 @@ fido_assert_set_sig 14 0 100.00% 7 0 fido_assert_set_count 10 0 100.00% 17 0 100.00% assert.c:fido_dev_get_assert_wait 21 0 100.00% 14 0 100.00% assert.c:fido_dev_get_assert_tx 56 2 96.43% 62 5 91.94% -assert.c:fido_dev_get_assert_rx 19 0 100.00% 27 0 100.00% +assert.c:fido_dev_get_assert_rx 27 0 100.00% 36 0 100.00% assert.c:adjust_assert_count 24 0 100.00% 26 0 100.00% assert.c:parse_assert_reply 12 0 100.00% 24 0 100.00% assert.c:fido_get_next_assert_tx 8 0 100.00% 8 0 100.00% -assert.c:fido_get_next_assert_rx 15 2 86.67% 21 4 80.95% +assert.c:fido_get_next_assert_rx 23 2 91.30% 29 5 82.76% assert.c:decrypt_hmac_secrets 9 0 100.00% 15 0 100.00% +assert.c:get_es256_hash 16 0 100.00% 17 0 100.00% +assert.c:get_es384_hash 16 0 100.00% 17 0 100.00% +assert.c:get_eddsa_hash 6 0 100.00% 9 0 100.00% assert.c:check_extensions 5 0 100.00% 9 0 100.00% assert.c:fido_assert_reset_extattr 1 0 100.00% 5 0 100.00% assert.c:fido_assert_clean_authdata 1 0 100.00% 5 0 100.00% ----------------------------------------------------------------------------------------------------------------- -TOTAL 565 42 92.57% 694 42 93.95% +TOTAL 605 43 92.89% 745 46 93.83% File '/libfido2/src/authkey.c': Name Regions Miss Cover Lines Miss Cover @@ -80,10 +83,10 @@ Name Regions Miss Cover Lines Miss fido_dev_authkey 1 0 100.00% 3 0 100.00% authkey.c:fido_dev_authkey_wait 10 0 100.00% 7 0 100.00% authkey.c:fido_dev_authkey_tx 19 0 100.00% 25 0 100.00% -authkey.c:fido_dev_authkey_rx 6 0 100.00% 14 0 100.00% +authkey.c:fido_dev_authkey_rx 14 0 100.00% 21 0 100.00% authkey.c:parse_authkey 8 0 100.00% 10 0 100.00% ----------------------------------------------------------------------------------------------------------------- -TOTAL 44 0 100.00% 59 0 100.00% +TOTAL 52 0 100.00% 66 0 100.00% File '/libfido2/src/bio.c': Name Regions Miss Cover Lines Miss Cover @@ -117,28 +120,28 @@ fido_bio_enroll_last_status 1 0 100.00% 3 0 bio.c:bio_get_template_array_wait 11 0 100.00% 7 0 100.00% bio.c:bio_tx 43 0 100.00% 55 0 100.00% bio.c:bio_prepare_hmac 18 0 100.00% 29 0 100.00% -bio.c:bio_rx_template_array 11 0 100.00% 17 0 100.00% +bio.c:bio_rx_template_array 19 0 100.00% 24 0 100.00% bio.c:bio_parse_template_array 26 1 96.15% 27 4 85.19% bio.c:decode_template_array 12 1 91.67% 18 3 83.33% bio.c:decode_template 9 0 100.00% 15 0 100.00% bio.c:bio_set_template_name_wait 19 0 100.00% 20 0 100.00% bio.c:bio_enroll_begin_wait 17 0 100.00% 19 0 100.00% -bio.c:bio_rx_enroll_begin 15 0 100.00% 24 0 100.00% +bio.c:bio_rx_enroll_begin 23 0 100.00% 31 0 100.00% bio.c:bio_parse_enroll_status 20 0 100.00% 28 0 100.00% bio.c:bio_parse_template_id 8 0 100.00% 10 0 100.00% bio.c:bio_enroll_continue_wait 19 0 100.00% 20 0 100.00% -bio.c:bio_rx_enroll_continue 11 0 100.00% 18 0 100.00% +bio.c:bio_rx_enroll_continue 19 0 100.00% 25 0 100.00% bio.c:bio_enroll_cancel_wait 11 11 0.00% 10 10 0.00% bio.c:bio_enroll_remove_wait 17 0 100.00% 19 0 100.00% bio.c:bio_get_info_wait 11 0 100.00% 10 0 100.00% -bio.c:bio_rx_info 11 0 100.00% 17 0 100.00% +bio.c:bio_rx_info 19 0 100.00% 24 0 100.00% bio.c:bio_reset_info 1 0 100.00% 4 0 100.00% bio.c:bio_parse_info 20 0 100.00% 28 0 100.00% bio.c:bio_reset_template_array 4 0 100.00% 7 0 100.00% bio.c:bio_reset_template 1 0 100.00% 5 0 100.00% bio.c:bio_reset_enroll 3 0 100.00% 6 0 100.00% ----------------------------------------------------------------------------------------------------------------- -TOTAL 419 20 95.23% 559 24 95.71% +TOTAL 451 20 95.57% 587 24 95.91% File '/libfido2/src/blob.c': Name Regions Miss Cover Lines Miss Cover @@ -192,7 +195,7 @@ cbor_encode_pin_opt 4 0 100.00% 8 0 cbor_encode_change_pin_auth 32 1 96.88% 36 3 91.67% cbor_encode_assert_ext 33 0 100.00% 32 0 100.00% cbor_decode_fmt 13 0 100.00% 15 0 100.00% -cbor_decode_pubkey 21 1 95.24% 30 2 93.33% +cbor_decode_pubkey 26 1 96.15% 36 2 94.44% cbor_decode_cred_authdata 31 1 96.77% 35 3 91.43% cbor_decode_assert_authdata 21 0 100.00% 32 0 100.00% cbor_decode_attstmt 13 0 100.00% 16 0 100.00% @@ -200,38 +203,39 @@ cbor_decode_uint64 4 0 100.00% 8 0 cbor_decode_cred_id 8 0 100.00% 9 0 100.00% cbor_decode_user 8 0 100.00% 9 0 100.00% cbor_decode_rp_entity 8 0 100.00% 9 0 100.00% +cbor_decode_bool 10 0 100.00% 11 0 100.00% cbor_build_uint 10 1 90.00% 9 1 88.89% cbor_array_append 17 0 100.00% 21 0 100.00% -cbor_array_drop 18 2 88.89% 17 3 82.35% +cbor_array_drop 18 0 100.00% 17 0 100.00% cbor.c:ctap_check_cbor 28 0 100.00% 26 0 100.00% cbor.c:check_key_type 8 0 100.00% 7 0 100.00% cbor.c:cbor_add_arg 13 0 100.00% 21 0 100.00% cbor.c:cbor_add_uint8 14 0 100.00% 21 0 100.00% cbor.c:cbor_encode_largeblob_key_ext 6 0 100.00% 6 0 100.00% cbor.c:cbor_encode_hmac_secret_param 59 4 93.22% 66 8 87.88% -cbor.c:get_cose_alg 36 0 100.00% 38 0 100.00% +cbor.c:get_cose_alg 46 1 97.83% 45 3 93.33% cbor.c:find_cose_alg 35 0 100.00% 33 0 100.00% cbor.c:decode_attcred 25 0 100.00% 44 0 100.00% cbor.c:decode_cred_extensions 14 0 100.00% 24 0 100.00% -cbor.c:decode_cred_extension 49 10 79.59% 49 17 65.31% +cbor.c:decode_cred_extension 41 1 97.56% 45 3 93.33% cbor.c:decode_assert_extensions 14 0 100.00% 23 0 100.00% cbor.c:decode_assert_extension 19 0 100.00% 27 0 100.00% -cbor.c:decode_attstmt_entry 52 0 100.00% 50 0 100.00% +cbor.c:decode_attstmt_entry 56 0 100.00% 51 0 100.00% cbor.c:decode_x5c 4 0 100.00% 6 0 100.00% cbor.c:decode_cred_id_entry 10 0 100.00% 19 0 100.00% cbor.c:decode_user_entry 25 0 100.00% 35 0 100.00% cbor.c:decode_rp_entity_entry 15 0 100.00% 25 0 100.00% ------------------------------------------------------------------------------------------------------------------ -TOTAL 1049 23 97.81% 1237 45 96.36% +TOTAL 1070 13 98.79% 1258 31 97.54% File '/libfido2/src/compress.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------ fido_compress 1 0 100.00% 3 0 100.00% fido_uncompress 6 0 100.00% 5 0 100.00% -compress.c:rfc1951_deflate 33 2 93.94% 47 3 93.62% +compress.c:rfc1951_deflate 33 4 87.88% 47 6 87.23% compress.c:rfc1950_inflate 27 2 92.59% 22 4 81.82% -compress.c:rfc1951_inflate 38 10 73.68% 45 17 62.22% +compress.c:rfc1951_inflate 38 8 78.95% 45 14 68.89% ------------------------------------------------------------------------------------------------------------------ TOTAL 105 14 86.67% 122 24 80.33% @@ -244,21 +248,21 @@ fido_dev_set_pin_minlen 1 0 100.00% 4 fido_dev_force_pin_change 1 0 100.00% 4 0 100.00% fido_dev_set_pin_minlen_rpid 6 0 100.00% 15 0 100.00% config.c:config_enable_entattest_wait 6 0 100.00% 7 0 100.00% -config.c:config_tx 37 0 100.00% 48 0 100.00% +config.c:config_tx 41 0 100.00% 49 0 100.00% config.c:config_prepare_hmac 8 0 100.00% 19 0 100.00% config.c:config_toggle_always_uv_wait 6 0 100.00% 7 0 100.00% config.c:config_pin_minlen 5 0 100.00% 7 0 100.00% config.c:config_pin_minlen_tx 36 0 100.00% 32 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 108 0 100.00% 151 0 100.00% +TOTAL 112 0 100.00% 152 0 100.00% File '/libfido2/src/cred.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- fido_dev_make_cred 12 0 100.00% 10 0 100.00% fido_check_rp_id 4 0 100.00% 11 0 100.00% -fido_cred_verify 56 2 96.43% 72 4 94.44% -fido_cred_verify_self 58 4 93.10% 83 7 91.57% +fido_cred_verify 59 2 96.61% 75 4 94.67% +fido_cred_verify_self 60 6 90.00% 87 11 87.36% fido_cred_new 1 0 100.00% 3 0 100.00% fido_cred_reset_tx 1 0 100.00% 19 0 100.00% fido_cred_reset_rx 1 0 100.00% 7 0 100.00% @@ -280,9 +284,9 @@ fido_cred_set_rk 2 0 100.00% 4 fido_cred_set_uv 2 0 100.00% 4 0 100.00% fido_cred_set_prot 21 0 100.00% 14 0 100.00% fido_cred_set_pin_minlen 7 0 100.00% 8 0 100.00% -fido_cred_set_blob 13 2 84.62% 8 1 87.50% +fido_cred_set_blob 13 0 100.00% 8 0 100.00% fido_cred_set_fmt 20 4 80.00% 12 2 83.33% -fido_cred_set_type 17 0 100.00% 7 0 100.00% +fido_cred_set_type 23 2 91.30% 9 1 88.89% fido_cred_type 1 0 100.00% 3 0 100.00% fido_cred_flags 1 0 100.00% 3 0 100.00% fido_cred_sigcount 1 0 100.00% 3 0 100.00% @@ -298,8 +302,8 @@ fido_cred_authdata_raw_ptr 1 0 100.00% 3 fido_cred_authdata_raw_len 1 0 100.00% 3 0 100.00% fido_cred_attstmt_ptr 1 0 100.00% 3 0 100.00% fido_cred_attstmt_len 1 0 100.00% 3 0 100.00% -fido_cred_pubkey_ptr 9 0 100.00% 18 0 100.00% -fido_cred_pubkey_len 9 0 100.00% 18 0 100.00% +fido_cred_pubkey_ptr 11 0 100.00% 21 0 100.00% +fido_cred_pubkey_len 11 0 100.00% 21 0 100.00% fido_cred_id_ptr 1 0 100.00% 3 0 100.00% fido_cred_id_len 1 0 100.00% 3 0 100.00% fido_cred_aaguid_ptr 1 0 100.00% 3 0 100.00% @@ -320,12 +324,12 @@ cred.c:fido_dev_make_cred_tx 64 0 100.00% 70 cred.c:fido_dev_make_cred_rx 29 0 100.00% 32 0 100.00% cred.c:parse_makecred_reply 14 0 100.00% 27 0 100.00% cred.c:check_extensions 2 0 100.00% 6 0 100.00% -cred.c:get_signed_hash_u2f 27 0 100.00% 26 0 100.00% -cred.c:verify_attstmt 23 2 91.30% 40 6 85.00% +cred.c:get_signed_hash_u2f 27 0 100.00% 27 0 100.00% +cred.c:verify_attstmt 25 2 92.00% 43 6 86.05% cred.c:fido_cred_clean_authdata 1 0 100.00% 8 0 100.00% cred.c:fido_cred_clean_attstmt 1 0 100.00% 8 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 634 36 94.32% 830 39 95.30% +TOTAL 651 38 94.16% 849 43 94.94% File '/libfido2/src/credman.c': Name Regions Miss Cover Lines Miss Cover @@ -353,32 +357,32 @@ fido_credman_rp_id_hash_ptr 4 0 100.00% 5 credman.c:credman_get_metadata_wait 11 0 100.00% 8 0 100.00% credman.c:credman_tx 36 0 100.00% 50 0 100.00% credman.c:credman_prepare_hmac 31 1 96.77% 50 2 96.00% -credman.c:credman_rx_metadata 11 0 100.00% 17 0 100.00% +credman.c:credman_rx_metadata 19 0 100.00% 24 0 100.00% credman.c:credman_parse_metadata 9 0 100.00% 17 0 100.00% credman.c:credman_get_rk_wait 27 0 100.00% 23 0 100.00% -credman.c:credman_rx_rk 19 0 100.00% 27 0 100.00% +credman.c:credman_rx_rk 27 0 100.00% 35 0 100.00% credman.c:credman_parse_rk_count 16 0 100.00% 20 0 100.00% credman.c:credman_grow_array 17 2 88.24% 21 5 76.19% credman.c:credman_parse_rk 23 0 100.00% 31 0 100.00% -credman.c:credman_rx_next_rk 15 2 86.67% 21 4 80.95% +credman.c:credman_rx_next_rk 23 2 91.30% 29 5 82.76% credman.c:credman_del_rk_wait 16 0 100.00% 15 0 100.00% credman.c:credman_get_rp_wait 23 0 100.00% 15 0 100.00% -credman.c:credman_rx_rp 19 0 100.00% 27 0 100.00% +credman.c:credman_rx_rp 27 0 100.00% 35 0 100.00% credman.c:credman_parse_rp_count 16 0 100.00% 20 0 100.00% credman.c:credman_parse_rp 9 0 100.00% 17 0 100.00% -credman.c:credman_rx_next_rp 15 2 86.67% 21 4 80.95% +credman.c:credman_rx_next_rp 23 2 91.30% 29 5 82.76% credman.c:credman_set_dev_rk_wait 11 0 100.00% 8 0 100.00% credman.c:credman_reset_rk 4 0 100.00% 9 0 100.00% credman.c:credman_reset_rp 4 0 100.00% 12 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 382 10 97.38% 518 18 96.53% +TOTAL 422 10 97.63% 557 20 96.41% File '/libfido2/src/dev.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- fido_dev_info_manifest 2 0 100.00% 11 0 100.00% fido_dev_open_with_info 5 5 0.00% 6 6 0.00% -fido_dev_open 13 6 53.85% 16 6 62.50% +fido_dev_open 13 4 69.23% 16 6 62.50% fido_dev_close 9 2 77.78% 8 1 87.50% fido_dev_set_sigmask 18 18 0.00% 11 11 0.00% fido_dev_cancel 11 0 100.00% 8 0 100.00% @@ -410,7 +414,7 @@ fido_dev_maxmsgsize 1 0 100.00% 3 fido_dev_set_timeout 6 2 66.67% 6 1 83.33% dev.c:run_manifest 10 0 100.00% 13 0 100.00% dev.c:fido_dev_open_wait 10 0 100.00% 7 0 100.00% -dev.c:fido_dev_open_tx 56 15 73.21% 56 26 53.57% +dev.c:fido_dev_open_tx 56 11 80.36% 56 20 64.29% dev.c:set_random_report_len 11 0 100.00% 6 0 100.00% dev.c:fido_dev_open_rx 36 1 97.22% 53 1 98.11% dev.c:fido_dev_set_flags 1 0 100.00% 5 0 100.00% @@ -418,7 +422,7 @@ dev.c:fido_dev_set_extension_flags 7 0 100.00% 7 dev.c:fido_dev_set_option_flags 31 0 100.00% 20 0 100.00% dev.c:fido_dev_set_protocol_flags 11 0 100.00% 17 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 332 71 78.61% 378 86 77.25% +TOTAL 332 65 80.42% 378 80 78.84% File '/libfido2/src/ecdh.c': Name Regions Miss Cover Lines Miss Cover @@ -478,10 +482,31 @@ es256.c:decode_coord 8 0 100.00% 10 ------------------------------------------------------------------------------------------------------------------- TOTAL 315 7 97.78% 372 12 96.77% +File '/libfido2/src/es384.c': +Name Regions Miss Cover Lines Miss Cover +------------------------------------------------------------------------------------------------------------------- +es384_pk_decode 8 0 100.00% 9 0 100.00% +es384_pk_new 1 0 100.00% 3 0 100.00% +es384_pk_free 6 0 100.00% 7 0 100.00% +es384_pk_from_ptr 15 0 100.00% 17 0 100.00% +es384_pk_to_EVP_PKEY 42 0 100.00% 53 0 100.00% +es384_pk_from_EC_KEY 42 2 95.24% 47 4 91.49% +es384_pk_from_EVP_PKEY 8 2 75.00% 7 1 85.71% +es384_verify_sig 12 2 83.33% 19 5 73.68% +es384_pk_verify_sig 7 1 85.71% 13 2 84.62% +es384.c:decode_pubkey_point 9 0 100.00% 13 0 100.00% +es384.c:decode_coord 8 1 87.50% 10 3 70.00% +------------------------------------------------------------------------------------------------------------------- +TOTAL 158 8 94.94% 198 15 92.42% + File '/libfido2/src/extern.h': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- +File '/libfido2/src/fallthrough.h': +Name Regions Miss Cover Lines Miss Cover +------------------------------------------------------------------------------------------------------------------- + File '/libfido2/src/fido.h': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- @@ -510,7 +535,7 @@ File '/libfido2/src/hid_linux.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- fido_hid_manifest 35 4 88.57% 41 2 95.12% -fido_hid_open 27 27 0.00% 40 40 0.00% +fido_hid_open 33 33 0.00% 51 51 0.00% fido_hid_close 3 3 0.00% 6 6 0.00% fido_hid_set_sigmask 2 2 0.00% 6 6 0.00% fido_hid_read 15 15 0.00% 21 21 0.00% @@ -518,13 +543,13 @@ fido_hid_write 12 12 0.00% 17 1 fido_hid_report_in_len 1 1 0.00% 4 4 0.00% fido_hid_report_out_len 1 1 0.00% 4 4 0.00% hid_linux.c:copy_info 34 0 100.00% 44 0 100.00% -hid_linux.c:is_fido 10 2 80.00% 14 2 85.71% +hid_linux.c:is_fido 15 1 93.33% 16 1 93.75% hid_linux.c:get_parent_attr 6 0 100.00% 9 0 100.00% hid_linux.c:parse_uevent 12 0 100.00% 24 0 100.00% hid_linux.c:get_usb_attr 1 0 100.00% 3 0 100.00% hid_linux.c:get_report_descriptor 14 1 92.86% 17 3 82.35% ------------------------------------------------------------------------------------------------------------------- -TOTAL 173 68 60.69% 250 105 58.00% +TOTAL 184 73 60.33% 263 115 56.27% File '/libfido2/src/hid_unix.c': Name Regions Miss Cover Lines Miss Cover @@ -539,8 +564,8 @@ Name Regions Miss Cover Lines Mis ------------------------------------------------------------------------------------------------------------------- fido_dev_get_cbor_info_wait 10 0 100.00% 7 0 100.00% fido_dev_get_cbor_info 1 0 100.00% 4 0 100.00% -fido_cbor_info_new 1 0 100.00% 3 0 100.00% -fido_cbor_info_reset 1 0 100.00% 8 0 100.00% +fido_cbor_info_new 4 0 100.00% 7 0 100.00% +fido_cbor_info_reset 1 0 100.00% 10 0 100.00% fido_cbor_info_free 6 0 100.00% 8 0 100.00% fido_cbor_info_versions_ptr 1 0 100.00% 3 0 100.00% fido_cbor_info_versions_len 1 0 100.00% 3 0 100.00% @@ -559,33 +584,44 @@ fido_cbor_info_maxcredcntlst 1 0 100.00% 3 fido_cbor_info_maxcredidlen 1 0 100.00% 3 0 100.00% fido_cbor_info_maxlargeblob 1 0 100.00% 3 0 100.00% fido_cbor_info_fwversion 1 0 100.00% 3 0 100.00% +fido_cbor_info_minpinlen 1 0 100.00% 3 0 100.00% +fido_cbor_info_maxrpid_minpinlen 1 0 100.00% 3 0 100.00% +fido_cbor_info_uv_attempts 1 0 100.00% 3 0 100.00% +fido_cbor_info_uv_modality 1 0 100.00% 3 0 100.00% +fido_cbor_info_rk_remaining 1 0 100.00% 3 0 100.00% fido_cbor_info_protocols_ptr 1 0 100.00% 3 0 100.00% fido_cbor_info_protocols_len 1 0 100.00% 3 0 100.00% fido_cbor_info_algorithm_count 1 0 100.00% 3 0 100.00% fido_cbor_info_algorithm_type 4 0 100.00% 5 0 100.00% fido_cbor_info_algorithm_cose 4 0 100.00% 5 0 100.00% +fido_cbor_info_new_pin_required 1 0 100.00% 3 0 100.00% +fido_cbor_info_certs_name_ptr 1 0 100.00% 3 0 100.00% +fido_cbor_info_certs_value_ptr 1 0 100.00% 3 0 100.00% +fido_cbor_info_certs_len 1 0 100.00% 3 0 100.00% info.c:fido_dev_get_cbor_info_tx 8 0 100.00% 9 0 100.00% -info.c:fido_dev_get_cbor_info_rx 6 0 100.00% 14 0 100.00% -info.c:parse_reply_element 20 0 100.00% 39 0 100.00% +info.c:fido_dev_get_cbor_info_rx 14 0 100.00% 21 0 100.00% +info.c:parse_reply_element 32 0 100.00% 59 0 100.00% info.c:decode_string_array 12 0 100.00% 17 0 100.00% info.c:decode_string 4 0 100.00% 10 0 100.00% info.c:decode_aaguid 8 0 100.00% 10 0 100.00% info.c:decode_options 11 0 100.00% 15 0 100.00% -info.c:decode_option 11 0 100.00% 17 0 100.00% +info.c:decode_option 7 0 100.00% 15 0 100.00% info.c:decode_protocols 12 0 100.00% 17 0 100.00% info.c:decode_protocol 6 0 100.00% 12 0 100.00% info.c:decode_algorithms 12 0 100.00% 17 0 100.00% info.c:decode_algorithm 9 0 100.00% 17 0 100.00% info.c:decode_algorithm_entry 20 0 100.00% 27 0 100.00% +info.c:decode_certs 11 0 100.00% 15 0 100.00% +info.c:decode_cert 7 0 100.00% 15 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 186 0 100.00% 321 0 100.00% +TOTAL 232 0 100.00% 409 0 100.00% File '/libfido2/src/io.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- fido_tx 14 0 100.00% 11 0 100.00% fido_rx 13 1 92.31% 14 3 78.57% -fido_rx_cbor_status 8 0 100.00% 10 0 100.00% +fido_rx_cbor_status 16 0 100.00% 19 0 100.00% io.c:transport_tx 7 0 100.00% 10 0 100.00% io.c:tx_empty 9 0 100.00% 14 0 100.00% io.c:tx_pkt 7 0 100.00% 10 0 100.00% @@ -597,7 +633,7 @@ io.c:rx 40 2 95.00% 52 io.c:rx_preamble 23 2 91.30% 22 5 77.27% io.c:rx_frame 11 0 100.00% 11 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 185 7 96.22% 221 12 94.57% +TOTAL 193 7 96.37% 230 12 94.78% File '/libfido2/src/iso7816.c': Name Regions Miss Cover Lines Miss Cover @@ -621,7 +657,7 @@ fido_dev_largeblob_set_array 14 0 100.00% 19 largeblob.c:largeblob_get_array 32 0 100.00% 36 0 100.00% largeblob.c:get_chunklen 10 1 90.00% 9 1 88.89% largeblob.c:largeblob_get_tx 19 0 100.00% 24 0 100.00% -largeblob.c:largeblob_get_rx 15 0 100.00% 21 0 100.00% +largeblob.c:largeblob_get_rx 26 0 100.00% 30 0 100.00% largeblob.c:parse_largeblob_reply 8 0 100.00% 9 0 100.00% largeblob.c:largeblob_array_check 7 0 100.00% 16 0 100.00% largeblob.c:largeblob_array_digest 10 0 100.00% 9 0 100.00% @@ -635,7 +671,7 @@ largeblob.c:largeblob_reset 1 0 100.00% 5 largeblob.c:largeblob_encode 16 0 100.00% 21 0 100.00% largeblob.c:largeblob_new 1 0 100.00% 3 0 100.00% largeblob.c:largeblob_seal 20 0 100.00% 32 0 100.00% -largeblob.c:largeblob_get_nonce 8 1 87.50% 16 3 81.25% +largeblob.c:largeblob_get_nonce 8 0 100.00% 16 0 100.00% largeblob.c:largeblob_free 6 0 100.00% 8 0 100.00% largeblob.c:largeblob_add 27 2 92.59% 35 3 91.43% largeblob.c:largeblob_drop 21 0 100.00% 27 0 100.00% @@ -644,7 +680,7 @@ largeblob.c:largeblob_get_uv_token 19 0 100.00% 23 largeblob.c:largeblob_set_tx 35 0 100.00% 36 0 100.00% largeblob.c:prepare_hmac 13 2 84.62% 23 7 69.57% ------------------------------------------------------------------------------------------------------------------- -TOTAL 514 19 96.30% 684 46 93.27% +TOTAL 525 18 96.57% 693 43 93.80% File '/libfido2/src/log.c': Name Regions Miss Cover Lines Miss Cover @@ -662,8 +698,8 @@ TOTAL 39 5 87.18% 63 File '/libfido2/src/netlink.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- -fido_nl_power_nfc 18 1 94.44% 24 3 87.50% -fido_nl_get_nfc_target 17 1 94.12% 31 3 90.32% +fido_nl_power_nfc 18 0 100.00% 24 0 100.00% +fido_nl_get_nfc_target 17 0 100.00% 31 0 100.00% fido_nl_free 10 2 80.00% 9 2 77.78% fido_nl_new 16 1 93.75% 26 3 88.46% set_netlink_io_functions 1 0 100.00% 4 0 100.00% @@ -675,7 +711,7 @@ netlink.c:nlmsg_setattr 15 1 93.33% 17 netlink.c:nlmsg_tx 10 1 90.00% 13 3 76.92% netlink.c:nlmsg_ptr 1 0 100.00% 3 0 100.00% netlink.c:nlmsg_len 1 0 100.00% 3 0 100.00% -netlink.c:nlmsg_rx 11 3 72.73% 17 9 47.06% +netlink.c:nlmsg_rx 11 2 81.82% 17 6 64.71% netlink.c:nl_parse_reply 20 0 100.00% 28 0 100.00% netlink.c:nlmsg_from_buf 15 0 100.00% 17 0 100.00% netlink.c:nlmsg_type 1 0 100.00% 3 0 100.00% @@ -685,14 +721,14 @@ netlink.c:nlmsg_get_genl 6 0 100.00% 7 netlink.c:nlmsg_iter 6 0 100.00% 13 0 100.00% netlink.c:nlmsg_getattr 1 0 100.00% 3 0 100.00% netlink.c:nla_from_buf 17 0 100.00% 21 0 100.00% -netlink.c:nl_nfc_poll 18 1 94.44% 25 3 88.00% +netlink.c:nl_nfc_poll 18 0 100.00% 25 0 100.00% netlink.c:parse_nfc_event 10 0 100.00% 17 0 100.00% netlink.c:nla_type 1 0 100.00% 3 0 100.00% netlink.c:nla_get_u32 1 0 100.00% 3 0 100.00% netlink.c:nla_read 6 0 100.00% 7 0 100.00% -netlink.c:nl_dump_nfc_target 19 1 94.74% 31 3 90.32% +netlink.c:nl_dump_nfc_target 19 0 100.00% 31 0 100.00% netlink.c:parse_target 9 0 100.00% 13 0 100.00% -netlink.c:nl_get_nfc_family 23 1 95.65% 33 3 90.91% +netlink.c:nl_get_nfc_family 23 0 100.00% 33 0 100.00% netlink.c:nlmsg_set_u16 1 0 100.00% 3 0 100.00% netlink.c:nlmsg_set_str 1 0 100.00% 3 0 100.00% netlink.c:parse_family 10 0 100.00% 17 0 100.00% @@ -703,15 +739,16 @@ netlink.c:parse_mcastgrps 1 0 100.00% 3 netlink.c:parse_mcastgrp 15 0 100.00% 24 0 100.00% netlink.c:nla_get_str 10 0 100.00% 11 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 329 14 95.74% 498 33 93.37% +TOTAL 329 8 97.57% 498 15 96.99% File '/libfido2/src/nfc.c': Name Regions Miss Cover Lines Miss Cover ------------------------------------------------------------------------------------------------------------------- fido_nfc_tx 28 0 100.00% 43 0 100.00% fido_nfc_rx 8 0 100.00% 13 0 100.00% +nfc_is_fido 13 1 92.31% 21 3 85.71% fido_is_nfc 3 0 100.00% 3 0 100.00% -fido_dev_set_nfc 4 4 0.00% 18 18 0.00% +fido_dev_set_nfc 4 1 75.00% 18 3 83.33% nfc.c:nfc_do_tx 20 0 100.00% 25 0 100.00% nfc.c:tx_short_apdu 14 0 100.00% 32 0 100.00% nfc.c:rx_init 25 0 100.00% 27 0 100.00% @@ -720,7 +757,7 @@ nfc.c:rx_msg 18 2 88.89% 23 nfc.c:rx_apdu 14 1 92.86% 22 3 86.36% nfc.c:tx_get_response 4 0 100.00% 11 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 142 7 95.07% 223 27 87.89% +TOTAL 155 5 96.77% 244 15 93.85% File '/libfido2/src/nfc_linux.c': Name Regions Miss Cover Lines Miss Cover @@ -731,15 +768,15 @@ fido_nfc_close 1 1 0.00% 4 fido_nfc_set_sigmask 2 2 0.00% 6 6 0.00% fido_nfc_read 14 14 0.00% 30 30 0.00% fido_nfc_write 12 12 0.00% 18 18 0.00% -nfc_linux.c:copy_info 41 8 80.49% 47 5 89.36% -nfc_linux.c:get_usb_attr 1 0 100.00% 3 0 100.00% -nfc_linux.c:get_parent_attr 6 0 100.00% 9 0 100.00% +nfc_linux.c:copy_info 39 22 43.59% 44 16 63.64% +nfc_linux.c:get_usb_attr 1 1 0.00% 3 3 0.00% +nfc_linux.c:get_parent_attr 6 6 0.00% 9 9 0.00% nfc_linux.c:sysnum_from_syspath 15 0 100.00% 17 0 100.00% nfc_linux.c:nfc_new 6 0 100.00% 11 0 100.00% nfc_linux.c:nfc_target_connect 9 9 0.00% 21 21 0.00% nfc_linux.c:nfc_free 12 0 100.00% 11 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 174 56 67.82% 245 103 57.96% +TOTAL 172 77 55.23% 242 126 47.93% File '/libfido2/src/pcsc.c': Name Regions Miss Cover Lines Miss Cover @@ -754,11 +791,11 @@ fido_pcsc_rx 1 0 100.00% 3 fido_is_pcsc 3 0 100.00% 3 0 100.00% fido_dev_set_pcsc 4 1 75.00% 18 3 83.33% pcsc.c:list_readers 24 0 100.00% 24 0 100.00% -pcsc.c:copy_info 27 0 100.00% 37 0 100.00% +pcsc.c:copy_info 30 0 100.00% 41 0 100.00% pcsc.c:get_reader 25 0 100.00% 28 0 100.00% pcsc.c:prepare_io_request 11 0 100.00% 17 0 100.00% ------------------------------------------------------------------------------------------------------------------- -TOTAL 201 1 99.50% 278 3 98.92% +TOTAL 204 1 99.51% 282 3 98.94% File '/libfido2/src/pin.c': Name Regions Miss Cover Lines Miss Cover @@ -774,30 +811,30 @@ pin.c:ctap21_uv_token_tx 49 0 100.00% 53 pin.c:pin_sha256_enc 19 0 100.00% 24 0 100.00% pin.c:encode_uv_permission 20 1 95.00% 19 3 84.21% pin.c:ctap20_uv_token_tx 37 0 100.00% 45 0 100.00% -pin.c:uv_token_rx 20 0 100.00% 30 0 100.00% +pin.c:uv_token_rx 27 0 100.00% 34 0 100.00% pin.c:parse_uv_token 8 0 100.00% 10 0 100.00% pin.c:fido_dev_set_pin_wait 21 0 100.00% 24 0 100.00% pin.c:fido_dev_change_pin_tx 45 0 100.00% 56 0 100.00% pin.c:pin_pad64_enc 15 0 100.00% 21 0 100.00% -pin.c:pad64 18 0 100.00% 19 0 100.00% +pin.c:pad64 18 0 100.00% 20 0 100.00% pin.c:fido_dev_set_pin_tx 33 0 100.00% 41 0 100.00% pin.c:fido_dev_get_pin_retry_count_wait 10 0 100.00% 7 0 100.00% pin.c:fido_dev_get_retry_count_tx 19 0 100.00% 23 0 100.00% -pin.c:fido_dev_get_pin_retry_count_rx 11 0 100.00% 17 0 100.00% +pin.c:fido_dev_get_pin_retry_count_rx 19 0 100.00% 24 0 100.00% pin.c:parse_pin_retry_count 1 0 100.00% 3 0 100.00% pin.c:parse_retry_count 13 0 100.00% 16 0 100.00% pin.c:fido_dev_get_uv_retry_count_wait 10 0 100.00% 7 0 100.00% -pin.c:fido_dev_get_uv_retry_count_rx 11 0 100.00% 17 0 100.00% +pin.c:fido_dev_get_uv_retry_count_rx 19 0 100.00% 24 0 100.00% pin.c:parse_uv_retry_count 1 0 100.00% 3 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 403 3 99.26% 495 4 99.19% +TOTAL 426 3 99.30% 514 4 99.22% File '/libfido2/src/random.c': Name Regions Miss Cover Lines Miss Cover --------------------------------------------------------------------------------------------------------------------- -fido_get_random 6 1 83.33% 6 1 83.33% +fido_get_random 6 0 100.00% 6 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 6 1 83.33% 6 1 83.33% +TOTAL 6 0 100.00% 6 0 100.00% File '/libfido2/src/reset.c': Name Regions Miss Cover Lines Miss Cover @@ -812,10 +849,10 @@ File '/libfido2/src/rs1.c': Name Regions Miss Cover Lines Miss Cover --------------------------------------------------------------------------------------------------------------------- rs1_verify_sig 20 1 95.00% 30 3 90.00% -rs1.c:rs1_get_EVP_MD 4 1 75.00% 6 1 83.33% +rs1.c:rs1_get_EVP_MD 4 0 100.00% 6 0 100.00% rs1.c:rs1_free_EVP_MD 1 0 100.00% 3 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 25 2 92.00% 39 4 89.74% +TOTAL 25 1 96.00% 39 3 92.31% File '/libfido2/src/rs256.c': Name Regions Miss Cover Lines Miss Cover @@ -823,10 +860,10 @@ Name Regions Miss Cover Lines M rs256_pk_decode 8 0 100.00% 9 0 100.00% rs256_pk_new 1 0 100.00% 3 0 100.00% rs256_pk_free 6 0 100.00% 7 0 100.00% -rs256_pk_from_ptr 6 0 100.00% 6 0 100.00% -rs256_pk_to_EVP_PKEY 32 0 100.00% 39 0 100.00% -rs256_pk_from_RSA 32 4 87.50% 26 6 76.92% -rs256_pk_from_EVP_PKEY 7 2 71.43% 7 1 85.71% +rs256_pk_from_ptr 10 0 100.00% 12 0 100.00% +rs256_pk_to_EVP_PKEY 35 0 100.00% 43 0 100.00% +rs256_pk_from_RSA 32 6 81.25% 26 9 65.38% +rs256_pk_from_EVP_PKEY 8 2 75.00% 7 1 85.71% rs256_verify_sig 20 1 95.00% 30 2 93.33% rs256_pk_verify_sig 7 1 85.71% 13 2 84.62% rs256.c:decode_rsa_pubkey 9 0 100.00% 13 0 100.00% @@ -834,7 +871,7 @@ rs256.c:decode_bignum 8 0 100.00% 10 rs256.c:rs256_get_EVP_MD 4 0 100.00% 6 0 100.00% rs256.c:rs256_free_EVP_MD 1 0 100.00% 3 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 141 8 94.33% 172 11 93.60% +TOTAL 149 10 93.29% 182 14 92.31% File '/libfido2/src/time.c': Name Regions Miss Cover Lines Miss Cover @@ -856,39 +893,40 @@ TOTAL 67 0 100.00% 79 File '/libfido2/src/tpm.c': Name Regions Miss Cover Lines Miss Cover --------------------------------------------------------------------------------------------------------------------- -fido_get_signed_hash_tpm 25 1 96.00% 39 3 92.31% -tpm.c:check_es256_pubarea 19 1 94.74% 30 3 90.00% +fido_get_signed_hash_tpm 25 0 100.00% 39 0 100.00% +tpm.c:check_es256_pubarea 19 0 100.00% 30 0 100.00% tpm.c:bswap_es256_pubarea 1 0 100.00% 12 0 100.00% -tpm.c:check_rs256_pubarea 17 1 94.12% 28 3 89.29% +tpm.c:check_rs256_pubarea 17 0 100.00% 28 0 100.00% tpm.c:bswap_rs256_pubarea 1 0 100.00% 10 0 100.00% tpm.c:check_sha1_certinfo 15 0 100.00% 38 0 100.00% tpm.c:get_signed_sha1 17 0 100.00% 19 0 100.00% tpm.c:get_signed_name 7 0 100.00% 10 0 100.00% tpm.c:bswap_sha1_certinfo 1 0 100.00% 8 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 103 3 97.09% 194 9 95.36% +TOTAL 103 0 100.00% 194 0 100.00% File '/libfido2/src/types.c': Name Regions Miss Cover Lines Miss Cover --------------------------------------------------------------------------------------------------------------------- fido_str_array_free 4 0 100.00% 7 0 100.00% -fido_opt_array_free 4 0 100.00% 8 0 100.00% +fido_opt_array_free 4 0 100.00% 9 0 100.00% fido_byte_array_free 1 0 100.00% 5 0 100.00% fido_algo_free 1 0 100.00% 5 0 100.00% fido_algo_array_free 4 0 100.00% 7 0 100.00% +fido_cert_array_free 4 0 100.00% 9 0 100.00% fido_str_array_pack 11 0 100.00% 14 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 25 0 100.00% 46 0 100.00% +TOTAL 29 0 100.00% 56 0 100.00% File '/libfido2/src/u2f.c': Name Regions Miss Cover Lines Miss Cover --------------------------------------------------------------------------------------------------------------------- -u2f_register 69 0 100.00% 75 0 100.00% -u2f_authenticate 32 0 100.00% 36 0 100.00% -u2f_get_touch_begin 30 0 100.00% 39 0 100.00% -u2f_get_touch_status 18 0 100.00% 26 0 100.00% -u2f.c:key_lookup 44 0 100.00% 59 0 100.00% -u2f.c:send_dummy_register 30 0 100.00% 39 0 100.00% +u2f_register 76 0 100.00% 81 0 100.00% +u2f_authenticate 33 0 100.00% 37 0 100.00% +u2f_get_touch_begin 37 0 100.00% 45 0 100.00% +u2f_get_touch_status 26 0 100.00% 36 0 100.00% +u2f.c:key_lookup 51 0 100.00% 65 0 100.00% +u2f.c:send_dummy_register 37 0 100.00% 45 0 100.00% u2f.c:delay_ms 13 1 92.31% 15 3 80.00% u2f.c:parse_register_reply 49 0 100.00% 62 0 100.00% u2f.c:x5c_get 21 1 95.24% 26 3 88.46% @@ -897,11 +935,11 @@ u2f.c:encode_cred_attstmt 45 0 100.00% 52 u2f.c:encode_cred_authdata 33 2 93.94% 61 6 90.16% u2f.c:cbor_blob_from_ec_point 22 0 100.00% 31 0 100.00% u2f.c:u2f_authenticate_single 32 0 100.00% 43 0 100.00% -u2f.c:do_auth 49 0 100.00% 61 0 100.00% +u2f.c:do_auth 56 0 100.00% 67 0 100.00% u2f.c:parse_auth_reply 23 0 100.00% 23 0 100.00% u2f.c:authdata_fake 12 0 100.00% 27 0 100.00% --------------------------------------------------------------------------------------------------------------------- -TOTAL 528 4 99.24% 685 12 98.25% +TOTAL 572 4 99.30% 726 12 98.35% File '/libfido2/src/util.c': Name Regions Miss Cover Lines Miss Cover diff --git a/fuzz/fuzz_assert.c b/fuzz/fuzz_assert.c index 4331148b5e06..603957ec2bac 100644 --- a/fuzz/fuzz_assert.c +++ b/fuzz/fuzz_assert.c @@ -1,7 +1,8 @@ /* - * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <assert.h> @@ -163,7 +164,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); @@ -314,6 +315,27 @@ out: } /* + * Do a dummy conversion to exercise es384_pk_from_EVP_PKEY(). + */ +static void +es384_convert(const es384_pk_t *k) +{ + EVP_PKEY *pkey = NULL; + es384_pk_t *pk = NULL; + int r; + + if ((pkey = es384_pk_to_EVP_PKEY(k)) == NULL || + (pk = es384_pk_new()) == NULL) + goto out; + + r = es384_pk_from_EVP_PKEY(pk, pkey); + consume(&r, sizeof(r)); +out: + es384_pk_free(&pk); + EVP_PKEY_free(pkey); +} + +/* * Do a dummy conversion to exercise rs256_pk_from_EVP_PKEY(). */ static void @@ -362,6 +384,7 @@ test(const struct param *p) { fido_assert_t *assert = NULL; es256_pk_t *es256_pk = NULL; + es384_pk_t *es384_pk = NULL; rs256_pk_t *rs256_pk = NULL; eddsa_pk_t *eddsa_pk = NULL; uint8_t flags; @@ -399,6 +422,19 @@ test(const struct param *p) rs256_convert(pk); break; + case 2: + cose_alg = COSE_ES384; + + if ((es384_pk = es384_pk_new()) == NULL) + return; + + /* XXX reuse p->es256 as es384 */ + es384_pk_from_ptr(es384_pk, p->es256.body, p->es256.len); + pk = es384_pk; + + es384_convert(pk); + + break; default: cose_alg = COSE_EDDSA; @@ -452,6 +488,7 @@ test(const struct param *p) out: es256_pk_free(&es256_pk); + es384_pk_free(&es384_pk); rs256_pk_free(&rs256_pk); eddsa_pk_free(&eddsa_pk); diff --git a/fuzz/fuzz_bio.c b/fuzz/fuzz_bio.c index 49a50932a543..6ebfd151a3d8 100644 --- a/fuzz/fuzz_bio.c +++ b/fuzz/fuzz_bio.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 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 <assert.h> @@ -177,7 +178,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); diff --git a/fuzz/fuzz_cred.c b/fuzz/fuzz_cred.c index d7b630224054..a0866dc6e133 100644 --- a/fuzz/fuzz_cred.c +++ b/fuzz/fuzz_cred.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2019-2021 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <assert.h> @@ -173,7 +174,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); @@ -361,6 +362,9 @@ test_cred(const struct param *p) case 1: cose_alg = COSE_RS256; break; + case 2: + cose_alg = COSE_ES384; + break; default: cose_alg = COSE_EDDSA; break; diff --git a/fuzz/fuzz_credman.c b/fuzz/fuzz_credman.c index fb34f22f8147..1cb95dce3fab 100644 --- a/fuzz/fuzz_credman.c +++ b/fuzz/fuzz_credman.c @@ -2,6 +2,7 @@ * Copyright (c) 2019-2021 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 <assert.h> @@ -164,7 +165,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); diff --git a/fuzz/fuzz_hid.c b/fuzz/fuzz_hid.c index eaf00dc92de8..27ccb2feadfa 100644 --- a/fuzz/fuzz_hid.c +++ b/fuzz/fuzz_hid.c @@ -2,6 +2,7 @@ * Copyright (c) 2020-2021 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 <assert.h> @@ -127,7 +128,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); diff --git a/fuzz/fuzz_largeblob.c b/fuzz/fuzz_largeblob.c index 3289ed46e2a7..432629681e58 100644 --- a/fuzz/fuzz_largeblob.c +++ b/fuzz/fuzz_largeblob.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <assert.h> @@ -141,7 +142,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); diff --git a/fuzz/fuzz_mgmt.c b/fuzz/fuzz_mgmt.c index 41077e23766c..6a5e7b667952 100644 --- a/fuzz/fuzz_mgmt.c +++ b/fuzz/fuzz_mgmt.c @@ -2,6 +2,7 @@ * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <assert.h> @@ -161,7 +162,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); @@ -223,6 +224,7 @@ dev_get_cbor_info(const struct param *p) fido_cbor_info_t *ci; uint64_t n; uint8_t proto, major, minor, build, flags; + bool v; set_wire_data(p->info_wire_data.body, p->info_wire_data.len); @@ -276,28 +278,43 @@ dev_get_cbor_info(const struct param *p) consume(&cose, sizeof(cose)); } + for (size_t i = 0; i < fido_cbor_info_certs_len(ci); i++) { + char * const *na = fido_cbor_info_certs_name_ptr(ci); + const uint64_t *va = fido_cbor_info_certs_value_ptr(ci); + consume(na[i], strlen(na[i])); + consume(&va[i], sizeof(va[i])); + } + n = fido_cbor_info_maxmsgsiz(ci); consume(&n, sizeof(n)); - n = fido_cbor_info_maxcredbloblen(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_maxlargeblob(ci); consume(&n, sizeof(n)); - n = fido_cbor_info_fwversion(ci); consume(&n, sizeof(n)); + n = fido_cbor_info_minpinlen(ci); + consume(&n, sizeof(n)); + n = fido_cbor_info_maxrpid_minpinlen(ci); + consume(&n, sizeof(n)); + n = fido_cbor_info_uv_attempts(ci); + consume(&n, sizeof(n)); + n = fido_cbor_info_uv_modality(ci); + consume(&n, sizeof(n)); + n = (uint64_t)fido_cbor_info_rk_remaining(ci); + consume(&n, sizeof(n)); consume(fido_cbor_info_aaguid_ptr(ci), fido_cbor_info_aaguid_len(ci)); consume(fido_cbor_info_protocols_ptr(ci), fido_cbor_info_protocols_len(ci)); + v = fido_cbor_info_new_pin_required(ci); + consume(&v, sizeof(v)); + out: fido_dev_close(dev); fido_dev_free(&dev); diff --git a/fuzz/fuzz_netlink.c b/fuzz/fuzz_netlink.c index 2447215a2471..2fa897e46fe3 100644 --- a/fuzz/fuzz_netlink.c +++ b/fuzz/fuzz_netlink.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <assert.h> @@ -98,7 +99,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); diff --git a/fuzz/fuzz_pcsc.c b/fuzz/fuzz_pcsc.c index 4a066ec32e1f..f0f6ccaad13e 100644 --- a/fuzz/fuzz_pcsc.c +++ b/fuzz/fuzz_pcsc.c @@ -2,6 +2,7 @@ * Copyright (c) 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 */ #define _FIDO_INTERNAL @@ -116,7 +117,7 @@ size_t pack_dummy(uint8_t *ptr, size_t len) { struct param dummy; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&dummy, 0, sizeof(dummy)); @@ -231,7 +232,9 @@ test(const struct param *p) set_pcsc_parameters(&p->pcsc_list); set_pcsc_io_functions(nfc_read, nfc_write, consume); + set_wire_data(p->wiredata_init.body, p->wiredata_init.len); test_manifest(); + test_misc(); set_wire_data(p->wiredata_init.body, p->wiredata_init.len); diff --git a/fuzz/libfuzzer.c b/fuzz/libfuzzer.c index 09aec4ea2b68..073ebe655cf2 100644 --- a/fuzz/libfuzzer.c +++ b/fuzz/libfuzzer.c @@ -1,9 +1,12 @@ /* - * 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. + * SPDX-License-Identifier: BSD-2-Clause */ +#include <openssl/sha.h> + #include <err.h> #include <fcntl.h> #include <stdbool.h> @@ -15,6 +18,8 @@ #include "mutator_aux.h" +extern int fuzz_save_corpus; + static bool debug; static unsigned int flags = MUTATE_ALL; static unsigned long long test_fail; @@ -32,7 +37,7 @@ save_seed(const char *opt) const char *path; int fd = -1, status = 1; void *buf = NULL; - const size_t buflen = 4096; + const size_t buflen = MAXCORPUS; size_t n; struct param *p = NULL; @@ -73,6 +78,50 @@ fail: return status; } +static int +save_corpus(const struct param *p) +{ + uint8_t blob[MAXCORPUS], dgst[SHA256_DIGEST_LENGTH]; + size_t blob_len; + char path[PATH_MAX]; + int r, fd; + + if ((blob_len = pack(blob, sizeof(blob), p)) == 0 || + blob_len > sizeof(blob)) { + warnx("pack"); + return -1; + } + + if (SHA256(blob, blob_len, dgst) != dgst) { + warnx("sha256"); + return -1; + } + + if ((r = snprintf(path, sizeof(path), "saved_corpus_%02x%02x%02x%02x" + "%02x%02x%02x%02x", dgst[0], dgst[1], dgst[2], dgst[3], dgst[4], + dgst[5], dgst[6], dgst[7])) < 0 || (size_t)r >= sizeof(path)) { + warnx("snprintf"); + return -1; + } + + if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, 0644)) == -1) { + warn("open %s", path); + return -1; + } + + if (write(fd, blob, blob_len) != (ssize_t)blob_len) { + warn("write"); + r = -1; + } else { + warnx("wrote %s", path); + r = 0; + } + + close(fd); + + return r; +} + static void parse_mutate_flags(const char *opt, unsigned int *mutate_flags) { @@ -116,7 +165,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct param *p; - if (size > 4096) + if (size > MAXCORPUS) return 0; if (++test_total % 100000 == 0 && debug) { @@ -128,7 +177,11 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) if ((p = unpack(data, size)) == NULL) test_fail++; else { + fuzz_save_corpus = 0; test(p); + if (fuzz_save_corpus && save_corpus(p) < 0) + fprintf(stderr, "%s: failed to save corpus\n", + __func__); free(p); } @@ -140,7 +193,7 @@ LLVMFuzzerCustomMutator(uint8_t *data, size_t size, size_t maxsize, unsigned int seed) NO_MSAN { struct param *p; - uint8_t blob[4096]; + uint8_t blob[MAXCORPUS]; size_t blob_len; memset(&p, 0, sizeof(p)); diff --git a/fuzz/mutator_aux.c b/fuzz/mutator_aux.c index 660fbe4e67e7..64c633f15f92 100644 --- a/fuzz/mutator_aux.c +++ b/fuzz/mutator_aux.c @@ -1,7 +1,8 @@ /* - * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <assert.h> @@ -19,6 +20,7 @@ int fido_nfc_rx(fido_dev_t *, uint8_t, unsigned char *, size_t, int); int fido_nfc_tx(fido_dev_t *, uint8_t, const unsigned char *, size_t); size_t LLVMFuzzerMutate(uint8_t *, size_t, size_t); +extern int prng_up; static const uint8_t *wire_data_ptr = NULL; static size_t wire_data_len = 0; @@ -157,7 +159,6 @@ mutate_string(char *s) s[n] = '\0'; } -/* XXX should fail, but doesn't */ static int buf_read(unsigned char *ptr, size_t len, int ms) { @@ -165,6 +166,11 @@ buf_read(unsigned char *ptr, size_t len, int ms) (void)ms; + if (prng_up && uniform_random(400) < 1) { + errno = EIO; + return -1; + } + if (wire_data_len < len) n = wire_data_len; else @@ -183,7 +189,7 @@ buf_write(const unsigned char *ptr, size_t len) { consume(ptr, len); - if (uniform_random(400) < 1) { + if (prng_up && uniform_random(400) < 1) { errno = EIO; return -1; } diff --git a/fuzz/mutator_aux.h b/fuzz/mutator_aux.h index 730f58635b16..5ad566140a8e 100644 --- a/fuzz/mutator_aux.h +++ b/fuzz/mutator_aux.h @@ -2,11 +2,14 @@ * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #ifndef _MUTATOR_AUX_H #define _MUTATOR_AUX_H +#include <sys/types.h> + #include <stddef.h> #include <stdint.h> #include <cbor.h> @@ -17,7 +20,7 @@ #include "../src/fido/credman.h" #include "../src/fido/eddsa.h" #include "../src/fido/es256.h" -#include "../src/fido/es256.h" +#include "../src/fido/es384.h" #include "../src/fido/rs256.h" #include "../src/netlink.h" @@ -48,8 +51,9 @@ #define MUTATE_WIREDATA 0x04 #define MUTATE_ALL (MUTATE_SEED | MUTATE_PARAM | MUTATE_WIREDATA) -#define MAXSTR 1024 -#define MAXBLOB 3600 +#define MAXSTR 1024 +#define MAXBLOB 3600 +#define MAXCORPUS 8192 #define HID_DEV_HANDLE 0x68696421 #define NFC_DEV_HANDLE 0x6e666321 diff --git a/fuzz/pcsc.c b/fuzz/pcsc.c index f8400a5e766d..f6a3e9bdd773 100644 --- a/fuzz/pcsc.c +++ b/fuzz/pcsc.c @@ -2,6 +2,7 @@ * Copyright (c) 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 <assert.h> diff --git a/fuzz/preload-fuzz.c b/fuzz/preload-fuzz.c index efcb8c632605..f18848dda34c 100644 --- a/fuzz/preload-fuzz.c +++ b/fuzz/preload-fuzz.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 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 */ /* diff --git a/fuzz/preload-snoop.c b/fuzz/preload-snoop.c index 373acc560a60..34d57ade82f9 100644 --- a/fuzz/preload-snoop.c +++ b/fuzz/preload-snoop.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 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 */ /* diff --git a/fuzz/report.tgz b/fuzz/report.tgz Binary files differindex 1b44addb6982..e984ee9dc765 100644 --- a/fuzz/report.tgz +++ b/fuzz/report.tgz diff --git a/fuzz/summary.txt b/fuzz/summary.txt index 305cb0d84c45..0f79600f801d 100644 --- a/fuzz/summary.txt +++ b/fuzz/summary.txt @@ -3,52 +3,52 @@ Filename Regions Missed Regions Cover Funct fuzz/clock.c 24 1 95.83% 4 0 100.00% 35 1 97.14% fuzz/pcsc.c 59 0 100.00% 8 0 100.00% 75 12 84.00% fuzz/prng.c 31 0 100.00% 2 0 100.00% 35 1 97.14% -fuzz/udev.c 109 1 99.08% 17 0 100.00% 126 11 91.27% +fuzz/udev.c 110 2 98.18% 17 0 100.00% 126 12 90.48% fuzz/uniform_random.c 7 1 85.71% 1 0 100.00% 12 1 91.67% -fuzz/wrap.c 17 0 100.00% 3 0 100.00% 29 0 100.00% +fuzz/wrap.c 23 0 100.00% 3 0 100.00% 29 0 100.00% openbsd-compat/explicit_bzero.c 4 0 100.00% 1 0 100.00% 7 0 100.00% openbsd-compat/freezero.c 4 0 100.00% 1 0 100.00% 6 0 100.00% openbsd-compat/recallocarray.c 41 7 82.93% 1 0 100.00% 36 7 80.56% -openbsd-compat/strlcat.c 12 1 91.67% 1 0 100.00% 21 1 95.24% openbsd-compat/timingsafe_bcmp.c 4 0 100.00% 1 0 100.00% 7 0 100.00% -src/aes256.c 118 4 96.61% 8 0 100.00% 157 14 91.08% -src/assert.c 565 42 92.57% 56 3 94.64% 694 42 93.95% -src/authkey.c 44 0 100.00% 5 0 100.00% 59 0 100.00% -src/bio.c 419 20 95.23% 49 2 95.92% 559 24 95.71% +src/aes256.c 118 3 97.46% 8 0 100.00% 157 11 92.99% +src/assert.c 605 43 92.89% 59 3 94.92% 745 46 93.83% +src/authkey.c 52 0 100.00% 5 0 100.00% 66 0 100.00% +src/bio.c 451 20 95.57% 49 2 95.92% 587 24 95.91% src/blob.c 53 2 96.23% 10 0 100.00% 83 4 95.18% src/buf.c 8 1 87.50% 2 0 100.00% 16 1 93.75% -src/cbor.c 1049 23 97.81% 54 0 100.00% 1237 45 96.36% +src/cbor.c 1070 13 98.79% 55 0 100.00% 1258 31 97.54% src/compress.c 105 14 86.67% 5 0 100.00% 122 24 80.33% -src/config.c 108 0 100.00% 11 0 100.00% 151 0 100.00% -src/cred.c 634 36 94.32% 69 2 97.10% 830 39 95.30% -src/credman.c 382 10 97.38% 40 0 100.00% 518 18 96.53% -src/dev.c 332 71 78.61% 41 6 85.37% 378 86 77.25% +src/config.c 112 0 100.00% 11 0 100.00% 152 0 100.00% +src/cred.c 651 38 94.16% 69 2 97.10% 849 43 94.94% +src/credman.c 422 10 97.63% 40 0 100.00% 557 20 96.41% +src/dev.c 332 65 80.42% 41 6 85.37% 378 80 78.84% src/ecdh.c 117 2 98.29% 4 0 100.00% 146 5 96.58% src/eddsa.c 88 5 94.32% 10 0 100.00% 114 9 92.11% src/err.c 122 10 91.80% 1 0 100.00% 126 10 92.06% src/es256.c 315 7 97.78% 19 0 100.00% 372 12 96.77% +src/es384.c 158 8 94.94% 11 0 100.00% 198 15 92.42% src/hid.c 87 2 97.70% 14 0 100.00% 145 3 97.93% -src/hid_linux.c 173 68 60.69% 14 7 50.00% 250 105 58.00% +src/hid_linux.c 184 73 60.33% 14 7 50.00% 263 115 56.27% src/hid_unix.c 29 21 27.59% 2 0 100.00% 43 26 39.53% -src/info.c 186 0 100.00% 40 0 100.00% 321 0 100.00% -src/io.c 185 7 96.22% 13 0 100.00% 221 12 94.57% +src/info.c 232 0 100.00% 51 0 100.00% 409 0 100.00% +src/io.c 193 7 96.37% 13 0 100.00% 230 12 94.78% src/iso7816.c 18 1 94.44% 5 0 100.00% 38 1 97.37% -src/largeblob.c 514 19 96.30% 30 0 100.00% 684 46 93.27% +src/largeblob.c 525 18 96.57% 30 0 100.00% 693 43 93.80% src/log.c 39 5 87.18% 7 1 85.71% 63 7 88.89% -src/netlink.c 329 14 95.74% 40 0 100.00% 498 33 93.37% -src/nfc.c 142 7 95.07% 11 1 90.91% 223 27 87.89% -src/nfc_linux.c 174 56 67.82% 13 5 61.54% 245 103 57.96% -src/pcsc.c 201 1 99.50% 13 0 100.00% 278 3 98.92% -src/pin.c 403 3 99.26% 26 0 100.00% 495 4 99.19% -src/random.c 6 1 83.33% 1 0 100.00% 6 1 83.33% +src/netlink.c 329 8 97.57% 40 0 100.00% 498 15 96.99% +src/nfc.c 155 5 96.77% 12 0 100.00% 244 15 93.85% +src/nfc_linux.c 172 77 55.23% 13 7 46.15% 242 126 47.93% +src/pcsc.c 204 1 99.51% 13 0 100.00% 282 3 98.94% +src/pin.c 426 3 99.30% 26 0 100.00% 514 4 99.22% +src/random.c 6 0 100.00% 1 0 100.00% 6 0 100.00% src/reset.c 24 0 100.00% 3 0 100.00% 23 0 100.00% -src/rs1.c 25 2 92.00% 3 0 100.00% 39 4 89.74% -src/rs256.c 141 8 94.33% 13 0 100.00% 172 11 93.60% +src/rs1.c 25 1 96.00% 3 0 100.00% 39 3 92.31% +src/rs256.c 149 10 93.29% 13 0 100.00% 182 14 92.31% src/time.c 43 3 93.02% 3 0 100.00% 43 2 95.35% src/touch.c 67 0 100.00% 2 0 100.00% 79 0 100.00% -src/tpm.c 103 3 97.09% 9 0 100.00% 194 9 95.36% -src/types.c 25 0 100.00% 6 0 100.00% 46 0 100.00% -src/u2f.c 528 4 99.24% 17 0 100.00% 685 12 98.25% +src/tpm.c 103 0 100.00% 9 0 100.00% 194 0 100.00% +src/types.c 29 0 100.00% 7 0 100.00% 56 0 100.00% +src/u2f.c 572 4 99.30% 17 0 100.00% 726 12 98.35% src/util.c 14 1 92.86% 1 0 100.00% 14 1 92.86% Files which contain no functions: @@ -56,8 +56,9 @@ fuzz/mutator_aux.h 0 0 - openbsd-compat/openbsd-compat.h 0 0 - 0 0 - 0 0 - openbsd-compat/time.h 0 0 - 0 0 - 0 0 - src/extern.h 0 0 - 0 0 - 0 0 - +src/fallthrough.h 0 0 - 0 0 - 0 0 - src/fido.h 0 0 - 0 0 - 0 0 - src/fido/err.h 0 0 - 0 0 - 0 0 - src/fido/param.h 0 0 - 0 0 - 0 0 - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -TOTAL 8227 484 94.12% 710 27 96.20% 10756 777 92.78% +TOTAL 8711 492 94.35% 737 28 96.20% 11320 771 93.19% diff --git a/fuzz/udev.c b/fuzz/udev.c index 3984d8f555ed..3194012ab97e 100644 --- a/fuzz/udev.c +++ b/fuzz/udev.c @@ -2,6 +2,7 @@ * Copyright (c) 2021 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 <sys/types.h> @@ -241,7 +242,7 @@ __wrap_ioctl(int fd, unsigned long request, ...) va_start(ap, request); - switch (request) { + switch (IOCTL_REQ(request)) { case IOCTL_REQ(HIDIOCGRDESCSIZE): *va_arg(ap, int *) = (int)report_descriptor->len; break; diff --git a/fuzz/wiredata_fido2.h b/fuzz/wiredata_fido2.h index 68504325450e..6c66c545b235 100644 --- a/fuzz/wiredata_fido2.h +++ b/fuzz/wiredata_fido2.h @@ -2,6 +2,7 @@ * Copyright (c) 2020-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 */ #ifndef _WIREDATA_FIDO2_H diff --git a/fuzz/wiredata_u2f.h b/fuzz/wiredata_u2f.h index afe418fe9d96..3be22d34b6c2 100644 --- a/fuzz/wiredata_u2f.h +++ b/fuzz/wiredata_u2f.h @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 */ #ifndef _WIREDATA_U2F_H diff --git a/fuzz/wrap.c b/fuzz/wrap.c index 4d6ac77a98bb..6f40ea1d079e 100644 --- a/fuzz/wrap.c +++ b/fuzz/wrap.c @@ -2,9 +2,11 @@ * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <sys/types.h> +#include <sys/random.h> #include <sys/socket.h> #include <openssl/bn.h> @@ -22,9 +24,13 @@ extern int prng_up; +int fuzz_save_corpus; + /* * Build wrappers around functions of interest, and have them fail - * in a pseudo-random manner. + * in a pseudo-random manner. A uniform probability of 0.25% (1/400) + * allows for a depth of log(0.5)/log(399/400) > 276 operations + * before simulated errors become statistically more likely. */ #define WRAP(type, name, args, retval, param, prob) \ @@ -70,6 +76,14 @@ WRAP(char *, 1 ) +WRAP(ssize_t, + getrandom, + (void *buf, size_t buflen, unsigned int flags), + -1, + (buf, buflen, flags), + 1 +) + WRAP(int, EVP_Cipher, (EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, @@ -653,11 +667,11 @@ int __real_deflate(z_streamp, int); int __wrap_deflate(z_streamp strm, int flush) { - if (uniform_random(400) < 1) { + if (prng_up && uniform_random(400) < 1) { return Z_BUF_ERROR; } /* should never happen, but we check for it */ - if (uniform_random(400) < 1) { + if (prng_up && uniform_random(400) < 1) { strm->avail_out = UINT_MAX; return Z_STREAM_END; } @@ -673,7 +687,7 @@ __wrap_asprintf(char **strp, const char *fmt, ...) va_list ap; int r; - if (uniform_random(400) < 1) { + if (prng_up && uniform_random(400) < 1) { *strp = (void *)0xdeadbeef; return -1; } diff --git a/fuzz/wrapped.sym b/fuzz/wrapped.sym index 59224565ee0a..219a0d8b8f46 100644 --- a/fuzz/wrapped.sym +++ b/fuzz/wrapped.sym @@ -63,6 +63,7 @@ EVP_PKEY_verify_init EVP_sha1 EVP_sha256 fido_tx +getrandom HMAC HMAC_CTX_new HMAC_Final diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index 910ee684e9fb..cf32a3a94208 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -1,6 +1,7 @@ # 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 find_program(MANDOC_PATH mandoc) find_program(GZIP_PATH gzip) @@ -11,6 +12,7 @@ message(STATUS "GZIP_PATH: ${GZIP_PATH}") list(APPEND MAN_SOURCES eddsa_pk_new.3 es256_pk_new.3 + es384_pk_new.3 fido2-assert.1 fido2-cred.1 fido2-token.1 @@ -52,6 +54,11 @@ list(APPEND MAN_ALIAS es256_pk_new es256_pk_from_EVP_PKEY es256_pk_new es256_pk_from_ptr es256_pk_new es256_pk_to_EVP_PKEY + es384_pk_new es384_pk_free + es384_pk_new es384_pk_from_EC_KEY + es384_pk_new es384_pk_from_EVP_PKEY + es384_pk_new es384_pk_from_ptr + es384_pk_new es384_pk_to_EVP_PKEY fido_assert_new fido_assert_authdata_len fido_assert_new fido_assert_authdata_ptr fido_assert_new fido_assert_blob_len @@ -114,22 +121,31 @@ list(APPEND MAN_ALIAS fido_cbor_info_new fido_cbor_info_algorithm_cose fido_cbor_info_new fido_cbor_info_algorithm_count fido_cbor_info_new fido_cbor_info_algorithm_type + fido_cbor_info_new fido_cbor_info_certs_len + fido_cbor_info_new fido_cbor_info_certs_name_ptr + fido_cbor_info_new fido_cbor_info_certs_value_ptr 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_fwversion 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_maxrpid_minpinlen + fido_cbor_info_new fido_cbor_info_minpinlen + fido_cbor_info_new fido_cbor_info_new_pin_required fido_cbor_info_new fido_cbor_info_options_len fido_cbor_info_new fido_cbor_info_options_name_ptr fido_cbor_info_new fido_cbor_info_options_value_ptr fido_cbor_info_new fido_cbor_info_protocols_len fido_cbor_info_new fido_cbor_info_protocols_ptr + fido_cbor_info_new fido_cbor_info_rk_remaining fido_cbor_info_new fido_cbor_info_transports_len fido_cbor_info_new fido_cbor_info_transports_ptr + fido_cbor_info_new fido_cbor_info_uv_attempts + fido_cbor_info_new fido_cbor_info_uv_modality fido_cbor_info_new fido_cbor_info_versions_len fido_cbor_info_new fido_cbor_info_versions_ptr fido_cbor_info_new fido_dev_get_cbor_info diff --git a/man/check.sh b/man/check.sh index 951afeb88e0b..d969a7afb666 100755 --- a/man/check.sh +++ b/man/check.sh @@ -3,6 +3,7 @@ # Copyright (c) 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 T=$(mktemp -d) || exit 1 find . -maxdepth 1 -type f -name '*.3' -print0 > "$T/files" diff --git a/man/eddsa_pk_new.3 b/man/eddsa_pk_new.3 index 998def484790..428d724a45ee 100644 --- a/man/eddsa_pk_new.3 +++ b/man/eddsa_pk_new.3 @@ -1,8 +1,31 @@ -.\" Copyright (c) 2019 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. +.\" Copyright (c) 2019-2022 Yubico AB. All rights reserved. .\" -.Dd $Mdocdate: May 15 2019 $ +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd $Mdocdate: July 15 2022 $ .Dt EDDSA_PK_NEW 3 .Os .Sh NAME @@ -117,6 +140,7 @@ On error, a different error code defined in is returned. .Sh SEE ALSO .Xr es256_pk_new 3 , +.Xr es384_pk_new 3 , .Xr fido_assert_verify 3 , .Xr fido_cred_pubkey_ptr 3 , .Xr rs256_pk_new 3 diff --git a/man/es256_pk_new.3 b/man/es256_pk_new.3 index 5e184340a575..7d6be4d6223c 100644 --- a/man/es256_pk_new.3 +++ b/man/es256_pk_new.3 @@ -1,8 +1,31 @@ -.\" Copyright (c) 2018-2021 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. +.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved. .\" -.Dd $Mdocdate: May 24 2018 $ +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd $Mdocdate: July 15 2022 $ .Dt ES256_PK_NEW 3 .Os .Sh NAME @@ -135,6 +158,7 @@ On error, a different error code defined in is returned. .Sh SEE ALSO .Xr eddsa_pk_new 3 , +.Xr es384_pk_new 3 , .Xr fido_assert_verify 3 , .Xr fido_cred_pubkey_ptr 3 , .Xr rs256_pk_new 3 diff --git a/man/es384_pk_new.3 b/man/es384_pk_new.3 new file mode 100644 index 000000000000..e865913b7807 --- /dev/null +++ b/man/es384_pk_new.3 @@ -0,0 +1,164 @@ +.\" Copyright (c) 2022 Yubico AB. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd $Mdocdate: July 15 2022 $ +.Dt ES384_PK_NEW 3 +.Os +.Sh NAME +.Nm es384_pk_new , +.Nm es384_pk_free , +.Nm es384_pk_from_EC_KEY , +.Nm es384_pk_from_EVP_PKEY , +.Nm es384_pk_from_ptr , +.Nm es384_pk_to_EVP_PKEY +.Nd FIDO2 COSE ES384 API +.Sh SYNOPSIS +.In openssl/ec.h +.In fido/es384.h +.Ft es384_pk_t * +.Fn es384_pk_new "void" +.Ft void +.Fn es384_pk_free "es384_pk_t **pkp" +.Ft int +.Fn es384_pk_from_EC_KEY "es384_pk_t *pk" "const EC_KEY *ec" +.Ft int +.Fn es384_pk_from_EVP_PKEY "es384_pk_t *pk" "const EVP_PKEY *pkey" +.Ft int +.Fn es384_pk_from_ptr "es384_pk_t *pk" "const void *ptr" "size_t len" +.Ft EVP_PKEY * +.Fn es384_pk_to_EVP_PKEY "const es384_pk_t *pk" +.Sh DESCRIPTION +ES384 is the name given in the CBOR Object Signing and Encryption +(COSE) RFC to ECDSA over P-384 with SHA-384. +The COSE ES384 API of +.Em libfido2 +is an auxiliary API with routines to convert between the different +ECDSA public key types used in +.Em libfido2 +and +.Em OpenSSL . +.Pp +In +.Em libfido2 , +ES384 public keys are abstracted by the +.Vt es384_pk_t +type. +.Pp +The +.Fn es384_pk_new +function returns a pointer to a newly allocated, empty +.Vt es384_pk_t +type. +If memory cannot be allocated, NULL is returned. +.Pp +The +.Fn es384_pk_free +function releases the memory backing +.Fa *pkp , +where +.Fa *pkp +must have been previously allocated by +.Fn es384_pk_new . +On return, +.Fa *pkp +is set to NULL. +Either +.Fa pkp +or +.Fa *pkp +may be NULL, in which case +.Fn es384_pk_free +is a NOP. +.Pp +The +.Fn es384_pk_from_EC_KEY +function fills +.Fa pk +with the contents of +.Fa ec . +No references to +.Fa ec +are kept. +.Pp +The +.Fn es384_pk_from_EVP_PKEY +function fills +.Fa pk +with the contents of +.Fa pkey . +No references to +.Fa pkey +are kept. +.Pp +The +.Fn es384_pk_from_ptr +function fills +.Fa pk +with the contents of +.Fa ptr , +where +.Fa ptr +points to +.Fa len +bytes. +The +.Fa ptr +pointer may point to an uncompressed point, or to the +concatenation of the x and y coordinates. +No references to +.Fa ptr +are kept. +.Pp +The +.Fn es384_pk_to_EVP_PKEY +function converts +.Fa pk +to a newly allocated +.Fa EVP_PKEY +type with a reference count of 1. +No internal references to the returned pointer are kept. +If an error occurs, +.Fn es384_pk_to_EVP_PKEY +returns NULL. +.Sh RETURN VALUES +The +.Fn es384_pk_from_EC_KEY , +.Fn es384_pk_from_EVP_PKEY , +and +.Fn es384_pk_from_ptr +functions return +.Dv FIDO_OK +on success. +On error, a different error code defined in +.In fido/err.h +is returned. +.Sh SEE ALSO +.Xr eddsa_pk_new 3 , +.Xr es256_pk_new 3 , +.Xr fido_assert_verify 3 , +.Xr fido_cred_pubkey_ptr 3 , +.Xr rs256_pk_new 3 diff --git a/man/fido2-assert.1 b/man/fido2-assert.1 index ee8135c18483..0ee6e0942ba2 100644 --- a/man/fido2-assert.1 +++ b/man/fido2-assert.1 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: November 5 2019 $ .Dt FIDO2-ASSERT 1 diff --git a/man/fido2-cred.1 b/man/fido2-cred.1 index 0b10e74a0507..bd82499acac4 100644 --- a/man/fido2-cred.1 +++ b/man/fido2-cred.1 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: November 5 2019 $ .Dt FIDO2-CRED 1 diff --git a/man/fido2-token.1 b/man/fido2-token.1 index 4f8b8d08efe6..65a228cb1a31 100644 --- a/man/fido2-token.1 +++ b/man/fido2-token.1 @@ -1,6 +1,29 @@ .\" 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: April 11 2022 $ .Dt FIDO2-TOKEN 1 diff --git a/man/fido_assert_allow_cred.3 b/man/fido_assert_allow_cred.3 index 7fd730c3f63c..0690efcff4ba 100644 --- a/man/fido_assert_allow_cred.3 +++ b/man/fido_assert_allow_cred.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 23 2018 $ .Dt FIDO_ASSERT_ALLOW_CRED 3 diff --git a/man/fido_assert_new.3 b/man/fido_assert_new.3 index 413b7a7ba2ef..192625e32630 100644 --- a/man/fido_assert_new.3 +++ b/man/fido_assert_new.3 @@ -1,6 +1,29 @@ .\" 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: April 27 2022 $ .Dt FIDO_ASSERT_NEW 3 @@ -154,6 +177,10 @@ in .Fa assert . If not NULL, the values returned by these functions point to NUL-terminated UTF-8 strings. +The user display name, icon, and name attributes will typically +only be returned by the authenticator if user verification was +performed by the authenticator and multiple resident/discoverable +credentials were involved in the assertion. .Pp The .Fn fido_assert_authdata_ptr , diff --git a/man/fido_assert_set_authdata.3 b/man/fido_assert_set_authdata.3 index 0d512b655012..f3a307fd05b8 100644 --- a/man/fido_assert_set_authdata.3 +++ b/man/fido_assert_set_authdata.3 @@ -1,6 +1,29 @@ .\" 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: April 27 2022 $ .Dt FIDO_ASSERT_SET_AUTHDATA 3 diff --git a/man/fido_assert_verify.3 b/man/fido_assert_verify.3 index 8c0823703434..1b79448b6c32 100644 --- a/man/fido_assert_verify.3 +++ b/man/fido_assert_verify.3 @@ -1,8 +1,31 @@ -.\" Copyright (c) 2018 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. +.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved. .\" -.Dd $Mdocdate: May 24 2018 $ +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd $Mdocdate: July 15 2022 $ .Dt FIDO_ASSERT_VERIFY 3 .Os .Sh NAME @@ -42,6 +65,7 @@ where .Fa cose_alg is .Dv COSE_ES256 , +.Dv COSE_ES384 , .Dv COSE_RS256 , or .Dv COSE_EDDSA , @@ -49,6 +73,7 @@ and .Fa pk points to a .Vt es256_pk_t , +.Vt es384_pk_t , .Vt rs256_pk_t , or .Vt eddsa_pk_t diff --git a/man/fido_bio_dev_get_info.3 b/man/fido_bio_dev_get_info.3 index 7f1696fc12a4..b8fc1043c231 100644 --- a/man/fido_bio_dev_get_info.3 +++ b/man/fido_bio_dev_get_info.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2019 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: September 13 2019 $ .Dt FIDO_BIO_DEV_GET_INFO 3 diff --git a/man/fido_bio_enroll_new.3 b/man/fido_bio_enroll_new.3 index 37b842e644fd..536ba9af9f91 100644 --- a/man/fido_bio_enroll_new.3 +++ b/man/fido_bio_enroll_new.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2019 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: September 13 2019 $ .Dt FIDO_BIO_ENROLL_NEW 3 diff --git a/man/fido_bio_info_new.3 b/man/fido_bio_info_new.3 index a7435fd615e7..41343068b162 100644 --- a/man/fido_bio_info_new.3 +++ b/man/fido_bio_info_new.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2019 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: September 13 2019 $ .Dt FIDO_BIO_INFO_NEW 3 diff --git a/man/fido_bio_template.3 b/man/fido_bio_template.3 index 232f3ead2ab3..a8ff8bc38dc6 100644 --- a/man/fido_bio_template.3 +++ b/man/fido_bio_template.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2019 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: September 13 2019 $ .Dt FIDO_BIO_TEMPLATE 3 diff --git a/man/fido_cbor_info_new.3 b/man/fido_cbor_info_new.3 index 45c143f5df62..a8168c05c916 100644 --- a/man/fido_cbor_info_new.3 +++ b/man/fido_cbor_info_new.3 @@ -1,6 +1,29 @@ .\" 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: April 22 2022 $ .Dt FIDO_CBOR_INFO_NEW 3 @@ -19,6 +42,9 @@ .Nm fido_cbor_info_algorithm_type , .Nm fido_cbor_info_algorithm_cose , .Nm fido_cbor_info_algorithm_count , +.Nm fido_cbor_info_certs_name_ptr , +.Nm fido_cbor_info_certs_value_ptr , +.Nm fido_cbor_info_certs_len , .Nm fido_cbor_info_aaguid_len , .Nm fido_cbor_info_extensions_len , .Nm fido_cbor_info_protocols_len , @@ -30,7 +56,13 @@ .Nm fido_cbor_info_maxcredcntlst , .Nm fido_cbor_info_maxcredidlen , .Nm fido_cbor_info_maxlargeblob , -.Nm fido_cbor_info_fwversion +.Nm fido_cbor_info_maxrpid_minpinlen , +.Nm fido_cbor_info_minpinlen , +.Nm fido_cbor_info_fwversion , +.Nm fido_cbor_info_uv_attempts , +.Nm fido_cbor_info_uv_modality , +.Nm fido_cbor_info_rk_remaining , +.Nm fido_cbor_info_new_pin_required .Nd FIDO2 CBOR Info API .Sh SYNOPSIS .In fido.h @@ -60,6 +92,12 @@ .Fn fido_cbor_info_algorithm_cose "const fido_cbor_info_t *ci" "size_t idx" .Ft size_t .Fn fido_cbor_info_algorithm_count "const fido_cbor_info_t *ci" +.Ft char ** +.Fn fido_cbor_info_certs_name_ptr "const fido_cbor_info_t *ci" +.Ft const uint64_t * +.Fn fido_cbor_info_certs_value_ptr "const fido_cbor_info_t *ci" +.Ft size_t +.Fn fido_cbor_info_certs_len "const fido_cbor_info_t *ci" .Ft size_t .Fn fido_cbor_info_aaguid_len "const fido_cbor_info_t *ci" .Ft size_t @@ -83,7 +121,19 @@ .Ft uint64_t .Fn fido_cbor_info_maxlargeblob "const fido_cbor_info_t *ci" .Ft uint64_t +.Fn fido_cbor_info_maxrpid_minpinlen "const fido_cbor_info_t *ci" +.Ft uint64_t +.Fn fido_cbor_info_minpinlen "const fido_cbor_info_t *ci" +.Ft uint64_t .Fn fido_cbor_info_fwversion "const fido_cbor_info_t *ci" +.Ft uint64_t +.Fn fido_cbor_info_uv_attempts "const fido_cbor_info_t *ci" +.Ft uint64_t +.Fn fido_cbor_info_uv_modality "const fido_cbor_info_t *ci" +.Ft int64_t +.Fn fido_cbor_info_rk_remaining "const fido_cbor_info_t *ci" +.Ft bool +.Fn fido_cbor_info_new_pin_required "const fido_cbor_info_t *ci" .Sh DESCRIPTION The .Fn fido_cbor_info_new @@ -180,6 +230,17 @@ has an (index) value of 0. .Pp The +.Fn fido_cbor_info_certs_name_ptr +and +.Fn fido_cbor_info_certs_value_ptr +functions return pointers to the array of certification names and their +respective values +in +.Fa ci . +The length of the certifications array is returned by +.Fn fido_cbor_info_certs_len . +.Pp +The .Fn fido_cbor_info_maxmsgsiz function returns the maximum message size attribute of .Fa ci . @@ -204,16 +265,93 @@ as reported in .Fa ci . .Pp The +.Fn fido_cbor_info_maxrpid_minpinlen +function returns the maximum number of RP IDs that may be passed to +.Xr fido_dev_set_pin_minlen_rpid 3 , +as reported in +.Fa ci . +The minimum PIN length attribute is a CTAP 2.1 addition. +If the attribute is not advertised by the authenticator, the +.Fn fido_cbor_info_maxrpid_minpinlen +function returns zero. +.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_minpinlen +function returns the minimum PIN length enforced by the +authenticator as reported in +.Fa ci . +The minimum PIN length attribute is a CTAP 2.1 addition. +If the attribute is not advertised by the authenticator, the +.Fn fido_cbor_info_minpinlen +function returns zero. +.Pp +The .Fn fido_cbor_info_fwversion function returns the firmware version attribute of .Fa ci . .Pp +The +.Fn fido_cbor_info_uv_attempts +function returns the number of UV attempts that the platform may +attempt before falling back to PIN authentication. +If 1, then all +.Xr fido_dev_get_uv_retry_count 3 +retries are handled internally by the authenticator and the +platform may only attempt non-PIN UV once. +The UV attempts attribute is a CTAP 2.1 addition. +If the attribute is not advertised by the authenticator, +the +.Fn fido_cbor_info_uv_attempts +function returns zero. +.Pp +The +.Fn fido_cbor_info_uv_modality +function returns a bitmask representing different UV modes +supported by the authenticator, as defined in the FIDO Registry of +Predefined Values and reported in +.Fa ci . +See the +.Em FIDO_UV_MODE_* +definitions in +.In fido/param.h +for the set of values defined by libfido2 and a brief description +of each. +The UV modality attribute is a CTAP 2.1 addition. +If the attribute is not advertised by the authenticator, the +.Fn fido_cbor_info_uv_modality +function returns zero. +.Pp +The +.Fn fido_cbor_info_rk_remaining +function returns the estimated number of additional +resident/discoverable credentials that can be stored on the +authenticator as reported in +.Fa ci . +The estimated number of remaining resident credentials is a +CTAP 2.1 addition. +If the attribute is not advertised by the authenticator, the +.Fn fido_cbor_info_rk_remaining +function returns -1. +.Pp +The +.Fn fido_cbor_info_new_pin_required +function returns whether a new PIN is required by the authenticator +as reported in +.Fa ci . +If +.Fn fido_cbor_info_new_pin_required +returns true, operations requiring PIN authentication will fail +until a new PIN is set on the authenticator. +The +.Xr fido_dev_set_pin 3 +function can be used to set a new PIN. +.Pp A complete example of how to use these functions can be found in the .Pa example/info.c file shipped with @@ -238,4 +376,14 @@ without the .Em const qualifier is invoked. .Sh SEE ALSO -.Xr fido_dev_open 3 +.Xr fido_dev_get_uv_retry_count 3 , +.Xr fido_dev_open 3 , +.Xr fido_dev_set_pin 3 , +.Xr fido_dev_set_pin_minlen_rpid 3 +.Rs +.%D 2021-05-25 +.%O Review Draft, Version 2.2 +.%Q FIDO Alliance +.%R FIDO Registry of Predefined Values +.%U https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-rd-20210525.html +.Re diff --git a/man/fido_cred_exclude.3 b/man/fido_cred_exclude.3 index 2aa87f28976f..0d4ba75ecbef 100644 --- a/man/fido_cred_exclude.3 +++ b/man/fido_cred_exclude.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 23 2018 $ .Dt FIDO_CRED_EXCLUDE 3 diff --git a/man/fido_cred_new.3 b/man/fido_cred_new.3 index ee7ac96a6b0b..4f8b1be7bc45 100644 --- a/man/fido_cred_new.3 +++ b/man/fido_cred_new.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018-2021 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 23 2018 $ .Dt FIDO_CRED_NEW 3 @@ -189,7 +212,7 @@ for the protection policies understood by The .Fn fido_cred_fmt function returns a pointer to a NUL-terminated string containing -the format of +the attestation statement format identifier of .Fa cred , or NULL if .Fa cred diff --git a/man/fido_cred_set_authdata.3 b/man/fido_cred_set_authdata.3 index 921a682f8f91..e4538325b291 100644 --- a/man/fido_cred_set_authdata.3 +++ b/man/fido_cred_set_authdata.3 @@ -1,8 +1,31 @@ -.\" Copyright (c) 2018-2021 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. +.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved. .\" -.Dd $Mdocdate: May 23 2018 $ +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd $Mdocdate: July 15 2022 $ .Dt FIDO_CRED_SET_AUTHDATA 3 .Os .Sh NAME @@ -287,7 +310,7 @@ by default, allowing the authenticator to use its default settings. .Pp The .Fn fido_cred_set_fmt -function sets the attestation format of +function sets the attestation statement format identifier of .Fa cred to .Fa fmt , @@ -297,15 +320,18 @@ must be .Vt "packed" .Pq the format used in FIDO2 , .Vt "fido-u2f" -.Pq the format used by U2F , +.Pq the format used in U2F , +.Vt "tpm" +.Pq the format used by TPM-based authenticators , or .Vt "none" . A copy of .Fa fmt is made, and no references to the passed pointer are kept. -Note that not all authenticators support FIDO2 and therefore may not +Note that not all authenticators support FIDO2 and therefore may only be able to generate -.Vt "packed" . +.Vt fido-u2f +attestation statements. .Pp The .Fn fido_cred_set_type @@ -316,11 +342,13 @@ where .Fa cose_alg is .Dv COSE_ES256 , +.Dv COSE_ES384 , .Dv COSE_RS256 , or .Dv COSE_EDDSA . The type of a credential may only be set once. -Note that not all authenticators support COSE_RS256 or COSE_EDDSA. +Note that not all authenticators support COSE_RS256, COSE_ES384, or +COSE_EDDSA. .Pp Use of the .Nm diff --git a/man/fido_cred_verify.3 b/man/fido_cred_verify.3 index 696dec293e4d..9548870204c7 100644 --- a/man/fido_cred_verify.3 +++ b/man/fido_cred_verify.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018-2021 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 23 2018 $ .Dt FIDO_CRED_VERIFY 3 diff --git a/man/fido_credman_metadata_new.3 b/man/fido_credman_metadata_new.3 index cd6722e24aa8..122020bd68b1 100644 --- a/man/fido_credman_metadata_new.3 +++ b/man/fido_credman_metadata_new.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2019-2021 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: June 28 2019 $ .Dt FIDO_CREDMAN_METADATA_NEW 3 diff --git a/man/fido_dev_enable_entattest.3 b/man/fido_dev_enable_entattest.3 index a06746b61317..7617f22389e2 100644 --- a/man/fido_dev_enable_entattest.3 +++ b/man/fido_dev_enable_entattest.3 @@ -1,6 +1,29 @@ -.\" Copyright (c) 2020 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. +.\" Copyright (c) 2020-2022 Yubico AB. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: March 30 2022 $ .Dt FIDO_DEV_ENABLE_ENTATTEST 3 @@ -97,6 +120,10 @@ NUL-terminated UTF-8 strings. A copy of .Fa rpid is made, and no reference to it or its contents is kept. +The maximum value of +.Fa n +supported by the authenticator can be obtained using +.Xr fido_cbor_info_maxrpid_minpinlen 3 . .Pp Configuration settings are reflected in the payload returned by the authenticator in response to a @@ -116,6 +143,7 @@ On success, .Dv FIDO_OK is returned. .Sh SEE ALSO +.Xr fido_cbor_info_maxrpid_minpinlen 3 , .Xr fido_cred_pin_minlen 3 , .Xr fido_dev_get_cbor_info 3 , .Xr fido_dev_reset 3 diff --git a/man/fido_dev_get_assert.3 b/man/fido_dev_get_assert.3 index bc67e441cca3..bb2fc43b8b24 100644 --- a/man/fido_dev_get_assert.3 +++ b/man/fido_dev_get_assert.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 24 2018 $ .Dt FIDO_DEV_GET_ASSERT 3 diff --git a/man/fido_dev_get_touch_begin.3 b/man/fido_dev_get_touch_begin.3 index f3b8335cec12..f015eff2cb3c 100644 --- a/man/fido_dev_get_touch_begin.3 +++ b/man/fido_dev_get_touch_begin.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2020 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: August 5 2020 $ .Dt FIDO_DEV_GET_TOUCH_BEGIN 3 diff --git a/man/fido_dev_info_manifest.3 b/man/fido_dev_info_manifest.3 index 4be7e3a60490..a70a3cb299ac 100644 --- a/man/fido_dev_info_manifest.3 +++ b/man/fido_dev_info_manifest.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: March 30 2022 $ .Dt FIDO_DEV_INFO_MANIFEST 3 diff --git a/man/fido_dev_largeblob_get.3 b/man/fido_dev_largeblob_get.3 index c42208158c5e..12dd319485e1 100644 --- a/man/fido_dev_largeblob_get.3 +++ b/man/fido_dev_largeblob_get.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2020 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: October 26 2020 $ .Dt FIDO_LARGEBLOB_GET 3 @@ -68,8 +91,7 @@ function retrieves the authenticator's .Dq largeBlobs CBOR array and, on success, returns the first blob .Pq iterating from array index zero -that can be -decrypted by +that can be decrypted by .Fa key_ptr , where .Fa key_ptr @@ -179,8 +201,8 @@ is returned. .Xr fido_cred_largeblob_key_len 3 , .Xr fido_cred_largeblob_key_ptr 3 , .Xr fido_cred_set_extensions 3 , -.Xr fido_credman_dev_get_rk 3 , -.Xr fido_credman_dev_get_rp 3 , +.Xr fido_credman_get_dev_rk 3 , +.Xr fido_credman_get_dev_rp 3 , .Xr fido_dev_get_assert 3 , .Xr fido_dev_make_cred 3 .Sh CAVEATS diff --git a/man/fido_dev_make_cred.3 b/man/fido_dev_make_cred.3 index 60b77fb9c010..b13f9a14bc85 100644 --- a/man/fido_dev_make_cred.3 +++ b/man/fido_dev_make_cred.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 23 2018 $ .Dt FIDO_DEV_MAKE_CRED 3 diff --git a/man/fido_dev_open.3 b/man/fido_dev_open.3 index cdb148fe8b16..f839e26787b4 100644 --- a/man/fido_dev_open.3 +++ b/man/fido_dev_open.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 25 2018 $ .Dt FIDO_DEV_OPEN 3 diff --git a/man/fido_dev_set_io_functions.3 b/man/fido_dev_set_io_functions.3 index 8c2067c41f66..e3e10bae5aaf 100644 --- a/man/fido_dev_set_io_functions.3 +++ b/man/fido_dev_set_io_functions.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018-2021 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 25 2018 $ .Dt FIDO_DEV_SET_IO_FUNCTIONS 3 diff --git a/man/fido_dev_set_pin.3 b/man/fido_dev_set_pin.3 index b58ba6c86f89..eec062dda1cd 100644 --- a/man/fido_dev_set_pin.3 +++ b/man/fido_dev_set_pin.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 25 2018 $ .Dt FIDO_DEV_SET_PIN 3 @@ -89,6 +112,8 @@ are defined in On success, .Dv FIDO_OK is returned. +.Sh SEE ALSO +.Xr fido_cbor_info_uv_attempts 3 .Sh CAVEATS Regarding .Fn fido_dev_reset , diff --git a/man/fido_init.3 b/man/fido_init.3 index 1254f934b73b..12437e1b1a78 100644 --- a/man/fido_init.3 +++ b/man/fido_init.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 25 2018 $ .Dt FIDO_INIT 3 diff --git a/man/fido_strerr.3 b/man/fido_strerr.3 index 9d4ef35aa402..94b48bd621df 100644 --- a/man/fido_strerr.3 +++ b/man/fido_strerr.3 @@ -1,6 +1,29 @@ .\" Copyright (c) 2018 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. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause .\" .Dd $Mdocdate: May 25 2018 $ .Dt FIDO_STRERR 3 diff --git a/man/rs256_pk_new.3 b/man/rs256_pk_new.3 index 24a27bf8cdab..0c0ab78b507c 100644 --- a/man/rs256_pk_new.3 +++ b/man/rs256_pk_new.3 @@ -1,8 +1,31 @@ -.\" Copyright (c) 2018-2021 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. +.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved. .\" -.Dd $Mdocdate: May 24 2018 $ +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are +.\" met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd $Mdocdate: July 15 2022 $ .Dt RS256_PK_NEW 3 .Os .Sh NAME @@ -132,5 +155,6 @@ is returned. .Sh SEE ALSO .Xr eddsa_pk_new 3 , .Xr es256_pk_new 3 , +.Xr es384_pk_new 3 , .Xr fido_assert_verify 3 , .Xr fido_cred_pubkey_ptr 3 diff --git a/openbsd-compat/clock_gettime.c b/openbsd-compat/clock_gettime.c index ca261a65e7f1..bbf978c42893 100644 --- a/openbsd-compat/clock_gettime.c +++ b/openbsd-compat/clock_gettime.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 "openbsd-compat.h" diff --git a/openbsd-compat/endian_win32.c b/openbsd-compat/endian_win32.c index 9981dfafbaeb..756c0cbdc838 100644 --- a/openbsd-compat/endian_win32.c +++ b/openbsd-compat/endian_win32.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 "openbsd-compat.h" diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 1518ff755b97..9f1ea3e7cf51 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h @@ -2,6 +2,7 @@ * Copyright (c) 2018-2021 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 */ #ifndef _OPENBSD_COMPAT_H diff --git a/regress/CMakeLists.txt b/regress/CMakeLists.txt index 87482ef35362..246bffa175c4 100644 --- a/regress/CMakeLists.txt +++ b/regress/CMakeLists.txt @@ -1,14 +1,15 @@ # 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 add_custom_target(regress) -macro(add_regress_test NAME SOURCES) +macro(add_regress_test NAME SOURCES LIB) add_executable(${NAME} ${SOURCES}) - target_link_libraries(${NAME} fido2) add_test(${NAME} ${NAME}) add_dependencies(regress ${NAME}) + target_link_libraries(${NAME} ${LIB}) endmacro() if(MSVC AND BUILD_SHARED_LIBS) @@ -17,6 +18,14 @@ if(MSVC AND BUILD_SHARED_LIBS) "${CBOR_BIN_DIRS}/${CBOR_LIBRARIES}.dll" "${CRYPTO_BIN_DIRS}/${CRYPTO_LIBRARIES}.dll" "${ZLIB_BIN_DIRS}/${ZLIB_LIBRARIES}.dll" + "$<TARGET_FILE:${_FIDO2_LIBRARY}>" + "${CMAKE_CURRENT_BINARY_DIR}") +endif() + +if(CYGWIN AND BUILD_SHARED_LIBS) + add_custom_command(TARGET regress POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "$<TARGET_FILE:${_FIDO2_LIBRARY}>" "${CMAKE_CURRENT_BINARY_DIR}") endif() @@ -31,13 +40,16 @@ else() WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) endif() -add_regress_test(regress_assert assert.c) -add_regress_test(regress_compress compress.c) -add_regress_test(regress_cred cred.c) -add_regress_test(regress_dev dev.c) -add_regress_test(regress_eddsa eddsa.c) -add_regress_test(regress_es256 es256.c) -add_regress_test(regress_rs256 rs256.c) +add_regress_test(regress_assert assert.c ${_FIDO2_LIBRARY}) +add_regress_test(regress_cred cred.c ${_FIDO2_LIBRARY}) +add_regress_test(regress_dev dev.c ${_FIDO2_LIBRARY}) +add_regress_test(regress_eddsa eddsa.c ${_FIDO2_LIBRARY}) +add_regress_test(regress_es256 es256.c ${_FIDO2_LIBRARY}) +add_regress_test(regress_es384 es384.c ${_FIDO2_LIBRARY}) +add_regress_test(regress_rs256 rs256.c ${_FIDO2_LIBRARY}) +if(BUILD_STATIC_LIBS) + add_regress_test(regress_compress compress.c fido2) +endif() if(MINGW) # needed for nanosleep() in mingw diff --git a/regress/assert.c b/regress/assert.c index 695a3b78edcc..98609257b8b5 100644 --- a/regress/assert.c +++ b/regress/assert.c @@ -2,6 +2,7 @@ * Copyright (c) 2018-2021 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 */ #undef NDEBUG diff --git a/regress/compress.c b/regress/compress.c index 5d537838bdeb..7afc8bb339a7 100644 --- a/regress/compress.c +++ b/regress/compress.c @@ -2,6 +2,7 @@ * Copyright (c) 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 */ #undef NDEBUG diff --git a/regress/cred.c b/regress/cred.c index c62ff8e4dcb4..e4dc76ac1f0d 100644 --- a/regress/cred.c +++ b/regress/cred.c @@ -2,6 +2,7 @@ * Copyright (c) 2018-2021 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 */ #undef NDEBUG diff --git a/regress/dev.c b/regress/dev.c index 92031e17066c..0ba552b70552 100644 --- a/regress/dev.c +++ b/regress/dev.c @@ -2,6 +2,7 @@ * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #undef NDEBUG diff --git a/regress/eddsa.c b/regress/eddsa.c index 42236ea58adf..06236987ed17 100644 --- a/regress/eddsa.c +++ b/regress/eddsa.c @@ -2,6 +2,7 @@ * Copyright (c) 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 */ #undef NDEBUG diff --git a/regress/es256.c b/regress/es256.c index 17ef27fd4c98..3a62a415977e 100644 --- a/regress/es256.c +++ b/regress/es256.c @@ -2,6 +2,7 @@ * Copyright (c) 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 */ #undef NDEBUG diff --git a/regress/es384.c b/regress/es384.c new file mode 100644 index 000000000000..b55ce015e17a --- /dev/null +++ b/regress/es384.c @@ -0,0 +1,213 @@ +/* + * Copyright (c) 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 + */ + +#undef NDEBUG + +#include <assert.h> +#include <string.h> + +#define _FIDO_INTERNAL + +#include <fido.h> +#include <fido/es384.h> + +#include <openssl/bio.h> +#include <openssl/pem.h> + +#define ASSERT_NOT_NULL(e) assert((e) != NULL) +#define ASSERT_NULL(e) assert((e) == NULL) +#define ASSERT_INVAL(e) assert((e) == FIDO_ERR_INVALID_ARGUMENT) +#define ASSERT_OK(e) assert((e) == FIDO_OK) + +static const char short_x[] = \ +"-----BEGIN PUBLIC KEY-----\n" +"MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEAAZ/VVCUmFU6aH9kJdDnUHCCglkatFTX\n" +"onMwIvNYyS8BW/HOoZiOQLs2Hg+qifwaP1pHKILzCVfFmWuZMhxhtmjNXFuOPDnS\n" +"Wa1PMdkCoWXA2BbXxnqL9v36gIOcFBil\n" +"-----END PUBLIC KEY-----"; + +static const char short_y[] = \ +"-----BEGIN PUBLIC KEY-----\n" +"MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEuDpRBAg87cnWVhxbWnaWlnj100w9pm5k\n" +"6T4eYToISaIhEK70TnGwULHX0+qHCYEGACOM7B/ZJbqjo6I7MIXaKZLemGi+tqvy\n" +"ajBAsTVSyrYBLQjTMMcaFmYmsxvFx7pK\n" +"-----END PUBLIC KEY-----\n"; + +static const char brainpoolP384r1[] = \ +"-----BEGIN PUBLIC KEY-----\n" +"MHowFAYHKoZIzj0CAQYJKyQDAwIIAQELA2IABFKswbBzqqyZ4h1zz8rivqHzJxAO\n" +"XC2aLyC9x5gwBM7GVu8k6jkX7VypRpg3yyCneiIQ+vVCNXgbDchJ0cPVuhwm3Zru\n" +"AK49dezUPahWF0YiJRFVeV+KyB/MEaaZvinzqw==\n" +"-----END PUBLIC KEY-----\n"; + +static const char secp384r1[] = \ +"-----BEGIN PUBLIC KEY-----\n" +"MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEdJN9DoqPtTNAOmjnECHBIqnJgyBW0rct\n" +"tbUSqQjb6UG2lldmrQJbgCP/ywuXvkkJl4yfXxOr0UP3rgcnqTVA1/46s2TG+R5u\n" +"NSQbCM1JPQuvTyFlAn5mdR8ZJJ8yPBQm\n" +"-----END PUBLIC KEY-----\n"; + +static const unsigned char brainpoolP384r1_raw[] = { + 0x04, 0x52, 0xac, 0xc1, 0xb0, 0x73, 0xaa, 0xac, + 0x99, 0xe2, 0x1d, 0x73, 0xcf, 0xca, 0xe2, 0xbe, + 0xa1, 0xf3, 0x27, 0x10, 0x0e, 0x5c, 0x2d, 0x9a, + 0x2f, 0x20, 0xbd, 0xc7, 0x98, 0x30, 0x04, 0xce, + 0xc6, 0x56, 0xef, 0x24, 0xea, 0x39, 0x17, 0xed, + 0x5c, 0xa9, 0x46, 0x98, 0x37, 0xcb, 0x20, 0xa7, + 0x7a, 0x22, 0x10, 0xfa, 0xf5, 0x42, 0x35, 0x78, + 0x1b, 0x0d, 0xc8, 0x49, 0xd1, 0xc3, 0xd5, 0xba, + 0x1c, 0x26, 0xdd, 0x9a, 0xee, 0x00, 0xae, 0x3d, + 0x75, 0xec, 0xd4, 0x3d, 0xa8, 0x56, 0x17, 0x46, + 0x22, 0x25, 0x11, 0x55, 0x79, 0x5f, 0x8a, 0xc8, + 0x1f, 0xcc, 0x11, 0xa6, 0x99, 0xbe, 0x29, 0xf3, + 0xab, +}; + +static const unsigned char secp384r1_raw[] = { + 0x04, 0x74, 0x93, 0x7d, 0x0e, 0x8a, 0x8f, 0xb5, + 0x33, 0x40, 0x3a, 0x68, 0xe7, 0x10, 0x21, 0xc1, + 0x22, 0xa9, 0xc9, 0x83, 0x20, 0x56, 0xd2, 0xb7, + 0x2d, 0xb5, 0xb5, 0x12, 0xa9, 0x08, 0xdb, 0xe9, + 0x41, 0xb6, 0x96, 0x57, 0x66, 0xad, 0x02, 0x5b, + 0x80, 0x23, 0xff, 0xcb, 0x0b, 0x97, 0xbe, 0x49, + 0x09, 0x97, 0x8c, 0x9f, 0x5f, 0x13, 0xab, 0xd1, + 0x43, 0xf7, 0xae, 0x07, 0x27, 0xa9, 0x35, 0x40, + 0xd7, 0xfe, 0x3a, 0xb3, 0x64, 0xc6, 0xf9, 0x1e, + 0x6e, 0x35, 0x24, 0x1b, 0x08, 0xcd, 0x49, 0x3d, + 0x0b, 0xaf, 0x4f, 0x21, 0x65, 0x02, 0x7e, 0x66, + 0x75, 0x1f, 0x19, 0x24, 0x9f, 0x32, 0x3c, 0x14, + 0x26, +}; + +static EVP_PKEY * +EVP_PKEY_from_PEM(const char *ptr, size_t len) +{ + BIO *bio = NULL; + EVP_PKEY *pkey = NULL; + + if ((bio = BIO_new(BIO_s_mem())) == NULL) { + warnx("BIO_new"); + goto out; + } + if (len > INT_MAX || BIO_write(bio, ptr, (int)len) != (int)len) { + warnx("BIO_write"); + goto out; + } + if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)) == NULL) + warnx("PEM_read_bio_PUBKEY"); +out: + BIO_free(bio); + + return pkey; +} + +static int +es384_pk_cmp(const char *ptr, size_t len) +{ + EVP_PKEY *pkA = NULL; + EVP_PKEY *pkB = NULL; + es384_pk_t *k = NULL; + int r, ok = -1; + + if ((pkA = EVP_PKEY_from_PEM(ptr, len)) == NULL) { + warnx("EVP_PKEY_from_PEM"); + goto out; + } + if ((k = es384_pk_new()) == NULL) { + warnx("es384_pk_new"); + goto out; + } + if ((r = es384_pk_from_EVP_PKEY(k, pkA)) != FIDO_OK) { + warnx("es384_pk_from_EVP_PKEY: 0x%x", r); + goto out; + } + if ((pkB = es384_pk_to_EVP_PKEY(k)) == NULL) { + warnx("es384_pk_to_EVP_PKEY"); + goto out; + } + if ((r = EVP_PKEY_cmp(pkA, pkB)) != 1) { + warnx("EVP_PKEY_cmp: %d", r); + goto out; + } + + ok = 0; +out: + EVP_PKEY_free(pkA); + EVP_PKEY_free(pkB); + es384_pk_free(&k); + + return ok; +} + +static void +short_coord(void) +{ + assert(es384_pk_cmp(short_x, sizeof(short_x)) == 0); + assert(es384_pk_cmp(short_y, sizeof(short_y)) == 0); +} + +static void +invalid_curve(const unsigned char *raw, size_t raw_len) +{ + EVP_PKEY *pkey; + es384_pk_t *pk; + + pkey = EVP_PKEY_from_PEM(brainpoolP384r1, sizeof(brainpoolP384r1)); + if (pkey == NULL) + return; /* assume no brainpool support in libcrypto */ + ASSERT_NOT_NULL((pk = es384_pk_new())); + ASSERT_INVAL(es384_pk_from_EVP_PKEY(pk, pkey)); + ASSERT_INVAL(es384_pk_from_ptr(pk, raw, raw_len)); + ASSERT_NULL(es384_pk_to_EVP_PKEY((const es384_pk_t *)raw)); + + EVP_PKEY_free(pkey); + es384_pk_free(&pk); +} + +static void +full_coord(void) +{ + assert(es384_pk_cmp(secp384r1, sizeof(secp384r1)) == 0); +} + +static void +valid_curve(const unsigned char *raw, size_t raw_len) +{ + EVP_PKEY *pkeyA; + EVP_PKEY *pkeyB; + es384_pk_t *pkA; + es384_pk_t *pkB; + + ASSERT_NOT_NULL((pkeyA = EVP_PKEY_from_PEM(secp384r1, sizeof(secp384r1)))); + ASSERT_NOT_NULL((pkA = es384_pk_new())); + ASSERT_NOT_NULL((pkB = es384_pk_new())); + ASSERT_OK(es384_pk_from_EVP_PKEY(pkA, pkeyA)); + ASSERT_OK(es384_pk_from_ptr(pkB, raw, raw_len)); + ASSERT_NOT_NULL((pkeyB = es384_pk_to_EVP_PKEY(pkB))); + assert(EVP_PKEY_cmp(pkeyA, pkeyB) == 1); + + EVP_PKEY_free(pkeyA); + EVP_PKEY_free(pkeyB); + es384_pk_free(&pkA); + es384_pk_free(&pkB); +} + +int +main(void) +{ + fido_init(0); + + short_coord(); + full_coord(); + + invalid_curve(brainpoolP384r1_raw, sizeof(brainpoolP384r1_raw)); /* uncompressed */ + invalid_curve(brainpoolP384r1_raw + 1, sizeof(brainpoolP384r1_raw) - 1); /* libfido2 */ + valid_curve(secp384r1_raw, sizeof(secp384r1_raw)); /* uncompressed */ + valid_curve(secp384r1_raw + 1, sizeof(secp384r1_raw) - 1); /* libfido2 */ + + exit(0); +} diff --git a/regress/rs256.c b/regress/rs256.c index f6e685a11da8..799396f07a02 100644 --- a/regress/rs256.c +++ b/regress/rs256.c @@ -2,6 +2,7 @@ * Copyright (c) 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 */ #undef NDEBUG diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44a87282869e..73493b1ea8e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ -# Copyright (c) 2018-2021 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 add_definitions(-D_FIDO_INTERNAL) @@ -21,6 +22,7 @@ list(APPEND FIDO_SOURCES eddsa.c err.c es256.c + es384.c hid.c info.c io.c @@ -83,11 +85,12 @@ else() endif() if(NOT MSVC) - set_source_files_properties(${FIDO_SOURCES} PROPERTIES COMPILE_FLAGS - "-Wconversion -Wsign-conversion") + set_source_files_properties(${FIDO_SOURCES} + PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}") endif() list(APPEND COMPAT_SOURCES + ../openbsd-compat/bsd-asprintf.c ../openbsd-compat/bsd-getpagesize.c ../openbsd-compat/clock_gettime.c ../openbsd-compat/endian_win32.c diff --git a/src/aes256.c b/src/aes256.c index f093b7ce0bd5..dcf716d65abb 100644 --- a/src/aes256.c +++ b/src/aes256.c @@ -2,6 +2,7 @@ * Copyright (c) 2021 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" diff --git a/src/assert.c b/src/assert.c index 949af919d25e..a690f46dc882 100644 --- a/src/assert.c +++ b/src/assert.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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 <openssl/sha.h> @@ -160,42 +161,51 @@ fail: static int fido_dev_get_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; fido_assert_reset_rx(assert); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } /* start with room for a single assertion */ - if ((assert->stmt = calloc(1, sizeof(fido_assert_stmt))) == NULL) - return (FIDO_ERR_INTERNAL); - + if ((assert->stmt = calloc(1, sizeof(fido_assert_stmt))) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } assert->stmt_len = 0; assert->stmt_cnt = 1; /* adjust as needed */ - if ((r = cbor_parse_reply(reply, (size_t)reply_len, assert, + if ((r = cbor_parse_reply(msg, (size_t)msglen, assert, adjust_assert_count)) != FIDO_OK) { fido_log_debug("%s: adjust_assert_count", __func__); - return (r); + goto out; } /* parse the first assertion */ - if ((r = cbor_parse_reply(reply, (size_t)reply_len, - &assert->stmt[assert->stmt_len], parse_assert_reply)) != FIDO_OK) { + if ((r = cbor_parse_reply(msg, (size_t)msglen, &assert->stmt[0], + parse_assert_reply)) != FIDO_OK) { fido_log_debug("%s: parse_assert_reply", __func__); - return (r); + goto out; } + assert->stmt_len = 1; - assert->stmt_len++; + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); - return (FIDO_OK); + return (r); } static int @@ -214,30 +224,40 @@ fido_get_next_assert_tx(fido_dev_t *dev, int *ms) static int fido_get_next_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } /* sanity check */ if (assert->stmt_len >= assert->stmt_cnt) { fido_log_debug("%s: stmt_len=%zu, stmt_cnt=%zu", __func__, assert->stmt_len, assert->stmt_cnt); - return (FIDO_ERR_INTERNAL); + r = FIDO_ERR_INTERNAL; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, + if ((r = cbor_parse_reply(msg, (size_t)msglen, &assert->stmt[assert->stmt_len], parse_assert_reply)) != FIDO_OK) { fido_log_debug("%s: parse_assert_reply", __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -365,59 +385,108 @@ check_extensions(int authdata_ext, int ext) return (0); } +static int +get_es256_hash(fido_blob_t *dgst, const fido_blob_t *clientdata, + const fido_blob_t *authdata) +{ + const EVP_MD *md; + EVP_MD_CTX *ctx = NULL; + + if (dgst->len < SHA256_DIGEST_LENGTH || + (md = EVP_sha256()) == NULL || + (ctx = EVP_MD_CTX_new()) == NULL || + EVP_DigestInit_ex(ctx, md, NULL) != 1 || + EVP_DigestUpdate(ctx, authdata->ptr, authdata->len) != 1 || + EVP_DigestUpdate(ctx, clientdata->ptr, clientdata->len) != 1 || + EVP_DigestFinal_ex(ctx, dgst->ptr, NULL) != 1) { + EVP_MD_CTX_free(ctx); + return (-1); + } + dgst->len = SHA256_DIGEST_LENGTH; + + EVP_MD_CTX_free(ctx); + + return (0); +} + +static int +get_es384_hash(fido_blob_t *dgst, const fido_blob_t *clientdata, + const fido_blob_t *authdata) +{ + const EVP_MD *md; + EVP_MD_CTX *ctx = NULL; + + if (dgst->len < SHA384_DIGEST_LENGTH || + (md = EVP_sha384()) == NULL || + (ctx = EVP_MD_CTX_new()) == NULL || + EVP_DigestInit_ex(ctx, md, NULL) != 1 || + EVP_DigestUpdate(ctx, authdata->ptr, authdata->len) != 1 || + EVP_DigestUpdate(ctx, clientdata->ptr, clientdata->len) != 1 || + EVP_DigestFinal_ex(ctx, dgst->ptr, NULL) != 1) { + EVP_MD_CTX_free(ctx); + return (-1); + } + dgst->len = SHA384_DIGEST_LENGTH; + + EVP_MD_CTX_free(ctx); + + return (0); +} + +static int +get_eddsa_hash(fido_blob_t *dgst, const fido_blob_t *clientdata, + const fido_blob_t *authdata) +{ + if (SIZE_MAX - authdata->len < clientdata->len || + dgst->len < authdata->len + clientdata->len) + return (-1); + + memcpy(dgst->ptr, authdata->ptr, authdata->len); + memcpy(dgst->ptr + authdata->len, clientdata->ptr, clientdata->len); + dgst->len = authdata->len + clientdata->len; + + return (0); +} + int fido_get_signed_hash(int cose_alg, fido_blob_t *dgst, const fido_blob_t *clientdata, const fido_blob_t *authdata_cbor) { cbor_item_t *item = NULL; - unsigned char *authdata_ptr = NULL; - size_t authdata_len; + fido_blob_t authdata; struct cbor_load_result cbor; - const EVP_MD *md = NULL; - EVP_MD_CTX *ctx = NULL; int ok = -1; + fido_log_debug("%s: cose_alg=%d", __func__, cose_alg); + if ((item = cbor_load(authdata_cbor->ptr, authdata_cbor->len, &cbor)) == NULL || cbor_isa_bytestring(item) == false || cbor_bytestring_is_definite(item) == false) { fido_log_debug("%s: authdata", __func__); goto fail; } + authdata.ptr = cbor_bytestring_handle(item); + authdata.len = cbor_bytestring_length(item); - authdata_ptr = cbor_bytestring_handle(item); - authdata_len = cbor_bytestring_length(item); - - if (cose_alg != COSE_EDDSA) { - if (dgst->len < SHA256_DIGEST_LENGTH || - (md = EVP_sha256()) == NULL || - (ctx = EVP_MD_CTX_new()) == NULL || - EVP_DigestInit_ex(ctx, md, NULL) != 1 || - EVP_DigestUpdate(ctx, authdata_ptr, authdata_len) != 1 || - EVP_DigestUpdate(ctx, clientdata->ptr, clientdata->len) != 1 || - EVP_DigestFinal_ex(ctx, dgst->ptr, NULL) != 1) { - fido_log_debug("%s: sha256", __func__); - goto fail; - } - dgst->len = SHA256_DIGEST_LENGTH; - } else { - if (SIZE_MAX - authdata_len < clientdata->len || - dgst->len < authdata_len + clientdata->len) { - fido_log_debug("%s: memcpy", __func__); - goto fail; - } - memcpy(dgst->ptr, authdata_ptr, authdata_len); - memcpy(dgst->ptr + authdata_len, clientdata->ptr, - clientdata->len); - dgst->len = authdata_len + clientdata->len; + switch (cose_alg) { + case COSE_ES256: + case COSE_RS256: + ok = get_es256_hash(dgst, clientdata, &authdata); + break; + case COSE_ES384: + ok = get_es384_hash(dgst, clientdata, &authdata); + break; + case COSE_EDDSA: + ok = get_eddsa_hash(dgst, clientdata, &authdata); + break; + default: + fido_log_debug("%s: unknown cose_alg", __func__); + break; } - - ok = 0; fail: if (item != NULL) cbor_decref(&item); - EVP_MD_CTX_free(ctx); - return (ok); } @@ -481,6 +550,9 @@ fido_assert_verify(const fido_assert_t *assert, size_t idx, int cose_alg, case COSE_ES256: ok = es256_pk_verify_sig(&dgst, pk, &stmt->sig); break; + case COSE_ES384: + ok = es384_pk_verify_sig(&dgst, pk, &stmt->sig); + break; case COSE_RS256: ok = rs256_pk_verify_sig(&dgst, pk, &stmt->sig); break; @@ -676,7 +748,8 @@ fido_assert_reset_tx(fido_assert_t *assert) assert->uv = FIDO_OPT_OMIT; } -static void fido_assert_reset_extattr(fido_assert_extattr_t *ext) +static void +fido_assert_reset_extattr(fido_assert_extattr_t *ext) { fido_blob_reset(&ext->hmac_secret_enc); fido_blob_reset(&ext->blob); diff --git a/src/authkey.c b/src/authkey.c index 33e0a8d44bd2..761562b26a1e 100644 --- a/src/authkey.c +++ b/src/authkey.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" @@ -60,22 +61,31 @@ fail: static int fido_dev_authkey_rx(fido_dev_t *dev, es256_pk_t *authkey, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; + unsigned char *msg; + int msglen; + int r; fido_log_debug("%s: dev=%p, authkey=%p, ms=%d", __func__, (void *)dev, (void *)authkey, *ms); memset(authkey, 0, sizeof(*authkey)); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - return (cbor_parse_reply(reply, (size_t)reply_len, authkey, - parse_authkey)); + r = cbor_parse_reply(msg, (size_t)msglen, authkey, parse_authkey); +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int diff --git a/src/bio.c b/src/bio.c index 8c52de5d76c3..57db85f53b23 100644 --- a/src/bio.c +++ b/src/bio.c @@ -1,7 +1,8 @@ /* - * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include "fido.h" @@ -233,25 +234,34 @@ bio_parse_template_array(const cbor_item_t *key, const cbor_item_t *val, static int bio_rx_template_array(fido_dev_t *dev, fido_bio_template_array_t *ta, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; bio_reset_template_array(ta); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, ta, + if ((r = cbor_parse_reply(msg, (size_t)msglen, ta, bio_parse_template_array)) != FIDO_OK) { fido_log_debug("%s: bio_parse_template_array" , __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -385,33 +395,43 @@ static int bio_rx_enroll_begin(fido_dev_t *dev, fido_bio_template_t *t, fido_bio_enroll_t *e, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; bio_reset_template(t); e->remaining_samples = 0; e->last_status = 0; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, e, + if ((r = cbor_parse_reply(msg, (size_t)msglen, e, bio_parse_enroll_status)) != FIDO_OK) { fido_log_debug("%s: bio_parse_enroll_status", __func__); - return (r); + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, &t->id, + + if ((r = cbor_parse_reply(msg, (size_t)msglen, &t->id, bio_parse_template_id)) != FIDO_OK) { fido_log_debug("%s: bio_parse_template_id", __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -487,26 +507,35 @@ fail: static int bio_rx_enroll_continue(fido_dev_t *dev, fido_bio_enroll_t *e, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; e->remaining_samples = 0; e->last_status = 0; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, e, + if ((r = cbor_parse_reply(msg, (size_t)msglen, e, bio_parse_enroll_status)) != FIDO_OK) { fido_log_debug("%s: bio_parse_enroll_status", __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -654,25 +683,34 @@ bio_parse_info(const cbor_item_t *key, const cbor_item_t *val, void *arg) static int bio_rx_info(fido_dev_t *dev, fido_bio_info_t *i, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; bio_reset_info(i); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, i, + if ((r = cbor_parse_reply(msg, (size_t)msglen, i, bio_parse_info)) != FIDO_OK) { fido_log_debug("%s: bio_parse_info" , __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int diff --git a/src/blob.c b/src/blob.c index 31e4cab0edc4..b431f49a00fc 100644 --- a/src/blob.c +++ b/src/blob.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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" diff --git a/src/blob.h b/src/blob.h index 76a8dd994f22..724718595513 100644 --- a/src/blob.h +++ b/src/blob.h @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ #ifndef _BLOB_H diff --git a/src/buf.c b/src/buf.c index f7161e64a9ca..42b6df1c24f1 100644 --- a/src/buf.c +++ b/src/buf.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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" diff --git a/src/cbor.c b/src/cbor.c index 8b7edece3d8e..ab99b34da085 100644 --- a/src/cbor.c +++ b/src/cbor.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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 <openssl/hmac.h> @@ -998,7 +999,13 @@ get_cose_alg(const cbor_item_t *item, int *cose_alg) fido_log_debug("%s: invalid kty/crv", __func__); return (-1); } - + break; + case COSE_ES384: + if (cose_key.kty != COSE_KTY_EC2 || + cose_key.crv != COSE_P384) { + fido_log_debug("%s: invalid kty/crv", __func__); + return (-1); + } break; case COSE_EDDSA: if (cose_key.kty != COSE_KTY_OKP || @@ -1006,14 +1013,12 @@ get_cose_alg(const cbor_item_t *item, int *cose_alg) fido_log_debug("%s: invalid kty/crv", __func__); return (-1); } - break; case COSE_RS256: if (cose_key.kty != COSE_KTY_RSA) { fido_log_debug("%s: invalid kty/crv", __func__); return (-1); } - break; default: fido_log_debug("%s: unknown alg %d", __func__, cose_key.alg); @@ -1041,6 +1046,12 @@ cbor_decode_pubkey(const cbor_item_t *item, int *type, void *key) return (-1); } break; + case COSE_ES384: + if (es384_pk_decode(item, key) < 0) { + fido_log_debug("%s: es384_pk_decode", __func__); + return (-1); + } + break; case COSE_RS256: if (rs256_pk_decode(item, key) < 0) { fido_log_debug("%s: rs256_pk_decode", __func__); @@ -1135,10 +1146,8 @@ decode_cred_extension(const cbor_item_t *key, const cbor_item_t *val, void *arg) } if (strcmp(type, "hmac-secret") == 0) { - if (cbor_isa_float_ctrl(val) == false || - cbor_float_get_width(val) != CBOR_FLOAT_0 || - cbor_is_bool(val) == false) { - fido_log_debug("%s: cbor type", __func__); + if (cbor_decode_bool(val, NULL) < 0) { + fido_log_debug("%s: cbor_decode_bool", __func__); goto out; } if (cbor_ctrl_value(val) == CBOR_CTRL_TRUE) @@ -1152,10 +1161,8 @@ decode_cred_extension(const cbor_item_t *key, const cbor_item_t *val, void *arg) authdata_ext->mask |= FIDO_EXT_CRED_PROTECT; authdata_ext->prot = cbor_get_uint8(val); } else if (strcmp(type, "credBlob") == 0) { - if (cbor_isa_float_ctrl(val) == false || - cbor_float_get_width(val) != CBOR_FLOAT_0 || - cbor_is_bool(val) == false) { - fido_log_debug("%s: cbor type", __func__); + if (cbor_decode_bool(val, NULL) < 0) { + fido_log_debug("%s: cbor_decode_bool", __func__); goto out; } if (cbor_ctrl_value(val) == CBOR_CTRL_TRUE) @@ -1407,8 +1414,9 @@ decode_attstmt_entry(const cbor_item_t *key, const cbor_item_t *val, void *arg) goto out; } attstmt->alg = -(int)cbor_get_int(val) - 1; - if (attstmt->alg != COSE_ES256 && attstmt->alg != COSE_RS256 && - attstmt->alg != COSE_EDDSA && attstmt->alg != COSE_RS1) { + if (attstmt->alg != COSE_ES256 && attstmt->alg != COSE_ES384 && + attstmt->alg != COSE_RS256 && attstmt->alg != COSE_EDDSA && + attstmt->alg != COSE_RS1) { fido_log_debug("%s: unsupported attstmt->alg=%d", __func__, attstmt->alg); goto out; @@ -1619,6 +1627,22 @@ cbor_decode_rp_entity(const cbor_item_t *item, fido_rp_t *rp) return (0); } +int +cbor_decode_bool(const cbor_item_t *item, bool *v) +{ + if (cbor_isa_float_ctrl(item) == false || + cbor_float_get_width(item) != CBOR_FLOAT_0 || + cbor_is_bool(item) == false) { + fido_log_debug("%s: cbor type", __func__); + return (-1); + } + + if (v != NULL) + *v = cbor_ctrl_value(item) == CBOR_CTRL_TRUE; + + return (0); +} + cbor_item_t * cbor_build_uint(const uint64_t value) { diff --git a/src/compress.c b/src/compress.c index 074bca876489..3be6fd52fc3f 100644 --- a/src/compress.c +++ b/src/compress.c @@ -2,6 +2,7 @@ * Copyright (c) 2020-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 <zlib.h> diff --git a/src/config.c b/src/config.c index 2baaab0fd62c..5302e118b63f 100644 --- a/src/config.c +++ b/src/config.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2020 Yubico AB. All rights reserved. + * Copyright (c) 2020-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" @@ -16,15 +17,17 @@ static int config_prepare_hmac(uint8_t subcmd, const cbor_item_t *item, fido_blob_t *hmac) { uint8_t prefix[32 + 2 * sizeof(uint8_t)], cbor[128]; - size_t cbor_len; + size_t cbor_len = 0; memset(prefix, 0xff, sizeof(prefix)); prefix[sizeof(prefix) - 2] = CTAP_CBOR_CONFIG; prefix[sizeof(prefix) - 1] = subcmd; - if ((cbor_len = cbor_serialize(item, cbor, sizeof(cbor))) == 0) { - fido_log_debug("%s: cbor_serialize", __func__); - return -1; + if (item != NULL) { + if ((cbor_len = cbor_serialize(item, cbor, sizeof(cbor))) == 0) { + fido_log_debug("%s: cbor_serialize", __func__); + return -1; + } } if ((hmac->ptr = malloc(cbor_len + sizeof(prefix))) == NULL) { fido_log_debug("%s: malloc", __func__); @@ -57,13 +60,16 @@ config_tx(fido_dev_t *dev, uint8_t subcmd, cbor_item_t **paramv, size_t paramc, goto fail; } + /* subCommandParams */ + if (paramc != 0 && + (argv[1] = cbor_flatten_vector(paramv, paramc)) == NULL) { + fido_log_debug("%s: cbor_flatten_vector", __func__); + goto fail; + } + /* pinProtocol, pinAuth */ - if (pin != NULL || (fido_dev_supports_permissions(dev) && - fido_dev_has_uv(dev))) { - if ((argv[1] = cbor_flatten_vector(paramv, paramc)) == NULL) { - fido_log_debug("%s: cbor_flatten_vector", __func__); - goto fail; - } + if (pin != NULL || + (fido_dev_supports_permissions(dev) && fido_dev_has_uv(dev))) { if (config_prepare_hmac(subcmd, argv[1], &hmac) < 0) { fido_log_debug("%s: config_prepare_hmac", __func__); goto fail; diff --git a/src/cred.c b/src/cred.c index 6da502c8d90a..188afe4e64aa 100644 --- a/src/cred.c +++ b/src/cred.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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 <openssl/sha.h> @@ -251,7 +252,7 @@ get_signed_hash_u2f(fido_blob_t *dgst, const unsigned char *rp_id, EVP_MD_CTX *ctx = NULL; int ok = -1; - if (dgst->len != SHA256_DIGEST_LENGTH || + if (dgst->len < SHA256_DIGEST_LENGTH || (md = EVP_sha256()) == NULL || (ctx = EVP_MD_CTX_new()) == NULL || EVP_DigestInit_ex(ctx, md, NULL) != 1 || @@ -266,6 +267,7 @@ get_signed_hash_u2f(fido_blob_t *dgst, const unsigned char *rp_id, fido_log_debug("%s: sha256", __func__); goto fail; } + dgst->len = SHA256_DIGEST_LENGTH; ok = 0; fail: @@ -302,6 +304,9 @@ verify_attstmt(const fido_blob_t *dgst, const fido_attstmt_t *attstmt) case COSE_ES256: ok = es256_verify_sig(dgst, pkey, &attstmt->sig); break; + case COSE_ES384: + ok = es384_verify_sig(dgst, pkey, &attstmt->sig); + break; case COSE_RS256: ok = rs256_verify_sig(dgst, pkey, &attstmt->sig); break; @@ -327,8 +332,9 @@ fail: int fido_cred_verify(const fido_cred_t *cred) { - unsigned char buf[SHA256_DIGEST_LENGTH]; + unsigned char buf[1024]; /* XXX */ fido_blob_t dgst; + int cose_alg; int r; dgst.ptr = buf; @@ -368,8 +374,11 @@ fido_cred_verify(const fido_cred_t *cred) goto out; } + if ((cose_alg = cred->attstmt.alg) == COSE_UNSPEC) + cose_alg = COSE_ES256; /* backwards compat */ + if (!strcmp(cred->fmt, "packed")) { - if (fido_get_signed_hash(COSE_ES256, &dgst, &cred->cdh, + if (fido_get_signed_hash(cose_alg, &dgst, &cred->cdh, &cred->authdata_cbor) < 0) { fido_log_debug("%s: fido_get_signed_hash", __func__); r = FIDO_ERR_INTERNAL; @@ -480,6 +489,10 @@ fido_cred_verify_self(const fido_cred_t *cred) ok = es256_pk_verify_sig(&dgst, &cred->attcred.pubkey.es256, &cred->attstmt.sig); break; + case COSE_ES384: + ok = es384_pk_verify_sig(&dgst, &cred->attcred.pubkey.es384, + &cred->attstmt.sig); + break; case COSE_RS256: ok = rs256_pk_verify_sig(&dgst, &cred->attcred.pubkey.rs256, &cred->attstmt.sig); @@ -965,8 +978,10 @@ fido_cred_set_fmt(fido_cred_t *cred, const char *fmt) int fido_cred_set_type(fido_cred_t *cred, int cose_alg) { - if ((cose_alg != COSE_ES256 && cose_alg != COSE_RS256 && - cose_alg != COSE_EDDSA) || cred->type != 0) + if (cred->type != 0) + return (FIDO_ERR_INVALID_ARGUMENT); + if (cose_alg != COSE_ES256 && cose_alg != COSE_ES384 && + cose_alg != COSE_RS256 && cose_alg != COSE_EDDSA) return (FIDO_ERR_INVALID_ARGUMENT); cred->type = cose_alg; @@ -1073,6 +1088,9 @@ fido_cred_pubkey_ptr(const fido_cred_t *cred) case COSE_ES256: ptr = &cred->attcred.pubkey.es256; break; + case COSE_ES384: + ptr = &cred->attcred.pubkey.es384; + break; case COSE_RS256: ptr = &cred->attcred.pubkey.rs256; break; @@ -1096,6 +1114,9 @@ fido_cred_pubkey_len(const fido_cred_t *cred) case COSE_ES256: len = sizeof(cred->attcred.pubkey.es256); break; + case COSE_ES384: + len = sizeof(cred->attcred.pubkey.es384); + break; case COSE_RS256: len = sizeof(cred->attcred.pubkey.rs256); break; diff --git a/src/credman.c b/src/credman.c index 8d2649a144f2..c36424233816 100644 --- a/src/credman.c +++ b/src/credman.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2019-2021 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <openssl/sha.h> @@ -19,7 +20,7 @@ #define CMD_UPDATE_CRED 0x07 static int -credman_grow_array(void **ptr, size_t *n_alloc, size_t *n_rx, size_t n, +credman_grow_array(void **ptr, size_t *n_alloc, const size_t *n_rx, size_t n, size_t size) { void *new_ptr; @@ -200,25 +201,34 @@ credman_parse_metadata(const cbor_item_t *key, const cbor_item_t *val, static int credman_rx_metadata(fido_dev_t *dev, fido_credman_metadata_t *metadata, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; memset(metadata, 0, sizeof(*metadata)); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, metadata, + if ((r = cbor_parse_reply(msg, (size_t)msglen, metadata, credman_parse_metadata)) != FIDO_OK) { fido_log_debug("%s: credman_parse_metadata", __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -325,69 +335,88 @@ credman_parse_rk_count(const cbor_item_t *key, const cbor_item_t *val, static int credman_rx_rk(fido_dev_t *dev, fido_credman_rk_t *rk, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; credman_reset_rk(rk); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } /* adjust as needed */ - if ((r = cbor_parse_reply(reply, (size_t)reply_len, rk, + if ((r = cbor_parse_reply(msg, (size_t)msglen, rk, credman_parse_rk_count)) != FIDO_OK) { fido_log_debug("%s: credman_parse_rk_count", __func__); - return (r); + goto out; } if (rk->n_alloc == 0) { fido_log_debug("%s: n_alloc=0", __func__); - return (FIDO_OK); + r = FIDO_OK; + goto out; } /* parse the first rk */ - if ((r = cbor_parse_reply(reply, (size_t)reply_len, &rk->ptr[0], + if ((r = cbor_parse_reply(msg, (size_t)msglen, &rk->ptr[0], credman_parse_rk)) != FIDO_OK) { fido_log_debug("%s: credman_parse_rk", __func__); - return (r); + goto out; } + rk->n_rx = 1; - rk->n_rx++; + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); - return (FIDO_OK); + return (r); } static int credman_rx_next_rk(fido_dev_t *dev, fido_credman_rk_t *rk, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; + + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } /* sanity check */ if (rk->n_rx >= rk->n_alloc) { fido_log_debug("%s: n_rx=%zu, n_alloc=%zu", __func__, rk->n_rx, rk->n_alloc); - return (FIDO_ERR_INTERNAL); + r = FIDO_ERR_INTERNAL; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, &rk->ptr[rk->n_rx], + if ((r = cbor_parse_reply(msg, (size_t)msglen, &rk->ptr[rk->n_rx], credman_parse_rk)) != FIDO_OK) { fido_log_debug("%s: credman_parse_rk", __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -534,69 +563,88 @@ credman_parse_rp_count(const cbor_item_t *key, const cbor_item_t *val, static int credman_rx_rp(fido_dev_t *dev, fido_credman_rp_t *rp, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; credman_reset_rp(rp); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } /* adjust as needed */ - if ((r = cbor_parse_reply(reply, (size_t)reply_len, rp, + if ((r = cbor_parse_reply(msg, (size_t)msglen, rp, credman_parse_rp_count)) != FIDO_OK) { fido_log_debug("%s: credman_parse_rp_count", __func__); - return (r); + goto out; } if (rp->n_alloc == 0) { fido_log_debug("%s: n_alloc=0", __func__); - return (FIDO_OK); + r = FIDO_OK; + goto out; } /* parse the first rp */ - if ((r = cbor_parse_reply(reply, (size_t)reply_len, &rp->ptr[0], + if ((r = cbor_parse_reply(msg, (size_t)msglen, &rp->ptr[0], credman_parse_rp)) != FIDO_OK) { fido_log_debug("%s: credman_parse_rp", __func__); - return (r); + goto out; } + rp->n_rx = 1; - rp->n_rx++; + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); - return (FIDO_OK); + return (r); } static int credman_rx_next_rp(fido_dev_t *dev, fido_credman_rp_t *rp, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } /* sanity check */ if (rp->n_rx >= rp->n_alloc) { fido_log_debug("%s: n_rx=%zu, n_alloc=%zu", __func__, rp->n_rx, rp->n_alloc); - return (FIDO_ERR_INTERNAL); + r = FIDO_ERR_INTERNAL; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, &rp->ptr[rp->n_rx], + if ((r = cbor_parse_reply(msg, (size_t)msglen, &rp->ptr[rp->n_rx], credman_parse_rp)) != FIDO_OK) { fido_log_debug("%s: credman_parse_rp", __func__); - return (r); + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int diff --git a/src/dev.c b/src/dev.c index 635e41714759..2d662a6cc48b 100644 --- a/src/dev.c +++ b/src/dev.c @@ -2,6 +2,7 @@ * 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" diff --git a/src/diff_exports.sh b/src/diff_exports.sh index 9cff0095a201..2e15cd0c5b9b 100755 --- a/src/diff_exports.sh +++ b/src/diff_exports.sh @@ -3,6 +3,7 @@ # Copyright (c) 2018 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 for f in export.gnu export.llvm export.msvc; do if [ ! -f "${f}" ]; then diff --git a/src/ecdh.c b/src/ecdh.c index 9c4f2b99e1a9..878f97615e3f 100644 --- a/src/ecdh.c +++ b/src/ecdh.c @@ -2,6 +2,7 @@ * Copyright (c) 2018-2021 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 <openssl/evp.h> diff --git a/src/eddsa.c b/src/eddsa.c index a94ae3023917..d043f89f9f37 100644 --- a/src/eddsa.c +++ b/src/eddsa.c @@ -2,6 +2,7 @@ * Copyright (c) 2019-2021 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 <openssl/bn.h> diff --git a/src/err.c b/src/err.c index 8c2ae5ff4170..3a6f3e0a6124 100644 --- a/src/err.c +++ b/src/err.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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/err.h" diff --git a/src/es256.c b/src/es256.c index 4d6e86f8a26d..17efb0ad2c16 100644 --- a/src/es256.c +++ b/src/es256.c @@ -2,6 +2,7 @@ * 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 <openssl/bn.h> diff --git a/src/es384.c b/src/es384.c new file mode 100644 index 000000000000..013d285ef7f0 --- /dev/null +++ b/src/es384.c @@ -0,0 +1,296 @@ +/* + * Copyright (c) 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 <openssl/bn.h> +#include <openssl/ecdsa.h> +#include <openssl/obj_mac.h> + +#include "fido.h" +#include "fido/es384.h" + +#if OPENSSL_VERSION_NUMBER >= 0x30000000 +#define get0_EC_KEY(x) EVP_PKEY_get0_EC_KEY((x)) +#else +#define get0_EC_KEY(x) EVP_PKEY_get0((x)) +#endif + +static int +decode_coord(const cbor_item_t *item, void *xy, size_t xy_len) +{ + if (cbor_isa_bytestring(item) == false || + cbor_bytestring_is_definite(item) == false || + cbor_bytestring_length(item) != xy_len) { + fido_log_debug("%s: cbor type", __func__); + return (-1); + } + + memcpy(xy, cbor_bytestring_handle(item), xy_len); + + return (0); +} + +static int +decode_pubkey_point(const cbor_item_t *key, const cbor_item_t *val, void *arg) +{ + es384_pk_t *k = arg; + + if (cbor_isa_negint(key) == false || + cbor_int_get_width(key) != CBOR_INT_8) + return (0); /* ignore */ + + switch (cbor_get_uint8(key)) { + case 1: /* x coordinate */ + return (decode_coord(val, &k->x, sizeof(k->x))); + case 2: /* y coordinate */ + return (decode_coord(val, &k->y, sizeof(k->y))); + } + + return (0); /* ignore */ +} + +int +es384_pk_decode(const cbor_item_t *item, es384_pk_t *k) +{ + if (cbor_isa_map(item) == false || + cbor_map_is_definite(item) == false || + cbor_map_iter(item, k, decode_pubkey_point) < 0) { + fido_log_debug("%s: cbor type", __func__); + return (-1); + } + + return (0); +} + +es384_pk_t * +es384_pk_new(void) +{ + return (calloc(1, sizeof(es384_pk_t))); +} + +void +es384_pk_free(es384_pk_t **pkp) +{ + es384_pk_t *pk; + + if (pkp == NULL || (pk = *pkp) == NULL) + return; + + freezero(pk, sizeof(*pk)); + *pkp = NULL; +} + +int +es384_pk_from_ptr(es384_pk_t *pk, const void *ptr, size_t len) +{ + const uint8_t *p = ptr; + EVP_PKEY *pkey; + + if (len < sizeof(*pk)) + return (FIDO_ERR_INVALID_ARGUMENT); + + if (len == sizeof(*pk) + 1 && *p == 0x04) + memcpy(pk, ++p, sizeof(*pk)); /* uncompressed format */ + else + memcpy(pk, ptr, sizeof(*pk)); /* libfido2 x||y format */ + + if ((pkey = es384_pk_to_EVP_PKEY(pk)) == NULL) { + fido_log_debug("%s: es384_pk_to_EVP_PKEY", __func__); + explicit_bzero(pk, sizeof(*pk)); + return (FIDO_ERR_INVALID_ARGUMENT); + } + + EVP_PKEY_free(pkey); + + return (FIDO_OK); +} + +EVP_PKEY * +es384_pk_to_EVP_PKEY(const es384_pk_t *k) +{ + BN_CTX *bnctx = NULL; + EC_KEY *ec = NULL; + EC_POINT *q = NULL; + EVP_PKEY *pkey = NULL; + BIGNUM *x = NULL; + BIGNUM *y = NULL; + const EC_GROUP *g = NULL; + int ok = -1; + + if ((bnctx = BN_CTX_new()) == NULL) + goto fail; + + BN_CTX_start(bnctx); + + if ((x = BN_CTX_get(bnctx)) == NULL || + (y = BN_CTX_get(bnctx)) == NULL) + goto fail; + + if (BN_bin2bn(k->x, sizeof(k->x), x) == NULL || + BN_bin2bn(k->y, sizeof(k->y), y) == NULL) { + fido_log_debug("%s: BN_bin2bn", __func__); + goto fail; + } + + if ((ec = EC_KEY_new_by_curve_name(NID_secp384r1)) == NULL || + (g = EC_KEY_get0_group(ec)) == NULL) { + fido_log_debug("%s: EC_KEY init", __func__); + goto fail; + } + + if ((q = EC_POINT_new(g)) == NULL || + EC_POINT_set_affine_coordinates_GFp(g, q, x, y, bnctx) == 0 || + EC_KEY_set_public_key(ec, q) == 0) { + fido_log_debug("%s: EC_KEY_set_public_key", __func__); + goto fail; + } + + if ((pkey = EVP_PKEY_new()) == NULL || + EVP_PKEY_assign_EC_KEY(pkey, ec) == 0) { + fido_log_debug("%s: EVP_PKEY_assign_EC_KEY", __func__); + goto fail; + } + + ec = NULL; /* at this point, ec belongs to evp */ + + ok = 0; +fail: + if (bnctx != NULL) { + BN_CTX_end(bnctx); + BN_CTX_free(bnctx); + } + + if (ec != NULL) + EC_KEY_free(ec); + if (q != NULL) + EC_POINT_free(q); + + if (ok < 0 && pkey != NULL) { + EVP_PKEY_free(pkey); + pkey = NULL; + } + + return (pkey); +} + +int +es384_pk_from_EC_KEY(es384_pk_t *pk, const EC_KEY *ec) +{ + BN_CTX *bnctx = NULL; + BIGNUM *x = NULL; + BIGNUM *y = NULL; + const EC_POINT *q = NULL; + EC_GROUP *g = NULL; + size_t dx; + size_t dy; + int ok = FIDO_ERR_INTERNAL; + int nx; + int ny; + + if ((q = EC_KEY_get0_public_key(ec)) == NULL || + (g = EC_GROUP_new_by_curve_name(NID_secp384r1)) == NULL || + (bnctx = BN_CTX_new()) == NULL) + goto fail; + + BN_CTX_start(bnctx); + + if ((x = BN_CTX_get(bnctx)) == NULL || + (y = BN_CTX_get(bnctx)) == NULL) + goto fail; + + if (EC_POINT_is_on_curve(g, q, bnctx) != 1) { + fido_log_debug("%s: EC_POINT_is_on_curve", __func__); + ok = FIDO_ERR_INVALID_ARGUMENT; + goto fail; + } + + if (EC_POINT_get_affine_coordinates_GFp(g, q, x, y, bnctx) == 0 || + (nx = BN_num_bytes(x)) < 0 || (size_t)nx > sizeof(pk->x) || + (ny = BN_num_bytes(y)) < 0 || (size_t)ny > sizeof(pk->y)) { + fido_log_debug("%s: EC_POINT_get_affine_coordinates_GFp", + __func__); + goto fail; + } + + dx = sizeof(pk->x) - (size_t)nx; + dy = sizeof(pk->y) - (size_t)ny; + + if ((nx = BN_bn2bin(x, pk->x + dx)) < 0 || (size_t)nx > sizeof(pk->x) || + (ny = BN_bn2bin(y, pk->y + dy)) < 0 || (size_t)ny > sizeof(pk->y)) { + fido_log_debug("%s: BN_bn2bin", __func__); + goto fail; + } + + ok = FIDO_OK; +fail: + EC_GROUP_free(g); + + if (bnctx != NULL) { + BN_CTX_end(bnctx); + BN_CTX_free(bnctx); + } + + return (ok); +} + +int +es384_pk_from_EVP_PKEY(es384_pk_t *pk, const EVP_PKEY *pkey) +{ + const EC_KEY *ec; + + if (EVP_PKEY_base_id(pkey) != EVP_PKEY_EC || + (ec = get0_EC_KEY(pkey)) == NULL) + return (FIDO_ERR_INVALID_ARGUMENT); + + return (es384_pk_from_EC_KEY(pk, ec)); +} + +int +es384_verify_sig(const fido_blob_t *dgst, EVP_PKEY *pkey, + const fido_blob_t *sig) +{ + EVP_PKEY_CTX *pctx = NULL; + int ok = -1; + + if (EVP_PKEY_base_id(pkey) != EVP_PKEY_EC) { + fido_log_debug("%s: EVP_PKEY_base_id", __func__); + goto fail; + } + + if ((pctx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL || + EVP_PKEY_verify_init(pctx) != 1 || + EVP_PKEY_verify(pctx, sig->ptr, sig->len, dgst->ptr, + dgst->len) != 1) { + fido_log_debug("%s: EVP_PKEY_verify", __func__); + goto fail; + } + + ok = 0; +fail: + EVP_PKEY_CTX_free(pctx); + + return (ok); +} + +int +es384_pk_verify_sig(const fido_blob_t *dgst, const es384_pk_t *pk, + const fido_blob_t *sig) +{ + EVP_PKEY *pkey; + int ok = -1; + + if ((pkey = es384_pk_to_EVP_PKEY(pk)) == NULL || + es384_verify_sig(dgst, pkey, sig) < 0) { + fido_log_debug("%s: es384_verify_sig", __func__); + goto fail; + } + + ok = 0; +fail: + EVP_PKEY_free(pkey); + + return (ok); +} diff --git a/src/export.gnu b/src/export.gnu index 8fc94af31c92..6916837ecbcc 100644 --- a/src/export.gnu +++ b/src/export.gnu @@ -11,6 +11,12 @@ es256_pk_from_ptr; es256_pk_new; es256_pk_to_EVP_PKEY; + es384_pk_free; + es384_pk_from_EC_KEY; + es384_pk_from_EVP_PKEY; + es384_pk_from_ptr; + es384_pk_new; + es384_pk_to_EVP_PKEY; fido_assert_allow_cred; fido_assert_authdata_len; fido_assert_authdata_ptr; @@ -82,23 +88,32 @@ fido_cbor_info_algorithm_cose; fido_cbor_info_algorithm_count; fido_cbor_info_algorithm_type; + fido_cbor_info_certs_len; + fido_cbor_info_certs_name_ptr; + fido_cbor_info_certs_value_ptr; fido_cbor_info_extensions_len; fido_cbor_info_extensions_ptr; fido_cbor_info_free; + fido_cbor_info_fwversion; 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_maxrpid_minpinlen; + fido_cbor_info_minpinlen; fido_cbor_info_new; + fido_cbor_info_new_pin_required; fido_cbor_info_options_len; fido_cbor_info_options_name_ptr; fido_cbor_info_options_value_ptr; fido_cbor_info_protocols_len; fido_cbor_info_protocols_ptr; + fido_cbor_info_rk_remaining; fido_cbor_info_transports_len; fido_cbor_info_transports_ptr; + fido_cbor_info_uv_attempts; + fido_cbor_info_uv_modality; fido_cbor_info_versions_len; fido_cbor_info_versions_ptr; fido_cred_attstmt_len; diff --git a/src/export.llvm b/src/export.llvm index df9a667f7477..bd21fb4a54f7 100644 --- a/src/export.llvm +++ b/src/export.llvm @@ -9,6 +9,12 @@ _es256_pk_from_EVP_PKEY _es256_pk_from_ptr _es256_pk_new _es256_pk_to_EVP_PKEY +_es384_pk_free +_es384_pk_from_EC_KEY +_es384_pk_from_EVP_PKEY +_es384_pk_from_ptr +_es384_pk_new +_es384_pk_to_EVP_PKEY _fido_assert_allow_cred _fido_assert_authdata_len _fido_assert_authdata_ptr @@ -80,23 +86,32 @@ _fido_cbor_info_aaguid_ptr _fido_cbor_info_algorithm_cose _fido_cbor_info_algorithm_count _fido_cbor_info_algorithm_type +_fido_cbor_info_certs_len +_fido_cbor_info_certs_name_ptr +_fido_cbor_info_certs_value_ptr _fido_cbor_info_extensions_len _fido_cbor_info_extensions_ptr _fido_cbor_info_free +_fido_cbor_info_fwversion _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_maxrpid_minpinlen +_fido_cbor_info_minpinlen _fido_cbor_info_new +_fido_cbor_info_new_pin_required _fido_cbor_info_options_len _fido_cbor_info_options_name_ptr _fido_cbor_info_options_value_ptr _fido_cbor_info_protocols_len _fido_cbor_info_protocols_ptr +_fido_cbor_info_rk_remaining _fido_cbor_info_transports_len _fido_cbor_info_transports_ptr +_fido_cbor_info_uv_attempts +_fido_cbor_info_uv_modality _fido_cbor_info_versions_len _fido_cbor_info_versions_ptr _fido_cred_attstmt_len diff --git a/src/export.msvc b/src/export.msvc index a9082152f5cc..55147f99e67f 100644 --- a/src/export.msvc +++ b/src/export.msvc @@ -10,6 +10,12 @@ es256_pk_from_EVP_PKEY es256_pk_from_ptr es256_pk_new es256_pk_to_EVP_PKEY +es384_pk_free +es384_pk_from_EC_KEY +es384_pk_from_EVP_PKEY +es384_pk_from_ptr +es384_pk_new +es384_pk_to_EVP_PKEY fido_assert_allow_cred fido_assert_authdata_len fido_assert_authdata_ptr @@ -81,23 +87,32 @@ fido_cbor_info_aaguid_ptr fido_cbor_info_algorithm_cose fido_cbor_info_algorithm_count fido_cbor_info_algorithm_type +fido_cbor_info_certs_len +fido_cbor_info_certs_name_ptr +fido_cbor_info_certs_value_ptr fido_cbor_info_extensions_len fido_cbor_info_extensions_ptr fido_cbor_info_free +fido_cbor_info_fwversion 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_maxrpid_minpinlen +fido_cbor_info_minpinlen fido_cbor_info_new +fido_cbor_info_new_pin_required fido_cbor_info_options_len fido_cbor_info_options_name_ptr fido_cbor_info_options_value_ptr fido_cbor_info_protocols_len fido_cbor_info_protocols_ptr +fido_cbor_info_rk_remaining fido_cbor_info_transports_len fido_cbor_info_transports_ptr +fido_cbor_info_uv_attempts +fido_cbor_info_uv_modality fido_cbor_info_versions_len fido_cbor_info_versions_ptr fido_cred_attstmt_len diff --git a/src/extern.h b/src/extern.h index 84536d58b6f8..1bc95b27805d 100644 --- a/src/extern.h +++ b/src/extern.h @@ -2,6 +2,7 @@ * 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 */ #ifndef _EXTERN_H @@ -57,6 +58,7 @@ cbor_item_t *es256_pk_encode(const es256_pk_t *, int); /* cbor decoding functions */ int cbor_decode_attstmt(const cbor_item_t *, fido_attstmt_t *); +int cbor_decode_bool(const cbor_item_t *, bool *); int cbor_decode_cred_authdata(const cbor_item_t *, int, fido_blob_t *, fido_authdata_t *, fido_attcred_t *, fido_cred_ext_t *); int cbor_decode_assert_authdata(const cbor_item_t *, fido_blob_t *, @@ -68,6 +70,7 @@ int cbor_decode_rp_entity(const cbor_item_t *, fido_rp_t *); int cbor_decode_uint64(const cbor_item_t *, uint64_t *); int cbor_decode_user(const cbor_item_t *, fido_user_t *); int es256_pk_decode(const cbor_item_t *, es256_pk_t *); +int es384_pk_decode(const cbor_item_t *, es384_pk_t *); int rs256_pk_decode(const cbor_item_t *, rs256_pk_t *); int eddsa_pk_decode(const cbor_item_t *, eddsa_pk_t *); @@ -119,6 +122,7 @@ size_t fido_hid_report_out_len(void *); /* nfc i/o */ bool fido_is_nfc(const char *); +bool nfc_is_fido(const char *); void *fido_nfc_open(const char *); void fido_nfc_close(void *); int fido_nfc_read(void *, unsigned char *, size_t, int); @@ -194,6 +198,7 @@ int fido_do_ecdh(fido_dev_t *, es256_pk_t **, fido_blob_t **, int *); /* types */ void fido_algo_array_free(fido_algo_array_t *); void fido_byte_array_free(fido_byte_array_t *); +void fido_cert_array_free(fido_cert_array_t *); void fido_opt_array_free(fido_opt_array_t *); void fido_str_array_free(fido_str_array_t *); void fido_algo_free(fido_algo_t *); @@ -216,11 +221,14 @@ int fido_to_uint64(const char *, int, uint64_t *); /* crypto */ int es256_verify_sig(const fido_blob_t *, EVP_PKEY *, const fido_blob_t *); +int es384_verify_sig(const fido_blob_t *, EVP_PKEY *, const fido_blob_t *); int rs256_verify_sig(const fido_blob_t *, EVP_PKEY *, const fido_blob_t *); int eddsa_verify_sig(const fido_blob_t *, EVP_PKEY *, const fido_blob_t *); int rs1_verify_sig(const fido_blob_t *, EVP_PKEY *, const fido_blob_t *); int es256_pk_verify_sig(const fido_blob_t *, const es256_pk_t *, const fido_blob_t *); +int es384_pk_verify_sig(const fido_blob_t *, const es384_pk_t *, + const fido_blob_t *); int rs256_pk_verify_sig(const fido_blob_t *, const rs256_pk_t *, const fido_blob_t *); int eddsa_pk_verify_sig(const fido_blob_t *, const eddsa_pk_t *, diff --git a/src/fallthrough.h b/src/fallthrough.h new file mode 100644 index 000000000000..bdfd30fd63eb --- /dev/null +++ b/src/fallthrough.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + */ + +#ifndef _FALLTHROUGH_H +#define _FALLTHROUGH_H + +#if defined(__GNUC__) +#if __has_attribute(fallthrough) +#define FALLTHROUGH __attribute__((fallthrough)); +#endif +#endif /* __GNUC__ */ + +#ifndef FALLTHROUGH +#define FALLTHROUGH /* FALLTHROUGH */ +#endif + +#endif /* !_FALLTHROUGH_H */ diff --git a/src/fido.h b/src/fido.h index 63d6de87b5aa..ce7da160619e 100644 --- a/src/fido.h +++ b/src/fido.h @@ -1,7 +1,29 @@ /* - * Copyright (c) 2018 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. + * Copyright (c) 2018-2022 Yubico AB. All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_H @@ -66,6 +88,7 @@ const unsigned char *fido_assert_sig_ptr(const fido_assert_t *, size_t); const unsigned char *fido_assert_user_id_ptr(const fido_assert_t *, size_t); const unsigned char *fido_assert_blob_ptr(const fido_assert_t *, size_t); +char **fido_cbor_info_certs_name_ptr(const fido_cbor_info_t *); char **fido_cbor_info_extensions_ptr(const fido_cbor_info_t *); char **fido_cbor_info_options_name_ptr(const fido_cbor_info_t *); char **fido_cbor_info_transports_ptr(const fido_cbor_info_t *); @@ -86,6 +109,7 @@ const char *fido_dev_info_path(const fido_dev_info_t *); const char *fido_dev_info_product_string(const fido_dev_info_t *); const fido_dev_info_t *fido_dev_info_ptr(const fido_dev_info_t *, size_t); const uint8_t *fido_cbor_info_protocols_ptr(const fido_cbor_info_t *); +const uint64_t *fido_cbor_info_certs_value_ptr(const fido_cbor_info_t *); const unsigned char *fido_cbor_info_aaguid_ptr(const fido_cbor_info_t *); const unsigned char *fido_cred_aaguid_ptr(const fido_cred_t *); const unsigned char *fido_cred_attstmt_ptr(const fido_cred_t *); @@ -178,6 +202,7 @@ size_t fido_assert_user_id_len(const fido_assert_t *, size_t); size_t fido_assert_blob_len(const fido_assert_t *, size_t); size_t fido_cbor_info_aaguid_len(const fido_cbor_info_t *); size_t fido_cbor_info_algorithm_count(const fido_cbor_info_t *); +size_t fido_cbor_info_certs_len(const fido_cbor_info_t *); size_t fido_cbor_info_extensions_len(const fido_cbor_info_t *); size_t fido_cbor_info_options_len(const fido_cbor_info_t *); size_t fido_cbor_info_protocols_len(const fido_cbor_info_t *); @@ -207,12 +232,17 @@ 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_fwversion(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 *); +uint64_t fido_cbor_info_maxrpid_minpinlen(const fido_cbor_info_t *); +uint64_t fido_cbor_info_minpinlen(const fido_cbor_info_t *); +uint64_t fido_cbor_info_uv_attempts(const fido_cbor_info_t *); +uint64_t fido_cbor_info_uv_modality(const fido_cbor_info_t *); +int64_t fido_cbor_info_rk_remaining(const fido_cbor_info_t *); bool fido_dev_has_pin(const fido_dev_t *); bool fido_dev_has_uv(const fido_dev_t *); @@ -223,6 +253,7 @@ bool fido_dev_supports_cred_prot(const fido_dev_t *); bool fido_dev_supports_permissions(const fido_dev_t *); bool fido_dev_supports_pin(const fido_dev_t *); bool fido_dev_supports_uv(const fido_dev_t *); +bool fido_cbor_info_new_pin_required(const fido_cbor_info_t *); int fido_dev_largeblob_get(fido_dev_t *, const unsigned char *, size_t, unsigned char **, size_t *); diff --git a/src/fido/bio.h b/src/fido/bio.h index afe9ca4752b4..f5039e03dc90 100644 --- a/src/fido/bio.h +++ b/src/fido/bio.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2019 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_BIO_H diff --git a/src/fido/config.h b/src/fido/config.h index d8134a3c7b6c..cba286f08f88 100644 --- a/src/fido/config.h +++ b/src/fido/config.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2020 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_CONFIG_H diff --git a/src/fido/credman.h b/src/fido/credman.h index 66a966970501..9f9dff1d5f05 100644 --- a/src/fido/credman.h +++ b/src/fido/credman.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2019-2021 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_CREDMAN_H diff --git a/src/fido/eddsa.h b/src/fido/eddsa.h index 083721cc3d3f..7981a6f8bae3 100644 --- a/src/fido/eddsa.h +++ b/src/fido/eddsa.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2019 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_EDDSA_H diff --git a/src/fido/err.h b/src/fido/err.h index 74fdf9d2bfe8..7db25f269126 100644 --- a/src/fido/err.h +++ b/src/fido/err.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2018 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_ERR_H diff --git a/src/fido/es256.h b/src/fido/es256.h index 683494dadfe2..0450de29e831 100644 --- a/src/fido/es256.h +++ b/src/fido/es256.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2018-2021 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_ES256_H diff --git a/src/fido/es384.h b/src/fido/es384.h new file mode 100644 index 000000000000..b4b4ca71ccbe --- /dev/null +++ b/src/fido/es384.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Yubico AB. All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _FIDO_ES384_H +#define _FIDO_ES384_H + +#include <openssl/ec.h> + +#include <stdint.h> +#include <stdlib.h> + +#ifdef _FIDO_INTERNAL +#include "types.h" +#else +#include <fido.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +es384_pk_t *es384_pk_new(void); +void es384_pk_free(es384_pk_t **); +EVP_PKEY *es384_pk_to_EVP_PKEY(const es384_pk_t *); + +int es384_pk_from_EC_KEY(es384_pk_t *, const EC_KEY *); +int es384_pk_from_EVP_PKEY(es384_pk_t *, const EVP_PKEY *); +int es384_pk_from_ptr(es384_pk_t *, const void *, size_t); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !_FIDO_ES384_H */ diff --git a/src/fido/param.h b/src/fido/param.h index 7c6db98cfd5d..511370bca272 100644 --- a/src/fido/param.h +++ b/src/fido/param.h @@ -1,7 +1,29 @@ /* - * Copyright (c) 2018-2021 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. + * Copyright (c) 2018-2022 Yubico AB. All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_PARAM_H @@ -82,12 +104,13 @@ #define FIDO_CAP_NMSG 0x08 /* if set, device doesn't support CTAP_CMD_MSG */ /* Supported COSE algorithms. */ -#define COSE_UNSPEC 0 -#define COSE_ES256 -7 -#define COSE_EDDSA -8 -#define COSE_ECDH_ES256 -25 -#define COSE_RS256 -257 -#define COSE_RS1 -65535 +#define COSE_UNSPEC 0 +#define COSE_ES256 -7 +#define COSE_EDDSA -8 +#define COSE_ECDH_ES256 -25 +#define COSE_ES384 -35 +#define COSE_RS256 -257 +#define COSE_RS1 -65535 /* Supported COSE types. */ #define COSE_KTY_OKP 1 @@ -96,6 +119,7 @@ /* Supported curves. */ #define COSE_P256 1 +#define COSE_P384 2 #define COSE_ED25519 6 /* Supported extensions. */ @@ -118,4 +142,19 @@ FIDO_EXT_MINPINLEN) #endif /* _FIDO_INTERNAL */ +/* Recognised UV modes. */ +#define FIDO_UV_MODE_TUP 0x0001 /* internal test of user presence */ +#define FIDO_UV_MODE_FP 0x0002 /* internal fingerprint check */ +#define FIDO_UV_MODE_PIN 0x0004 /* internal pin check */ +#define FIDO_UV_MODE_VOICE 0x0008 /* internal voice recognition */ +#define FIDO_UV_MODE_FACE 0x0010 /* internal face recognition */ +#define FIDO_UV_MODE_LOCATION 0x0020 /* internal location check */ +#define FIDO_UV_MODE_EYE 0x0040 /* internal eyeprint check */ +#define FIDO_UV_MODE_DRAWN 0x0080 /* internal drawn pattern check */ +#define FIDO_UV_MODE_HAND 0x0100 /* internal handprint verification */ +#define FIDO_UV_MODE_NONE 0x0200 /* TUP/UV not required */ +#define FIDO_UV_MODE_ALL 0x0400 /* all supported UV modes required */ +#define FIDO_UV_MODE_EXT_PIN 0x0800 /* external pin verification */ +#define FIDO_UV_MODE_EXT_DRAWN 0x1000 /* external drawn pattern check */ + #endif /* !_FIDO_PARAM_H */ diff --git a/src/fido/rs256.h b/src/fido/rs256.h index 039816191783..6f8c78195f8d 100644 --- a/src/fido/rs256.h +++ b/src/fido/rs256.h @@ -1,7 +1,29 @@ /* * Copyright (c) 2018-2021 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_RS256_H diff --git a/src/fido/types.h b/src/fido/types.h index 593a6a6b4813..cfb4c7a75315 100644 --- a/src/fido/types.h +++ b/src/fido/types.h @@ -1,7 +1,29 @@ /* * 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 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _FIDO_TYPES_H @@ -73,6 +95,12 @@ typedef struct es256_sk { unsigned char d[32]; } es256_sk_t; +/* COSE ES384 (ECDSA over P-384 with SHA-384) public key */ +typedef struct es384_pk { + unsigned char x[48]; + unsigned char y[48]; +} es384_pk_t; + /* COSE RS256 (2048-bit RSA with PKCS1 padding and SHA-256) public key */ typedef struct rs256_pk { unsigned char n[256]; @@ -105,6 +133,7 @@ typedef struct fido_attcred { int type; /* credential's cose algorithm */ union { /* credential's public key */ es256_pk_t es256; + es384_pk_t es384; rs256_pk_t rs256; eddsa_pk_t eddsa; } pubkey; @@ -219,6 +248,12 @@ typedef struct fido_algo_array { size_t len; } fido_algo_array_t; +typedef struct fido_cert_array { + char **name; + uint64_t *value; + size_t len; +} fido_cert_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 */ @@ -233,6 +268,13 @@ typedef struct fido_cbor_info { uint64_t fwversion; /* firmware version */ uint64_t maxcredbloblen; /* max credBlob length */ uint64_t maxlargeblob; /* max largeBlob array length */ + uint64_t maxrpid_minlen; /* max rpid in set_pin_minlen_rpid */ + uint64_t minpinlen; /* min pin len enforced */ + uint64_t uv_attempts; /* platform uv attempts */ + uint64_t uv_modality; /* bitmask of supported uv types */ + int64_t rk_remaining; /* remaining resident credentials */ + bool new_pin_reqd; /* new pin required */ + fido_cert_array_t certs; /* associated certifications */ } fido_cbor_info_t; typedef struct fido_dev_info { @@ -281,6 +323,7 @@ typedef struct fido_dev fido_dev_t; typedef struct fido_dev_info fido_dev_info_t; typedef struct es256_pk es256_pk_t; typedef struct es256_sk es256_sk_t; +typedef struct es384_pk es384_pk_t; typedef struct rs256_pk rs256_pk_t; typedef struct eddsa_pk eddsa_pk_t; #endif /* _FIDO_INTERNAL */ diff --git a/src/hid.c b/src/hid.c index 926272b6b3ed..662bd44adfca 100644 --- a/src/hid.c +++ b/src/hid.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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" diff --git a/src/hid_freebsd.c b/src/hid_freebsd.c index 21e408ffd53f..2bbe80b5349c 100644 --- a/src/hid_freebsd.c +++ b/src/hid_freebsd.c @@ -2,12 +2,17 @@ * Copyright (c) 2020-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 <sys/types.h> +#include <sys/param.h> #include <dev/usb/usb_ioctl.h> #include <dev/usb/usbhid.h> +#if __FreeBSD_version >= 1300500 +#include <dev/hid/hidraw.h> +#define USE_HIDRAW /* see usbhid(4) and hidraw(4) on FreeBSD 13+ */ +#endif #include <errno.h> #include <unistd.h> @@ -57,8 +62,60 @@ is_fido(int fd) return (usage_page == 0xf1d0); } +#ifdef USE_HIDRAW static int -copy_info(fido_dev_info_t *di, const char *path) +copy_info_hidraw(fido_dev_info_t *di, const char *path) +{ + int fd = -1; + int ok = -1; + struct usb_device_info udi; + struct hidraw_devinfo devinfo; + char rawname[129]; + + memset(di, 0, sizeof(*di)); + memset(&udi, 0, sizeof(udi)); + memset(&devinfo, 0, sizeof(devinfo)); + memset(rawname, 0, sizeof(rawname)); + + if ((fd = fido_hid_unix_open(path)) == -1 || is_fido(fd) == 0) + goto fail; + + if (ioctl(fd, IOCTL_REQ(USB_GET_DEVICEINFO), &udi) == -1) { + if (ioctl(fd, IOCTL_REQ(HIDIOCGRAWINFO), &devinfo) == -1 || + ioctl(fd, IOCTL_REQ(HIDIOCGRAWNAME(128)), rawname) == -1 || + (di->path = strdup(path)) == NULL || + (di->manufacturer = strdup(UHID_VENDOR)) == NULL || + (di->product = strdup(rawname)) == NULL) + goto fail; + di->vendor_id = devinfo.vendor; + di->product_id = devinfo.product; + } else { + if ((di->path = strdup(path)) == NULL || + (di->manufacturer = strdup(udi.udi_vendor)) == NULL || + (di->product = strdup(udi.udi_product)) == NULL) + goto fail; + di->vendor_id = (int16_t)udi.udi_vendorNo; + di->product_id = (int16_t)udi.udi_productNo; + } + + ok = 0; +fail: + if (fd != -1 && close(fd) == -1) + fido_log_error(errno, "%s: close %s", __func__, path); + + if (ok < 0) { + free(di->path); + free(di->manufacturer); + free(di->product); + explicit_bzero(di, sizeof(*di)); + } + + return (ok); +} +#endif /* USE_HIDRAW */ + +static int +copy_info_uhid(fido_dev_info_t *di, const char *path) { int fd = -1; int ok = -1; @@ -81,7 +138,6 @@ copy_info(fido_dev_info_t *di, const char *path) (di->manufacturer = strdup(udi.udi_vendor)) == NULL || (di->product = strdup(udi.udi_product)) == NULL) goto fail; - di->vendor_id = (int16_t)udi.udi_vendorNo; di->product_id = (int16_t)udi.udi_productNo; @@ -112,9 +168,29 @@ fido_hid_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen) if (devlist == NULL || olen == NULL) return (FIDO_ERR_INVALID_ARGUMENT); - for (i = *olen = 0; i < MAX_UHID && *olen < ilen; i++) { + *olen = 0; + +#ifdef USE_HIDRAW + for (i = 0; i < MAX_UHID && *olen < ilen; i++) { + snprintf(path, sizeof(path), "/dev/hidraw%zu", i); + if (copy_info_hidraw(&devlist[*olen], path) == 0) { + devlist[*olen].io = (fido_dev_io_t) { + fido_hid_open, + fido_hid_close, + fido_hid_read, + fido_hid_write, + }; + ++(*olen); + } + } + /* hidraw(4) is preferred over uhid(4) */ + if (*olen != 0) + return (FIDO_OK); +#endif /* USE_HIDRAW */ + + for (i = 0; i < MAX_UHID && *olen < ilen; i++) { snprintf(path, sizeof(path), "/dev/uhid%zu", i); - if (copy_info(&devlist[*olen], path) == 0) { + if (copy_info_uhid(&devlist[*olen], path) == 0) { devlist[*olen].io = (fido_dev_io_t) { fido_hid_open, fido_hid_close, @@ -151,6 +227,10 @@ fido_hid_open(const char *path) ugd.ugd_data = buf; ugd.ugd_maxlen = sizeof(buf); + /* + * N.B. if ctx->fd is an hidraw(4) device, the ioctl() below puts it in + * uhid(4) compat mode, which we need to keep fido_hid_write() as-is. + */ if ((r = ioctl(ctx->fd, IOCTL_REQ(USB_GET_REPORT_DESC), &ugd) == -1) || ugd.ugd_actlen > sizeof(buf) || fido_hid_get_report_len(ugd.ugd_data, ugd.ugd_actlen, diff --git a/src/hid_hidapi.c b/src/hid_hidapi.c index f6d21711e152..fed6f69a2237 100644 --- a/src/hid_hidapi.c +++ b/src/hid_hidapi.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 Google LLC. 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 */ #ifdef __linux__ @@ -133,14 +134,14 @@ static bool is_fido(const struct hid_device_info *hdi) { uint32_t usage_page = 0; - struct hidraw_report_descriptor hrd; + struct hidraw_report_descriptor *hrd; - memset(&hrd, 0, sizeof(hrd)); + if ((hrd = calloc(1, sizeof(*hrd))) == NULL || + get_report_descriptor(hdi->path, hrd) < 0 || + fido_hid_get_usage(hrd->value, hrd->size, &usage_page) < 0) + usage_page = 0; - if (get_report_descriptor(hdi->path, &hrd) < 0 || - fido_hid_get_usage(hrd.value, hrd.size, &usage_page) < 0) { - return false; - } + free(hrd); return usage_page == 0xf1d0; } diff --git a/src/hid_linux.c b/src/hid_linux.c index c4ce4fd578a6..841a95b08e41 100644 --- a/src/hid_linux.c +++ b/src/hid_linux.c @@ -1,7 +1,8 @@ /* - * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <sys/types.h> @@ -54,20 +55,21 @@ get_report_descriptor(int fd, struct hidraw_report_descriptor *hrd) static bool is_fido(const char *path) { - int fd; - uint32_t usage_page = 0; - struct hidraw_report_descriptor hrd; - - memset(&hrd, 0, sizeof(hrd)); - - if ((fd = fido_hid_unix_open(path)) == -1) - return (false); - - if (get_report_descriptor(fd, &hrd) < 0 || - fido_hid_get_usage(hrd.value, hrd.size, &usage_page) < 0) + int fd = -1; + uint32_t usage_page = 0; + struct hidraw_report_descriptor *hrd = NULL; + + if ((hrd = calloc(1, sizeof(*hrd))) == NULL || + (fd = fido_hid_unix_open(path)) == -1) + goto out; + if (get_report_descriptor(fd, hrd) < 0 || + fido_hid_get_usage(hrd->value, hrd->size, &usage_page) < 0) usage_page = 0; - if (close(fd) == -1) +out: + free(hrd); + + if (fd != -1 && close(fd) == -1) fido_log_error(errno, "%s: close", __func__); return (usage_page == 0xf1d0); @@ -240,9 +242,13 @@ void * fido_hid_open(const char *path) { struct hid_linux *ctx; - struct hidraw_report_descriptor hrd; + struct hidraw_report_descriptor *hrd; struct timespec tv_pause; long interval_ms, retries = 0; + bool looped; + +retry: + looped = false; if ((ctx = calloc(1, sizeof(*ctx))) == NULL || (ctx->fd = fido_hid_unix_open(path)) == -1) { @@ -256,7 +262,8 @@ fido_hid_open(const char *path) fido_hid_close(ctx); return (NULL); } - if (retries++ >= 15) { + looped = true; + if (retries++ >= 20) { fido_log_debug("%s: flock timeout", __func__); fido_hid_close(ctx); return (NULL); @@ -271,8 +278,15 @@ fido_hid_open(const char *path) } } - if (get_report_descriptor(ctx->fd, &hrd) < 0 || - fido_hid_get_report_len(hrd.value, hrd.size, &ctx->report_in_len, + if (looped) { + fido_log_debug("%s: retrying", __func__); + fido_hid_close(ctx); + goto retry; + } + + if ((hrd = calloc(1, sizeof(*hrd))) == NULL || + get_report_descriptor(ctx->fd, hrd) < 0 || + fido_hid_get_report_len(hrd->value, hrd->size, &ctx->report_in_len, &ctx->report_out_len) < 0 || ctx->report_in_len == 0 || ctx->report_out_len == 0) { fido_log_debug("%s: using default report sizes", __func__); @@ -280,6 +294,8 @@ fido_hid_open(const char *path) ctx->report_out_len = CTAP_MAX_REPORT_LEN; } + free(hrd); + return (ctx); } diff --git a/src/hid_netbsd.c b/src/hid_netbsd.c index c24c6de7ce29..d5b9fad33412 100644 --- a/src/hid_netbsd.c +++ b/src/hid_netbsd.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <sys/types.h> diff --git a/src/hid_openbsd.c b/src/hid_openbsd.c index 2993d10dad9d..2d08aca42aee 100644 --- a/src/hid_openbsd.c +++ b/src/hid_openbsd.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 Google LLC. 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 <sys/types.h> diff --git a/src/hid_osx.c b/src/hid_osx.c index a5fa8281f81e..9309762f163c 100644 --- a/src/hid_osx.c +++ b/src/hid_osx.c @@ -2,6 +2,7 @@ * 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <sys/types.h> diff --git a/src/hid_unix.c b/src/hid_unix.c index 946b2dc3b65f..e53882d79e86 100644 --- a/src/hid_unix.c +++ b/src/hid_unix.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <sys/stat.h> diff --git a/src/hid_win.c b/src/hid_win.c index fe403bcf46f1..bc98a1701b0d 100644 --- a/src/hid_win.c +++ b/src/hid_win.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2019-2021 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. + * SPDX-License-Identifier: BSD-2-Clause */ #include <sys/types.h> @@ -27,7 +28,7 @@ WINSETUPAPI WINBOOL WINAPI SetupDiGetDevicePropertyW(HDEVINFO, DWORD, PDWORD, DWORD); #endif -#if defined(__MINGW32__) +#if defined(__MINGW32__) && __MINGW64_VERSION_MAJOR < 8 DEFINE_DEVPROPKEY(DEVPKEY_Device_Parent, 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 8); #endif diff --git a/src/info.c b/src/info.c index ea26f22297a6..cd30828d7ce9 100644 --- a/src/info.c +++ b/src/info.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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" @@ -68,10 +69,8 @@ decode_option(const cbor_item_t *key, const cbor_item_t *val, void *arg) fido_opt_array_t *o = arg; const size_t i = o->len; - if (cbor_isa_float_ctrl(val) == false || - cbor_float_get_width(val) != CBOR_FLOAT_0 || - cbor_is_bool(val) == false) { - fido_log_debug("%s: cbor type", __func__); + if (cbor_decode_bool(val, NULL) < 0) { + fido_log_debug("%s: cbor_decode_bool", __func__); return (0); /* ignore */ } @@ -237,9 +236,54 @@ decode_algorithms(const cbor_item_t *item, fido_algo_array_t *aa) } static int +decode_cert(const cbor_item_t *key, const cbor_item_t *val, void *arg) +{ + fido_cert_array_t *c = arg; + const size_t i = c->len; + + if (cbor_is_int(val) == false) { + fido_log_debug("%s: cbor_is_int", __func__); + return (0); /* ignore */ + } + + if (cbor_string_copy(key, &c->name[i]) < 0) { + fido_log_debug("%s: cbor_string_copy", __func__); + return (0); /* ignore */ + } + + /* keep name/value and len consistent */ + c->value[i] = cbor_get_int(val); + c->len++; + + return (0); +} + +static int +decode_certs(const cbor_item_t *item, fido_cert_array_t *c) +{ + c->name = NULL; + c->value = NULL; + c->len = 0; + + if (cbor_isa_map(item) == false || + cbor_map_is_definite(item) == false) { + fido_log_debug("%s: cbor type", __func__); + return (-1); + } + + c->name = calloc(cbor_map_size(item), sizeof(char *)); + c->value = calloc(cbor_map_size(item), sizeof(uint64_t)); + if (c->name == NULL || c->value == NULL) + return (-1); + + return (cbor_map_iter(item, c, decode_cert)); +} + +static int parse_reply_element(const cbor_item_t *key, const cbor_item_t *val, void *arg) { fido_cbor_info_t *ci = arg; + uint64_t x; if (cbor_isa_uint(key) == false || cbor_int_get_width(key) != CBOR_INT_8) { @@ -270,12 +314,31 @@ parse_reply_element(const cbor_item_t *key, const cbor_item_t *val, void *arg) return (decode_algorithms(val, &ci->algorithms)); case 11: /* maxSerializedLargeBlobArray */ return (cbor_decode_uint64(val, &ci->maxlargeblob)); + case 12: /* forcePINChange */ + return (cbor_decode_bool(val, &ci->new_pin_reqd)); + case 13: /* minPINLength */ + return (cbor_decode_uint64(val, &ci->minpinlen)); case 14: /* fwVersion */ return (cbor_decode_uint64(val, &ci->fwversion)); case 15: /* maxCredBlobLen */ return (cbor_decode_uint64(val, &ci->maxcredbloblen)); + case 16: /* maxRPIDsForSetMinPINLength */ + return (cbor_decode_uint64(val, &ci->maxrpid_minlen)); + case 17: /* preferredPlatformUvAttempts */ + return (cbor_decode_uint64(val, &ci->uv_attempts)); + case 18: /* uvModality */ + return (cbor_decode_uint64(val, &ci->uv_modality)); + case 19: /* certifications */ + return (decode_certs(val, &ci->certs)); + case 20: /* remainingDiscoverableCredentials */ + if (cbor_decode_uint64(val, &x) < 0 || x > INT64_MAX) { + fido_log_debug("%s: cbor_decode_uint64", __func__); + return (-1); + } + ci->rk_remaining = (int64_t)x; + return (0); default: /* ignore */ - fido_log_debug("%s: cbor type", __func__); + fido_log_debug("%s: cbor type: 0x%02x", __func__, cbor_get_uint8(key)); return (0); } } @@ -298,22 +361,31 @@ fido_dev_get_cbor_info_tx(fido_dev_t *dev, int *ms) static int fido_dev_get_cbor_info_rx(fido_dev_t *dev, fido_cbor_info_t *ci, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; + unsigned char *msg; + int msglen; + int r; fido_log_debug("%s: dev=%p, ci=%p, ms=%d", __func__, (void *)dev, (void *)ci, *ms); fido_cbor_info_reset(ci); - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - return (cbor_parse_reply(reply, (size_t)reply_len, ci, - parse_reply_element)); + r = cbor_parse_reply(msg, (size_t)msglen, ci, parse_reply_element); +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } int @@ -347,7 +419,14 @@ fido_dev_get_cbor_info(fido_dev_t *dev, fido_cbor_info_t *ci) fido_cbor_info_t * fido_cbor_info_new(void) { - return (calloc(1, sizeof(fido_cbor_info_t))); + fido_cbor_info_t *ci; + + if ((ci = calloc(1, sizeof(fido_cbor_info_t))) == NULL) + return (NULL); + + fido_cbor_info_reset(ci); + + return (ci); } void @@ -359,6 +438,8 @@ fido_cbor_info_reset(fido_cbor_info_t *ci) fido_opt_array_free(&ci->options); fido_byte_array_free(&ci->protocols); fido_algo_array_free(&ci->algorithms); + fido_cert_array_free(&ci->certs); + ci->rk_remaining = -1; } void @@ -475,6 +556,36 @@ fido_cbor_info_fwversion(const fido_cbor_info_t *ci) return (ci->fwversion); } +uint64_t +fido_cbor_info_minpinlen(const fido_cbor_info_t *ci) +{ + return (ci->minpinlen); +} + +uint64_t +fido_cbor_info_maxrpid_minpinlen(const fido_cbor_info_t *ci) +{ + return (ci->maxrpid_minlen); +} + +uint64_t +fido_cbor_info_uv_attempts(const fido_cbor_info_t *ci) +{ + return (ci->uv_attempts); +} + +uint64_t +fido_cbor_info_uv_modality(const fido_cbor_info_t *ci) +{ + return (ci->uv_modality); +} + +int64_t +fido_cbor_info_rk_remaining(const fido_cbor_info_t *ci) +{ + return (ci->rk_remaining); +} + const uint8_t * fido_cbor_info_protocols_ptr(const fido_cbor_info_t *ci) { @@ -510,3 +621,27 @@ fido_cbor_info_algorithm_cose(const fido_cbor_info_t *ci, size_t idx) return (ci->algorithms.ptr[idx].cose); } + +bool +fido_cbor_info_new_pin_required(const fido_cbor_info_t *ci) +{ + return (ci->new_pin_reqd); +} + +char ** +fido_cbor_info_certs_name_ptr(const fido_cbor_info_t *ci) +{ + return (ci->certs.name); +} + +const uint64_t * +fido_cbor_info_certs_value_ptr(const fido_cbor_info_t *ci) +{ + return (ci->certs.value); +} + +size_t +fido_cbor_info_certs_len(const fido_cbor_info_t *ci) +{ + return (ci->certs.len); +} @@ -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" @@ -331,14 +332,25 @@ fido_rx(fido_dev_t *d, uint8_t cmd, void *buf, size_t count, int *ms) int fido_rx_cbor_status(fido_dev_t *d, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; + unsigned char *msg; + int msglen; + int r; - if ((reply_len = fido_rx(d, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0 || (size_t)reply_len < 1) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + + if ((msglen = fido_rx(d, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0 || + (size_t)msglen < 1) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - return (reply[0]); + r = msg[0]; +out: + freezero(msg, FIDO_MAXMSG); + + return (r); } diff --git a/src/iso7816.c b/src/iso7816.c index a4902277c6d8..5bba10697ee4 100644 --- a/src/iso7816.c +++ b/src/iso7816.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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" diff --git a/src/iso7816.h b/src/iso7816.h index 9bfad1fbab9d..7545719c6f1b 100644 --- a/src/iso7816.h +++ b/src/iso7816.h @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ #ifndef _ISO7816_H diff --git a/src/largeblob.c b/src/largeblob.c index c8173170766d..c1f2e62b2a6a 100644 --- a/src/largeblob.c +++ b/src/largeblob.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2020 Yubico AB. All rights reserved. + * Copyright (c) 2020-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 <openssl/sha.h> @@ -200,27 +201,38 @@ parse_largeblob_reply(const cbor_item_t *key, const cbor_item_t *val, static int largeblob_get_rx(fido_dev_t *dev, fido_blob_t **chunk, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len, r; + unsigned char *msg; + int msglen, r; *chunk = NULL; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto out; + } + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return FIDO_ERR_RX; + r = FIDO_ERR_RX; + goto out; } if ((*chunk = fido_blob_new()) == NULL) { fido_log_debug("%s: fido_blob_new", __func__); - return FIDO_ERR_INTERNAL; + r = FIDO_ERR_INTERNAL; + goto out; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, *chunk, + if ((r = cbor_parse_reply(msg, (size_t)msglen, *chunk, parse_largeblob_reply)) != FIDO_OK) { fido_log_debug("%s: parse_largeblob_reply", __func__); - fido_blob_free(chunk); - return r; + goto out; } - return FIDO_OK; + r = FIDO_OK; +out: + if (r != FIDO_OK) + fido_blob_free(chunk); + + freezero(msg, FIDO_MAXMSG); + + return r; } static cbor_item_t * diff --git a/src/log.c b/src/log.c index ab18ae12b4fa..e54f8fca6b90 100644 --- a/src/log.c +++ b/src/log.c @@ -2,6 +2,7 @@ * Copyright (c) 2018-2021 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 */ #undef _GNU_SOURCE /* XSI strerror_r() */ diff --git a/src/netlink.c b/src/netlink.c index 8f14e2c3bac3..2a9216c39058 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <sys/socket.h> diff --git a/src/netlink.h b/src/netlink.h index 9b98064ab8e7..c600b522196a 100644 --- a/src/netlink.h +++ b/src/netlink.h @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 */ #ifndef _FIDO_NETLINK_H diff --git a/src/nfc.c b/src/nfc.c index 8e1221bb5057..2e97d5fc50da 100644 --- a/src/nfc.c +++ b/src/nfc.c @@ -2,6 +2,7 @@ * Copyright (c) 2020-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 <stdio.h> @@ -289,6 +290,35 @@ fido_nfc_rx(fido_dev_t *d, uint8_t cmd, unsigned char *buf, size_t count, int ms } } +bool +nfc_is_fido(const char *path) +{ + bool fido = false; + fido_dev_t *d; + int r; + + if ((d = fido_dev_new()) == NULL) { + fido_log_debug("%s: fido_dev_new", __func__); + goto fail; + } + /* fido_dev_open selects the fido applet */ + if ((r = fido_dev_open(d, path)) != FIDO_OK) { + fido_log_debug("%s: fido_dev_open: 0x%x", __func__, r); + goto fail; + } + if ((r = fido_dev_close(d)) != FIDO_OK) { + fido_log_debug("%s: fido_dev_close: 0x%x", __func__, r); + goto fail; + + } + + fido = true; +fail: + fido_dev_free(&d); + + return fido; +} + #ifdef USE_NFC bool fido_is_nfc(const char *path) diff --git a/src/nfc_linux.c b/src/nfc_linux.c index 4673dc2b7d18..4b69eb1c54c2 100644 --- a/src/nfc_linux.c +++ b/src/nfc_linux.c @@ -2,6 +2,7 @@ * Copyright (c) 2020-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 <sys/types.h> @@ -59,7 +60,6 @@ copy_info(fido_dev_info_t *di, struct udev *udev, const char *name; char *str; struct udev_device *dev = NULL; - void *ctx = NULL; uint64_t id; int ok = -1; @@ -72,6 +72,10 @@ copy_info(fido_dev_info_t *di, struct udev *udev, di->path = NULL; goto fail; } + if (nfc_is_fido(di->path) == false) { + fido_log_debug("%s: nfc_is_fido: %s", __func__, di->path); + goto fail; + } if ((di->manufacturer = get_usb_attr(dev, "manufacturer")) == NULL) di->manufacturer = strdup(""); if ((di->product = get_usb_attr(dev, "product")) == NULL) @@ -88,17 +92,10 @@ copy_info(fido_dev_info_t *di, struct udev *udev, di->product_id = (int16_t)id; free(str); - if ((ctx = fido_nfc_open(di->path)) == NULL) { - fido_log_debug("%s: fido_nfc_open", __func__); - goto fail; - } - ok = 0; fail: if (dev != NULL) udev_device_unref(dev); - if (ctx != NULL) - fido_nfc_close(ctx); if (ok < 0) { free(di->path); diff --git a/src/packed.h b/src/packed.h index 3857c22dd2ba..5f53ae565b75 100644 --- a/src/packed.h +++ b/src/packed.h @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ #ifndef _PACKED_H diff --git a/src/pcsc.c b/src/pcsc.c index c02251e9bfe1..d7bd6c65ed60 100644 --- a/src/pcsc.c +++ b/src/pcsc.c @@ -3,6 +3,7 @@ * Copyright (c) 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 */ #if __APPLE__ @@ -149,6 +150,10 @@ copy_info(fido_dev_info_t *di, SCARDCONTEXT ctx, const char *reader, size_t idx) fido_log_debug("%s: asprintf", __func__); goto fail; } + if (nfc_is_fido(di->path) == false) { + fido_log_debug("%s: nfc_is_fido: %s", __func__, di->path); + goto fail; + } if ((di->manufacturer = strdup("PC/SC")) == NULL || (di->product = strdup(reader)) == NULL) goto fail; diff --git a/src/pin.c b/src/pin.c index 30eeb086a6ef..c3dd9271ed71 100644 --- a/src/pin.c +++ b/src/pin.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 <openssl/sha.h> @@ -72,7 +73,7 @@ pad64(const char *pin, fido_blob_t **ppin) size_t ppin_len; pin_len = strlen(pin); - if (pin_len < 4 || pin_len > 255) { + if (pin_len < 4 || pin_len > 63) { fido_log_debug("%s: invalid pin length", __func__); return (FIDO_ERR_PIN_POLICY_VIOLATION); } @@ -81,7 +82,8 @@ pad64(const char *pin, fido_blob_t **ppin) return (FIDO_ERR_INTERNAL); ppin_len = (pin_len + 63U) & ~63U; - if (ppin_len < pin_len || ((*ppin)->ptr = calloc(1, ppin_len)) == NULL) { + if (ppin_len < pin_len || + ((*ppin)->ptr = calloc(1, ppin_len)) == NULL) { fido_blob_free(ppin); return (FIDO_ERR_INTERNAL); } @@ -284,8 +286,8 @@ uv_token_rx(fido_dev_t *dev, const fido_blob_t *ecdh, fido_blob_t *token, int *ms) { fido_blob_t *aes_token = NULL; - unsigned char reply[FIDO_MAXMSG]; - int reply_len; + unsigned char *msg = NULL; + int msglen; int r; if ((aes_token = fido_blob_new()) == NULL) { @@ -293,14 +295,18 @@ uv_token_rx(fido_dev_t *dev, const fido_blob_t *ecdh, fido_blob_t *token, goto fail; } - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto fail; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); r = FIDO_ERR_RX; goto fail; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, aes_token, + if ((r = cbor_parse_reply(msg, (size_t)msglen, aes_token, parse_uv_token)) != FIDO_OK) { fido_log_debug("%s: parse_uv_token", __func__); goto fail; @@ -315,6 +321,7 @@ uv_token_rx(fido_dev_t *dev, const fido_blob_t *ecdh, fido_blob_t *token, r = FIDO_OK; fail: fido_blob_free(&aes_token); + freezero(msg, FIDO_MAXMSG); return (r); } @@ -579,25 +586,34 @@ fail: static int fido_dev_get_pin_retry_count_rx(fido_dev_t *dev, int *retries, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; *retries = 0; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto fail; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto fail; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, retries, + if ((r = cbor_parse_reply(msg, (size_t)msglen, retries, parse_pin_retry_count)) != FIDO_OK) { fido_log_debug("%s: parse_pin_retry_count", __func__); - return (r); + goto fail; } - return (FIDO_OK); + r = FIDO_OK; +fail: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int @@ -623,25 +639,34 @@ fido_dev_get_retry_count(fido_dev_t *dev, int *retries) static int fido_dev_get_uv_retry_count_rx(fido_dev_t *dev, int *retries, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *msg; + int msglen; + int r; *retries = 0; - if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply), - ms)) < 0) { + if ((msg = malloc(FIDO_MAXMSG)) == NULL) { + r = FIDO_ERR_INTERNAL; + goto fail; + } + + if ((msglen = fido_rx(dev, CTAP_CMD_CBOR, msg, FIDO_MAXMSG, ms)) < 0) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto fail; } - if ((r = cbor_parse_reply(reply, (size_t)reply_len, retries, + if ((r = cbor_parse_reply(msg, (size_t)msglen, retries, parse_uv_retry_count)) != FIDO_OK) { fido_log_debug("%s: parse_uv_retry_count", __func__); - return (r); + goto fail; } - return (FIDO_OK); + r = FIDO_OK; +fail: + freezero(msg, FIDO_MAXMSG); + + return (r); } static int diff --git a/src/random.c b/src/random.c index f13482bfddf9..9688d35ca945 100644 --- a/src/random.c +++ b/src/random.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 <sys/types.h> diff --git a/src/reset.c b/src/reset.c index c5fe6dfe7ac1..4e09dbbca5cf 100644 --- a/src/reset.c +++ b/src/reset.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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" diff --git a/src/rs1.c b/src/rs1.c index 134068b16747..03636b5cdf42 100644 --- a/src/rs1.c +++ b/src/rs1.c @@ -2,6 +2,7 @@ * Copyright (c) 2021 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 <openssl/rsa.h> diff --git a/src/rs256.c b/src/rs256.c index 95bae167a177..59ceb948fa07 100644 --- a/src/rs256.c +++ b/src/rs256.c @@ -2,6 +2,7 @@ * 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 <openssl/bn.h> diff --git a/src/time.c b/src/time.c index b82b61874498..fd0e4e3ca33e 100644 --- a/src/time.c +++ b/src/time.c @@ -2,6 +2,7 @@ * Copyright (c) 2021 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 <errno.h> diff --git a/src/touch.c b/src/touch.c index 66b1c3478c0a..6844e2c2dbc0 100644 --- a/src/touch.c +++ b/src/touch.c @@ -2,6 +2,7 @@ * 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 <openssl/sha.h> diff --git a/src/tpm.c b/src/tpm.c index 74244f8cbf08..69c48c3d4d86 100644 --- a/src/tpm.c +++ b/src/tpm.c @@ -2,6 +2,7 @@ * Copyright (c) 2021 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 */ /* diff --git a/src/types.c b/src/types.c index 54c0ca582865..f31f8da12952 100644 --- a/src/types.c +++ b/src/types.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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" @@ -27,6 +28,7 @@ fido_opt_array_free(fido_opt_array_t *oa) free(oa->value); oa->name = NULL; oa->value = NULL; + oa->len = 0; } void @@ -57,6 +59,19 @@ fido_algo_array_free(fido_algo_array_t *aa) aa->len = 0; } +void +fido_cert_array_free(fido_cert_array_t *ca) +{ + for (size_t i = 0; i < ca->len; i++) + free(ca->name[i]); + + free(ca->name); + free(ca->value); + ca->name = NULL; + ca->value = NULL; + ca->len = 0; +} + int fido_str_array_pack(fido_str_array_t *sa, const char * const *v, size_t n) { diff --git a/src/u2f.c b/src/u2f.c index 6ebfcc7bb848..b1f7bce3b7ab 100644 --- a/src/u2f.c +++ b/src/u2f.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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 <openssl/sha.h> @@ -14,6 +15,7 @@ #include "fido.h" #include "fido/es256.h" +#include "fallthrough.h" #define U2F_PACE_MS (100) @@ -143,9 +145,9 @@ static int send_dummy_register(fido_dev_t *dev, int *ms) { iso7816_apdu_t *apdu = NULL; + unsigned char *reply = NULL; unsigned char challenge[SHA256_DIGEST_LENGTH]; unsigned char application[SHA256_DIGEST_LENGTH]; - unsigned char reply[FIDO_MAXMSG]; int r; /* dummy challenge & application */ @@ -161,6 +163,12 @@ send_dummy_register(fido_dev_t *dev, int *ms) goto fail; } + if ((reply = malloc(FIDO_MAXMSG)) == NULL) { + fido_log_debug("%s: malloc", __func__); + r = FIDO_ERR_INTERNAL; + goto fail; + } + do { if (fido_tx(dev, CTAP_CMD_MSG, iso7816_ptr(apdu), iso7816_len(apdu), ms) < 0) { @@ -168,7 +176,7 @@ send_dummy_register(fido_dev_t *dev, int *ms) r = FIDO_ERR_TX; goto fail; } - if (fido_rx(dev, CTAP_CMD_MSG, &reply, sizeof(reply), ms) < 2) { + if (fido_rx(dev, CTAP_CMD_MSG, reply, FIDO_MAXMSG, ms) < 2) { fido_log_debug("%s: fido_rx", __func__); r = FIDO_ERR_RX; goto fail; @@ -183,6 +191,7 @@ send_dummy_register(fido_dev_t *dev, int *ms) r = FIDO_OK; fail: iso7816_free(&apdu); + freezero(reply, FIDO_MAXMSG); return (r); } @@ -192,9 +201,9 @@ key_lookup(fido_dev_t *dev, const char *rp_id, const fido_blob_t *key_id, int *found, int *ms) { iso7816_apdu_t *apdu = NULL; + unsigned char *reply = NULL; unsigned char challenge[SHA256_DIGEST_LENGTH]; unsigned char rp_id_hash[SHA256_DIGEST_LENGTH]; - unsigned char reply[FIDO_MAXMSG]; uint8_t key_id_len; int r; @@ -228,13 +237,19 @@ key_lookup(fido_dev_t *dev, const char *rp_id, const fido_blob_t *key_id, goto fail; } + if ((reply = malloc(FIDO_MAXMSG)) == NULL) { + fido_log_debug("%s: malloc", __func__); + r = FIDO_ERR_INTERNAL; + goto fail; + } + if (fido_tx(dev, CTAP_CMD_MSG, iso7816_ptr(apdu), iso7816_len(apdu), ms) < 0) { fido_log_debug("%s: fido_tx", __func__); r = FIDO_ERR_TX; goto fail; } - if (fido_rx(dev, CTAP_CMD_MSG, &reply, sizeof(reply), ms) != 2) { + if (fido_rx(dev, CTAP_CMD_MSG, reply, FIDO_MAXMSG, ms) != 2) { fido_log_debug("%s: fido_rx", __func__); r = FIDO_ERR_RX; goto fail; @@ -256,6 +271,7 @@ key_lookup(fido_dev_t *dev, const char *rp_id, const fido_blob_t *key_id, r = FIDO_OK; fail: iso7816_free(&apdu); + freezero(reply, FIDO_MAXMSG); return (r); } @@ -298,8 +314,8 @@ do_auth(fido_dev_t *dev, const fido_blob_t *cdh, const char *rp_id, const fido_blob_t *key_id, fido_blob_t *sig, fido_blob_t *ad, int *ms) { iso7816_apdu_t *apdu = NULL; + unsigned char *reply = NULL; unsigned char rp_id_hash[SHA256_DIGEST_LENGTH]; - unsigned char reply[FIDO_MAXMSG]; int reply_len; uint8_t key_id_len; int r; @@ -336,6 +352,12 @@ do_auth(fido_dev_t *dev, const fido_blob_t *cdh, const char *rp_id, goto fail; } + if ((reply = malloc(FIDO_MAXMSG)) == NULL) { + fido_log_debug("%s: malloc", __func__); + r = FIDO_ERR_INTERNAL; + goto fail; + } + do { if (fido_tx(dev, CTAP_CMD_MSG, iso7816_ptr(apdu), iso7816_len(apdu), ms) < 0) { @@ -343,8 +365,8 @@ do_auth(fido_dev_t *dev, const fido_blob_t *cdh, const char *rp_id, r = FIDO_ERR_TX; goto fail; } - if ((reply_len = fido_rx(dev, CTAP_CMD_MSG, &reply, - sizeof(reply), ms)) < 2) { + if ((reply_len = fido_rx(dev, CTAP_CMD_MSG, reply, + FIDO_MAXMSG, ms)) < 2) { fido_log_debug("%s: fido_rx", __func__); r = FIDO_ERR_RX; goto fail; @@ -364,6 +386,7 @@ do_auth(fido_dev_t *dev, const fido_blob_t *cdh, const char *rp_id, fail: iso7816_free(&apdu); + freezero(reply, FIDO_MAXMSG); return (r); } @@ -643,7 +666,7 @@ u2f_register(fido_dev_t *dev, fido_cred_t *cred, int *ms) { iso7816_apdu_t *apdu = NULL; unsigned char rp_id_hash[SHA256_DIGEST_LENGTH]; - unsigned char reply[FIDO_MAXMSG]; + unsigned char *reply = NULL; int reply_len; int found; int r; @@ -694,6 +717,12 @@ u2f_register(fido_dev_t *dev, fido_cred_t *cred, int *ms) goto fail; } + if ((reply = malloc(FIDO_MAXMSG)) == NULL) { + fido_log_debug("%s: malloc", __func__); + r = FIDO_ERR_INTERNAL; + goto fail; + } + do { if (fido_tx(dev, CTAP_CMD_MSG, iso7816_ptr(apdu), iso7816_len(apdu), ms) < 0) { @@ -701,8 +730,8 @@ u2f_register(fido_dev_t *dev, fido_cred_t *cred, int *ms) r = FIDO_ERR_TX; goto fail; } - if ((reply_len = fido_rx(dev, CTAP_CMD_MSG, &reply, - sizeof(reply), ms)) < 2) { + if ((reply_len = fido_rx(dev, CTAP_CMD_MSG, reply, + FIDO_MAXMSG, ms)) < 2) { fido_log_debug("%s: fido_rx", __func__); r = FIDO_ERR_RX; goto fail; @@ -721,6 +750,7 @@ u2f_register(fido_dev_t *dev, fido_cred_t *cred, int *ms) } fail: iso7816_free(&apdu); + freezero(reply, FIDO_MAXMSG); return (r); } @@ -804,7 +834,7 @@ u2f_authenticate(fido_dev_t *dev, fido_assert_t *fa, int *ms) &fa->allow_list.ptr[i], fa, nfound, ms))) { case FIDO_OK: nauth_ok++; - /* FALLTHROUGH */ + FALLTHROUGH case FIDO_ERR_USER_PRESENCE_REQUIRED: nfound++; break; @@ -834,9 +864,9 @@ u2f_get_touch_begin(fido_dev_t *dev, int *ms) iso7816_apdu_t *apdu = NULL; const char *clientdata = FIDO_DUMMY_CLIENTDATA; const char *rp_id = FIDO_DUMMY_RP_ID; + unsigned char *reply = NULL; unsigned char clientdata_hash[SHA256_DIGEST_LENGTH]; unsigned char rp_id_hash[SHA256_DIGEST_LENGTH]; - unsigned char reply[FIDO_MAXMSG]; int r; memset(&clientdata_hash, 0, sizeof(clientdata_hash)); @@ -858,9 +888,15 @@ u2f_get_touch_begin(fido_dev_t *dev, int *ms) goto fail; } + if ((reply = malloc(FIDO_MAXMSG)) == NULL) { + fido_log_debug("%s: malloc", __func__); + r = FIDO_ERR_INTERNAL; + goto fail; + } + if (dev->attr.flags & FIDO_CAP_WINK) { fido_tx(dev, CTAP_CMD_WINK, NULL, 0, ms); - fido_rx(dev, CTAP_CMD_WINK, &reply, sizeof(reply), ms); + fido_rx(dev, CTAP_CMD_WINK, reply, FIDO_MAXMSG, ms); } if (fido_tx(dev, CTAP_CMD_MSG, iso7816_ptr(apdu), @@ -873,6 +909,7 @@ u2f_get_touch_begin(fido_dev_t *dev, int *ms) r = FIDO_OK; fail: iso7816_free(&apdu); + freezero(reply, FIDO_MAXMSG); return (r); } @@ -880,21 +917,28 @@ fail: int u2f_get_touch_status(fido_dev_t *dev, int *touched, int *ms) { - unsigned char reply[FIDO_MAXMSG]; - int reply_len; - int r; + unsigned char *reply; + int reply_len; + int r; + + if ((reply = malloc(FIDO_MAXMSG)) == NULL) { + fido_log_debug("%s: malloc", __func__); + r = FIDO_ERR_INTERNAL; + goto out; + } - if ((reply_len = fido_rx(dev, CTAP_CMD_MSG, &reply, sizeof(reply), + if ((reply_len = fido_rx(dev, CTAP_CMD_MSG, reply, FIDO_MAXMSG, ms)) < 2) { fido_log_debug("%s: fido_rx", __func__); - return (FIDO_OK); /* ignore */ + r = FIDO_OK; /* ignore */ + goto out; } switch ((reply[reply_len - 2] << 8) | reply[reply_len - 1]) { case SW_CONDITIONS_NOT_SATISFIED: if ((r = u2f_get_touch_begin(dev, ms)) != FIDO_OK) { fido_log_debug("%s: u2f_get_touch_begin", __func__); - return (r); + goto out; } *touched = 0; break; @@ -903,8 +947,13 @@ u2f_get_touch_status(fido_dev_t *dev, int *touched, int *ms) break; default: fido_log_debug("%s: unexpected sw", __func__); - return (FIDO_ERR_RX); + r = FIDO_ERR_RX; + goto out; } - return (FIDO_OK); + r = FIDO_OK; +out: + freezero(reply, FIDO_MAXMSG); + + return (r); } diff --git a/src/util.c b/src/util.c index 61e120cfd06c..25281bb51b28 100644 --- a/src/util.c +++ b/src/util.c @@ -2,6 +2,7 @@ * Copyright (c) 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 <errno.h> diff --git a/src/winhello.c b/src/winhello.c index f9ab6061fd60..e0453cb8c70f 100644 --- a/src/winhello.c +++ b/src/winhello.c @@ -2,6 +2,7 @@ * Copyright (c) 2021-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 <sys/types.h> @@ -354,6 +355,9 @@ pack_cose(WEBAUTHN_COSE_CREDENTIAL_PARAMETER *alg, case COSE_ES256: alg->lAlg = WEBAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256; break; + case COSE_ES384: + alg->lAlg = WEBAUTHN_COSE_ALGORITHM_ECDSA_P384_WITH_SHA384; + break; case COSE_EDDSA: alg->lAlg = -8; /* XXX */; break; diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c81397f41fb9..e1f4366c4ef3 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,6 +1,7 @@ -# 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 list(APPEND COMPAT_SOURCES ../openbsd-compat/bsd-getpagesize.c @@ -31,7 +32,7 @@ if(NOT MSVC) set_source_files_properties(assert_get.c assert_verify.c base64.c bio.c config.c cred_make.c cred_verify.c credman.c fido2-assert.c fido2-cred.c fido2-token.c pin.c token.c util.c - PROPERTIES COMPILE_FLAGS "-Wconversion -Wsign-conversion") + PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}") endif() add_executable(fido2-cred diff --git a/tools/assert_get.c b/tools/assert_get.c index c38040253520..8260fb8359f5 100644 --- a/tools/assert_get.c +++ b/tools/assert_get.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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> @@ -209,8 +210,8 @@ assert_get(int argc, char **argv) fido_dev_t *dev = NULL; fido_assert_t *assert = NULL; struct toggle opt; - char pin[1024]; char prompt[1024]; + char pin[128]; char *in_path = NULL; char *out_path = NULL; FILE *in_f = NULL; @@ -284,6 +285,10 @@ assert_get(int argc, char **argv) errx(1, "snprintf"); if (!readpassphrase(prompt, pin, sizeof(pin), RPP_ECHO_OFF)) errx(1, "readpassphrase"); + if (strlen(pin) < 4 || strlen(pin) > 63) { + explicit_bzero(pin, sizeof(pin)); + errx(1, "invalid PIN length"); + } r = fido_dev_get_assert(dev, assert, pin); } else r = fido_dev_get_assert(dev, assert, NULL); diff --git a/tools/assert_verify.c b/tools/assert_verify.c index 7985e95042c5..4cc2e86bff13 100644 --- a/tools/assert_verify.c +++ b/tools/assert_verify.c @@ -1,11 +1,13 @@ /* - * 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> #include <fido/es256.h> +#include <fido/es384.h> #include <fido/rs256.h> #include <fido/eddsa.h> @@ -93,40 +95,54 @@ load_pubkey(int type, const char *file) RSA *rsa = NULL; EVP_PKEY *eddsa = NULL; es256_pk_t *es256_pk = NULL; + es384_pk_t *es384_pk = NULL; rs256_pk_t *rs256_pk = NULL; eddsa_pk_t *eddsa_pk = NULL; void *pk = NULL; - if (type == COSE_ES256) { + switch (type) { + case COSE_ES256: if ((ec = read_ec_pubkey(file)) == NULL) errx(1, "read_ec_pubkey"); if ((es256_pk = es256_pk_new()) == NULL) errx(1, "es256_pk_new"); if (es256_pk_from_EC_KEY(es256_pk, ec) != FIDO_OK) errx(1, "es256_pk_from_EC_KEY"); - pk = es256_pk; EC_KEY_free(ec); - } else if (type == COSE_RS256) { + break; + case COSE_ES384: + if ((ec = read_ec_pubkey(file)) == NULL) + errx(1, "read_ec_pubkey"); + if ((es384_pk = es384_pk_new()) == NULL) + errx(1, "es384_pk_new"); + if (es384_pk_from_EC_KEY(es384_pk, ec) != FIDO_OK) + errx(1, "es384_pk_from_EC_KEY"); + pk = es384_pk; + EC_KEY_free(ec); + break; + case COSE_RS256: if ((rsa = read_rsa_pubkey(file)) == NULL) errx(1, "read_rsa_pubkey"); if ((rs256_pk = rs256_pk_new()) == NULL) errx(1, "rs256_pk_new"); if (rs256_pk_from_RSA(rs256_pk, rsa) != FIDO_OK) errx(1, "rs256_pk_from_RSA"); - pk = rs256_pk; RSA_free(rsa); - } else if (type == COSE_EDDSA) { + break; + case COSE_EDDSA: if ((eddsa = read_eddsa_pubkey(file)) == NULL) errx(1, "read_eddsa_pubkey"); if ((eddsa_pk = eddsa_pk_new()) == NULL) errx(1, "eddsa_pk_new"); if (eddsa_pk_from_EVP_PKEY(eddsa_pk, eddsa) != FIDO_OK) errx(1, "eddsa_pk_from_EVP_PKEY"); - pk = eddsa_pk; EVP_PKEY_free(eddsa); + break; + default: + errx(1, "invalid type %d", type); } return (pk); diff --git a/tools/base64.c b/tools/base64.c index e13119823c98..2cfa98ddb254 100644 --- a/tools/base64.c +++ b/tools/base64.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 <openssl/bio.h> diff --git a/tools/bio.c b/tools/bio.c index 1ce1041c30c6..7a1406d70de5 100644 --- a/tools/bio.c +++ b/tools/bio.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 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> diff --git a/tools/config.c b/tools/config.c index 3eea4c9b6cf6..49253e83f3b7 100644 --- a/tools/config.c +++ b/tools/config.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <stdio.h> diff --git a/tools/cred_make.c b/tools/cred_make.c index 7955fa2b7f9f..a6239ec27aec 100644 --- a/tools/cred_make.c +++ b/tools/cred_make.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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> @@ -137,7 +138,7 @@ cred_make(int argc, char **argv) fido_dev_t *dev = NULL; fido_cred_t *cred = NULL; char prompt[1024]; - char pin[1024]; + char pin[128]; char *in_path = NULL; char *out_path = NULL; FILE *in_f = NULL; @@ -221,6 +222,10 @@ cred_make(int argc, char **argv) errx(1, "snprintf"); if (!readpassphrase(prompt, pin, sizeof(pin), RPP_ECHO_OFF)) errx(1, "readpassphrase"); + if (strlen(pin) < 4 || strlen(pin) > 63) { + explicit_bzero(pin, sizeof(pin)); + errx(1, "invalid PIN length"); + } r = fido_dev_make_cred(dev, cred, pin); } diff --git a/tools/cred_verify.c b/tools/cred_verify.c index d622ed7369bd..3eae435899df 100644 --- a/tools/cred_verify.c +++ b/tools/cred_verify.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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> diff --git a/tools/credman.c b/tools/credman.c index d7fb15580f87..a0a3149d5dfb 100644 --- a/tools/credman.c +++ b/tools/credman.c @@ -2,6 +2,7 @@ * Copyright (c) 2019 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> diff --git a/tools/extern.h b/tools/extern.h index 8b25dadd45ac..ed4b348cfe46 100644 --- a/tools/extern.h +++ b/tools/extern.h @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ #ifndef _EXTERN_H_ @@ -85,7 +86,8 @@ int token_info(int, char **, char *); int token_list(int, char **, char *); int token_reset(char *); int token_set(int, char **, char *); -int write_ec_pubkey(FILE *, const void *, size_t); +int write_es256_pubkey(FILE *, const void *, size_t); +int write_es384_pubkey(FILE *, const void *, size_t); int write_rsa_pubkey(FILE *, const void *, size_t); int read_file(const char *, u_char **, size_t *); int write_file(const char *, const u_char *, size_t); diff --git a/tools/fido2-assert.c b/tools/fido2-assert.c index c363d9a49927..d05c541651cb 100644 --- a/tools/fido2-assert.c +++ b/tools/fido2-assert.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ /* diff --git a/tools/fido2-attach.sh b/tools/fido2-attach.sh index d4bc44989f2b..ef02db6b9ff0 100755 --- a/tools/fido2-attach.sh +++ b/tools/fido2-attach.sh @@ -3,6 +3,7 @@ # Copyright (c) 2020 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 DEV="" diff --git a/tools/fido2-cred.c b/tools/fido2-cred.c index 9463cd591e75..965dbf9ef1ad 100644 --- a/tools/fido2-cred.c +++ b/tools/fido2-cred.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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 */ /* diff --git a/tools/fido2-detach.sh b/tools/fido2-detach.sh index 9cd2e64bbe31..140278fc6993 100755 --- a/tools/fido2-detach.sh +++ b/tools/fido2-detach.sh @@ -3,6 +3,7 @@ # Copyright (c) 2020 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 DEV="$(fido2-token -L | sed 's/^\(.*\): .*$/\1/;q')" diff --git a/tools/fido2-token.c b/tools/fido2-token.c index e6d9f9f96381..412c2f9016c5 100644 --- a/tools/fido2-token.c +++ b/tools/fido2-token.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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> diff --git a/tools/fido2-unprot.sh b/tools/fido2-unprot.sh index 44b28b8d06b8..7d8c77936ee9 100755 --- a/tools/fido2-unprot.sh +++ b/tools/fido2-unprot.sh @@ -3,6 +3,7 @@ # Copyright (c) 2020 Fabian Henneke. # 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 if [ $(uname) != "Linux" ] ; then diff --git a/tools/include_check.sh b/tools/include_check.sh index e684d0b6f12d..70abada1640d 100755 --- a/tools/include_check.sh +++ b/tools/include_check.sh @@ -3,6 +3,7 @@ # Copyright (c) 2019 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 check() { for f in $(find $1 -maxdepth 1 -name '*.h'); do diff --git a/tools/largeblob.c b/tools/largeblob.c index fc2584ce8bdf..00cf79ea8fef 100644 --- a/tools/largeblob.c +++ b/tools/largeblob.c @@ -2,6 +2,7 @@ * Copyright (c) 2020 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 <sys/types.h> diff --git a/tools/pin.c b/tools/pin.c index f342347d1ff5..8b2697ed8e1e 100644 --- a/tools/pin.c +++ b/tools/pin.c @@ -2,6 +2,7 @@ * Copyright (c) 2018 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> @@ -21,8 +22,8 @@ pin_set(char *path) { fido_dev_t *dev = NULL; char prompt[1024]; - char pin1[1024]; - char pin2[1024]; + char pin1[128]; + char pin2[128]; int r; int status = 1; @@ -55,6 +56,11 @@ pin_set(char *path) goto out; } + if (strlen(pin1) < 4 || strlen(pin1) > 63) { + fprintf(stderr, "invalid PIN length\n"); + goto out; + } + if ((r = fido_dev_set_pin(dev, pin1, NULL)) != FIDO_OK) { warnx("fido_dev_set_pin: %s", fido_strerr(r)); goto out; @@ -76,9 +82,9 @@ pin_change(char *path) { fido_dev_t *dev = NULL; char prompt[1024]; - char pin0[1024]; - char pin1[1024]; - char pin2[1024]; + char pin0[128]; + char pin1[128]; + char pin2[128]; int r; int status = 1; @@ -98,6 +104,11 @@ pin_change(char *path) goto out; } + if (strlen(pin0) < 4 || strlen(pin0) > 63) { + warnx("invalid PIN length"); + goto out; + } + r = snprintf(prompt, sizeof(prompt), "Enter new PIN for %s: ", path); if (r < 0 || (size_t)r >= sizeof(prompt)) { warnx("snprintf"); @@ -125,6 +136,11 @@ pin_change(char *path) goto out; } + if (strlen(pin1) < 4 || strlen(pin1) > 63) { + fprintf(stderr, "invalid PIN length\n"); + goto out; + } + if ((r = fido_dev_set_pin(dev, pin1, pin0)) != FIDO_OK) { warnx("fido_dev_set_pin: %s", fido_strerr(r)); goto out; diff --git a/tools/test.sh b/tools/test.sh index 02d82d5a18cd..67b757e80a8d 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -1,8 +1,9 @@ #!/bin/sh -ex -# Copyright (c) 2021 Yubico AB. All rights reserved. +# Copyright (c) 2021-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 # usage: ./test.sh "$(mktemp -d fido2test-XXXXXXXX)" device @@ -16,6 +17,9 @@ cd "$1" DEV="$2" +TYPE="es256" +#TYPE="es384" +#TYPE="eddsa" make_cred() { sed /^$/d > cred_param << EOF @@ -24,11 +28,11 @@ $1 some user name $(dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64) EOF - fido2-cred -M $2 "${DEV}" > "$3" < cred_param + fido2-cred -M $2 "${DEV}" "${TYPE}" > "$3" < cred_param } verify_cred() { - fido2-cred -V $1 > cred_out < "$2" + fido2-cred -V $1 "${TYPE}" > cred_out < "$2" head -1 cred_out > "$3" tail -n +2 cred_out > "$4" } @@ -44,23 +48,25 @@ EOF } verify_assert() { - fido2-assert -V $1 "$2" < "$3" + fido2-assert -V $1 "$2" "${TYPE}" < "$3" } dd if=/dev/urandom bs=32 count=1 | base64 > hmac-salt # u2f -make_cred no.tld "-u" u2f -! make_cred no.tld "-ru" /dev/null -! make_cred no.tld "-uc1" /dev/null -! make_cred no.tld "-uc2" /dev/null -verify_cred "--" u2f u2f-cred u2f-pubkey -! verify_cred "-h" u2f /dev/null /dev/null -! verify_cred "-v" u2f /dev/null /dev/null -verify_cred "-c0" u2f /dev/null /dev/null -! verify_cred "-c1" u2f /dev/null /dev/null -! verify_cred "-c2" u2f /dev/null /dev/null -! verify_cred "-c3" u2f /dev/null /dev/null +if [ "x${TYPE}" = "xes256" ]; then + make_cred no.tld "-u" u2f + ! make_cred no.tld "-ru" /dev/null + ! make_cred no.tld "-uc1" /dev/null + ! make_cred no.tld "-uc2" /dev/null + verify_cred "--" u2f u2f-cred u2f-pubkey + ! verify_cred "-h" u2f /dev/null /dev/null + ! verify_cred "-v" u2f /dev/null /dev/null + verify_cred "-c0" u2f /dev/null /dev/null + ! verify_cred "-c1" u2f /dev/null /dev/null + ! verify_cred "-c2" u2f /dev/null /dev/null + ! verify_cred "-c3" u2f /dev/null /dev/null +fi # wrap (non-resident) make_cred no.tld "--" wrap @@ -105,10 +111,12 @@ verify_cred "-hc0" rk-hs /dev/null /dev/null ! verify_cred "-c3" rk-hs /dev/null /dev/null # u2f -get_assert no.tld "-u" u2f-cred /dev/null u2f-assert -! get_assert no.tld "-u -t up=false" u2f-cred /dev/null /dev/null -verify_assert "--" u2f-pubkey u2f-assert -verify_assert "-p" u2f-pubkey u2f-assert +if [ "x${TYPE}" = "xes256" ]; then + get_assert no.tld "-u" u2f-cred /dev/null u2f-assert + ! get_assert no.tld "-u -t up=false" u2f-cred /dev/null /dev/null + verify_assert "--" u2f-pubkey u2f-assert + verify_assert "-p" u2f-pubkey u2f-assert +fi # wrap (non-resident) get_assert no.tld "--" wrap-cred /dev/null wrap-assert diff --git a/tools/token.c b/tools/token.c index 9124e7b7fd29..366d5a15ab04 100644 --- a/tools/token.c +++ b/tools/token.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> @@ -95,6 +96,22 @@ print_opt_array(const char *label, char * const *name, const bool *value, } 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"); +} + +static void print_algorithms(const fido_cbor_info_t *ci) { const char *cose, *type; @@ -108,15 +125,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); @@ -162,6 +182,101 @@ print_maxlargeblob(uint64_t maxlargeblob) } static void +print_maxrpid_minpinlen(uint64_t maxrpid) +{ + if (maxrpid > 0) + printf("maxrpids in minpinlen: %d\n", (int)maxrpid); +} + +static void +print_minpinlen(uint64_t minpinlen) +{ + if (minpinlen > 0) + printf("minpinlen: %d\n", (int)minpinlen); +} + +static void +print_uv_attempts(uint64_t uv_attempts) +{ + if (uv_attempts > 0) + printf("platform uv attempt(s): %d\n", (int)uv_attempts); +} + +static void +print_uv_modality(uint64_t uv_modality) +{ + uint64_t mode; + bool printed = false; + + if (uv_modality == 0) + return; + + printf("uv modality: 0x%x (", (int)uv_modality); + + for (size_t i = 0; i < 64; i++) { + mode = 1ULL << i; + if ((uv_modality & mode) == 0) + continue; + if (printed) + printf(", "); + switch (mode) { + case FIDO_UV_MODE_TUP: + printf("test of user presence"); + break; + case FIDO_UV_MODE_FP: + printf("fingerprint check"); + break; + case FIDO_UV_MODE_PIN: + printf("pin check"); + break; + case FIDO_UV_MODE_VOICE: + printf("voice recognition"); + break; + case FIDO_UV_MODE_FACE: + printf("face recognition"); + break; + case FIDO_UV_MODE_LOCATION: + printf("location check"); + break; + case FIDO_UV_MODE_EYE: + printf("eyeprint check"); + break; + case FIDO_UV_MODE_DRAWN: + printf("drawn pattern check"); + break; + case FIDO_UV_MODE_HAND: + printf("handprint verification"); + break; + case FIDO_UV_MODE_NONE: + printf("none"); + break; + case FIDO_UV_MODE_ALL: + printf("all required"); + break; + case FIDO_UV_MODE_EXT_PIN: + printf("external pin"); + break; + case FIDO_UV_MODE_EXT_DRAWN: + printf("external drawn pattern check"); + break; + default: + printf("unknown 0x%llx", (unsigned long long)mode); + break; + } + printed = true; + } + + printf(")\n"); +} + +static void +print_rk_remaining(int64_t rk_remaining) +{ + if (rk_remaining != -1) + printf("remaining rk(s): %d\n", (int)rk_remaining); +} + +static void print_fwversion(uint64_t fwversion) { printf("fwversion: 0x%x\n", (int)fwversion); @@ -256,6 +371,14 @@ token_info(int argc, char **argv, 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)); @@ -268,8 +391,14 @@ token_info(int argc, char **argv, char *path) /* print maximum length of serialized largeBlob array */ print_maxlargeblob(fido_cbor_info_maxlargeblob(ci)); - /* print firmware version */ - print_fwversion(fido_cbor_info_fwversion(ci)); + /* print maximum number of RP IDs in fido_dev_set_pin_minlen_rpid() */ + print_maxrpid_minpinlen(fido_cbor_info_maxrpid_minpinlen(ci)); + + /* print estimated number of 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), @@ -280,11 +409,20 @@ token_info(int argc, char **argv, char *path) else printf("pin retries: %d\n", retrycnt); + printf("pin change required: %s\n", + fido_cbor_info_new_pin_required(ci) ? "true" : "false"); + if (fido_dev_get_uv_retry_count(dev, &retrycnt) != FIDO_OK) printf("uv retries: undefined\n"); else printf("uv retries: %d\n", retrycnt); + /* print platform uv attempts */ + print_uv_attempts(fido_cbor_info_uv_attempts(ci)); + + /* print supported uv mechanisms */ + print_uv_modality(fido_cbor_info_uv_modality(ci)); + bio_info(dev); fido_cbor_info_free(&ci); diff --git a/tools/util.c b/tools/util.c index 612d81b2000c..0e518bbc5ce2 100644 --- a/tools/util.c +++ b/tools/util.c @@ -1,7 +1,8 @@ /* - * Copyright (c) 2018-2021 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 <sys/types.h> @@ -13,6 +14,7 @@ #include <fido.h> #include <fido/es256.h> +#include <fido/es384.h> #include <fido/rs256.h> #include <fido/eddsa.h> @@ -244,7 +246,7 @@ fail: } int -write_ec_pubkey(FILE *f, const void *ptr, size_t len) +write_es256_pubkey(FILE *f, const void *ptr, size_t len) { EVP_PKEY *pkey = NULL; es256_pk_t *pk = NULL; @@ -281,6 +283,44 @@ fail: return (ok); } +int +write_es384_pubkey(FILE *f, const void *ptr, size_t len) +{ + EVP_PKEY *pkey = NULL; + es384_pk_t *pk = NULL; + int ok = -1; + + if ((pk = es384_pk_new()) == NULL) { + warnx("es384_pk_new"); + goto fail; + } + + if (es384_pk_from_ptr(pk, ptr, len) != FIDO_OK) { + warnx("es384_pk_from_ptr"); + goto fail; + } + + if ((pkey = es384_pk_to_EVP_PKEY(pk)) == NULL) { + warnx("es384_pk_to_EVP_PKEY"); + goto fail; + } + + if (PEM_write_PUBKEY(f, pkey) == 0) { + warnx("PEM_write_PUBKEY"); + goto fail; + } + + ok = 0; +fail: + es384_pk_free(&pk); + + if (pkey != NULL) { + EVP_PKEY_free(pkey); + } + + return (ok); +} + RSA * read_rsa_pubkey(const char *path) { @@ -425,16 +465,24 @@ print_cred(FILE *out_f, int type, const fido_cred_t *cred) fprintf(out_f, "%s\n", id); - if (type == COSE_ES256) { - write_ec_pubkey(out_f, fido_cred_pubkey_ptr(cred), + switch (type) { + case COSE_ES256: + write_es256_pubkey(out_f, fido_cred_pubkey_ptr(cred), + fido_cred_pubkey_len(cred)); + break; + case COSE_ES384: + write_es384_pubkey(out_f, fido_cred_pubkey_ptr(cred), fido_cred_pubkey_len(cred)); - } else if (type == COSE_RS256) { + break; + case COSE_RS256: write_rsa_pubkey(out_f, fido_cred_pubkey_ptr(cred), fido_cred_pubkey_len(cred)); - } else if (type == COSE_EDDSA) { + break; + case COSE_EDDSA: write_eddsa_pubkey(out_f, fido_cred_pubkey_ptr(cred), fido_cred_pubkey_len(cred)); - } else { + break; + default: errx(1, "print_cred: unknown type"); } @@ -446,6 +494,8 @@ cose_type(const char *str, int *type) { if (strcmp(str, "es256") == 0) *type = COSE_ES256; + else if (strcmp(str, "es384") == 0) + *type = COSE_ES384; else if (strcmp(str, "rs256") == 0) *type = COSE_RS256; else if (strcmp(str, "eddsa") == 0) @@ -462,12 +512,14 @@ const char * cose_string(int type) { switch (type) { - case COSE_EDDSA: - return ("eddsa"); case COSE_ES256: return ("es256"); + case COSE_ES384: + return ("es384"); case COSE_RS256: return ("rs256"); + case COSE_EDDSA: + return ("eddsa"); default: return ("unknown"); } diff --git a/udev/70-u2f.rules b/udev/70-u2f.rules index 6e1f88bbd042..913bef2a9936 100644 --- a/udev/70-u2f.rules +++ b/udev/70-u2f.rules @@ -1,9 +1,32 @@ # Copyright (c) 2020 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. - -# This file is automatically generated, and should -# be used with udev 188 or newer. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# SPDX-License-Identifier: BSD-2-Clause + +# This file is automatically generated, and should be used with udev 188 +# or newer. ACTION!="add|change", GOTO="fido_end" diff --git a/udev/CMakeLists.txt b/udev/CMakeLists.txt index 29a9d41fe37d..abddb80f4d82 100644 --- a/udev/CMakeLists.txt +++ b/udev/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright (c) 2018 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 if(UDEV_RULES_DIR) install(FILES 70-u2f.rules DESTINATION ${UDEV_RULES_DIR}) diff --git a/udev/check.sh b/udev/check.sh index 97bbb97b26c8..804a8843b378 100755 --- a/udev/check.sh +++ b/udev/check.sh @@ -3,6 +3,7 @@ # Copyright (c) 2020 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 sort_by_id() { awk '{ printf "%d\n", $3 }' | sort -Cnu diff --git a/udev/fidodevs b/udev/fidodevs index d519acd2ca73..d8a80fc1a4ee 100644 --- a/udev/fidodevs +++ b/udev/fidodevs @@ -1,6 +1,7 @@ # Copyright (c) 2020 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 # After modifying this file, regenerate 70-u2f.rules: # ./genrules.awk fidodevs > 70-u2f.rules diff --git a/udev/genrules.awk b/udev/genrules.awk index 2a85c7cbf98f..3dad667da923 100755 --- a/udev/genrules.awk +++ b/udev/genrules.awk @@ -3,14 +3,38 @@ # Copyright (c) 2020 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 NR == 1 { print "# Copyright (c) 2020 Yubico AB. All rights reserved." - print "# Use of this source code is governed by a BSD-style" - print "# license that can be found in the LICENSE file." + print "#" + print "# Redistribution and use in source and binary forms, with or without" + print "# modification, are permitted provided that the following conditions are" + print "# met:" + print "# " + print "# 1. Redistributions of source code must retain the above copyright" + print "# notice, this list of conditions and the following disclaimer." + print "# 2. Redistributions in binary form must reproduce the above copyright" + print "# notice, this list of conditions and the following disclaimer in" + print "# the documentation and/or other materials provided with the" + print "# distribution." + print "# " + print "# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS" + print "# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT" + print "# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR" + print "# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT" + print "# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL," + print "# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT" + print "# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE," + print "# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY" + print "# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT" + print "# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE" + print "# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + print "#" + print "# SPDX-License-Identifier: BSD-2-Clause" print "" - print "# This file is automatically generated, and should" - print "# be used with udev 188 or newer." + print "# This file is automatically generated, and should be used with udev 188" + print "# or newer." print "" print "ACTION!=\"add|change\", GOTO=\"fido_end\"" diff --git a/windows/build.ps1 b/windows/build.ps1 index bd63c7f21095..4c3a9699b07a 100644 --- a/windows/build.ps1 +++ b/windows/build.ps1 @@ -1,6 +1,7 @@ # Copyright (c) 2021-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 param( [string]$CMakePath = "C:\Program Files\CMake\bin\cmake.exe", diff --git a/windows/const.ps1 b/windows/const.ps1 index 8acc2b2e829a..31426e99fec6 100644 --- a/windows/const.ps1 +++ b/windows/const.ps1 @@ -1,12 +1,13 @@ # Copyright (c) 2021 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 # LibreSSL coordinates. New-Variable -Name 'LIBRESSL_URL' ` -Value 'https://fastly.cdn.openbsd.org/pub/OpenBSD/LibreSSL' ` -Option Constant -New-Variable -Name 'LIBRESSL' -Value 'libressl-3.5.2' -Option Constant +New-Variable -Name 'LIBRESSL' -Value 'libressl-3.5.3' -Option Constant # libcbor coordinates. New-Variable -Name 'LIBCBOR' -Value 'libcbor-0.9.0' -Option Constant diff --git a/windows/cygwin.ps1 b/windows/cygwin.ps1 index 6e602b6d9474..0681830a911d 100755 --- a/windows/cygwin.ps1 +++ b/windows/cygwin.ps1 @@ -1,6 +1,7 @@ # Copyright (c) 2021 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 param( [string]$GPGPath = "C:\Program Files (x86)\GnuPG\bin\gpg.exe", diff --git a/windows/release.ps1 b/windows/release.ps1 index 6f3f4e9600df..423ec20f7e59 100644 --- a/windows/release.ps1 +++ b/windows/release.ps1 @@ -1,6 +1,7 @@ # Copyright (c) 2021-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 $ErrorActionPreference = "Stop" $Architectures = @('x64', 'Win32', 'ARM64', 'ARM') |