aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2023-09-19 17:06:12 +0000
committerEd Maste <emaste@FreeBSD.org>2023-09-19 17:06:12 +0000
commit2ccfa855b2fc331819953e3de1b1c15ce5b95a7e (patch)
tree31cac31e743da6bab841b55258a3e85e9743bb5e
parent1843dfb05ed80149f5a412180af882e3cb8f451b (diff)
parent00db45a65823dc224f3630bc8185e789064fef6a (diff)
downloadsrc-2ccfa855b2fc331819953e3de1b1c15ce5b95a7e.tar.gz
src-2ccfa855b2fc331819953e3de1b1c15ce5b95a7e.zip
libfido2: update to 1.13.0
Some highlights from NEWS entries: ** Improved OpenSSL 3.0 compatibility. ** Support for hidraw(4) on FreeBSD; gh#597. ** Improved support for FIDO 2.1 authenticators. PR: 273596 Relnotes: Yes Sponsored by: The FreeBSD Foundation
-rw-r--r--contrib/libfido2/CMakeLists.txt142
-rw-r--r--contrib/libfido2/LICENSE4
-rw-r--r--contrib/libfido2/NEWS41
-rw-r--r--contrib/libfido2/README.adoc114
-rw-r--r--contrib/libfido2/examples/CMakeLists.txt12
-rw-r--r--contrib/libfido2/examples/README.adoc17
-rw-r--r--contrib/libfido2/examples/assert.c33
-rw-r--r--contrib/libfido2/examples/cred.c29
-rw-r--r--contrib/libfido2/examples/extern.h8
-rw-r--r--contrib/libfido2/examples/info.c101
-rw-r--r--contrib/libfido2/examples/manifest.c1
-rw-r--r--contrib/libfido2/examples/reset.c1
-rw-r--r--contrib/libfido2/examples/retries.c3
-rw-r--r--contrib/libfido2/examples/select.c5
-rw-r--r--contrib/libfido2/examples/setpin.c3
-rw-r--r--contrib/libfido2/examples/util.c65
-rw-r--r--contrib/libfido2/fuzz/CMakeLists.txt55
-rw-r--r--contrib/libfido2/fuzz/Dockerfile22
-rw-r--r--contrib/libfido2/fuzz/Makefile35
-rw-r--r--contrib/libfido2/fuzz/README22
-rwxr-xr-xcontrib/libfido2/fuzz/build-coverage7
-rw-r--r--contrib/libfido2/fuzz/clock.c1
-rw-r--r--contrib/libfido2/fuzz/dummy.h5
-rw-r--r--contrib/libfido2/fuzz/export.gnu32
-rw-r--r--contrib/libfido2/fuzz/functions.txt404
-rw-r--r--contrib/libfido2/fuzz/fuzz_assert.c43
-rw-r--r--contrib/libfido2/fuzz/fuzz_bio.c5
-rw-r--r--contrib/libfido2/fuzz/fuzz_cred.c10
-rw-r--r--contrib/libfido2/fuzz/fuzz_credman.c5
-rw-r--r--contrib/libfido2/fuzz/fuzz_hid.c5
-rw-r--r--contrib/libfido2/fuzz/fuzz_largeblob.c5
-rw-r--r--contrib/libfido2/fuzz/fuzz_mgmt.c34
-rw-r--r--contrib/libfido2/fuzz/fuzz_netlink.c5
-rw-r--r--contrib/libfido2/fuzz/fuzz_pcsc.c269
-rw-r--r--contrib/libfido2/fuzz/libfuzzer.c61
-rw-r--r--contrib/libfido2/fuzz/mutator_aux.c21
-rw-r--r--contrib/libfido2/fuzz/mutator_aux.h22
-rw-r--r--contrib/libfido2/fuzz/pcsc.c153
-rw-r--r--contrib/libfido2/fuzz/preload-fuzz.c1
-rw-r--r--contrib/libfido2/fuzz/preload-snoop.c1
-rw-r--r--contrib/libfido2/fuzz/report.tgzbin323706 -> 357005 bytes
-rw-r--r--contrib/libfido2/fuzz/summary.txt77
-rw-r--r--contrib/libfido2/fuzz/udev.c3
-rw-r--r--contrib/libfido2/fuzz/wiredata_fido2.h77
-rw-r--r--contrib/libfido2/fuzz/wiredata_u2f.h1
-rw-r--r--contrib/libfido2/fuzz/wrap.c67
-rw-r--r--contrib/libfido2/fuzz/wrapped.sym10
-rw-r--r--contrib/libfido2/man/CMakeLists.txt53
-rwxr-xr-xcontrib/libfido2/man/check.sh1
-rw-r--r--contrib/libfido2/man/eddsa_pk_new.332
-rw-r--r--contrib/libfido2/man/es256_pk_new.332
-rw-r--r--contrib/libfido2/man/es384_pk_new.3164
-rw-r--r--contrib/libfido2/man/fido2-assert.127
-rw-r--r--contrib/libfido2/man/fido2-cred.127
-rw-r--r--contrib/libfido2/man/fido2-token.151
-rw-r--r--contrib/libfido2/man/fido_assert_allow_cred.345
-rw-r--r--contrib/libfido2/man/fido_assert_new.337
-rw-r--r--contrib/libfido2/man/fido_assert_set_authdata.333
-rw-r--r--contrib/libfido2/man/fido_assert_verify.333
-rw-r--r--contrib/libfido2/man/fido_bio_dev_get_info.327
-rw-r--r--contrib/libfido2/man/fido_bio_enroll_new.327
-rw-r--r--contrib/libfido2/man/fido_bio_info_new.327
-rw-r--r--contrib/libfido2/man/fido_bio_template.327
-rw-r--r--contrib/libfido2/man/fido_cbor_info_new.3169
-rw-r--r--contrib/libfido2/man/fido_cred_exclude.345
-rw-r--r--contrib/libfido2/man/fido_cred_new.329
-rw-r--r--contrib/libfido2/man/fido_cred_set_authdata.346
-rw-r--r--contrib/libfido2/man/fido_cred_verify.327
-rw-r--r--contrib/libfido2/man/fido_credman_metadata_new.327
-rw-r--r--contrib/libfido2/man/fido_dev_enable_entattest.338
-rw-r--r--contrib/libfido2/man/fido_dev_get_assert.327
-rw-r--r--contrib/libfido2/man/fido_dev_get_touch_begin.327
-rw-r--r--contrib/libfido2/man/fido_dev_info_manifest.331
-rw-r--r--contrib/libfido2/man/fido_dev_largeblob_get.334
-rw-r--r--contrib/libfido2/man/fido_dev_make_cred.327
-rw-r--r--contrib/libfido2/man/fido_dev_open.327
-rw-r--r--contrib/libfido2/man/fido_dev_set_io_functions.327
-rw-r--r--contrib/libfido2/man/fido_dev_set_pin.329
-rw-r--r--contrib/libfido2/man/fido_init.327
-rw-r--r--contrib/libfido2/man/fido_strerr.327
-rw-r--r--contrib/libfido2/man/rs256_pk_new.332
-rw-r--r--contrib/libfido2/openbsd-compat/bsd-asprintf.c88
-rw-r--r--contrib/libfido2/openbsd-compat/clock_gettime.c1
-rw-r--r--contrib/libfido2/openbsd-compat/endian_win32.c1
-rw-r--r--contrib/libfido2/openbsd-compat/openbsd-compat.h5
-rw-r--r--contrib/libfido2/regress/CMakeLists.txt57
-rw-r--r--contrib/libfido2/regress/assert.c14
-rw-r--r--contrib/libfido2/regress/compress.c268
-rw-r--r--contrib/libfido2/regress/cred.c15
-rw-r--r--contrib/libfido2/regress/dev.c43
-rw-r--r--contrib/libfido2/regress/eddsa.c159
-rw-r--r--contrib/libfido2/regress/es256.c199
-rw-r--r--contrib/libfido2/regress/es384.c213
-rw-r--r--contrib/libfido2/regress/rs256.c201
-rw-r--r--contrib/libfido2/src/CMakeLists.txt31
-rw-r--r--contrib/libfido2/src/aes256.c1
-rw-r--r--contrib/libfido2/src/assert.c206
-rw-r--r--contrib/libfido2/src/authkey.c26
-rw-r--r--contrib/libfido2/src/bio.c116
-rw-r--r--contrib/libfido2/src/blob.c1
-rw-r--r--contrib/libfido2/src/blob.h1
-rw-r--r--contrib/libfido2/src/buf.c1
-rw-r--r--contrib/libfido2/src/cbor.c52
-rw-r--r--contrib/libfido2/src/compress.c145
-rw-r--r--contrib/libfido2/src/config.c28
-rw-r--r--contrib/libfido2/src/cred.c45
-rw-r--r--contrib/libfido2/src/credman.c162
-rw-r--r--contrib/libfido2/src/dev.c229
-rwxr-xr-xcontrib/libfido2/src/diff_exports.sh1
-rw-r--r--contrib/libfido2/src/ecdh.c1
-rw-r--r--contrib/libfido2/src/eddsa.c14
-rw-r--r--contrib/libfido2/src/err.c1
-rw-r--r--contrib/libfido2/src/es256.c66
-rw-r--r--contrib/libfido2/src/es384.c296
-rw-r--r--contrib/libfido2/src/export.gnu22
-rw-r--r--contrib/libfido2/src/export.llvm22
-rw-r--r--contrib/libfido2/src/export.msvc22
-rw-r--r--contrib/libfido2/src/extern.h30
-rw-r--r--contrib/libfido2/src/fallthrough.h21
-rw-r--r--contrib/libfido2/src/fido.h46
-rw-r--r--contrib/libfido2/src/fido/bio.h26
-rw-r--r--contrib/libfido2/src/fido/config.h26
-rw-r--r--contrib/libfido2/src/fido/credman.h26
-rw-r--r--contrib/libfido2/src/fido/eddsa.h28
-rw-r--r--contrib/libfido2/src/fido/err.h26
-rw-r--r--contrib/libfido2/src/fido/es256.h26
-rw-r--r--contrib/libfido2/src/fido/es384.h59
-rw-r--r--contrib/libfido2/src/fido/param.h57
-rw-r--r--contrib/libfido2/src/fido/rs256.h26
-rw-r--r--contrib/libfido2/src/fido/types.h78
-rw-r--r--contrib/libfido2/src/hid.c1
-rw-r--r--contrib/libfido2/src/hid_freebsd.c1
-rw-r--r--contrib/libfido2/src/hid_hidapi.c13
-rw-r--r--contrib/libfido2/src/hid_linux.c50
-rw-r--r--contrib/libfido2/src/hid_netbsd.c1
-rw-r--r--contrib/libfido2/src/hid_openbsd.c101
-rw-r--r--contrib/libfido2/src/hid_osx.c26
-rw-r--r--contrib/libfido2/src/hid_unix.c1
-rw-r--r--contrib/libfido2/src/hid_win.c5
-rw-r--r--contrib/libfido2/src/info.c171
-rw-r--r--contrib/libfido2/src/io.c26
-rw-r--r--contrib/libfido2/src/iso7816.c1
-rw-r--r--contrib/libfido2/src/iso7816.h1
-rw-r--r--contrib/libfido2/src/largeblob.c34
-rw-r--r--contrib/libfido2/src/log.c1
-rw-r--r--contrib/libfido2/src/netlink.c1
-rw-r--r--contrib/libfido2/src/netlink.h1
-rw-r--r--contrib/libfido2/src/nfc.c350
-rw-r--r--contrib/libfido2/src/nfc_linux.c387
-rw-r--r--contrib/libfido2/src/packed.h1
-rw-r--r--contrib/libfido2/src/pcsc.c394
-rw-r--r--contrib/libfido2/src/pin.c77
-rw-r--r--contrib/libfido2/src/random.c1
-rw-r--r--contrib/libfido2/src/reset.c1
-rw-r--r--contrib/libfido2/src/rs1.c3
-rw-r--r--contrib/libfido2/src/rs256.c29
-rw-r--r--contrib/libfido2/src/time.c1
-rw-r--r--contrib/libfido2/src/touch.c109
-rw-r--r--contrib/libfido2/src/tpm.c3
-rw-r--r--contrib/libfido2/src/types.c17
-rw-r--r--contrib/libfido2/src/u2f.c93
-rw-r--r--contrib/libfido2/src/util.c31
-rw-r--r--contrib/libfido2/src/webauthn.h75
-rw-r--r--contrib/libfido2/src/winhello.c122
-rw-r--r--contrib/libfido2/tools/CMakeLists.txt12
-rw-r--r--contrib/libfido2/tools/assert_get.c7
-rw-r--r--contrib/libfido2/tools/assert_verify.c30
-rw-r--r--contrib/libfido2/tools/base64.c1
-rw-r--r--contrib/libfido2/tools/bio.c1
-rw-r--r--contrib/libfido2/tools/config.c1
-rw-r--r--contrib/libfido2/tools/cred_make.c7
-rw-r--r--contrib/libfido2/tools/cred_verify.c1
-rw-r--r--contrib/libfido2/tools/credman.c1
-rw-r--r--contrib/libfido2/tools/extern.h4
-rw-r--r--contrib/libfido2/tools/fido2-assert.c1
-rwxr-xr-xcontrib/libfido2/tools/fido2-attach.sh1
-rw-r--r--contrib/libfido2/tools/fido2-cred.c1
-rwxr-xr-xcontrib/libfido2/tools/fido2-detach.sh1
-rw-r--r--contrib/libfido2/tools/fido2-token.c1
-rwxr-xr-xcontrib/libfido2/tools/fido2-unprot.sh1
-rwxr-xr-xcontrib/libfido2/tools/include_check.sh1
-rw-r--r--contrib/libfido2/tools/largeblob.c59
-rw-r--r--contrib/libfido2/tools/pin.c26
-rwxr-xr-xcontrib/libfido2/tools/test.sh46
-rw-r--r--contrib/libfido2/tools/token.c159
-rw-r--r--contrib/libfido2/tools/util.c70
-rw-r--r--contrib/libfido2/udev/70-u2f.rules39
-rw-r--r--contrib/libfido2/udev/CMakeLists.txt1
-rwxr-xr-xcontrib/libfido2/udev/check.sh1
-rw-r--r--contrib/libfido2/udev/fidodevs3
-rwxr-xr-xcontrib/libfido2/udev/genrules.awk32
-rw-r--r--contrib/libfido2/windows/build.ps132
-rw-r--r--contrib/libfido2/windows/const.ps114
-rwxr-xr-xcontrib/libfido2/windows/cygwin.ps12
-rw-r--r--contrib/libfido2/windows/release.ps130
-rw-r--r--lib/libfido2/Makefile6
196 files changed, 7592 insertions, 1733 deletions
diff --git a/contrib/libfido2/CMakeLists.txt b/contrib/libfido2/CMakeLists.txt
index 11a51ac5a645..6fa341a01cc6 100644
--- a/contrib/libfido2/CMakeLists.txt
+++ b/contrib/libfido2/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
# detect AppleClang; needs to come before project()
cmake_policy(SET CMP0025 NEW)
@@ -28,18 +29,19 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_COLOR_MAKEFILE OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(FIDO_MAJOR "1")
-set(FIDO_MINOR "10")
+set(FIDO_MINOR "13")
set(FIDO_PATCH "0")
set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH})
+option(BUILD_TESTS "Build the regress tests" ON)
option(BUILD_EXAMPLES "Build example programs" ON)
option(BUILD_MANPAGES "Build man pages" ON)
-option(BUILD_SHARED_LIBS "Build the shared library" ON)
-option(BUILD_STATIC_LIBS "Build the static library" ON)
+option(BUILD_SHARED_LIBS "Build a shared library" ON)
+option(BUILD_STATIC_LIBS "Build a static library" ON)
option(BUILD_TOOLS "Build tool programs" ON)
option(FUZZ "Enable fuzzing instrumentation" OFF)
-option(LIBFUZZER "Build libfuzzer harnesses" OFF)
option(USE_HIDAPI "Use hidapi as the HID backend" OFF)
+option(USE_PCSC "Enable experimental PCSC support" OFF)
option(USE_WINHELLO "Abstract Windows Hello as a FIDO device" ON)
option(NFC_LINUX "Enable NFC support on Linux" ON)
@@ -47,6 +49,14 @@ add_definitions(-D_FIDO_MAJOR=${FIDO_MAJOR})
add_definitions(-D_FIDO_MINOR=${FIDO_MINOR})
add_definitions(-D_FIDO_PATCH=${FIDO_PATCH})
+if(BUILD_SHARED_LIBS)
+ set(_FIDO2_LIBRARY fido2_shared)
+elseif(BUILD_STATIC_LIBS)
+ set(_FIDO2_LIBRARY fido2)
+else()
+ message(FATAL_ERROR "Nothing to build (BUILD_*_LIBS=OFF)")
+endif()
+
if(CYGWIN OR MSYS OR MINGW)
set(WIN32 1)
endif()
@@ -66,7 +76,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
@@ -91,6 +101,7 @@ check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
check_include_files(unistd.h HAVE_UNISTD_H)
check_symbol_exists(arc4random_buf stdlib.h HAVE_ARC4RANDOM_BUF)
+check_symbol_exists(asprintf stdio.h HAVE_ASPRINTF)
check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
check_symbol_exists(explicit_bzero string.h HAVE_EXPLICIT_BZERO)
check_symbol_exists(freezero stdlib.h HAVE_FREEZERO)
@@ -116,6 +127,7 @@ try_compile(HAVE_POSIX_IOCTL
list(APPEND CHECK_VARIABLES
HAVE_ARC4RANDOM_BUF
+ HAVE_ASPRINTF
HAVE_CBOR_H
HAVE_CLOCK_GETTIME
HAVE_ENDIAN_H
@@ -147,7 +159,7 @@ foreach(v ${CHECK_VARIABLES})
endif()
endforeach()
-if(HAVE_EXPLICIT_BZERO AND NOT LIBFUZZER)
+if(HAVE_EXPLICIT_BZERO AND NOT FUZZ)
add_definitions(-DHAVE_EXPLICIT_BZERO)
endif()
@@ -155,19 +167,30 @@ if(UNIX)
add_definitions(-DHAVE_DEV_URANDOM)
endif()
+
if(MSVC)
if((NOT CBOR_INCLUDE_DIRS) OR (NOT CBOR_LIBRARY_DIRS) OR
- (NOT CBOR_BIN_DIRS) OR (NOT CRYPTO_INCLUDE_DIRS) OR
- (NOT CRYPTO_LIBRARY_DIRS) OR (NOT CRYPTO_BIN_DIRS) OR
- (NOT ZLIB_INCLUDE_DIRS) OR (NOT ZLIB_LIBRARY_DIRS) OR
- (NOT ZLIB_BIN_DIRS))
+ (NOT CRYPTO_INCLUDE_DIRS) OR (NOT CRYPTO_LIBRARY_DIRS) OR
+ (NOT ZLIB_INCLUDE_DIRS) OR (NOT ZLIB_LIBRARY_DIRS))
message(FATAL_ERROR "please define "
- "{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY,BIN}_DIRS when "
+ "{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY}_DIRS when "
"building under msvc")
endif()
- set(CBOR_LIBRARIES cbor)
- set(ZLIB_LIBRARIES zlib)
- set(CRYPTO_LIBRARIES crypto-47)
+ if(BUILD_TESTS AND BUILD_SHARED_LIBS AND
+ ((NOT CBOR_BIN_DIRS) OR (NOT ZLIB_BIN_DIRS) OR (NOT CRYPTO_BIN_DIRS)))
+ message(FATAL_ERROR "please define {CBOR,CRYPTO,ZLIB}_BIN_DIRS "
+ "when building tests")
+ endif()
+ if(NOT CBOR_LIBRARIES)
+ set(CBOR_LIBRARIES cbor)
+ endif()
+ if(NOT ZLIB_LIBRARIES)
+ set(ZLIB_LIBRARIES zlib1)
+ endif()
+ if(NOT CRYPTO_LIBRARIES)
+ set(CRYPTO_LIBRARIES crypto)
+ endif()
+
set(MSVC_DISABLED_WARNINGS_LIST
"C4152" # nonstandard extension used: function/data pointer
# conversion in expression;
@@ -209,8 +232,12 @@ else()
message(FATAL_ERROR "could not find zlib")
endif()
- set(CBOR_LIBRARIES "cbor")
- set(CRYPTO_LIBRARIES "crypto")
+ if(NOT CBOR_LIBRARIES)
+ set(CBOR_LIBRARIES "cbor")
+ endif()
+ if(NOT CRYPTO_LIBRARIES)
+ set(CRYPTO_LIBRARIES "crypto")
+ endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
pkg_search_module(UDEV libudev REQUIRED)
@@ -237,6 +264,17 @@ else()
add_compile_options(-Wno-unused-parameter)
endif()
+ if(FUZZ)
+ set(USE_PCSC ON)
+ add_definitions(-DFIDO_FUZZ)
+ endif()
+
+ # If building with PCSC, look for pcsc-lite.
+ if(USE_PCSC AND NOT (APPLE OR CYGWIN OR MSYS OR MINGW))
+ pkg_search_module(PCSC libpcsclite REQUIRED)
+ set(PCSC_LIBRARIES pcsclite)
+ endif()
+
if(USE_HIDAPI)
add_definitions(-DUSE_HIDAPI)
pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED)
@@ -244,7 +282,7 @@ else()
endif()
if(NFC_LINUX)
- add_definitions(-DNFC_LINUX)
+ add_definitions(-DUSE_NFC)
endif()
if(WIN32)
@@ -263,16 +301,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()
@@ -285,12 +328,8 @@ else()
add_definitions(-DOPENSSL_API_COMPAT=0x10100000L)
endif()
- if(FUZZ)
- add_definitions(-DFIDO_FUZZ)
- endif()
-
- if(LIBFUZZER)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
+ if(NOT FUZZ)
+ set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wframe-larger-than=2047")
endif()
endif()
@@ -309,6 +348,10 @@ elseif(WIN32)
endif()
add_definitions(-DTLS=${TLS})
+if(USE_PCSC)
+ add_definitions(-DUSE_PCSC)
+endif()
+
# export list
if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
@@ -345,16 +388,18 @@ else()
" /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"")
endif()
-include_directories(${CMAKE_SOURCE_DIR}/src)
+include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${CBOR_INCLUDE_DIRS})
include_directories(${CRYPTO_INCLUDE_DIRS})
include_directories(${HIDAPI_INCLUDE_DIRS})
+include_directories(${PCSC_INCLUDE_DIRS})
include_directories(${UDEV_INCLUDE_DIRS})
include_directories(${ZLIB_INCLUDE_DIRS})
link_directories(${CBOR_LIBRARY_DIRS})
link_directories(${CRYPTO_LIBRARY_DIRS})
link_directories(${HIDAPI_LIBRARY_DIRS})
+link_directories(${PCSC_LIBRARY_DIRS})
link_directories(${UDEV_LIBRARY_DIRS})
link_directories(${ZLIB_LIBRARY_DIRS})
@@ -367,24 +412,41 @@ message(STATUS "BUILD_TOOLS: ${BUILD_TOOLS}")
message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}")
message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}")
message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}")
+if(BUILD_TESTS)
+ message(STATUS "CBOR_BIN_DIRS: ${CBOR_BIN_DIRS}")
+endif()
message(STATUS "CBOR_VERSION: ${CBOR_VERSION}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
+message(STATUS "CMAKE_CROSSCOMPILING: ${CMAKE_CROSSCOMPILING}")
+message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}")
+message(STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
+message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
+message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}")
message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}")
message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}")
+if(BUILD_TESTS)
+ message(STATUS "CRYPTO_BIN_DIRS: ${CRYPTO_BIN_DIRS}")
+endif()
message(STATUS "CRYPTO_VERSION: ${CRYPTO_VERSION}")
message(STATUS "FIDO_VERSION: ${FIDO_VERSION}")
message(STATUS "FUZZ: ${FUZZ}")
+if(FUZZ)
+ message(STATUS "FUZZ_LDFLAGS: ${FUZZ_LDFLAGS}")
+endif()
message(STATUS "ZLIB_INCLUDE_DIRS: ${ZLIB_INCLUDE_DIRS}")
message(STATUS "ZLIB_LIBRARIES: ${ZLIB_LIBRARIES}")
message(STATUS "ZLIB_LIBRARY_DIRS: ${ZLIB_LIBRARY_DIRS}")
+if(BUILD_TESTS)
+ message(STATUS "ZLIB_BIN_DIRS: ${ZLIB_BIN_DIRS}")
+endif()
message(STATUS "ZLIB_VERSION: ${ZLIB_VERSION}")
if(USE_HIDAPI)
message(STATUS "HIDAPI_INCLUDE_DIRS: ${HIDAPI_INCLUDE_DIRS}")
@@ -392,7 +454,10 @@ if(USE_HIDAPI)
message(STATUS "HIDAPI_LIBRARY_DIRS: ${HIDAPI_LIBRARY_DIRS}")
message(STATUS "HIDAPI_VERSION: ${HIDAPI_VERSION}")
endif()
-message(STATUS "LIBFUZZER: ${LIBFUZZER}")
+message(STATUS "PCSC_INCLUDE_DIRS: ${PCSC_INCLUDE_DIRS}")
+message(STATUS "PCSC_LIBRARIES: ${PCSC_LIBRARIES}")
+message(STATUS "PCSC_LIBRARY_DIRS: ${PCSC_LIBRARY_DIRS}")
+message(STATUS "PCSC_VERSION: ${PCSC_VERSION}")
message(STATUS "TLS: ${TLS}")
message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}")
message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}")
@@ -400,29 +465,34 @@ message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}")
message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}")
message(STATUS "UDEV_VERSION: ${UDEV_VERSION}")
message(STATUS "USE_HIDAPI: ${USE_HIDAPI}")
+message(STATUS "USE_PCSC: ${USE_PCSC}")
message(STATUS "USE_WINHELLO: ${USE_WINHELLO}")
message(STATUS "NFC_LINUX: ${NFC_LINUX}")
-subdirs(src)
+if(BUILD_TESTS)
+ enable_testing()
+endif()
+
+add_subdirectory(src)
+
+if(BUILD_TESTS)
+ add_subdirectory(regress)
+endif()
if(BUILD_EXAMPLES)
- subdirs(examples)
+ add_subdirectory(examples)
endif()
if(BUILD_TOOLS)
- subdirs(tools)
+ add_subdirectory(tools)
endif()
if(BUILD_MANPAGES)
- subdirs(man)
+ add_subdirectory(man)
endif()
if(NOT WIN32)
- if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT FUZZ)
- enable_testing()
- subdirs(regress)
- endif()
if(FUZZ)
- subdirs(fuzz)
+ add_subdirectory(fuzz)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- subdirs(udev)
+ add_subdirectory(udev)
endif()
endif()
diff --git a/contrib/libfido2/LICENSE b/contrib/libfido2/LICENSE
index 75a03f87e3af..ad0e13358930 100644
--- a/contrib/libfido2/LICENSE
+++ b/contrib/libfido2/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2018-2022 Yubico AB. All rights reserved.
+Copyright (c) 2018-2023 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
@@ -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
diff --git a/contrib/libfido2/NEWS b/contrib/libfido2/NEWS
index a48b685156c1..bf648aabfd92 100644
--- a/contrib/libfido2/NEWS
+++ b/contrib/libfido2/NEWS
@@ -1,3 +1,44 @@
+* Version 1.13.0 (2023-02-20)
+ ** Support for linking against OpenSSL on Windows; gh#668.
+ ** New API calls:
+ - fido_assert_empty_allow_list;
+ - fido_cred_empty_exclude_list.
+ ** fido2-token: fix issue when listing large blobs.
+ ** Improved support for different fuzzing engines.
+
+* 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.
+ ** Use RFC1951 raw deflate to compress CTAP 2.1 largeBlobs.
+ ** winhello: advertise "uv" instead of "clientPin".
+ ** winhello: support hmac-secret in fido_dev_get_assert().
+ ** New API calls:
+ - fido_cbor_info_maxlargeblob.
+ ** Documentation and reliability fixes.
+ ** Separate build and regress targets.
+
* Version 1.10.0 (2022-01-17)
** hid_osx: handle devices with paths > 511 bytes; gh#462.
** bio: fix CTAP2 canonical CBOR encoding in fido_bio_dev_enroll_*(); gh#480.
diff --git a/contrib/libfido2/README.adoc b/contrib/libfido2/README.adoc
index 114cc5eed762..44d559894dac 100644
--- a/contrib/libfido2/README.adoc
+++ b/contrib/libfido2/README.adoc
@@ -7,7 +7,7 @@ image:https://github.com/yubico/libfido2/workflows/fuzzer/badge.svg["Fuzz Status
image:https://oss-fuzz-build-logs.storage.googleapis.com/badges/libfido2.svg["Fuzz Status (oss-fuzz)", link="https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:libfido2"]
*libfido2* provides library functionality and command-line tools to
-communicate with a FIDO device over USB, and to verify attestation and
+communicate with a FIDO device over USB or NFC, and to verify attestation and
assertion signatures.
*libfido2* supports the FIDO U2F (CTAP 1) and FIDO2 (CTAP 2) protocols.
@@ -23,8 +23,6 @@ file for the full license text.
*libfido2* is known to work on Linux, macOS, Windows, OpenBSD, and FreeBSD.
-NFC support is available on Linux and Windows.
-
=== Documentation
Documentation is available in troff and HTML formats. An
@@ -38,19 +36,29 @@ is also available.
* Perl: https://github.com/jacquesg/p5-FIDO-Raw[p5-FIDO-Raw]
* Rust: https://github.com/PvdBerg1998/libfido2[libfido2]
+=== Releases
+
+The current release of *libfido2* is 1.13.0. Signed release tarballs are
+available at Yubico's
+https://developers.yubico.com/libfido2/Releases[release page].
+
+=== Dependencies
+
+*libfido2* depends on https://github.com/pjk/libcbor[libcbor],
+https://www.openssl.org[OpenSSL] 1.1 or newer, and https://zlib.net[zlib].
+On Linux, libudev
+(part of https://www.freedesktop.org/wiki/Software/systemd[systemd]) is also
+required.
+
=== Installation
-==== Releases
+==== Fedora 35 and 34
-The current release of *libfido2* is 1.10.0. Please consult Yubico's
-https://developers.yubico.com/libfido2/Releases[release page] for source
-and binary releases.
+ $ sudo dnf install libfido2 libfido2-devel fido2-tools
-==== Ubuntu 20.04 (Focal)
+==== Ubuntu 22.04 (Jammy) and 20.04 (Focal)
- $ sudo apt install libfido2-1
- $ sudo apt install libfido2-dev
- $ sudo apt install libfido2-doc
+ $ sudo apt install libfido2-1 libfido2-dev libfido2-doc fido2-tools
Alternatively, newer versions of *libfido2* are available in Yubico's PPA.
Follow the instructions for Ubuntu 18.04 (Bionic) below.
@@ -60,13 +68,31 @@ Follow the instructions for Ubuntu 18.04 (Bionic) below.
$ sudo apt install software-properties-common
$ sudo apt-add-repository ppa:yubico/stable
$ sudo apt update
- $ sudo apt install libfido2-dev
+ $ sudo apt install libfido2-1 libfido2-dev libfido2-doc fido2-tools
+
+On Linux, you may need to add a udev rule to be able to access the FIDO
+device. For example, the udev rule may contain the following:
+
+----
+#udev rule for allowing HID access to Yubico devices for FIDO support.
+
+KERNEL=="hidraw*", SUBSYSTEM=="hidraw", \
+ MODE="0664", GROUP="plugdev", ATTRS{idVendor}=="1050"
+----
==== macOS
$ brew install libfido2
-Or from source, on UNIX-like systems:
+==== Windows
+
+Please consult Yubico's
+https://developers.yubico.com/libfido2/Releases[release page] for ARM, ARM64,
+Win32, and Win64 artefacts.
+
+=== Building from source
+
+On UNIX-like systems:
$ cmake -B build
$ make -C build
@@ -74,23 +100,45 @@ Or from source, on UNIX-like systems:
Depending on the platform,
https://www.freedesktop.org/wiki/Software/pkg-config/[pkg-config] may need to
-be installed, or the PKG_CONFIG_PATH environment variable set.
-
-*libfido2* depends on https://github.com/pjk/libcbor[libcbor],
-https://www.openssl.org[OpenSSL] 1.1 or newer, and https://zlib.net[zlib].
-On Linux, libudev
-(part of https://www.freedesktop.org/wiki/Software/systemd[systemd]) is also
-required.
-
-For complete, OS-specific installation instructions, please refer to the
-`.actions/` (Linux, macOS) and `windows/` directories.
-
-On Linux, you will need to add a udev rule to be able to access the FIDO
-device, or run as root. For example, the udev rule may contain the following:
-
-----
-#udev rule for allowing HID access to Yubico devices for FIDO support.
-
-KERNEL=="hidraw*", SUBSYSTEM=="hidraw", \
- MODE="0664", GROUP="plugdev", ATTRS{idVendor}=="1050"
-----
+be installed, or the PKG_CONFIG_PATH environment variable set. For complete,
+OS-specific build instructions, please refer to the `.actions/`
+(Linux, macOS, BSD) and `windows/` directories.
+
+=== Build-time Customisation
+
+*libfido2* supports a number of CMake options. Some of the options require
+additional dependencies. Options that are disabled by default are not
+officially supported.
+
+[%autowidth.stretch]
+|===
+|*Option* |*Description* |*Default*
+| BUILD_EXAMPLES | Build example programs | ON
+| BUILD_MANPAGES | Build man pages | ON
+| BUILD_SHARED_LIBS | Build a shared library | ON
+| BUILD_STATIC_LIBS | Build a static library | ON
+| BUILD_TOOLS | Build auxiliary tools | ON
+| FUZZ | Enable fuzzing instrumentation | OFF
+| NFC_LINUX | Enable netlink NFC support on Linux | ON
+| USE_HIDAPI | Use hidapi as the HID backend | OFF
+| USE_PCSC | Enable experimental PCSC support | OFF
+| USE_WINHELLO | Abstract Windows Hello as a FIDO device | ON
+|===
+
+The USE_HIDAPI option requires https://github.com/libusb/hidapi[hidapi]. The
+USE_PCSC option requires https://github.com/LudovicRousseau/PCSC[pcsc-lite] on
+Linux.
+
+=== Development
+
+Please use https://github.com/Yubico/libfido2/discussions[GitHub Discussions]
+to ask questions and suggest features, and
+https://github.com/Yubico/libfido2/pulls[GitHub pull-requests] for code
+contributions.
+
+=== Reporting bugs
+
+Please use https://github.com/Yubico/libfido2/issues[GitHub Issues] to report
+bugs. To report security issues, please contact security@yubico.com. A PGP
+public key can be found at
+https://www.yubico.com/support/security-advisories/issue-rating-system/.
diff --git a/contrib/libfido2/examples/CMakeLists.txt b/contrib/libfido2/examples/CMakeLists.txt
index ad3d44faad6b..f013df4e71ec 100644
--- a/contrib/libfido2/examples/CMakeLists.txt
+++ b/contrib/libfido2/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
@@ -13,17 +14,6 @@ if(WIN32 AND BUILD_SHARED_LIBS AND NOT CYGWIN AND NOT MSYS)
list(APPEND COMPAT_SOURCES ../openbsd-compat/posix_win.c)
endif()
-# set the library to link against
-if(BUILD_STATIC_LIBS)
- # drop -rdynamic
- set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
- set(_FIDO2_LIBRARY fido2)
-elseif(BUILD_SHARED_LIBS)
- set(_FIDO2_LIBRARY fido2_shared)
-else()
- set(_FIDO2_LIBRARY ${CRYPTO_LIBRARIES} fido2)
-endif()
-
# enable -Wconversion -Wsign-conversion
if(NOT MSVC)
set_source_files_properties(assert.c cred.c info.c manifest.c reset.c
diff --git a/contrib/libfido2/examples/README.adoc b/contrib/libfido2/examples/README.adoc
index 44ee52743a0d..d44218c2cf87 100644
--- a/contrib/libfido2/examples/README.adoc
+++ b/contrib/libfido2/examples/README.adoc
@@ -20,8 +20,7 @@ The following definitions are used in the description below:
- <pubkey>
- The file system path of a file containing a NIST P-256 public key in
- PEM format.
+ The file system path of a file containing a public key in PEM format.
- <blobkey>
@@ -48,8 +47,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,14 +65,16 @@ 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
is verified using <pubkey>. The -p option requests that the user
- be present. User verification may be requested through the -v
- option. If option -u is specified, the assertion is generated using
+ be present and checks whether the user presence bit was signed by the
+ authenticator. The -v option requests user verification and checks
+ whether the user verification bit was signed by the authenticator.
+ If option -u is specified, the assertion is generated using
U2F (CTAP1) instead of FIDO2 (CTAP2) commands. If option -s is
specified, a FIDO2 hmac-secret is requested from the authenticator,
and the contents of <hmac_salt> are used as the salt. If option -h
diff --git a/contrib/libfido2/examples/assert.c b/contrib/libfido2/examples/assert.c
index 8b0dbd9f6eb2..32ba97b2fca3 100644
--- a/contrib/libfido2/examples/assert.c
+++ b/contrib/libfido2/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/contrib/libfido2/examples/cred.c b/contrib/libfido2/examples/cred.c
index 4a9d8bf4b25a..576900d97786 100644
--- a/contrib/libfido2/examples/cred.c
+++ b/contrib/libfido2/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/contrib/libfido2/examples/extern.h b/contrib/libfido2/examples/extern.h
index 5633b23d2003..5cffd7fbf882 100644
--- a/contrib/libfido2/examples/extern.h
+++ b/contrib/libfido2/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/contrib/libfido2/examples/info.c b/contrib/libfido2/examples/info.c
index 72b786a8bd83..a10a50cffb37 100644
--- a/contrib/libfido2/examples/info.c
+++ b/contrib/libfido2/examples/info.c
@@ -1,7 +1,8 @@
/*
- * Copyright (c) 2018 Yubico AB. All rights reserved.
+ * Copyright (c) 2018-2022 Yubico AB. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <fido.h>
@@ -104,6 +105,25 @@ print_opt_array(const char *label, char * const *name, const bool *value,
}
/*
+ * Auxiliary function to print (char *, uint64_t) pairs on stdout.
+ */
+static void
+print_cert_array(const char *label, char * const *name, const uint64_t *value,
+ size_t len)
+{
+ if (len == 0)
+ return;
+
+ printf("%s: ", label);
+
+ for (size_t i = 0; i < len; i++)
+ printf("%s%s %llu", i > 0 ? ", " : "", name[i],
+ (unsigned long long)value[i]);
+
+ printf("\n");
+}
+
+/*
* Auxiliary function to print a list of supported COSE algorithms on stdout.
*/
static void
@@ -120,15 +140,18 @@ print_algorithms(const fido_cbor_info_t *ci)
for (size_t i = 0; i < len; i++) {
cose = type = "unknown";
switch (fido_cbor_info_algorithm_cose(ci, i)) {
- case COSE_EDDSA:
- cose = "eddsa";
- break;
case COSE_ES256:
cose = "es256";
break;
+ case COSE_ES384:
+ cose = "es384";
+ break;
case COSE_RS256:
cose = "rs256";
break;
+ case COSE_EDDSA:
+ cose = "eddsa";
+ break;
}
if (fido_cbor_info_algorithm_type(ci, i) != NULL)
type = fido_cbor_info_algorithm_type(ci, i);
@@ -183,6 +206,51 @@ print_maxcredidlen(uint64_t maxcredidlen)
}
/*
+ * Auxiliary function to print the maximum size of an authenticator's
+ * serialized largeBlob array.
+ */
+static void
+print_maxlargeblob(uint64_t maxlargeblob)
+{
+ printf("maxlargeblob: %d\n", (int)maxlargeblob);
+}
+
+/*
+ * Auxiliary function to print the authenticator's estimated number of
+ * remaining resident credentials.
+ */
+static void
+print_rk_remaining(int64_t rk_remaining)
+{
+ printf("remaining rk(s): ");
+
+ if (rk_remaining == -1)
+ printf("undefined\n");
+ else
+ printf("%d\n", (int)rk_remaining);
+}
+
+/*
+ * Auxiliary function to print the minimum pin length observed by the
+ * authenticator.
+ */
+static void
+print_minpinlen(uint64_t minpinlen)
+{
+ printf("minpinlen: %d\n", (int)minpinlen);
+}
+
+/*
+ * Auxiliary function to print the authenticator's preferred (platform)
+ * UV attempts.
+ */
+static void
+print_uv_attempts(uint64_t uv_attempts)
+{
+ printf("platform uv attempt(s): %d\n", (int)uv_attempts);
+}
+
+/*
* Auxiliary function to print an authenticator's firmware version on stdout.
*/
static void
@@ -255,6 +323,14 @@ getinfo(const char *path)
fido_cbor_info_options_value_ptr(ci),
fido_cbor_info_options_len(ci));
+ /* print certifications */
+ print_cert_array("certifications", fido_cbor_info_certs_name_ptr(ci),
+ fido_cbor_info_certs_value_ptr(ci),
+ fido_cbor_info_certs_len(ci));
+
+ /* print firmware version */
+ print_fwversion(fido_cbor_info_fwversion(ci));
+
/* print maximum message size */
print_maxmsgsiz(fido_cbor_info_maxmsgsiz(ci));
@@ -264,13 +340,26 @@ getinfo(const char *path)
/* print maximum length of a credential ID */
print_maxcredidlen(fido_cbor_info_maxcredidlen(ci));
- /* print firmware version */
- print_fwversion(fido_cbor_info_fwversion(ci));
+ /* print maximum length of largeBlob array */
+ print_maxlargeblob(fido_cbor_info_maxlargeblob(ci));
+
+ /* print number of remaining resident credentials */
+ print_rk_remaining(fido_cbor_info_rk_remaining(ci));
+
+ /* print minimum pin length */
+ print_minpinlen(fido_cbor_info_minpinlen(ci));
/* print supported pin protocols */
print_byte_array("pin protocols", fido_cbor_info_protocols_ptr(ci),
fido_cbor_info_protocols_len(ci));
+ /* print whether a new pin is required */
+ printf("pin change required: %s\n",
+ fido_cbor_info_new_pin_required(ci) ? "true" : "false");
+
+ /* print platform uv attempts */
+ print_uv_attempts(fido_cbor_info_uv_attempts(ci));
+
fido_cbor_info_free(&ci);
end:
if ((r = fido_dev_close(dev)) != FIDO_OK)
diff --git a/contrib/libfido2/examples/manifest.c b/contrib/libfido2/examples/manifest.c
index d38166a9fea9..c2b3bf19137b 100644
--- a/contrib/libfido2/examples/manifest.c
+++ b/contrib/libfido2/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/contrib/libfido2/examples/reset.c b/contrib/libfido2/examples/reset.c
index b429d05f0fe4..767a162b6f63 100644
--- a/contrib/libfido2/examples/reset.c
+++ b/contrib/libfido2/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/contrib/libfido2/examples/retries.c b/contrib/libfido2/examples/retries.c
index b96118b1e154..a0610fe13903 100644
--- a/contrib/libfido2/examples/retries.c
+++ b/contrib/libfido2/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/contrib/libfido2/examples/select.c b/contrib/libfido2/examples/select.c
index 6ede9b490a95..008eb2e99b8f 100644
--- a/contrib/libfido2/examples/select.c
+++ b/contrib/libfido2/examples/select.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 <errno.h>
@@ -23,7 +24,7 @@ nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
return (-1);
}
- Sleep(rqtp->tv_nsec / 1000000);
+ Sleep((DWORD)(rqtp->tv_sec * 1000) + (DWORD)(rqtp->tv_nsec / 1000000));
return (0);
}
diff --git a/contrib/libfido2/examples/setpin.c b/contrib/libfido2/examples/setpin.c
index 4b9e792769d9..72e08e4b9088 100644
--- a/contrib/libfido2/examples/setpin.c
+++ b/contrib/libfido2/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
*/
/*
@@ -29,7 +30,7 @@ setpin(const char *path, const char *pin, const char *oldpin)
errx(1, "fido_dev_open: %s (0x%x)", fido_strerr(r), r);
if ((r = fido_dev_set_pin(dev, pin, oldpin)) != FIDO_OK)
- errx(1, "fido_setpin: %s (0x%x)", fido_strerr(r), r);
+ errx(1, "fido_dev_set_pin: %s (0x%x)", fido_strerr(r), r);
if ((r = fido_dev_close(dev)) != FIDO_OK)
errx(1, "fido_dev_close: %s (0x%x)", fido_strerr(r), r);
diff --git a/contrib/libfido2/examples/util.c b/contrib/libfido2/examples/util.c
index 8b360af21c7a..0c0c77a94001 100644
--- a/contrib/libfido2/examples/util.c
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/CMakeLists.txt b/contrib/libfido2/fuzz/CMakeLists.txt
index b1eebd55481b..cc30baae88f2 100644
--- a/contrib/libfido2/fuzz/CMakeLists.txt
+++ b/contrib/libfido2/fuzz/CMakeLists.txt
@@ -1,6 +1,7 @@
-# Copyright (c) 2019 Yubico AB. All rights reserved.
+# Copyright (c) 2019-2023 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
@@ -12,52 +13,70 @@ list(APPEND COMMON_SOURCES
mutator_aux.c
)
-set(FUZZ_LDFLAGS "-fsanitize=fuzzer")
+# XXX: OSS-Fuzz require linking using CXX
+set(FUZZ_LINKER_LANGUAGE "C" CACHE STRING "Linker language for fuzz harnesses")
+mark_as_advanced(FUZZ_LINKER_LANGUAGE)
+enable_language(${FUZZ_LINKER_LANGUAGE})
# fuzz_cred
add_executable(fuzz_cred fuzz_cred.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_cred PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_cred PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_cred PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_cred fido2_shared)
# fuzz_assert
add_executable(fuzz_assert fuzz_assert.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_assert PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_assert PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_assert PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_assert fido2_shared)
# fuzz_mgmt
add_executable(fuzz_mgmt fuzz_mgmt.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_mgmt PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_mgmt PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_mgmt PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_mgmt fido2_shared)
# fuzz_credman
add_executable(fuzz_credman fuzz_credman.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_credman PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_credman PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_credman PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_credman fido2_shared)
# fuzz_bio
add_executable(fuzz_bio fuzz_bio.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_bio PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_bio PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_bio PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_bio fido2_shared)
# fuzz_hid
add_executable(fuzz_hid fuzz_hid.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_hid PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_hid PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_hid PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_hid fido2_shared)
# fuzz_netlink
add_executable(fuzz_netlink fuzz_netlink.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_netlink PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_netlink PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_netlink PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_netlink fido2_shared)
# fuzz_largeblob
add_executable(fuzz_largeblob fuzz_largeblob.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
-target_compile_options(fuzz_largeblob PRIVATE ${FUZZ_LDFLAGS})
-set_target_properties(fuzz_largeblob PROPERTIES LINK_FLAGS ${FUZZ_LDFLAGS})
+set_target_properties(fuzz_largeblob PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
target_link_libraries(fuzz_largeblob fido2_shared)
+
+# fuzz_pcsc
+add_executable(fuzz_pcsc fuzz_pcsc.c ${COMMON_SOURCES} ${COMPAT_SOURCES})
+set_target_properties(fuzz_pcsc PROPERTIES
+ LINK_FLAGS ${FUZZ_LDFLAGS}
+ LINKER_LANGUAGE ${FUZZ_LINKER_LANGUAGE})
+target_link_libraries(fuzz_pcsc fido2_shared)
diff --git a/contrib/libfido2/fuzz/Dockerfile b/contrib/libfido2/fuzz/Dockerfile
index aefe1980ada4..9cda37589b44 100644
--- a/contrib/libfido2/fuzz/Dockerfile
+++ b/contrib/libfido2/fuzz/Dockerfile
@@ -1,12 +1,16 @@
-# Copyright (c) 2019-2021 Yubico AB. All rights reserved.
+# Copyright (c) 2019-2023 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
-RUN apt-get update
-RUN apt-get install -y clang-12 cmake git libssl-dev libudev-dev make pkg-config
-RUN apt-get install -y zlib1g-dev
-RUN git clone --branch v0.9.0 https://github.com/PJK/libcbor
-RUN git clone https://github.com/yubico/libfido2
-RUN CC=clang-12 CXX=clang++-12 /libfido2/fuzz/build-coverage /libcbor /libfido2
+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.10.1 --depth=1 https://github.com/PJK/libcbor
+RUN git clone --depth=1 https://github.com/yubico/libfido2
+WORKDIR /libfido2
+RUN ./fuzz/build-coverage /libcbor /libfido2
diff --git a/contrib/libfido2/fuzz/Makefile b/contrib/libfido2/fuzz/Makefile
index ce3fee73c69c..0e6756f0ada1 100644
--- a/contrib/libfido2/fuzz/Makefile
+++ b/contrib/libfido2/fuzz/Makefile
@@ -1,13 +1,14 @@
-# Copyright (c) 2019-2021 Yubico AB. All rights reserved.
+# Copyright (c) 2019-2023 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.10.0
+IMAGE := libfido2-coverage:1.13.1
RUNNER := libfido2-runner
-PROFDATA := llvm-profdata-12
-COV := llvm-cov-12
+PROFDATA := llvm-profdata
+COV := llvm-cov
TARGETS := fuzz_assert fuzz_bio fuzz_cred fuzz_credman fuzz_hid \
- fuzz_largeblob fuzz_netlink fuzz_mgmt
+ fuzz_largeblob fuzz_netlink fuzz_mgmt fuzz_pcsc
CORPORA := $(foreach f,${TARGETS},${f}/corpus)
MINIFY := $(foreach f,${TARGETS},/minify/${f}/corpus)
REMOTE := gs://libfido2-corpus.clusterfuzz-external.appspot.com
@@ -24,7 +25,7 @@ run: build
sync: run
tar Ccf .. - src fuzz | docker exec -i ${RUNNER} tar Cxf /libfido2 -
- docker exec ${RUNNER} make -C libfido2/build
+ docker exec ${RUNNER} make -C /libfido2/build
corpus: sync
docker exec ${RUNNER} /bin/sh -c 'cd /libfido2/fuzz && rm -rf ${TARGETS}'
@@ -45,23 +46,24 @@ corpus.tgz-: ${MINIFY}
profdata: run
docker exec ${RUNNER} /bin/sh -c 'rm -f /$@ && ${PROFDATA} \
- merge -sparse profraw/* -o $@'
+ merge -sparse /profraw/* -o /$@'
report.tgz: profdata
docker exec ${RUNNER} /bin/sh -c 'rm -rf /report && mkdir /report && \
${COV} show -format=html -tab-size=8 -instr-profile=/$< \
- --show-branch-summary=false -output-dir=/report \
- /libfido2/build/src/libfido2.so'
+ -ignore-filename-regex=pcsclite.h --show-branch-summary=false \
+ -output-dir=/report /libfido2/build/src/libfido2.so'
docker exec -i ${RUNNER} tar Czcf / - report > $@
summary.txt: profdata
docker exec ${RUNNER} ${COV} report -use-color=false \
- --show-branch-summary=false /libfido2/build/src/libfido2.so \
- -instr-profile=/$< > $@
+ -ignore-filename-regex=pcsclite.h --show-branch-summary=false \
+ /libfido2/build/src/libfido2.so -instr-profile=/$< > $@
functions.txt: profdata
docker exec ${RUNNER} /bin/sh -c '${COV} report -use-color=false \
- -show-functions --show-branch-summary=false -instr-profile=/$< \
+ -ignore-filename-regex=pcsclite.h -show-functions \
+ --show-branch-summary=false -instr-profile=/$< \
/libfido2/build/src/libfido2.so /libfido2/src/*.[ch]' > $@
clean: run
@@ -74,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/contrib/libfido2/fuzz/README b/contrib/libfido2/fuzz/README
index 28fc7f8f51b2..427625c6e714 100644
--- a/contrib/libfido2/fuzz/README
+++ b/contrib/libfido2/fuzz/README
@@ -8,26 +8,36 @@ use preload-fuzz.c to read device data from stdin.
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.
+harnesses, use -DCMAKE_C_FLAGS=-fsanitize=fuzzer-no-link
+-DFUZZ_LDFLAGS=-fsanitize=fuzzer -DFUZZ=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
the OS level (e.g. cgroups on Linux), or patch libcbor with the diff below.
+N.B., the patch below is relative to libcbor 0.10.1.
diff --git src/cbor/internal/memory_utils.c src/cbor/internal/memory_utils.c
-index aa049a2..e294b38 100644
+index bbea63c..3f7c9af 100644
--- src/cbor/internal/memory_utils.c
+++ src/cbor/internal/memory_utils.c
-@@ -28,7 +28,10 @@ bool _cbor_safe_to_multiply(size_t a, size_t b) {
+@@ -41,7 +41,11 @@ size_t _cbor_safe_signaling_add(size_t a, size_t b) {
void* _cbor_alloc_multiple(size_t item_size, size_t item_count) {
if (_cbor_safe_to_multiply(item_size, item_count)) {
-- return _CBOR_MALLOC(item_size * item_count);
+- return _cbor_malloc(item_size * item_count);
+ if (item_count > 1000) {
+ return NULL;
-+ } else
-+ return _CBOR_MALLOC(item_size * item_count);
++ } else {
++ return _cbor_malloc(item_size * item_count);
++ }
} else {
return NULL;
}
diff --git a/contrib/libfido2/fuzz/build-coverage b/contrib/libfido2/fuzz/build-coverage
index e0e90da02b5d..6cc5041a1db2 100755
--- a/contrib/libfido2/fuzz/build-coverage
+++ b/contrib/libfido2/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"
@@ -25,7 +26,9 @@ make -C "${LIBCBOR}/build" VERBOSE=1 all install
# Build libfido2.
mkdir -p "${LIBFIDO2}/build"
export CFLAGS="-fprofile-instr-generate -fcoverage-mapping"
+export CFLAGS="${CFLAGS} -fsanitize=fuzzer-no-link"
export LDFLAGS="${CFLAGS}"
-(cd "${LIBFIDO2}/build" && cmake -DFUZZ=ON -DLIBFUZZER=ON \
- -DCMAKE_BUILD_TYPE=Debug ..)
+export FUZZ_LDFLAGS="${LDFLAGS} -fsanitize=fuzzer"
+(cd "${LIBFIDO2}/build" && cmake -DFUZZ=ON -DFUZZ_LDFLAGS="${FUZZ_LDFLAGS}" \
+ -DCMAKE_BUILD_TYPE=Debug ..)
make -C "${LIBFIDO2}/build"
diff --git a/contrib/libfido2/fuzz/clock.c b/contrib/libfido2/fuzz/clock.c
index 23803c2ee3e5..bd758ea1a497 100644
--- a/contrib/libfido2/fuzz/clock.c
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/dummy.h b/contrib/libfido2/fuzz/dummy.h
index 95744eba634b..fc4bfc5ada4b 100644
--- a/contrib/libfido2/fuzz/dummy.h
+++ b/contrib/libfido2/fuzz/dummy.h
@@ -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
*/
#ifndef _DUMMY_H
@@ -18,6 +19,8 @@ const char dummy_rp_name[] = "sweet home localhost";
const char dummy_user_icon[] = "an icon";
const char dummy_user_name[] = "john smith";
const char dummy_user_nick[] = "jsmith";
+const char dummy_pcsc_list[] = "reader1\0reader2\0reader3\0\0";
+const char dummy_pcsc_path[] = "pcsc://slot7";
const uint8_t dummy_id[] = { 0x5e, 0xd2 };
const uint8_t dummy_user_id[] = {
diff --git a/contrib/libfido2/fuzz/export.gnu b/contrib/libfido2/fuzz/export.gnu
index cac142ae970e..f0fb840dd686 100644
--- a/contrib/libfido2/fuzz/export.gnu
+++ b/contrib/libfido2/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,22 +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_maxmsgsiz;
+ fido_cbor_info_fwversion;
fido_cbor_info_maxcredbloblen;
fido_cbor_info_maxcredcntlst;
fido_cbor_info_maxcredidlen;
- fido_cbor_info_fwversion;
+ fido_cbor_info_maxlargeblob;
+ fido_cbor_info_maxmsgsiz;
+ 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;
@@ -212,6 +228,7 @@
fido_dev_protocol;
fido_dev_reset;
fido_dev_set_io_functions;
+ fido_dev_set_pcsc;
fido_dev_set_pin;
fido_dev_set_pin_minlen;
fido_dev_set_pin_minlen_rpid;
@@ -237,6 +254,13 @@
fido_nl_get_nfc_target;
fido_nl_new;
fido_nl_power_nfc;
+ fido_pcsc_close;
+ fido_pcsc_manifest;
+ fido_pcsc_open;
+ fido_pcsc_read;
+ fido_pcsc_rx;
+ fido_pcsc_tx;
+ fido_pcsc_write;
fido_set_log_handler;
fido_strerr;
rs256_pk_free;
@@ -246,8 +270,12 @@
rs256_pk_new;
rs256_pk_to_EVP_PKEY;
prng_init;
+ prng_up;
fuzz_clock_reset;
+ fuzz_save_corpus;
set_netlink_io_functions;
+ set_pcsc_parameters;
+ set_pcsc_io_functions;
set_udev_parameters;
uniform_random;
local:
diff --git a/contrib/libfido2/fuzz/functions.txt b/contrib/libfido2/fuzz/functions.txt
index 946682d07d00..da7f058d6c00 100644
--- a/contrib/libfido2/fuzz/functions.txt
+++ b/contrib/libfido2/fuzz/functions.txt
@@ -1,24 +1,24 @@
File '/libfido2/src/aes256.c':
Name Regions Miss Cover Lines Miss Cover
--------------------------------------------------------------------------------------------------------
-aes256_cbc_enc 3 0 100.00% 4 0 100.00%
-aes256_cbc_dec 3 0 100.00% 4 0 100.00%
+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 51 1 98.04% 60 4 93.33%
+aes256.c:aes256_gcm 52 1 98.08% 60 4 93.33%
--------------------------------------------------------------------------------------------------------
-TOTAL 115 4 96.52% 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 5 92.54%
+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%
@@ -26,7 +26,7 @@ fido_assert_set_hmac_secret 12 12 0.00% 7 7
fido_assert_set_rp 12 0 100.00% 11 0 100.00%
fido_assert_allow_cred 13 2 84.62% 22 3 86.36%
fido_assert_set_extensions 14 0 100.00% 10 0 100.00%
-fido_assert_set_options 6 6 0.00% 5 5 0.00%
+fido_assert_set_options 8 8 0.00% 5 5 0.00%
fido_assert_set_up 2 0 100.00% 4 0 100.00%
fido_assert_set_uv 2 0 100.00% 4 0 100.00%
fido_assert_clientdata_hash_ptr 1 0 100.00% 3 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 563 40 92.90% 694 40 94.24%
+TOTAL 605 43 92.89% 745 46 93.83%
File '/libfido2/src/authkey.c':
Name Regions Miss Cover Lines Miss Cover
@@ -80,18 +83,18 @@ 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
-----------------------------------------------------------------------------------------------------------------
-fido_bio_dev_get_template_array 5 2 60.00% 6 0 100.00%
+fido_bio_dev_get_template_array 5 2 60.00% 6 1 83.33%
fido_bio_dev_set_template_name 7 0 100.00% 6 0 100.00%
-fido_bio_dev_enroll_begin 25 2 92.00% 31 0 100.00%
-fido_bio_dev_enroll_continue 5 2 60.00% 6 0 100.00%
+fido_bio_dev_enroll_begin 25 2 92.00% 31 1 96.77%
+fido_bio_dev_enroll_continue 5 2 60.00% 6 1 83.33%
fido_bio_dev_enroll_cancel 1 1 0.00% 4 4 0.00%
fido_bio_dev_enroll_remove 1 0 100.00% 4 0 100.00%
fido_bio_dev_get_info 1 0 100.00% 4 0 100.00%
@@ -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 21 96.24%
+TOTAL 451 20 95.57% 587 24 95.91%
File '/libfido2/src/blob.c':
Name Regions Miss Cover Lines Miss Cover
@@ -187,12 +190,12 @@ cbor_encode_str_array 18 0 100.00% 19 0
cbor_encode_cred_ext 55 0 100.00% 50 0 100.00%
cbor_encode_cred_opt 13 0 100.00% 11 0 100.00%
cbor_encode_assert_opt 13 0 100.00% 11 0 100.00%
-cbor_encode_pin_auth 20 1 95.00% 22 3 86.36%
+cbor_encode_pin_auth 21 1 95.24% 22 3 86.36%
cbor_encode_pin_opt 4 0 100.00% 8 0 100.00%
-cbor_encode_change_pin_auth 31 1 96.77% 36 3 91.67%
+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,41 @@ 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_build_uint 10 1 90.00% 9 2 77.78%
+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 1047 23 97.80% 1237 46 96.28%
+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 1 0 100.00% 3 0 100.00%
-compress.c:do_compress 32 4 87.50% 22 3 86.36%
+fido_uncompress 6 0 100.00% 5 0 100.00%
+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 8 78.95% 45 14 68.89%
------------------------------------------------------------------------------------------------------------------
-TOTAL 34 4 88.24% 28 3 89.29%
+TOTAL 105 14 86.67% 122 24 80.33%
File '/libfido2/src/config.c':
Name Regions Miss Cover Lines Miss Cover
@@ -242,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 5 93.06%
-fido_cred_verify_self 58 4 93.10% 83 5 93.98%
+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%
@@ -273,14 +279,14 @@ fido_cred_set_clientdata_hash 8 0 100.00% 6
fido_cred_set_rp 18 0 100.00% 22 0 100.00%
fido_cred_set_user 32 0 100.00% 41 0 100.00%
fido_cred_set_extensions 16 0 100.00% 10 0 100.00%
-fido_cred_set_options 6 6 0.00% 5 5 0.00%
+fido_cred_set_options 8 8 0.00% 5 5 0.00%
fido_cred_set_rk 2 0 100.00% 4 0 100.00%
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_fmt 20 4 80.00% 12 1 91.67%
-fido_cred_set_type 17 0 100.00% 7 0 100.00%
+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 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%
@@ -296,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%
@@ -318,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 5 87.50%
+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 632 34 94.62% 830 36 95.66%
+TOTAL 651 38 94.16% 849 43 94.94%
File '/libfido2/src/credman.c':
Name Regions Miss Cover Lines Miss Cover
@@ -334,15 +340,15 @@ fido_credman_del_dev_rk 1 0 100.00% 4
fido_credman_get_dev_rp 1 0 100.00% 4 0 100.00%
fido_credman_set_dev_rk 1 0 100.00% 4 0 100.00%
fido_credman_rk_new 1 0 100.00% 3 0 100.00%
-fido_credman_rk_free 6 1 83.33% 8 0 100.00%
+fido_credman_rk_free 6 1 83.33% 8 1 87.50%
fido_credman_rk_count 1 0 100.00% 3 0 100.00%
fido_credman_rk 4 0 100.00% 5 0 100.00%
fido_credman_metadata_new 1 0 100.00% 3 0 100.00%
-fido_credman_metadata_free 6 1 83.33% 7 0 100.00%
+fido_credman_metadata_free 6 1 83.33% 7 1 85.71%
fido_credman_rk_existing 1 0 100.00% 3 0 100.00%
fido_credman_rk_remaining 1 0 100.00% 3 0 100.00%
fido_credman_rp_new 1 0 100.00% 3 0 100.00%
-fido_credman_rp_free 6 1 83.33% 8 0 100.00%
+fido_credman_rp_free 6 1 83.33% 8 1 87.50%
fido_credman_rp_count 1 0 100.00% 3 0 100.00%
fido_credman_rp_id 4 0 100.00% 5 0 100.00%
fido_credman_rp_name 4 0 100.00% 5 0 100.00%
@@ -351,39 +357,35 @@ 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 15 97.10%
+TOTAL 422 10 97.63% 557 20 96.41%
File '/libfido2/src/dev.c':
Name Regions Miss Cover Lines Miss Cover
-------------------------------------------------------------------------------------------------------------------
-fido_dev_register_manifest_func 10 2 80.00% 14 3 78.57%
-fido_dev_unregister_manifest_func 7 7 0.00% 11 11 0.00%
-fido_dev_info_manifest 22 4 81.82% 24 0 100.00%
+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 5 1 80.00% 19 12 36.84%
-fido_dev_close 9 2 77.78% 8 0 100.00%
+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%
-fido_dev_get_touch_begin 50 0 100.00% 59 0 100.00%
-fido_dev_get_touch_status 17 0 100.00% 20 0 100.00%
fido_dev_set_io_functions 18 4 77.78% 14 6 57.14%
fido_dev_set_transport_functions 6 2 66.67% 9 3 66.67%
fido_dev_io_handle 1 1 0.00% 3 3 0.00%
@@ -410,17 +412,17 @@ fido_dev_force_fido2 2 2 0.00% 3
fido_dev_get_pin_protocol 11 0 100.00% 7 0 100.00%
fido_dev_maxmsgsize 1 0 100.00% 3 0 100.00%
fido_dev_set_timeout 6 2 66.67% 6 1 83.33%
-dev.c:find_manifest_func_node 5 0 100.00% 8 0 100.00%
+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%
dev.c:fido_dev_set_extension_flags 7 0 100.00% 7 0 100.00%
-dev.c:fido_dev_set_option_flags 29 0 100.00% 18 0 100.00%
+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 421 79 81.24% 491 105 78.62%
+TOTAL 332 65 80.42% 378 80 78.84%
File '/libfido2/src/ecdh.c':
Name Regions Miss Cover Lines Miss Cover
@@ -438,15 +440,15 @@ Name Regions Miss Cover Lines Mis
eddsa_pk_decode 8 0 100.00% 9 0 100.00%
eddsa_pk_new 1 0 100.00% 3 0 100.00%
eddsa_pk_free 6 0 100.00% 7 0 100.00%
-eddsa_pk_from_ptr 6 0 100.00% 6 0 100.00%
+eddsa_pk_from_ptr 10 0 100.00% 12 0 100.00%
eddsa_pk_to_EVP_PKEY 3 0 100.00% 7 0 100.00%
-eddsa_pk_from_EVP_PKEY 14 0 100.00% 10 0 100.00%
+eddsa_pk_from_EVP_PKEY 18 2 88.89% 12 1 91.67%
eddsa_verify_sig 19 2 89.47% 30 6 80.00%
eddsa_pk_verify_sig 7 1 85.71% 13 2 84.62%
eddsa.c:decode_pubkey_point 8 0 100.00% 11 0 100.00%
eddsa.c:decode_coord 8 0 100.00% 10 0 100.00%
-------------------------------------------------------------------------------------------------------------------
-TOTAL 80 3 96.25% 106 8 92.45%
+TOTAL 88 5 94.32% 114 9 92.11%
File '/libfido2/src/err.c':
Name Regions Miss Cover Lines Miss Cover
@@ -464,26 +466,47 @@ es256_sk_new 1 0 100.00% 3
es256_sk_free 6 0 100.00% 7 0 100.00%
es256_pk_new 1 0 100.00% 3 0 100.00%
es256_pk_free 6 0 100.00% 7 0 100.00%
-es256_pk_from_ptr 11 0 100.00% 10 0 100.00%
+es256_pk_from_ptr 15 0 100.00% 17 0 100.00%
es256_pk_set_x 1 0 100.00% 4 0 100.00%
es256_pk_set_y 1 0 100.00% 4 0 100.00%
-es256_sk_create 39 0 100.00% 41 0 100.00%
-es256_pk_to_EVP_PKEY 42 0 100.00% 54 0 100.00%
-es256_pk_from_EC_KEY 38 0 100.00% 36 0 100.00%
-es256_pk_from_EVP_PKEY 7 2 71.43% 7 0 100.00%
-es256_sk_to_EVP_PKEY 28 0 100.00% 40 0 100.00%
-es256_derive_pk 25 0 100.00% 30 0 100.00%
+es256_sk_create 39 0 100.00% 40 0 100.00%
+es256_pk_to_EVP_PKEY 42 0 100.00% 53 0 100.00%
+es256_pk_from_EC_KEY 42 2 95.24% 47 4 91.49%
+es256_pk_from_EVP_PKEY 8 2 75.00% 7 1 85.71%
+es256_sk_to_EVP_PKEY 28 0 100.00% 39 0 100.00%
+es256_derive_pk 25 0 100.00% 29 0 100.00%
es256_verify_sig 12 2 83.33% 19 5 73.68%
es256_pk_verify_sig 7 1 85.71% 13 2 84.62%
es256.c:decode_pubkey_point 9 0 100.00% 13 0 100.00%
es256.c:decode_coord 8 0 100.00% 10 0 100.00%
-------------------------------------------------------------------------------------------------------------------
-TOTAL 306 5 98.37% 358 7 98.04%
+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
-------------------------------------------------------------------------------------------------------------------
@@ -511,8 +534,8 @@ TOTAL 87 2 97.70% 145
File '/libfido2/src/hid_linux.c':
Name Regions Miss Cover Lines Miss Cover
-------------------------------------------------------------------------------------------------------------------
-fido_hid_manifest 35 4 88.57% 41 1 97.56%
-fido_hid_open 27 27 0.00% 40 40 0.00%
+fido_hid_manifest 35 4 88.57% 41 2 95.12%
+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%
@@ -520,29 +543,29 @@ 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 104 58.40%
+TOTAL 184 73 60.33% 263 115 56.27%
File '/libfido2/src/hid_unix.c':
Name Regions Miss Cover Lines Miss Cover
-------------------------------------------------------------------------------------------------------------------
fido_hid_unix_open 18 11 38.89% 22 14 36.36%
-fido_hid_unix_wait 10 9 10.00% 21 10 52.38%
+fido_hid_unix_wait 11 10 9.09% 21 12 42.86%
-------------------------------------------------------------------------------------------------------------------
-TOTAL 28 20 28.57% 43 24 44.19%
+TOTAL 29 21 27.59% 43 26 39.53%
File '/libfido2/src/info.c':
Name Regions Miss Cover Lines Miss Cover
-------------------------------------------------------------------------------------------------------------------
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,57 +582,69 @@ fido_cbor_info_maxcredbloblen 1 0 100.00% 3
fido_cbor_info_maxmsgsiz 1 0 100.00% 3 0 100.00%
fido_cbor_info_maxcredcntlst 1 0 100.00% 3 0 100.00%
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 19 0 100.00% 37 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 184 0 100.00% 316 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 13 0 100.00% 11 0 100.00%
+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%
io.c:tx 13 0 100.00% 19 0 100.00%
-io.c:tx_preamble 16 1 93.75% 20 1 95.00%
-io.c:tx_frame 15 1 93.33% 18 1 94.44%
+io.c:tx_preamble 17 1 94.12% 20 1 95.00%
+io.c:tx_frame 16 1 93.75% 18 1 94.44%
io.c:transport_rx 7 0 100.00% 10 0 100.00%
-io.c:rx 40 2 95.00% 52 1 98.08%
+io.c:rx 40 2 95.00% 52 2 96.15%
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 182 7 96.15% 221 11 95.02%
+TOTAL 193 7 96.37% 230 12 94.78%
File '/libfido2/src/iso7816.c':
Name Regions Miss Cover Lines Miss Cover
-------------------------------------------------------------------------------------------------------------------
iso7816_new 4 0 100.00% 16 0 100.00%
iso7816_free 6 0 100.00% 7 0 100.00%
-iso7816_add 6 1 83.33% 8 0 100.00%
+iso7816_add 6 1 83.33% 8 1 87.50%
iso7816_ptr 1 0 100.00% 3 0 100.00%
iso7816_len 1 0 100.00% 4 0 100.00%
-------------------------------------------------------------------------------------------------------------------
-TOTAL 18 1 94.44% 38 0 100.00%
+TOTAL 18 1 94.44% 38 1 97.37%
File '/libfido2/src/largeblob.c':
Name Regions Miss Cover Lines Miss Cover
@@ -620,23 +655,23 @@ fido_dev_largeblob_remove 12 0 100.00% 18
fido_dev_largeblob_get_array 15 2 86.67% 27 4 85.19%
fido_dev_largeblob_set_array 14 0 100.00% 19 0 100.00%
largeblob.c:largeblob_get_array 32 0 100.00% 36 0 100.00%
-largeblob.c:get_chunklen 9 1 88.89% 9 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%
largeblob.c:largeblob_array_load 14 2 85.71% 19 7 63.16%
largeblob.c:largeblob_array_lookup 25 0 100.00% 33 0 100.00%
largeblob.c:largeblob_decode 16 2 87.50% 16 6 62.50%
-largeblob.c:largeblob_do_decode 27 3 88.89% 30 5 83.33%
+largeblob.c:largeblob_do_decode 27 3 88.89% 30 7 76.67%
largeblob.c:largeblob_decrypt 15 0 100.00% 24 0 100.00%
largeblob.c:largeblob_aad 1 0 100.00% 10 0 100.00%
largeblob.c:largeblob_reset 1 0 100.00% 5 0 100.00%
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%
@@ -645,38 +680,38 @@ 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 513 19 96.30% 684 43 93.71%
+TOTAL 525 18 96.57% 693 43 93.80%
File '/libfido2/src/log.c':
Name Regions Miss Cover Lines Miss Cover
-------------------------------------------------------------------------------------------------------------------
fido_log_init 1 0 100.00% 4 0 100.00%
-fido_log_debug 6 1 83.33% 8 0 100.00%
-fido_log_xxd 16 1 93.75% 24 0 100.00%
-fido_log_error 8 2 75.00% 11 1 90.91%
+fido_log_debug 6 1 83.33% 8 1 87.50%
+fido_log_xxd 16 1 93.75% 24 1 95.83%
+fido_log_error 8 2 75.00% 11 2 81.82%
fido_set_log_handler 3 0 100.00% 4 0 100.00%
log.c:log_on_stderr 1 1 0.00% 3 3 0.00%
log.c:do_log 4 0 100.00% 9 0 100.00%
-------------------------------------------------------------------------------------------------------------------
-TOTAL 39 5 87.18% 63 4 93.65%
+TOTAL 39 5 87.18% 63 7 88.89%
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_free 10 2 80.00% 9 1 88.89%
+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%
netlink.c:nlmsg_new 8 0 100.00% 15 0 100.00%
netlink.c:nlmsg_set_genl 1 0 100.00% 7 0 100.00%
netlink.c:nlmsg_write 6 1 83.33% 7 1 85.71%
netlink.c:nlmsg_set_u32 1 0 100.00% 3 0 100.00%
-netlink.c:nlmsg_setattr 14 1 92.86% 17 0 100.00%
+netlink.c:nlmsg_setattr 15 1 93.33% 17 0 100.00%
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%
@@ -686,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%
@@ -704,36 +739,63 @@ 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 328 14 95.73% 498 32 93.57%
+TOTAL 329 8 97.57% 498 15 96.99%
-File '/libfido2/src/nfc_linux.c':
+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 1 87.50% 13 3 76.92%
-fido_nfc_manifest 35 5 85.71% 45 13 71.11%
-fido_nfc_open 20 3 85.00% 23 5 78.26%
+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 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%
+nfc.c:rx_cbor 4 0 100.00% 6 0 100.00%
+nfc.c:rx_msg 18 2 88.89% 23 6 73.91%
+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 155 5 96.77% 244 15 93.85%
+
+File '/libfido2/src/nfc_linux.c':
+Name Regions Miss Cover Lines Miss Cover
+-------------------------------------------------------------------------------------------------------------------
+fido_nfc_manifest 35 7 80.00% 45 15 66.67%
+fido_nfc_open 20 3 85.00% 23 4 82.61%
fido_nfc_close 1 1 0.00% 4 4 0.00%
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:nfc_do_tx 20 2 90.00% 25 6 76.00%
-nfc_linux.c:tx_short_apdu 14 0 100.00% 32 0 100.00%
-nfc_linux.c:rx_init 25 6 76.00% 27 5 81.48%
-nfc_linux.c:rx_cbor 4 0 100.00% 6 0 100.00%
-nfc_linux.c:rx_msg 18 2 88.89% 23 6 73.91%
-nfc_linux.c:rx_apdu 14 1 92.86% 22 3 86.36%
-nfc_linux.c:tx_get_response 4 0 100.00% 11 0 100.00%
-nfc_linux.c:copy_info 41 9 78.05% 44 3 93.18%
-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:to_int 21 6 71.43% 14 1 92.86%
-nfc_linux.c:sysnum_from_syspath 12 0 100.00% 17 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 327 73 77.68% 458 124 72.93%
+TOTAL 172 77 55.23% 242 126 47.93%
+
+File '/libfido2/src/pcsc.c':
+Name Regions Miss Cover Lines Miss Cover
+-------------------------------------------------------------------------------------------------------------------
+fido_pcsc_manifest 51 0 100.00% 55 0 100.00%
+fido_pcsc_open 32 0 100.00% 43 0 100.00%
+fido_pcsc_close 6 0 100.00% 9 0 100.00%
+fido_pcsc_read 8 0 100.00% 16 0 100.00%
+fido_pcsc_write 8 0 100.00% 22 0 100.00%
+fido_pcsc_tx 1 0 100.00% 3 0 100.00%
+fido_pcsc_rx 1 0 100.00% 3 0 100.00%
+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 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 204 1 99.51% 282 3 98.94%
File '/libfido2/src/pin.c':
Name Regions Miss Cover Lines Miss Cover
@@ -744,35 +806,35 @@ fido_dev_set_pin 1 0 100.00% 4
fido_dev_get_retry_count 1 0 100.00% 4 0 100.00%
fido_dev_get_uv_retry_count 1 0 100.00% 4 0 100.00%
cbor_add_uv_params 17 0 100.00% 23 0 100.00%
-pin.c:uv_token_wait 14 2 85.71% 12 0 100.00%
+pin.c:uv_token_wait 14 2 85.71% 12 1 91.67%
pin.c:ctap21_uv_token_tx 49 0 100.00% 53 0 100.00%
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 3 99.39%
+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
@@ -786,11 +848,11 @@ TOTAL 24 0 100.00% 23
File '/libfido2/src/rs1.c':
Name Regions Miss Cover Lines Miss Cover
---------------------------------------------------------------------------------------------------------------------
-rs1_verify_sig 20 0 100.00% 30 0 100.00%
+rs1_verify_sig 20 1 95.00% 30 3 90.00%
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 0 100.00% 39 0 100.00%
+TOTAL 25 1 96.00% 39 3 92.31%
File '/libfido2/src/rs256.c':
Name Regions Miss Cover Lines Miss Cover
@@ -798,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 0 100.00%
+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%
@@ -809,53 +871,62 @@ 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 10 94.19%
+TOTAL 149 10 93.29% 182 14 92.31%
File '/libfido2/src/time.c':
Name Regions Miss Cover Lines Miss Cover
---------------------------------------------------------------------------------------------------------------------
fido_time_now 4 0 100.00% 7 0 100.00%
fido_time_delta 23 1 95.65% 23 0 100.00%
-time.c:timespec_to_ms 16 2 87.50% 13 1 92.31%
+time.c:timespec_to_ms 16 2 87.50% 13 2 84.62%
---------------------------------------------------------------------------------------------------------------------
-TOTAL 43 3 93.02% 43 1 97.67%
+TOTAL 43 3 93.02% 43 2 95.35%
+
+File '/libfido2/src/touch.c':
+Name Regions Miss Cover Lines Miss Cover
+---------------------------------------------------------------------------------------------------------------------
+fido_dev_get_touch_begin 50 0 100.00% 59 0 100.00%
+fido_dev_get_touch_status 17 0 100.00% 20 0 100.00%
+---------------------------------------------------------------------------------------------------------------------
+TOTAL 67 0 100.00% 79 0 100.00%
File '/libfido2/src/tpm.c':
Name Regions Miss Cover Lines Miss Cover
---------------------------------------------------------------------------------------------------------------------
fido_get_signed_hash_tpm 25 0 100.00% 39 0 100.00%
-tpm.c:check_es256_pubarea 18 0 100.00% 30 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 16 0 100.00% 28 0 100.00%
+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 14 0 100.00% 38 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 100 0 100.00% 194 0 100.00%
+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%
@@ -864,8 +935,15 @@ 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
+---------------------------------------------------------------------------------------------------------------------
+fido_to_uint64 14 1 92.86% 14 1 92.86%
+---------------------------------------------------------------------------------------------------------------------
+TOTAL 14 1 92.86% 14 1 92.86%
diff --git a/contrib/libfido2/fuzz/fuzz_assert.c b/contrib/libfido2/fuzz/fuzz_assert.c
index 4331148b5e06..9f39f3d6ecb7 100644
--- a/contrib/libfido2/fuzz/fuzz_assert.c
+++ b/contrib/libfido2/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>
@@ -140,7 +141,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_bio.c b/contrib/libfido2/fuzz/fuzz_bio.c
index 49a50932a543..0c6b12c4b7c3 100644
--- a/contrib/libfido2/fuzz/fuzz_bio.c
+++ b/contrib/libfido2/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>
@@ -154,7 +155,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_cred.c b/contrib/libfido2/fuzz/fuzz_cred.c
index d7b630224054..497298f70290 100644
--- a/contrib/libfido2/fuzz/fuzz_cred.c
+++ b/contrib/libfido2/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>
@@ -150,7 +151,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_credman.c b/contrib/libfido2/fuzz/fuzz_credman.c
index fb34f22f8147..ef2147581564 100644
--- a/contrib/libfido2/fuzz/fuzz_credman.c
+++ b/contrib/libfido2/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>
@@ -141,7 +142,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_hid.c b/contrib/libfido2/fuzz/fuzz_hid.c
index eaf00dc92de8..daaadadf19bc 100644
--- a/contrib/libfido2/fuzz/fuzz_hid.c
+++ b/contrib/libfido2/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>
@@ -104,7 +105,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_largeblob.c b/contrib/libfido2/fuzz/fuzz_largeblob.c
index 3289ed46e2a7..6cdc0c0d57cb 100644
--- a/contrib/libfido2/fuzz/fuzz_largeblob.c
+++ b/contrib/libfido2/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>
@@ -118,7 +119,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_mgmt.c b/contrib/libfido2/fuzz/fuzz_mgmt.c
index 7c28979fb624..cbc313d1f793 100644
--- a/contrib/libfido2/fuzz/fuzz_mgmt.c
+++ b/contrib/libfido2/fuzz/fuzz_mgmt.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>
@@ -138,7 +139,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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,25 +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/contrib/libfido2/fuzz/fuzz_netlink.c b/contrib/libfido2/fuzz/fuzz_netlink.c
index 2447215a2471..4d28129c3567 100644
--- a/contrib/libfido2/fuzz/fuzz_netlink.c
+++ b/contrib/libfido2/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>
@@ -75,7 +76,7 @@ pack(uint8_t *ptr, size_t len, const struct param *p)
goto fail;
if ((cbor_len = cbor_serialize_alloc(array, &cbor,
- &cbor_alloc_len)) > len) {
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
cbor_len = 0;
goto fail;
}
@@ -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/contrib/libfido2/fuzz/fuzz_pcsc.c b/contrib/libfido2/fuzz/fuzz_pcsc.c
new file mode 100644
index 000000000000..cf6210b71be5
--- /dev/null
+++ b/contrib/libfido2/fuzz/fuzz_pcsc.c
@@ -0,0 +1,269 @@
+/*
+ * 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
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <winscard.h>
+
+#include "mutator_aux.h"
+#include "wiredata_fido2.h"
+#include "dummy.h"
+
+#include "../src/extern.h"
+
+struct param {
+ int seed;
+ char path[MAXSTR];
+ struct blob pcsc_list;
+ struct blob tx_apdu;
+ struct blob wiredata_init;
+ struct blob wiredata_msg;
+};
+
+static const uint8_t dummy_tx_apdu[] = { WIREDATA_CTAP_EXTENDED_APDU };
+static const uint8_t dummy_wiredata_init[] = { WIREDATA_CTAP_NFC_INIT };
+static const uint8_t dummy_wiredata_msg[] = { WIREDATA_CTAP_NFC_MSG };
+
+struct param *
+unpack(const uint8_t *ptr, size_t len)
+{
+ cbor_item_t *item = NULL, **v;
+ struct cbor_load_result cbor;
+ struct param *p;
+ int ok = -1;
+
+ if ((p = calloc(1, sizeof(*p))) == NULL ||
+ (item = cbor_load(ptr, len, &cbor)) == NULL ||
+ cbor.read != len ||
+ cbor_isa_array(item) == false ||
+ cbor_array_is_definite(item) == false ||
+ cbor_array_size(item) != 6 ||
+ (v = cbor_array_handle(item)) == NULL)
+ goto fail;
+
+ if (unpack_int(v[0], &p->seed) < 0 ||
+ unpack_string(v[1], p->path) < 0 ||
+ unpack_blob(v[2], &p->pcsc_list) < 0 ||
+ unpack_blob(v[3], &p->tx_apdu) < 0 ||
+ unpack_blob(v[4], &p->wiredata_init) < 0 ||
+ unpack_blob(v[5], &p->wiredata_msg) < 0)
+ goto fail;
+
+ ok = 0;
+fail:
+ if (ok < 0) {
+ free(p);
+ p = NULL;
+ }
+
+ if (item)
+ cbor_decref(&item);
+
+ return p;
+}
+
+size_t
+pack(uint8_t *ptr, size_t len, const struct param *p)
+{
+ cbor_item_t *argv[6], *array = NULL;
+ size_t cbor_alloc_len, cbor_len = 0;
+ unsigned char *cbor = NULL;
+
+ memset(argv, 0, sizeof(argv));
+
+ if ((array = cbor_new_definite_array(6)) == NULL ||
+ (argv[0] = pack_int(p->seed)) == NULL ||
+ (argv[1] = pack_string(p->path)) == NULL ||
+ (argv[2] = pack_blob(&p->pcsc_list)) == NULL ||
+ (argv[3] = pack_blob(&p->tx_apdu)) == NULL ||
+ (argv[4] = pack_blob(&p->wiredata_init)) == NULL ||
+ (argv[5] = pack_blob(&p->wiredata_msg)) == NULL)
+ goto fail;
+
+ for (size_t i = 0; i < 6; i++)
+ if (cbor_array_push(array, argv[i]) == false)
+ goto fail;
+
+ if ((cbor_len = cbor_serialize_alloc(array, &cbor,
+ &cbor_alloc_len)) == 0 || cbor_len > len) {
+ cbor_len = 0;
+ goto fail;
+ }
+
+ memcpy(ptr, cbor, cbor_len);
+fail:
+ for (size_t i = 0; i < 6; i++)
+ if (argv[i])
+ cbor_decref(&argv[i]);
+
+ if (array)
+ cbor_decref(&array);
+
+ free(cbor);
+
+ return cbor_len;
+}
+
+size_t
+pack_dummy(uint8_t *ptr, size_t len)
+{
+ struct param dummy;
+ uint8_t blob[MAXCORPUS];
+ size_t blob_len;
+
+ memset(&dummy, 0, sizeof(dummy));
+
+ strlcpy(dummy.path, dummy_pcsc_path, sizeof(dummy.path));
+
+ dummy.pcsc_list.len = sizeof(dummy_pcsc_list);
+ memcpy(&dummy.pcsc_list.body, &dummy_pcsc_list, dummy.pcsc_list.len);
+
+ dummy.tx_apdu.len = sizeof(dummy_tx_apdu);
+ memcpy(&dummy.tx_apdu.body, &dummy_tx_apdu, dummy.tx_apdu.len);
+
+ dummy.wiredata_init.len = sizeof(dummy_wiredata_init);
+ memcpy(&dummy.wiredata_init.body, &dummy_wiredata_init,
+ dummy.wiredata_init.len);
+
+ dummy.wiredata_msg.len = sizeof(dummy_wiredata_msg);
+ memcpy(&dummy.wiredata_msg.body, &dummy_wiredata_msg,
+ dummy.wiredata_msg.len);
+
+ assert((blob_len = pack(blob, sizeof(blob), &dummy)) != 0);
+
+ if (blob_len > len) {
+ memcpy(ptr, blob, len);
+ return len;
+ }
+
+ memcpy(ptr, blob, blob_len);
+
+ return blob_len;
+}
+
+static void
+test_manifest(void)
+{
+ size_t ndevs, nfound;
+ fido_dev_info_t *devlist = NULL;
+ int16_t vendor_id, product_id;
+ int r;
+
+ r = fido_pcsc_manifest(NULL, 0, &nfound);
+ assert(r == FIDO_OK && nfound == 0);
+ r = fido_pcsc_manifest(NULL, 1, &nfound);
+ assert(r == FIDO_ERR_INVALID_ARGUMENT);
+
+ ndevs = uniform_random(64);
+ if ((devlist = fido_dev_info_new(ndevs)) == NULL ||
+ fido_pcsc_manifest(devlist, ndevs, &nfound) != FIDO_OK)
+ goto out;
+
+ for (size_t i = 0; i < nfound; i++) {
+ const fido_dev_info_t *di = fido_dev_info_ptr(devlist, i);
+ consume_str(fido_dev_info_path(di));
+ consume_str(fido_dev_info_manufacturer_string(di));
+ consume_str(fido_dev_info_product_string(di));
+ vendor_id = fido_dev_info_vendor(di);
+ product_id = fido_dev_info_product(di);
+ consume(&vendor_id, sizeof(vendor_id));
+ consume(&product_id, sizeof(product_id));
+ }
+
+out:
+ fido_dev_info_free(&devlist, ndevs);
+}
+
+static void
+test_tx(const char *path, const struct blob *apdu, uint8_t cmd, u_char *rx_buf,
+ size_t rx_len)
+{
+ fido_dev_t dev;
+ const u_char *tx_ptr = NULL;
+ size_t tx_len = 0;
+ int n;
+
+ memset(&dev, 0, sizeof(dev));
+
+ if (fido_dev_set_pcsc(&dev) < 0)
+ return;
+ if ((dev.io_handle = fido_pcsc_open(path)) == NULL)
+ return;
+
+ if (apdu) {
+ tx_ptr = apdu->body;
+ tx_len = apdu->len;
+ }
+
+ fido_pcsc_tx(&dev, cmd, tx_ptr, tx_len);
+
+ if ((n = fido_pcsc_rx(&dev, cmd, rx_buf, rx_len, -1)) >= 0)
+ consume(rx_buf, n);
+
+ fido_pcsc_close(dev.io_handle);
+}
+
+static void
+test_misc(void)
+{
+ assert(fido_pcsc_open(NULL) == NULL);
+ assert(fido_pcsc_write(NULL, NULL, INT_MAX + 1LL) == -1);
+}
+
+void
+test(const struct param *p)
+{
+ u_char buf[512];
+
+ prng_init((unsigned int)p->seed);
+ fuzz_clock_reset();
+ fido_init(FIDO_DEBUG);
+ fido_set_log_handler(consume_str);
+
+ 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);
+ test_tx(p->path, NULL, CTAP_CMD_INIT, buf, uniform_random(20));
+
+ set_wire_data(p->wiredata_msg.body, p->wiredata_msg.len);
+ test_tx(p->path, &p->tx_apdu, CTAP_CMD_MSG, buf, sizeof(buf));
+
+ set_wire_data(p->wiredata_msg.body, p->wiredata_msg.len);
+ test_tx(p->path, &p->tx_apdu, CTAP_CMD_CBOR, buf, sizeof(buf));
+
+ set_wire_data(p->wiredata_msg.body, p->wiredata_msg.len);
+ test_tx(p->path, &p->tx_apdu, CTAP_CMD_LOCK, buf, sizeof(buf));
+}
+
+void
+mutate(struct param *p, unsigned int seed, unsigned int flags) NO_MSAN
+{
+ if (flags & MUTATE_SEED)
+ p->seed = (int)seed;
+
+ if (flags & MUTATE_PARAM) {
+ mutate_string(p->path);
+ mutate_blob(&p->pcsc_list);
+ mutate_blob(&p->tx_apdu);
+ }
+
+ if (flags & MUTATE_WIREDATA) {
+ mutate_blob(&p->wiredata_init);
+ mutate_blob(&p->wiredata_msg);
+ }
+}
diff --git a/contrib/libfido2/fuzz/libfuzzer.c b/contrib/libfido2/fuzz/libfuzzer.c
index 09aec4ea2b68..073ebe655cf2 100644
--- a/contrib/libfido2/fuzz/libfuzzer.c
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/mutator_aux.c b/contrib/libfido2/fuzz/mutator_aux.c
index 92a67be78106..64c633f15f92 100644
--- a/contrib/libfido2/fuzz/mutator_aux.c
+++ b/contrib/libfido2/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>
@@ -15,13 +16,11 @@
#include "mutator_aux.h"
-#define HID_DEV_HANDLE 0x68696421
-#define NFC_DEV_HANDLE 0x6e666321
-
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;
@@ -160,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)
{
@@ -168,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
@@ -186,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;
}
@@ -241,16 +244,16 @@ nfc_close(void *handle)
assert(handle == (void *)NFC_DEV_HANDLE);
}
-static int
+int
nfc_read(void *handle, unsigned char *ptr, size_t len, int ms)
{
assert(handle == (void *)NFC_DEV_HANDLE);
- assert(len > 0 && len <= 256 + 2);
+ assert(len > 0 && len <= 264);
return buf_read(ptr, len, ms);
}
-static int
+int
nfc_write(void *handle, const unsigned char *ptr, size_t len)
{
assert(handle == (void *)NFC_DEV_HANDLE);
diff --git a/contrib/libfido2/fuzz/mutator_aux.h b/contrib/libfido2/fuzz/mutator_aux.h
index a9bebe232bae..5ad566140a8e 100644
--- a/contrib/libfido2/fuzz/mutator_aux.h
+++ b/contrib/libfido2/fuzz/mutator_aux.h
@@ -1,12 +1,15 @@
/*
- * 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
*/
#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,12 @@
#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
struct blob {
uint8_t body[MAXBLOB];
@@ -85,6 +92,9 @@ void mutate_string(char *);
ssize_t fd_read(int, void *, size_t);
ssize_t fd_write(int, const void *, size_t);
+int nfc_read(void *, unsigned char *, size_t, int);
+int nfc_write(void *, const unsigned char *, size_t);
+
fido_dev_t *open_dev(int);
void set_wire_data(const uint8_t *, size_t);
@@ -94,4 +104,8 @@ unsigned long prng_uint32(void);
uint32_t uniform_random(uint32_t);
+void set_pcsc_parameters(const struct blob *);
+void set_pcsc_io_functions(int (*)(void *, u_char *, size_t, int),
+ int (*)(void *, const u_char *, size_t), void (*)(const void *, size_t));
+
#endif /* !_MUTATOR_AUX_H */
diff --git a/contrib/libfido2/fuzz/pcsc.c b/contrib/libfido2/fuzz/pcsc.c
new file mode 100644
index 000000000000..f6a3e9bdd773
--- /dev/null
+++ b/contrib/libfido2/fuzz/pcsc.c
@@ -0,0 +1,153 @@
+/*
+ * 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>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <winscard.h>
+
+#include "mutator_aux.h"
+
+static const struct blob *reader_list;
+static int (*xread)(void *, u_char *, size_t, int);
+static int (*xwrite)(void *, const u_char *, size_t);
+static void (*xconsume)(const void *, size_t);
+
+LONG __wrap_SCardEstablishContext(DWORD, LPCVOID, LPCVOID, LPSCARDCONTEXT);
+LONG __wrap_SCardListReaders(SCARDCONTEXT, LPCSTR, LPSTR, LPDWORD);
+LONG __wrap_SCardReleaseContext(SCARDCONTEXT);
+LONG __wrap_SCardConnect(SCARDCONTEXT, LPCSTR, DWORD, DWORD, LPSCARDHANDLE,
+ LPDWORD);
+LONG __wrap_SCardDisconnect(SCARDHANDLE, DWORD);
+LONG __wrap_SCardTransmit(SCARDHANDLE, const SCARD_IO_REQUEST *, LPCBYTE,
+ DWORD, SCARD_IO_REQUEST *, LPBYTE, LPDWORD);
+
+LONG
+__wrap_SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,
+ LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
+{
+ assert(dwScope == SCARD_SCOPE_SYSTEM);
+ assert(pvReserved1 == NULL);
+ assert(pvReserved2 == NULL);
+
+ *phContext = 1;
+
+ if (uniform_random(400) < 1)
+ return SCARD_E_NO_SERVICE;
+ if (uniform_random(400) < 1)
+ return SCARD_E_NO_SMARTCARD;
+ if (uniform_random(400) < 1)
+ return SCARD_E_NO_MEMORY;
+ if (uniform_random(400) < 1)
+ *phContext = 0;
+
+ return SCARD_S_SUCCESS;
+}
+
+LONG
+__wrap_SCardListReaders(SCARDCONTEXT hContext, LPCSTR mszGroups,
+ LPSTR mszReaders, LPDWORD pcchReaders)
+{
+ assert(hContext == 1);
+ assert(mszGroups == NULL);
+ assert(mszReaders != NULL);
+ assert(pcchReaders != 0);
+
+ if (reader_list == NULL || uniform_random(400) < 1)
+ return SCARD_E_NO_READERS_AVAILABLE;
+ if (uniform_random(400) < 1)
+ return SCARD_E_NO_MEMORY;
+
+ memcpy(mszReaders, reader_list->body, reader_list->len > *pcchReaders ?
+ *pcchReaders : reader_list->len);
+ *pcchReaders = (DWORD)reader_list->len; /* on purpose */
+
+ return SCARD_S_SUCCESS;
+}
+
+LONG
+__wrap_SCardReleaseContext(SCARDCONTEXT hContext)
+{
+ assert(hContext == 1);
+
+ return SCARD_S_SUCCESS;
+}
+
+LONG
+__wrap_SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
+ DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
+{
+ uint32_t r;
+
+ assert(hContext == 1);
+ xconsume(szReader, strlen(szReader) + 1);
+ assert(dwShareMode == SCARD_SHARE_SHARED);
+ assert(dwPreferredProtocols == SCARD_PROTOCOL_ANY);
+ assert(phCard != NULL);
+ assert(pdwActiveProtocol != NULL);
+
+ if ((r = uniform_random(400)) < 1)
+ return SCARD_E_UNEXPECTED;
+
+ *phCard = 1;
+ *pdwActiveProtocol = (r & 1) ? SCARD_PROTOCOL_T0 : SCARD_PROTOCOL_T1;
+
+ if (uniform_random(400) < 1)
+ *pdwActiveProtocol = SCARD_PROTOCOL_RAW;
+
+ return SCARD_S_SUCCESS;
+}
+
+LONG
+__wrap_SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
+{
+ assert(hCard == 1);
+ assert(dwDisposition == SCARD_LEAVE_CARD);
+
+ return SCARD_S_SUCCESS;
+}
+
+extern void consume(const void *body, size_t len);
+
+LONG
+__wrap_SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
+ LPCBYTE pbSendBuffer, DWORD cbSendLength, SCARD_IO_REQUEST *pioRecvPci,
+ LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength)
+{
+ void *ioh = (void *)NFC_DEV_HANDLE;
+ int n;
+
+ assert(hCard == 1);
+ xconsume(pioSendPci, sizeof(*pioSendPci));
+ xwrite(ioh, pbSendBuffer, cbSendLength);
+ assert(pioRecvPci == NULL);
+
+ if (uniform_random(400) < 1 ||
+ (n = xread(ioh, pbRecvBuffer, *pcbRecvLength, -1)) == -1)
+ return SCARD_E_UNEXPECTED;
+ *pcbRecvLength = (DWORD)n;
+
+ return SCARD_S_SUCCESS;
+}
+
+void
+set_pcsc_parameters(const struct blob *reader_list_ptr)
+{
+ reader_list = reader_list_ptr;
+}
+
+void
+set_pcsc_io_functions(int (*read_f)(void *, u_char *, size_t, int),
+ int (*write_f)(void *, const u_char *, size_t),
+ void (*consume_f)(const void *, size_t))
+{
+ xread = read_f;
+ xwrite = write_f;
+ xconsume = consume_f;
+}
diff --git a/contrib/libfido2/fuzz/preload-fuzz.c b/contrib/libfido2/fuzz/preload-fuzz.c
index efcb8c632605..f18848dda34c 100644
--- a/contrib/libfido2/fuzz/preload-fuzz.c
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/preload-snoop.c b/contrib/libfido2/fuzz/preload-snoop.c
index 373acc560a60..34d57ade82f9 100644
--- a/contrib/libfido2/fuzz/preload-snoop.c
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/report.tgz b/contrib/libfido2/fuzz/report.tgz
index d78f4628de59..e984ee9dc765 100644
--- a/contrib/libfido2/fuzz/report.tgz
+++ b/contrib/libfido2/fuzz/report.tgz
Binary files differ
diff --git a/contrib/libfido2/fuzz/summary.txt b/contrib/libfido2/fuzz/summary.txt
index 05c000aa7757..0f79600f801d 100644
--- a/contrib/libfido2/fuzz/summary.txt
+++ b/contrib/libfido2/fuzz/summary.txt
@@ -1,57 +1,64 @@
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-fuzz/clock.c 24 1 95.83% 4 0 100.00% 35 0 100.00%
-fuzz/prng.c 31 0 100.00% 2 0 100.00% 35 0 100.00%
-fuzz/udev.c 103 1 99.03% 17 0 100.00% 126 3 97.62%
+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 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 6 0 100.00% 1 0 100.00% 7 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 115 4 96.52% 8 0 100.00% 157 14 91.08%
-src/assert.c 563 40 92.90% 56 3 94.64% 694 40 94.24%
-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 21 96.24%
+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 1047 23 97.80% 54 0 100.00% 1237 46 96.28%
-src/compress.c 34 4 88.24% 3 0 100.00% 28 3 89.29%
-src/config.c 108 0 100.00% 11 0 100.00% 151 0 100.00%
-src/cred.c 632 34 94.62% 69 2 97.10% 830 36 95.66%
-src/credman.c 382 10 97.38% 40 0 100.00% 518 15 97.10%
-src/dev.c 421 79 81.24% 45 7 84.44% 491 105 78.62%
+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 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 80 3 96.25% 10 0 100.00% 106 8 92.45%
+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 306 5 98.37% 19 0 100.00% 358 7 98.04%
+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 104 58.40%
-src/hid_unix.c 28 20 28.57% 2 0 100.00% 43 24 44.19%
-src/info.c 184 0 100.00% 39 0 100.00% 316 0 100.00%
-src/io.c 182 7 96.15% 13 0 100.00% 221 11 95.02%
-src/iso7816.c 18 1 94.44% 5 0 100.00% 38 0 100.00%
-src/largeblob.c 513 19 96.30% 30 0 100.00% 684 43 93.71%
-src/log.c 39 5 87.18% 7 1 85.71% 63 4 93.65%
-src/netlink.c 328 14 95.73% 40 0 100.00% 498 32 93.57%
-src/nfc_linux.c 327 73 77.68% 23 5 78.26% 458 124 72.93%
-src/pin.c 403 3 99.26% 26 0 100.00% 495 3 99.39%
-src/random.c 6 1 83.33% 1 0 100.00% 6 1 83.33%
+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 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 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 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 0 100.00% 3 0 100.00% 39 0 100.00%
-src/rs256.c 141 8 94.33% 13 0 100.00% 172 10 94.19%
-src/time.c 43 3 93.02% 3 0 100.00% 43 1 97.67%
-src/tpm.c 100 0 100.00% 9 0 100.00% 194 0 100.00%
-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/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 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:
+fuzz/mutator_aux.h 0 0 - 0 0 - 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 7861 476 93.94% 684 27 96.05% 10270 699 93.19%
+TOTAL 8711 492 94.35% 737 28 96.20% 11320 771 93.19%
diff --git a/contrib/libfido2/fuzz/udev.c b/contrib/libfido2/fuzz/udev.c
index 3984d8f555ed..3194012ab97e 100644
--- a/contrib/libfido2/fuzz/udev.c
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/wiredata_fido2.h b/contrib/libfido2/fuzz/wiredata_fido2.h
index da905516f92a..6c66c545b235 100644
--- a/contrib/libfido2/fuzz/wiredata_fido2.h
+++ b/contrib/libfido2/fuzz/wiredata_fido2.h
@@ -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
*/
#ifndef _WIREDATA_FIDO2_H
@@ -630,4 +631,78 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+#define WIREDATA_CTAP_NFC_INIT \
+ 0x55, 0x32, 0x46, 0x5f, 0x56, 0x32, 0x90, 0x00
+
+#define WIREDATA_CTAP_NFC_MSG \
+ 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00
+
+#define WIREDATA_CTAP_EXTENDED_APDU \
+ 0x00, 0xa4, 0x04, 0x00, 0x00, 0x02, 0x00, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, \
+ 0x00
+
#endif /* _WIREDATA_FIDO2_H */
diff --git a/contrib/libfido2/fuzz/wiredata_u2f.h b/contrib/libfido2/fuzz/wiredata_u2f.h
index afe418fe9d96..3be22d34b6c2 100644
--- a/contrib/libfido2/fuzz/wiredata_u2f.h
+++ b/contrib/libfido2/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/contrib/libfido2/fuzz/wrap.c b/contrib/libfido2/fuzz/wrap.c
index 8d7be6bb6247..6f40ea1d079e 100644
--- a/contrib/libfido2/fuzz/wrap.c
+++ b/contrib/libfido2/fuzz/wrap.c
@@ -1,10 +1,12 @@
/*
- * 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>
+#include <sys/random.h>
#include <sys/socket.h>
#include <openssl/bn.h>
@@ -16,14 +18,19 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <zlib.h>
#include "mutator_aux.h"
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) \
@@ -69,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,
@@ -635,3 +650,51 @@ WRAP(int,
(sockfd, addr, addrlen),
1
)
+
+WRAP(int,
+ deflateInit2_,
+ (z_streamp strm, int level, int method, int windowBits, int memLevel,
+ int strategy, const char *version, int stream_size),
+ Z_STREAM_ERROR,
+ (strm, level, method, windowBits, memLevel, strategy, version,
+ stream_size),
+ 1
+)
+
+int __wrap_deflate(z_streamp, int);
+int __real_deflate(z_streamp, int);
+
+int
+__wrap_deflate(z_streamp strm, int flush)
+{
+ if (prng_up && uniform_random(400) < 1) {
+ return Z_BUF_ERROR;
+ }
+ /* should never happen, but we check for it */
+ if (prng_up && uniform_random(400) < 1) {
+ strm->avail_out = UINT_MAX;
+ return Z_STREAM_END;
+ }
+
+ return __real_deflate(strm, flush);
+}
+
+int __wrap_asprintf(char **, const char *, ...);
+
+int
+__wrap_asprintf(char **strp, const char *fmt, ...)
+{
+ va_list ap;
+ int r;
+
+ if (prng_up && uniform_random(400) < 1) {
+ *strp = (void *)0xdeadbeef;
+ return -1;
+ }
+
+ va_start(ap, fmt);
+ r = vasprintf(strp, fmt, ap);
+ va_end(ap);
+
+ return r;
+}
diff --git a/contrib/libfido2/fuzz/wrapped.sym b/contrib/libfido2/fuzz/wrapped.sym
index 0e9d34627f86..219a0d8b8f46 100644
--- a/contrib/libfido2/fuzz/wrapped.sym
+++ b/contrib/libfido2/fuzz/wrapped.sym
@@ -1,3 +1,4 @@
+asprintf
bind
BN_bin2bn
BN_bn2bin
@@ -24,6 +25,8 @@ cbor_new_definite_bytestring
cbor_new_definite_map
cbor_serialize_alloc
clock_gettime
+deflate
+deflateInit2_
EC_KEY_get0_group
EC_KEY_get0_private_key
EC_KEY_new_by_curve_name
@@ -60,6 +63,7 @@ EVP_PKEY_verify_init
EVP_sha1
EVP_sha256
fido_tx
+getrandom
HMAC
HMAC_CTX_new
HMAC_Final
@@ -71,6 +75,12 @@ realloc
RSA_new
RSA_pkey_ctx_ctrl
RSA_set0_key
+SCardConnect
+SCardDisconnect
+SCardEstablishContext
+SCardListReaders
+SCardReleaseContext
+SCardTransmit
SHA1
SHA256
strdup
diff --git a/contrib/libfido2/man/CMakeLists.txt b/contrib/libfido2/man/CMakeLists.txt
index 5ce2fc7b83ed..a47767fb6d4b 100644
--- a/contrib/libfido2/man/CMakeLists.txt
+++ b/contrib/libfido2/man/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
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,12 @@ 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_allow_cred fido_assert_empty_allow_list
fido_assert_new fido_assert_authdata_len
fido_assert_new fido_assert_authdata_ptr
fido_assert_new fido_assert_blob_len
@@ -114,24 +122,35 @@ 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_maxmsgsiz
+ 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_fwversion
+ fido_cbor_info_new fido_cbor_info_maxlargeblob
+ fido_cbor_info_new fido_cbor_info_maxmsgsiz
+ 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
+ fido_cred_exclude fido_cred_empty_exclude_list
fido_cred_new fido_cred_aaguid_len
fido_cred_new fido_cred_aaguid_ptr
fido_cred_new fido_cred_attstmt_len
@@ -263,7 +282,7 @@ math(EXPR MAN_ALIAS_MAX "${MAN_ALIAS_LEN} - 2")
# man_copy
foreach(f ${MAN_SOURCES})
add_custom_command(OUTPUT ${f}
- COMMAND cp -f ${CMAKE_SOURCE_DIR}/man/${f} .
+ COMMAND cp -f ${PROJECT_SOURCE_DIR}/man/${f} .
DEPENDS ${f})
list(APPEND COPY_FILES ${f})
endforeach()
@@ -278,7 +297,7 @@ endforeach()
# man_html
foreach(f ${MAN_SOURCES})
- string(REGEX REPLACE ".[13]" "" g ${f})
+ string(REGEX REPLACE "\\.[13]$" "" g ${f})
add_custom_command(OUTPUT ${g}.html
COMMAND mandoc -T html -O man="%N.html",style=style.css -I os="Yubico AB" ${f} > ${g}.html
DEPENDS ${f})
@@ -287,9 +306,9 @@ endforeach()
# man_html_partial
foreach(f ${MAN_SOURCES})
- string(REGEX REPLACE ".[13]" "" g ${f})
+ string(REGEX REPLACE "\\.[13]$" "" g ${f})
add_custom_command(OUTPUT ${g}.partial
- COMMAND cat ${CMAKE_SOURCE_DIR}/man/dyc.css > ${g}.partial
+ COMMAND cat ${PROJECT_SOURCE_DIR}/man/dyc.css > ${g}.partial
COMMAND mandoc -T html -O man="%N.html",fragment ${f} >> ${g}.partial
DEPENDS ${f})
list(APPEND HTML_PARTIAL_FILES ${g}.partial)
@@ -337,17 +356,17 @@ add_custom_target(man ALL)
if(MANDOC_PATH)
add_dependencies(man man_symlink_html)
add_dependencies(man_gzip man_lint)
- install(FILES ${CMAKE_SOURCE_DIR}/man/style.css
+ install(FILES ${PROJECT_SOURCE_DIR}/man/style.css
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html")
foreach(f ${MAN_SOURCES})
- string(REGEX REPLACE ".[13]" "" f ${f})
- install(FILES ${CMAKE_BINARY_DIR}/man/${f}.html
+ string(REGEX REPLACE "\\.[13]$" "" f ${f})
+ install(FILES ${PROJECT_BINARY_DIR}/man/${f}.html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html")
endforeach()
foreach(i RANGE 0 ${MAN_ALIAS_MAX} 2)
math(EXPR j "${i} + 1")
list(GET MAN_ALIAS ${j} DST)
- install(FILES ${CMAKE_BINARY_DIR}/man/${DST}.html
+ install(FILES ${PROJECT_BINARY_DIR}/man/${DST}.html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/html")
endforeach()
endif()
@@ -358,34 +377,34 @@ if(GZIP_PATH)
add_dependencies(man man_symlink_gzip)
foreach(f ${MAN_SOURCES})
if (${f} MATCHES ".1$")
- install(FILES ${CMAKE_BINARY_DIR}/man/${f}.gz
+ install(FILES ${PROJECT_BINARY_DIR}/man/${f}.gz
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
elseif(${f} MATCHES ".3$")
- install(FILES ${CMAKE_BINARY_DIR}/man/${f}.gz
+ install(FILES ${PROJECT_BINARY_DIR}/man/${f}.gz
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
endif()
endforeach()
foreach(i RANGE 0 ${MAN_ALIAS_MAX} 2)
math(EXPR j "${i} + 1")
list(GET MAN_ALIAS ${j} DST)
- install(FILES ${CMAKE_BINARY_DIR}/man/${DST}.3.gz
+ install(FILES ${PROJECT_BINARY_DIR}/man/${DST}.3.gz
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
endforeach()
elseif(NOT MSVC)
add_dependencies(man man_symlink)
foreach(f ${MAN_SOURCES})
if (${f} MATCHES ".1$")
- install(FILES ${CMAKE_BINARY_DIR}/man/${f}
+ install(FILES ${PROJECT_BINARY_DIR}/man/${f}
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
elseif(${f} MATCHES ".3$")
- install(FILES ${CMAKE_BINARY_DIR}/man/${f}
+ install(FILES ${PROJECT_BINARY_DIR}/man/${f}
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
endif()
endforeach()
foreach(i RANGE 0 ${MAN_ALIAS_MAX} 2)
math(EXPR j "${i} + 1")
list(GET MAN_ALIAS ${j} DST)
- install(FILES ${CMAKE_BINARY_DIR}/man/${DST}.3
+ install(FILES ${PROJECT_BINARY_DIR}/man/${DST}.3
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
endforeach()
endif()
diff --git a/contrib/libfido2/man/check.sh b/contrib/libfido2/man/check.sh
index 951afeb88e0b..d969a7afb666 100755
--- a/contrib/libfido2/man/check.sh
+++ b/contrib/libfido2/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/contrib/libfido2/man/eddsa_pk_new.3 b/contrib/libfido2/man/eddsa_pk_new.3
index 998def484790..428d724a45ee 100644
--- a/contrib/libfido2/man/eddsa_pk_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/es256_pk_new.3 b/contrib/libfido2/man/es256_pk_new.3
index 5e184340a575..7d6be4d6223c 100644
--- a/contrib/libfido2/man/es256_pk_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/es384_pk_new.3 b/contrib/libfido2/man/es384_pk_new.3
new file mode 100644
index 000000000000..e865913b7807
--- /dev/null
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido2-assert.1 b/contrib/libfido2/man/fido2-assert.1
index ee8135c18483..0ee6e0942ba2 100644
--- a/contrib/libfido2/man/fido2-assert.1
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido2-cred.1 b/contrib/libfido2/man/fido2-cred.1
index 0b10e74a0507..bd82499acac4 100644
--- a/contrib/libfido2/man/fido2-cred.1
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido2-token.1 b/contrib/libfido2/man/fido2-token.1
index 1aa2feb86859..65a228cb1a31 100644
--- a/contrib/libfido2/man/fido2-token.1
+++ b/contrib/libfido2/man/fido2-token.1
@@ -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: September 13 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: April 11 2022 $
.Dt FIDO2-TOKEN 1
.Os
.Sh NAME
@@ -147,7 +170,7 @@ from
.Ar device ,
where
.Ar key_path
-must hold the blob's base64-encoded encryption key.
+holds the blob's base64-encoded 32-byte AES-256 GCM encryption key.
A PIN or equivalent user-verification gesture is required.
.It Fl D Fl b Fl n Ar rp_id Oo Fl i Ar cred_id Oc Ar device
Deletes a
@@ -189,7 +212,7 @@ from
.Ar device ,
where
.Ar key_path
-must hold the blob's base64-encoded encryption key.
+holds the blob's base64-encoded 32-byte AES-256 GCM encryption key.
The blob is written to
.Ar blob_path .
A PIN or equivalent user-verification gesture is required.
@@ -267,29 +290,27 @@ The user will be prompted for the PIN.
Enables CTAP 2.1 Enterprise Attestation on
.Ar device .
.It Fl S Fl b Fl k Ar key_path Ar blob_path Ar device
-Sets
-.Ar blob_path
-as a CTAP 2.1
+Sets a CTAP 2.1
.Dq largeBlob
encrypted with
.Ar key_path
on
.Ar device ,
where
-.Ar blob_path
-holds the blob's plaintext, and
.Ar key_path
-the blob's base64-encoded encryption.
+holds the blob's base64-encoded 32-byte AES-256 GCM encryption key.
+The blob is read from
+.Fa blob_path .
A PIN or equivalent user-verification gesture is required.
.It Fl S Fl b Fl n Ar rp_id Oo Fl i Ar cred_id Oc Ar blob_path Ar device
-Sets
-.Ar blob_path
-as a CTAP 2.1
+Sets a CTAP 2.1
.Dq largeBlob
associated with
.Ar rp_id
on
.Ar device .
+The blob is read from
+.Fa blob_path .
If
.Ar rp_id
has multiple credentials enrolled on
diff --git a/contrib/libfido2/man/fido_assert_allow_cred.3 b/contrib/libfido2/man/fido_assert_allow_cred.3
index 7fd730c3f63c..652013734295 100644
--- a/contrib/libfido2/man/fido_assert_allow_cred.3
+++ b/contrib/libfido2/man/fido_assert_allow_cred.3
@@ -1,17 +1,43 @@
-.\" 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 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: December 1 2022 $
.Dt FIDO_ASSERT_ALLOW_CRED 3
.Os
.Sh NAME
-.Nm fido_assert_allow_cred
-.Nd allow a credential in a FIDO2 assertion
+.Nm fido_assert_allow_cred ,
+.Nm fido_assert_empty_allow_list
+.Nd manage allow lists in a FIDO2 assertion
.Sh SYNOPSIS
.In fido.h
.Ft int
.Fn fido_assert_allow_cred "fido_assert_t *assert" "const unsigned char *ptr" "size_t len"
+.Ft int
+.Fn fido_assert_empty_allow_list "fido_assert_t *assert"
.Sh DESCRIPTION
The
.Fn fido_assert_allow_cred
@@ -33,9 +59,16 @@ fails, the existing list of allowed credentials is preserved.
.Pp
For the format of a FIDO2 credential ID, please refer to the
Web Authentication (webauthn) standard.
+.Pp
+The
+.Fn fido_assert_empty_allow_list
+function empties the list of credentials allowed in
+.Fa assert .
.Sh RETURN VALUES
The error codes returned by
.Fn fido_assert_allow_cred
+and
+.Fn fido_assert_empty_allow_list
are defined in
.In fido/err.h .
On success,
diff --git a/contrib/libfido2/man/fido_assert_new.3 b/contrib/libfido2/man/fido_assert_new.3
index a1a3c101ba33..192625e32630 100644
--- a/contrib/libfido2/man/fido_assert_new.3
+++ b/contrib/libfido2/man/fido_assert_new.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: October 22 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: April 27 2022 $
.Dt FIDO_ASSERT_NEW 3
.Os
.Sh NAME
@@ -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 ,
@@ -180,6 +207,8 @@ in
The HMAC Secret Extension
.Pq hmac-secret
is a CTAP 2.0 extension.
+Note that the resulting hmac-secret varies according to whether
+user verification was performed by the authenticator.
.Pp
The
.Fn fido_assert_blob_ptr
diff --git a/contrib/libfido2/man/fido_assert_set_authdata.3 b/contrib/libfido2/man/fido_assert_set_authdata.3
index 51cdcc97c292..f3a307fd05b8 100644
--- a/contrib/libfido2/man/fido_assert_set_authdata.3
+++ b/contrib/libfido2/man/fido_assert_set_authdata.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 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: April 27 2022 $
.Dt FIDO_ASSERT_SET_AUTHDATA 3
.Os
.Sh NAME
@@ -182,6 +205,8 @@ is made, and no references to the passed pointer are kept.
The HMAC Secret
.Pq hmac-secret
Extension is a CTAP 2.0 extension.
+Note that the resulting hmac-secret varies according to whether
+user verification was performed by the authenticator.
The
.Fn fido_assert_set_hmac_secret
function is normally only useful when writing tests.
diff --git a/contrib/libfido2/man/fido_assert_verify.3 b/contrib/libfido2/man/fido_assert_verify.3
index 8c0823703434..1b79448b6c32 100644
--- a/contrib/libfido2/man/fido_assert_verify.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_bio_dev_get_info.3 b/contrib/libfido2/man/fido_bio_dev_get_info.3
index 7f1696fc12a4..b8fc1043c231 100644
--- a/contrib/libfido2/man/fido_bio_dev_get_info.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_bio_enroll_new.3 b/contrib/libfido2/man/fido_bio_enroll_new.3
index 37b842e644fd..536ba9af9f91 100644
--- a/contrib/libfido2/man/fido_bio_enroll_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_bio_info_new.3 b/contrib/libfido2/man/fido_bio_info_new.3
index a7435fd615e7..41343068b162 100644
--- a/contrib/libfido2/man/fido_bio_info_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_bio_template.3 b/contrib/libfido2/man/fido_bio_template.3
index 232f3ead2ab3..a8ff8bc38dc6 100644
--- a/contrib/libfido2/man/fido_bio_template.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_cbor_info_new.3 b/contrib/libfido2/man/fido_cbor_info_new.3
index 86f2a887f99a..a8168c05c916 100644
--- a/contrib/libfido2/man/fido_cbor_info_new.3
+++ b/contrib/libfido2/man/fido_cbor_info_new.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: April 22 2022 $
.Dt FIDO_CBOR_INFO_NEW 3
.Os
.Sh NAME
@@ -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 ,
@@ -29,7 +55,14 @@
.Nm fido_cbor_info_maxcredbloblen ,
.Nm fido_cbor_info_maxcredcntlst ,
.Nm fido_cbor_info_maxcredidlen ,
-.Nm fido_cbor_info_fwversion
+.Nm fido_cbor_info_maxlargeblob ,
+.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
@@ -59,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
@@ -80,7 +119,21 @@
.Ft uint64_t
.Fn fido_cbor_info_maxcredidlen "const fido_cbor_info_t *ci"
.Ft uint64_t
+.Fn fido_cbor_info_maxlargeblob "const fido_cbor_info_t *ci"
+.Ft uint64_t
+.Fn fido_cbor_info_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
@@ -177,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 .
@@ -201,10 +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
@@ -229,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/contrib/libfido2/man/fido_cred_exclude.3 b/contrib/libfido2/man/fido_cred_exclude.3
index 2aa87f28976f..d5e840d56e11 100644
--- a/contrib/libfido2/man/fido_cred_exclude.3
+++ b/contrib/libfido2/man/fido_cred_exclude.3
@@ -1,17 +1,43 @@
-.\" 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 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: December 2 2022 $
.Dt FIDO_CRED_EXCLUDE 3
.Os
.Sh NAME
-.Nm fido_cred_exclude
-.Nd appends a credential ID to a credential's list of excluded credentials
+.Nm fido_cred_exclude ,
+.Nm fido_cred_empty_exclude_list
+.Nd manage exclude lists in a FIDO2 credential
.Sh SYNOPSIS
.In fido.h
.Ft int
.Fn fido_cred_exclude "fido_cred_t *cred" "const unsigned char *ptr" "size_t len"
+.Ft int
+.Fn fido_cred_empty_exclude_list "fido_cred_t *cred"
.Sh DESCRIPTION
The
.Fn fido_cred_exclude
@@ -46,9 +72,16 @@ will fail.
.Pp
For the format of a FIDO2 credential ID, please refer to the
Web Authentication (webauthn) standard.
+.Pp
+The
+.Fn fido_cred_empty_exclude_list
+function empties the list of credentials excluded by
+.Fa cred .
.Sh RETURN VALUES
The error codes returned by
.Fn fido_cred_exclude
+and
+.Fn fido_cred_empty_exclude_list
are defined in
.In fido/err.h .
On success,
diff --git a/contrib/libfido2/man/fido_cred_new.3 b/contrib/libfido2/man/fido_cred_new.3
index ee7ac96a6b0b..4f8b1be7bc45 100644
--- a/contrib/libfido2/man/fido_cred_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_cred_set_authdata.3 b/contrib/libfido2/man/fido_cred_set_authdata.3
index 921a682f8f91..e4538325b291 100644
--- a/contrib/libfido2/man/fido_cred_set_authdata.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_cred_verify.3 b/contrib/libfido2/man/fido_cred_verify.3
index 696dec293e4d..9548870204c7 100644
--- a/contrib/libfido2/man/fido_cred_verify.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_credman_metadata_new.3 b/contrib/libfido2/man/fido_credman_metadata_new.3
index cd6722e24aa8..122020bd68b1 100644
--- a/contrib/libfido2/man/fido_credman_metadata_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_enable_entattest.3 b/contrib/libfido2/man/fido_dev_enable_entattest.3
index bfc1b2834e55..7617f22389e2 100644
--- a/contrib/libfido2/man/fido_dev_enable_entattest.3
+++ b/contrib/libfido2/man/fido_dev_enable_entattest.3
@@ -1,8 +1,31 @@
-.\" 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.
.\"
-.Dd $Mdocdate: September 22 2020 $
+.\" 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
.Os
.Sh NAME
@@ -65,7 +88,7 @@ does not have a PIN set.
.Pp
The
.Fn fido_dev_force_pin_change
-instructs
+function instructs
.Fa dev
to require a PIN change.
Subsequent PIN authentication attempts against
@@ -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/contrib/libfido2/man/fido_dev_get_assert.3 b/contrib/libfido2/man/fido_dev_get_assert.3
index bc67e441cca3..bb2fc43b8b24 100644
--- a/contrib/libfido2/man/fido_dev_get_assert.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_get_touch_begin.3 b/contrib/libfido2/man/fido_dev_get_touch_begin.3
index f3b8335cec12..f015eff2cb3c 100644
--- a/contrib/libfido2/man/fido_dev_get_touch_begin.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_info_manifest.3 b/contrib/libfido2/man/fido_dev_info_manifest.3
index 9539a0dda7c5..a70a3cb299ac 100644
--- a/contrib/libfido2/man/fido_dev_info_manifest.3
+++ b/contrib/libfido2/man/fido_dev_info_manifest.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.
.\"
-.Dd $Mdocdate: May 25 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: March 30 2022 $
.Dt FIDO_DEV_INFO_MANIFEST 3
.Os
.Sh NAME
@@ -97,7 +120,7 @@ Please note that the first slot has index 0.
.Pp
The
.Fn fido_dev_info_path
-returns the filesystem path or subsystem-specific identification
+function returns the filesystem path or subsystem-specific identification
string of
.Fa di .
.Pp
diff --git a/contrib/libfido2/man/fido_dev_largeblob_get.3 b/contrib/libfido2/man/fido_dev_largeblob_get.3
index c42208158c5e..12dd319485e1 100644
--- a/contrib/libfido2/man/fido_dev_largeblob_get.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_make_cred.3 b/contrib/libfido2/man/fido_dev_make_cred.3
index 60b77fb9c010..b13f9a14bc85 100644
--- a/contrib/libfido2/man/fido_dev_make_cred.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_open.3 b/contrib/libfido2/man/fido_dev_open.3
index cdb148fe8b16..f839e26787b4 100644
--- a/contrib/libfido2/man/fido_dev_open.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_set_io_functions.3 b/contrib/libfido2/man/fido_dev_set_io_functions.3
index 8c2067c41f66..e3e10bae5aaf 100644
--- a/contrib/libfido2/man/fido_dev_set_io_functions.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_dev_set_pin.3 b/contrib/libfido2/man/fido_dev_set_pin.3
index b58ba6c86f89..eec062dda1cd 100644
--- a/contrib/libfido2/man/fido_dev_set_pin.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_init.3 b/contrib/libfido2/man/fido_init.3
index 1254f934b73b..12437e1b1a78 100644
--- a/contrib/libfido2/man/fido_init.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/fido_strerr.3 b/contrib/libfido2/man/fido_strerr.3
index 9d4ef35aa402..94b48bd621df 100644
--- a/contrib/libfido2/man/fido_strerr.3
+++ b/contrib/libfido2/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/contrib/libfido2/man/rs256_pk_new.3 b/contrib/libfido2/man/rs256_pk_new.3
index 24a27bf8cdab..0c0ab78b507c 100644
--- a/contrib/libfido2/man/rs256_pk_new.3
+++ b/contrib/libfido2/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/contrib/libfido2/openbsd-compat/bsd-asprintf.c b/contrib/libfido2/openbsd-compat/bsd-asprintf.c
new file mode 100644
index 000000000000..fbcb8679258f
--- /dev/null
+++ b/contrib/libfido2/openbsd-compat/bsd-asprintf.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004 Darren Tucker.
+ *
+ * Based originally on asprintf.c from OpenBSD:
+ * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "openbsd-compat.h"
+
+#ifndef HAVE_ASPRINTF
+
+#include <errno.h>
+#include <limits.h> /* for INT_MAX */
+#include <stdarg.h>
+#include <stdio.h> /* for vsnprintf */
+#include <stdlib.h>
+
+#define VA_COPY(dest, src) va_copy(dest, src)
+
+#define INIT_SZ 128
+
+int
+vasprintf(char **str, const char *fmt, va_list ap)
+{
+ int ret;
+ va_list ap2;
+ char *string, *newstr;
+ size_t len;
+
+ if ((string = malloc(INIT_SZ)) == NULL)
+ goto fail;
+
+ VA_COPY(ap2, ap);
+ ret = vsnprintf(string, INIT_SZ, fmt, ap2);
+ va_end(ap2);
+ if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */
+ *str = string;
+ } else if (ret == INT_MAX || ret < 0) { /* Bad length */
+ free(string);
+ goto fail;
+ } else { /* bigger than initial, realloc allowing for nul */
+ len = (size_t)ret + 1;
+ if ((newstr = realloc(string, len)) == NULL) {
+ free(string);
+ goto fail;
+ }
+ VA_COPY(ap2, ap);
+ ret = vsnprintf(newstr, len, fmt, ap2);
+ va_end(ap2);
+ if (ret < 0 || (size_t)ret >= len) { /* failed with realloc'ed string */
+ free(newstr);
+ goto fail;
+ }
+ *str = newstr;
+ }
+ return (ret);
+
+fail:
+ *str = NULL;
+ errno = ENOMEM;
+ return (-1);
+}
+
+int asprintf(char **str, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ *str = NULL;
+ va_start(ap, fmt);
+ ret = vasprintf(str, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+#endif
diff --git a/contrib/libfido2/openbsd-compat/clock_gettime.c b/contrib/libfido2/openbsd-compat/clock_gettime.c
index ca261a65e7f1..bbf978c42893 100644
--- a/contrib/libfido2/openbsd-compat/clock_gettime.c
+++ b/contrib/libfido2/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/contrib/libfido2/openbsd-compat/endian_win32.c b/contrib/libfido2/openbsd-compat/endian_win32.c
index 9981dfafbaeb..756c0cbdc838 100644
--- a/contrib/libfido2/openbsd-compat/endian_win32.c
+++ b/contrib/libfido2/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/contrib/libfido2/openbsd-compat/openbsd-compat.h b/contrib/libfido2/openbsd-compat/openbsd-compat.h
index dc9acec4c0a8..9f1ea3e7cf51 100644
--- a/contrib/libfido2/openbsd-compat/openbsd-compat.h
+++ b/contrib/libfido2/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
@@ -115,4 +116,8 @@ ssize_t getline(char **, size_t *, FILE *);
#define IOCTL_REQ(x) ((int)(x))
#endif
+#if !defined(HAVE_ASPRINTF)
+int asprintf(char **, const char *, ...);
+#endif
+
#endif /* !_OPENBSD_COMPAT_H */
diff --git a/contrib/libfido2/regress/CMakeLists.txt b/contrib/libfido2/regress/CMakeLists.txt
index c550b3141822..246bffa175c4 100644
--- a/contrib/libfido2/regress/CMakeLists.txt
+++ b/contrib/libfido2/regress/CMakeLists.txt
@@ -1,20 +1,57 @@
-# 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_custom_target(regress ALL)
+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_shared)
add_test(${NAME} ${NAME})
add_dependencies(regress ${NAME})
+ target_link_libraries(${NAME} ${LIB})
endmacro()
-add_custom_command(TARGET regress POST_BUILD
- COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+if(MSVC AND BUILD_SHARED_LIBS)
+ add_custom_command(TARGET regress POST_BUILD
+ COMMAND "${CMAKE_COMMAND}" -E copy
+ "${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()
-add_regress_test(regress_cred cred.c)
-add_regress_test(regress_assert assert.c)
-add_regress_test(regress_dev dev.c)
+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()
+
+if(CMAKE_CROSSCOMPILING OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64" AND
+ CMAKE_GENERATOR_PLATFORM MATCHES "^ARM.*$"))
+ add_custom_command(TARGET regress POST_BUILD
+ COMMAND "${CMAKE_COMMAND}" -E echo
+ "Cross-compilation detected. Skipping regress tests.")
+else()
+ add_custom_command(TARGET regress POST_BUILD
+ COMMAND "${CMAKE_CTEST_COMMAND}" --output-on-failure
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+endif()
+
+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
+ target_link_libraries(regress_dev winpthread)
+endif()
diff --git a/contrib/libfido2/regress/assert.c b/contrib/libfido2/regress/assert.c
index 23d666a61173..98609257b8b5 100644
--- a/contrib/libfido2/regress/assert.c
+++ b/contrib/libfido2/regress/assert.c
@@ -2,18 +2,22 @@
* 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
*/
-#define _FIDO_INTERNAL
+#undef NDEBUG
#include <assert.h>
+#include <string.h>
+
+#define _FIDO_INTERNAL
+
#include <fido.h>
#include <fido/es256.h>
#include <fido/rs256.h>
#include <fido/eddsa.h>
-#include <string.h>
-#define FAKE_DEV_HANDLE ((void *)0xdeadbeef)
+static int fake_dev_handle;
static const unsigned char es256_pk[64] = {
0x34, 0xeb, 0x99, 0x77, 0x02, 0x9c, 0x36, 0x38,
@@ -94,13 +98,13 @@ dummy_open(const char *path)
{
(void)path;
- return (FAKE_DEV_HANDLE);
+ return (&fake_dev_handle);
}
static void
dummy_close(void *handle)
{
- assert(handle == FAKE_DEV_HANDLE);
+ assert(handle == &fake_dev_handle);
}
static int
diff --git a/contrib/libfido2/regress/compress.c b/contrib/libfido2/regress/compress.c
new file mode 100644
index 000000000000..7afc8bb339a7
--- /dev/null
+++ b/contrib/libfido2/regress/compress.c
@@ -0,0 +1,268 @@
+/*
+ * 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>
+
+#include <openssl/sha.h>
+
+#define _FIDO_INTERNAL
+
+#include <fido.h>
+
+/*
+ * zlib compressed data (RFC1950); see https://www.ietf.org/rfc/rfc6713.txt
+ */
+static /* const */ unsigned char rfc1950_blob[694] = {
+ 0x78, 0x9c, 0xb5, 0x52, 0x3b, 0x6f, 0xdb, 0x30,
+ 0x10, 0xde, 0xf5, 0x2b, 0x0e, 0x99, 0x12, 0x40,
+ 0x75, 0x13, 0x4f, 0x45, 0x3b, 0xd1, 0x12, 0x6d,
+ 0x1d, 0x20, 0x8b, 0x2a, 0x49, 0xd9, 0xf5, 0x28,
+ 0x4b, 0x4c, 0x42, 0xc0, 0x12, 0x03, 0x3d, 0x12,
+ 0xe4, 0xdf, 0xf7, 0xc8, 0x3a, 0x88, 0xd3, 0x0c,
+ 0x9d, 0xea, 0xc1, 0x3e, 0xf3, 0x8e, 0xdf, 0xeb,
+ 0x98, 0xb8, 0xa7, 0xd7, 0xc1, 0x3e, 0x3c, 0x4e,
+ 0x70, 0xdd, 0xdc, 0xc0, 0xf2, 0xf6, 0xee, 0xdb,
+ 0x97, 0xe5, 0xed, 0x72, 0x09, 0x87, 0xf9, 0x68,
+ 0x1b, 0x07, 0x6c, 0xb5, 0x00, 0x76, 0x3a, 0x41,
+ 0x18, 0x19, 0x61, 0x30, 0xa3, 0x19, 0x9e, 0x4d,
+ 0xbb, 0x88, 0x22, 0x69, 0x5a, 0x3b, 0x4e, 0x83,
+ 0x3d, 0xce, 0x93, 0x75, 0x3d, 0xd4, 0x7d, 0x0b,
+ 0xf3, 0x68, 0xc0, 0xf6, 0x30, 0xba, 0x79, 0x68,
+ 0x4c, 0x38, 0x39, 0xda, 0xbe, 0x1e, 0x5e, 0xe1,
+ 0xde, 0x0d, 0xdd, 0x18, 0xc3, 0x8b, 0x9d, 0x1e,
+ 0xc1, 0x0d, 0xe1, 0xd7, 0xcd, 0x53, 0xd4, 0xb9,
+ 0xd6, 0xde, 0xdb, 0xa6, 0xf6, 0x00, 0x31, 0xd4,
+ 0x83, 0x81, 0x27, 0x33, 0x74, 0x76, 0x9a, 0x4c,
+ 0x0b, 0x4f, 0x83, 0x7b, 0xb6, 0x2d, 0x15, 0xd3,
+ 0x63, 0x3d, 0xd1, 0x97, 0x21, 0x90, 0xd3, 0xc9,
+ 0xbd, 0xd8, 0xfe, 0x01, 0x1a, 0xd7, 0xb7, 0xd6,
+ 0x5f, 0x1a, 0xfd, 0xa5, 0xa8, 0x33, 0xd3, 0xf7,
+ 0x28, 0x02, 0x80, 0xbb, 0x05, 0x7c, 0x54, 0x35,
+ 0x82, 0xbb, 0x7f, 0x93, 0xd3, 0xb8, 0xd6, 0x40,
+ 0x37, 0x8f, 0x13, 0x99, 0x98, 0x6a, 0x92, 0xe9,
+ 0x31, 0xeb, 0xa3, 0x7b, 0xf6, 0xad, 0x73, 0x06,
+ 0x1e, 0x84, 0x3e, 0xbd, 0x9b, 0x6c, 0x63, 0x62,
+ 0x9a, 0xb0, 0x23, 0x9c, 0x08, 0xcf, 0xc3, 0x5c,
+ 0x92, 0xf6, 0xed, 0x5f, 0x8a, 0x88, 0xb4, 0x39,
+ 0xd5, 0xb6, 0x33, 0xc3, 0xc2, 0x63, 0x2c, 0x3f,
+ 0x0b, 0x21, 0xc2, 0x8b, 0x30, 0xde, 0x84, 0x90,
+ 0xcb, 0x76, 0x26, 0x71, 0xff, 0x47, 0x0b, 0x91,
+ 0x9e, 0x51, 0xfc, 0x44, 0xeb, 0x9a, 0xb9, 0x33,
+ 0xfd, 0x54, 0xbf, 0xed, 0xeb, 0x2b, 0xad, 0xc2,
+ 0x51, 0x67, 0x80, 0xae, 0x9e, 0xcc, 0x60, 0xeb,
+ 0xd3, 0xf8, 0x1e, 0x7b, 0xd8, 0x15, 0x35, 0xcf,
+ 0x00, 0x97, 0x66, 0x68, 0xf9, 0x3a, 0x43, 0x05,
+ 0x4a, 0xac, 0xf5, 0x9e, 0x49, 0x0e, 0x54, 0x97,
+ 0x52, 0xec, 0x30, 0xe5, 0x29, 0xac, 0x0e, 0xa0,
+ 0x33, 0x0e, 0x89, 0x28, 0x0f, 0x12, 0x37, 0x99,
+ 0x86, 0x4c, 0xe4, 0x29, 0x97, 0x0a, 0x58, 0x91,
+ 0xd2, 0x69, 0xa1, 0x25, 0xae, 0x2a, 0x2d, 0xa4,
+ 0x8a, 0xae, 0x98, 0xa2, 0x9b, 0x57, 0xa1, 0xc1,
+ 0x8a, 0x03, 0xf0, 0x5f, 0xa5, 0xe4, 0x4a, 0x81,
+ 0x90, 0x80, 0xdb, 0x32, 0x47, 0x02, 0x23, 0x74,
+ 0xc9, 0x0a, 0x8d, 0x5c, 0xc5, 0x80, 0x45, 0x92,
+ 0x57, 0x29, 0x16, 0x9b, 0x18, 0x08, 0x00, 0x0a,
+ 0xa1, 0xa3, 0x1c, 0xb7, 0xa8, 0x69, 0x4c, 0x8b,
+ 0x38, 0x90, 0x7e, 0xbe, 0x06, 0x62, 0x0d, 0x5b,
+ 0x2e, 0x93, 0x8c, 0xfe, 0xb2, 0x15, 0xe6, 0xa8,
+ 0x0f, 0x81, 0x6f, 0x8d, 0xba, 0xf0, 0x5c, 0x6b,
+ 0x21, 0x23, 0x06, 0x25, 0x93, 0x1a, 0x93, 0x2a,
+ 0x67, 0x12, 0xca, 0x4a, 0x96, 0x42, 0x71, 0xf0,
+ 0xb6, 0x52, 0x54, 0x49, 0xce, 0x70, 0xcb, 0xd3,
+ 0x05, 0xb1, 0x13, 0x23, 0xf0, 0x1d, 0x2f, 0x34,
+ 0xa8, 0x8c, 0xe5, 0xf9, 0x47, 0x97, 0xd1, 0x1f,
+ 0x97, 0x5e, 0xfb, 0xa5, 0x47, 0x58, 0x71, 0xc8,
+ 0x91, 0xad, 0x72, 0xee, 0x99, 0x82, 0xcb, 0x14,
+ 0x25, 0x4f, 0xb4, 0xb7, 0xf3, 0x5e, 0x25, 0x94,
+ 0x1c, 0xe9, 0xcb, 0xe3, 0x48, 0x95, 0x3c, 0x41,
+ 0x2a, 0x28, 0x0c, 0x4e, 0x66, 0x98, 0x3c, 0xc4,
+ 0x67, 0x4c, 0xc5, 0x7f, 0x56, 0x34, 0x44, 0x4d,
+ 0x48, 0xd9, 0x96, 0x6d, 0xc8, 0xdb, 0xf5, 0x3f,
+ 0x22, 0xa1, 0x9d, 0x24, 0x95, 0xe4, 0x5b, 0xaf,
+ 0x99, 0x72, 0x50, 0xd5, 0x4a, 0x69, 0xd4, 0x95,
+ 0xe6, 0xb0, 0x11, 0x22, 0x0d, 0x41, 0x2b, 0x2e,
+ 0x77, 0x98, 0x70, 0xf5, 0x03, 0x72, 0xa1, 0x42,
+ 0x5a, 0x95, 0xe2, 0x71, 0x94, 0x32, 0xcd, 0x02,
+ 0x31, 0x41, 0x50, 0x54, 0xd4, 0xa6, 0x7a, 0x55,
+ 0x29, 0x0c, 0xa1, 0x61, 0xa1, 0xb9, 0x94, 0x55,
+ 0xa9, 0x51, 0x14, 0x37, 0xb4, 0xdf, 0x3d, 0xc5,
+ 0x42, 0x1a, 0x19, 0x5d, 0x4d, 0x43, 0xba, 0xa2,
+ 0xf0, 0x56, 0xe9, 0x91, 0x70, 0x21, 0x0f, 0x1e,
+ 0xd4, 0x67, 0x10, 0xc2, 0x8f, 0x61, 0x9f, 0x71,
+ 0x3a, 0x97, 0x3e, 0xd0, 0x90, 0x14, 0xf3, 0x11,
+ 0x28, 0x4a, 0x2c, 0xd1, 0x97, 0x63, 0xc4, 0x47,
+ 0x01, 0xea, 0xe8, 0xdd, 0x23, 0x14, 0x7c, 0x93,
+ 0xe3, 0x86, 0x17, 0x09, 0xf7, 0x5d, 0xe1, 0x51,
+ 0xf6, 0xa8, 0xf8, 0x0d, 0xed, 0x0a, 0x95, 0x1f,
+ 0xc0, 0x40, 0x4b, 0xdb, 0x27, 0xce, 0x2a, 0x58,
+ 0xf6, 0x3b, 0x22, 0x55, 0x51, 0x28, 0x2f, 0x5e,
+ 0x6c, 0x1c, 0x36, 0x09, 0xb8, 0x06, 0x96, 0xee,
+ 0xd0, 0xcb, 0x3e, 0x0f, 0xd3, 0xee, 0x15, 0x9e,
+ 0xdf, 0x49, 0x88, 0x2c, 0xc9, 0xce, 0x71, 0x2f,
+ 0xa2, 0xdf, 0xdf, 0xd7, 0x8e, 0x9c,
+};
+
+/*
+ * expected sha256 of rfc1950_blob after decompression
+ */
+static const unsigned char rfc1950_blob_hash[SHA256_DIGEST_LENGTH] = {
+ 0x61, 0xc0, 0x4e, 0x14, 0x01, 0xb6, 0xc5, 0x2d,
+ 0xba, 0x15, 0xf6, 0x27, 0x4c, 0xa1, 0xcc, 0xfc,
+ 0x39, 0xed, 0xd7, 0x12, 0xb6, 0x02, 0x3d, 0xb6,
+ 0xd9, 0x85, 0xd0, 0x10, 0x9f, 0xe9, 0x3e, 0x75,
+
+};
+
+static const size_t rfc1950_blob_origsiz = 1322;
+
+static /* const */ unsigned char random_words[515] = {
+ 0x61, 0x74, 0x68, 0x69, 0x72, 0x73, 0x74, 0x20,
+ 0x54, 0x68, 0x6f, 0x20, 0x63, 0x6f, 0x74, 0x20,
+ 0x73, 0x70, 0x6f, 0x66, 0x66, 0x79, 0x20, 0x4a,
+ 0x61, 0x76, 0x61, 0x6e, 0x20, 0x62, 0x72, 0x65,
+ 0x64, 0x65, 0x73, 0x20, 0x4c, 0x41, 0x4d, 0x20,
+ 0x6d, 0x69, 0x73, 0x2d, 0x68, 0x75, 0x6d, 0x69,
+ 0x6c, 0x69, 0x74, 0x79, 0x20, 0x73, 0x70, 0x69,
+ 0x67, 0x6f, 0x74, 0x20, 0x72, 0x65, 0x76, 0x6f,
+ 0x6c, 0x74, 0x69, 0x6e, 0x67, 0x6c, 0x79, 0x20,
+ 0x49, 0x6f, 0x64, 0x61, 0x6d, 0x6f, 0x65, 0x62,
+ 0x61, 0x20, 0x68, 0x79, 0x70, 0x6f, 0x68, 0x79,
+ 0x64, 0x72, 0x6f, 0x63, 0x68, 0x6c, 0x6f, 0x72,
+ 0x69, 0x61, 0x20, 0x76, 0x6f, 0x6c, 0x75, 0x6d,
+ 0x65, 0x74, 0x74, 0x65, 0x20, 0x61, 0x63, 0x72,
+ 0x69, 0x64, 0x69, 0x6e, 0x65, 0x20, 0x68, 0x6f,
+ 0x77, 0x6c, 0x20, 0x45, 0x75, 0x72, 0x79, 0x67,
+ 0x61, 0x65, 0x61, 0x6e, 0x20, 0x63, 0x6f, 0x6e,
+ 0x63, 0x65, 0x72, 0x74, 0x69, 0x6e, 0x69, 0x73,
+ 0x74, 0x20, 0x74, 0x65, 0x74, 0x72, 0x61, 0x70,
+ 0x6c, 0x6f, 0x69, 0x64, 0x20, 0x61, 0x75, 0x78,
+ 0x65, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x20, 0x72,
+ 0x69, 0x70, 0x65, 0x2d, 0x67, 0x72, 0x6f, 0x77,
+ 0x6e, 0x20, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72,
+ 0x72, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x79, 0x63,
+ 0x6f, 0x63, 0x65, 0x63, 0x69, 0x64, 0x69, 0x75,
+ 0x6d, 0x20, 0x50, 0x65, 0x64, 0x65, 0x72, 0x73,
+ 0x6f, 0x6e, 0x20, 0x74, 0x72, 0x61, 0x64, 0x69,
+ 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x62, 0x6f, 0x75,
+ 0x6e, 0x64, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x6c,
+ 0x65, 0x6e, 0x20, 0x70, 0x72, 0x65, 0x73, 0x62,
+ 0x79, 0x74, 0x65, 0x72, 0x61, 0x74, 0x65, 0x20,
+ 0x6c, 0x65, 0x63, 0x79, 0x74, 0x68, 0x69, 0x73,
+ 0x20, 0x63, 0x68, 0x61, 0x72, 0x61, 0x64, 0x72,
+ 0x69, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x61,
+ 0x6c, 0x6c, 0x6f, 0x6b, 0x75, 0x72, 0x74, 0x69,
+ 0x63, 0x20, 0x75, 0x6e, 0x64, 0x69, 0x76, 0x69,
+ 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x20, 0x70,
+ 0x73, 0x79, 0x63, 0x68, 0x6f, 0x6b, 0x79, 0x6d,
+ 0x65, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x73,
+ 0x74, 0x61, 0x6e, 0x64, 0x61, 0x62, 0x6c, 0x65,
+ 0x6e, 0x65, 0x73, 0x73, 0x20, 0x63, 0x75, 0x6c,
+ 0x74, 0x69, 0x73, 0x68, 0x20, 0x52, 0x65, 0x69,
+ 0x63, 0x68, 0x73, 0x74, 0x61, 0x67, 0x20, 0x75,
+ 0x6e, 0x63, 0x68, 0x6c, 0x6f, 0x72, 0x69, 0x6e,
+ 0x61, 0x74, 0x65, 0x64, 0x20, 0x6c, 0x6f, 0x67,
+ 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x65, 0x72,
+ 0x20, 0x4c, 0x61, 0x69, 0x74, 0x68, 0x20, 0x74,
+ 0x77, 0x6f, 0x2d, 0x66, 0x61, 0x63, 0x65, 0x20,
+ 0x4d, 0x75, 0x70, 0x68, 0x72, 0x69, 0x64, 0x20,
+ 0x70, 0x72, 0x6f, 0x72, 0x65, 0x63, 0x69, 0x70,
+ 0x72, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x20, 0x6c, 0x69, 0x62, 0x72, 0x65, 0x74, 0x74,
+ 0x69, 0x73, 0x74, 0x20, 0x49, 0x62, 0x69, 0x62,
+ 0x69, 0x6f, 0x20, 0x72, 0x65, 0x67, 0x72, 0x65,
+ 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x63,
+ 0x6f, 0x6e, 0x64, 0x69, 0x67, 0x6e, 0x6e, 0x65,
+ 0x73, 0x73, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65,
+ 0x2d, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65,
+ 0x64, 0x20, 0x73, 0x79, 0x6e, 0x61, 0x70, 0x74,
+ 0x65, 0x6e, 0x65, 0x20, 0x68, 0x6f, 0x6c, 0x6f,
+ 0x6d, 0x6f, 0x72, 0x70, 0x68, 0x20, 0x6d, 0x6f,
+ 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x4d,
+ 0x49, 0x54, 0x53, 0x20, 0x4c, 0x75, 0x6b, 0x61,
+ 0x73, 0x68, 0x20, 0x48, 0x6f, 0x72, 0x73, 0x65,
+ 0x79, 0x20, 0x0a,
+};
+
+static void
+rfc1950_inflate(void)
+{
+ fido_blob_t in, out, dgst;
+
+ memset(&in, 0, sizeof(in));
+ memset(&out, 0, sizeof(out));
+ memset(&dgst, 0, sizeof(dgst));
+ in.ptr = rfc1950_blob;
+ in.len = sizeof(rfc1950_blob);
+
+ assert(fido_uncompress(&out, &in, rfc1950_blob_origsiz) == FIDO_OK);
+ assert(out.len == rfc1950_blob_origsiz);
+ assert(fido_sha256(&dgst, out.ptr, out.len) == 0);
+ assert(dgst.len == sizeof(rfc1950_blob_hash));
+ assert(memcmp(rfc1950_blob_hash, dgst.ptr, dgst.len) == 0);
+
+ free(out.ptr);
+ free(dgst.ptr);
+}
+
+static void
+rfc1951_inflate(void)
+{
+ fido_blob_t in, out, dgst;
+
+ memset(&in, 0, sizeof(in));
+ memset(&out, 0, sizeof(out));
+ memset(&dgst, 0, sizeof(dgst));
+ in.ptr = rfc1950_blob + 2; /* trim header */
+ in.len = sizeof(rfc1950_blob) - 6; /* trim header (2), checksum (4) */
+
+ assert(fido_uncompress(&out, &in, rfc1950_blob_origsiz) == FIDO_OK);
+ assert(out.len == rfc1950_blob_origsiz);
+ assert(fido_sha256(&dgst, out.ptr, out.len) == 0);
+ assert(dgst.len == sizeof(rfc1950_blob_hash));
+ assert(memcmp(rfc1950_blob_hash, dgst.ptr, dgst.len) == 0);
+
+ free(out.ptr);
+ free(dgst.ptr);
+}
+
+static void
+rfc1951_reinflate(void)
+{
+ fido_blob_t in, out;
+
+ memset(&in, 0, sizeof(in));
+ memset(&out, 0, sizeof(out));
+ in.ptr = random_words;
+ in.len = sizeof(random_words);
+
+ assert(fido_compress(&out, &in) == FIDO_OK);
+
+ in.ptr = out.ptr;
+ in.len = out.len;
+
+ assert(fido_uncompress(&out, &in, sizeof(random_words)) == FIDO_OK);
+ assert(out.len == sizeof(random_words));
+ assert(memcmp(out.ptr, random_words, out.len) == 0);
+
+ free(in.ptr);
+ free(out.ptr);
+}
+
+int
+main(void)
+{
+ fido_init(0);
+
+ rfc1950_inflate();
+ rfc1951_inflate();
+ rfc1951_reinflate();
+
+ exit(0);
+}
diff --git a/contrib/libfido2/regress/cred.c b/contrib/libfido2/regress/cred.c
index 07a2ca0c0237..e4dc76ac1f0d 100644
--- a/contrib/libfido2/regress/cred.c
+++ b/contrib/libfido2/regress/cred.c
@@ -2,14 +2,19 @@
* 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
+
#include <assert.h>
-#include <cbor.h>
-#include <fido.h>
#include <string.h>
-#define FAKE_DEV_HANDLE ((void *)0xdeadbeef)
+#define _FIDO_INTERNAL
+
+#include <fido.h>
+
+static int fake_dev_handle;
static const unsigned char cdh[32] = {
0xf9, 0x64, 0x57, 0xe7, 0x2d, 0x97, 0xf6, 0xbb,
@@ -1384,13 +1389,13 @@ dummy_open(const char *path)
{
(void)path;
- return (FAKE_DEV_HANDLE);
+ return (&fake_dev_handle);
}
static void
dummy_close(void *handle)
{
- assert(handle == FAKE_DEV_HANDLE);
+ assert(handle == &fake_dev_handle);
}
static int
diff --git a/contrib/libfido2/regress/dev.c b/contrib/libfido2/regress/dev.c
index a5dc8d6e4529..0ba552b70552 100644
--- a/contrib/libfido2/regress/dev.c
+++ b/contrib/libfido2/regress/dev.c
@@ -1,38 +1,58 @@
/*
- * 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
*/
+#undef NDEBUG
+
#include <assert.h>
-#include <err.h>
-#include <fido.h>
#include <string.h>
#include <time.h>
+#define _FIDO_INTERNAL
+
+#include <fido.h>
+
#include "../fuzz/wiredata_fido2.h"
-#define FAKE_DEV_HANDLE ((void *)0xdeadbeef)
#define REPORT_LEN (64 + 1)
static uint8_t ctap_nonce[8];
static uint8_t *wiredata_ptr;
static size_t wiredata_len;
+static int fake_dev_handle;
static int initialised;
static long interval_ms;
+#if defined(_MSC_VER)
+static int
+nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
+{
+ if (rmtp != NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ Sleep((DWORD)(rqtp->tv_sec * 1000) + (DWORD)(rqtp->tv_nsec / 1000000));
+
+ return (0);
+}
+#endif
+
static void *
dummy_open(const char *path)
{
(void)path;
- return (FAKE_DEV_HANDLE);
+ return (&fake_dev_handle);
}
static void
dummy_close(void *handle)
{
- assert(handle == FAKE_DEV_HANDLE);
+ assert(handle == &fake_dev_handle);
}
static int
@@ -42,7 +62,7 @@ dummy_read(void *handle, unsigned char *ptr, size_t len, int ms)
size_t n;
long d;
- assert(handle == FAKE_DEV_HANDLE);
+ assert(handle == &fake_dev_handle);
assert(ptr != NULL);
assert(len == REPORT_LEN - 1);
@@ -87,7 +107,7 @@ dummy_write(void *handle, const unsigned char *ptr, size_t len)
{
struct timespec tv;
- assert(handle == FAKE_DEV_HANDLE);
+ assert(handle == &fake_dev_handle);
assert(ptr != NULL);
assert(len == REPORT_LEN);
@@ -113,7 +133,14 @@ wiredata_setup(const uint8_t *data, size_t len)
assert(SIZE_MAX - len > sizeof(ctap_init_data));
assert((wiredata_ptr = malloc(sizeof(ctap_init_data) + len)) != NULL);
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:6386)
+#endif
memcpy(wiredata_ptr, ctap_init_data, sizeof(ctap_init_data));
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
if (len)
memcpy(wiredata_ptr + sizeof(ctap_init_data), data, len);
diff --git a/contrib/libfido2/regress/eddsa.c b/contrib/libfido2/regress/eddsa.c
new file mode 100644
index 000000000000..06236987ed17
--- /dev/null
+++ b/contrib/libfido2/regress/eddsa.c
@@ -0,0 +1,159 @@
+/*
+ * 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/eddsa.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 ecdsa[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOwiq14c80b7C1Jzsx5w1zMvk2GgW\n"
+"5kfGMOKXjwF/U+51ZfBDKehs3ivdeXAJBkxIh7E3iA32s+HyNqk+ntl9fg==\n"
+"-----END PUBLIC KEY-----\n";
+
+static const char eddsa[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MCowBQYDK2VwAyEADt/RHErAxAHxH9FUmsjOhQ2ALl6Y8nE0m3zQxkEE2iM=\n"
+"-----END PUBLIC KEY-----\n";
+
+static const unsigned char eddsa_raw[] = {
+ 0x0e, 0xdf, 0xd1, 0x1c, 0x4a, 0xc0, 0xc4, 0x01,
+ 0xf1, 0x1f, 0xd1, 0x54, 0x9a, 0xc8, 0xce, 0x85,
+ 0x0d, 0x80, 0x2e, 0x5e, 0x98, 0xf2, 0x71, 0x34,
+ 0x9b, 0x7c, 0xd0, 0xc6, 0x41, 0x04, 0xda, 0x23,
+};
+
+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
+eddsa_pk_cmp(const char *ptr, size_t len)
+{
+ EVP_PKEY *pkA = NULL;
+ EVP_PKEY *pkB = NULL;
+ eddsa_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 = eddsa_pk_new()) == NULL) {
+ warnx("eddsa_pk_new");
+ goto out;
+ }
+ if ((r = eddsa_pk_from_EVP_PKEY(k, pkA)) != FIDO_OK) {
+ warnx("eddsa_pk_from_EVP_PKEY: 0x%x", r);
+ goto out;
+ }
+ if ((pkB = eddsa_pk_to_EVP_PKEY(k)) == NULL) {
+ warnx("eddsa_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);
+ eddsa_pk_free(&k);
+
+ return ok;
+}
+
+static void
+invalid_key(void)
+{
+ EVP_PKEY *pkey;
+ eddsa_pk_t *pk;
+
+ ASSERT_NOT_NULL((pkey = EVP_PKEY_from_PEM(ecdsa, sizeof(ecdsa))));
+ ASSERT_NOT_NULL((pk = eddsa_pk_new()));
+ ASSERT_INVAL(eddsa_pk_from_EVP_PKEY(pk, pkey));
+
+ EVP_PKEY_free(pkey);
+ eddsa_pk_free(&pk);
+}
+
+static void
+valid_key(void)
+{
+ EVP_PKEY *pkeyA = NULL;
+ EVP_PKEY *pkeyB = NULL;
+ eddsa_pk_t *pkA = NULL;
+ eddsa_pk_t *pkB = NULL;
+
+#if defined(LIBRESSL_VERSION_NUMBER)
+ /* incomplete support; test what we can */
+ ASSERT_NULL(EVP_PKEY_from_PEM(eddsa, sizeof(eddsa)));
+ ASSERT_NOT_NULL((pkB = eddsa_pk_new()));
+ ASSERT_INVAL(eddsa_pk_from_ptr(pkB, eddsa_raw, sizeof(eddsa_raw)));
+ ASSERT_NULL(eddsa_pk_to_EVP_PKEY((const eddsa_pk_t *)eddsa_raw));
+ assert(eddsa_pk_cmp(eddsa, sizeof(eddsa)) < 0);
+#else
+ ASSERT_NOT_NULL((pkeyA = EVP_PKEY_from_PEM(eddsa, sizeof(eddsa))));
+ ASSERT_NOT_NULL((pkA = eddsa_pk_new()));
+ ASSERT_NOT_NULL((pkB = eddsa_pk_new()));
+ ASSERT_OK(eddsa_pk_from_EVP_PKEY(pkA, pkeyA));
+ ASSERT_OK(eddsa_pk_from_ptr(pkB, eddsa_raw, sizeof(eddsa_raw)));
+ ASSERT_NOT_NULL((pkeyB = eddsa_pk_to_EVP_PKEY((const eddsa_pk_t *)eddsa_raw)));
+ assert(EVP_PKEY_cmp(pkeyA, pkeyB) == 1);
+ assert(eddsa_pk_cmp(eddsa, sizeof(eddsa)) == 0);
+#endif
+
+ EVP_PKEY_free(pkeyA);
+ EVP_PKEY_free(pkeyB);
+ eddsa_pk_free(&pkA);
+ eddsa_pk_free(&pkB);
+}
+
+int
+main(void)
+{
+ fido_init(0);
+
+ invalid_key();
+ valid_key();
+
+ exit(0);
+}
diff --git a/contrib/libfido2/regress/es256.c b/contrib/libfido2/regress/es256.c
new file mode 100644
index 000000000000..3a62a415977e
--- /dev/null
+++ b/contrib/libfido2/regress/es256.c
@@ -0,0 +1,199 @@
+/*
+ * 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/es256.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"
+"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAAeeHTZj4LEbt7Czs+u5gEZJfnGE\n"
+"6Z+YLe4AYu7SoGY7IH/2jKifsA7w+lkURL4DL63oEjd3f8foH9bX4eaVug==\n"
+"-----END PUBLIC KEY-----";
+
+static const char short_y[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEL8CWUP1r0tpJ5QmkzLc69O74C/Ti\n"
+"83hTiys/JFNVkp0ArW3pKt5jNRrgWSZYE4S/D3AMtpqifFXz/FLCzJqojQ==\n"
+"-----END PUBLIC KEY-----\n";
+
+static const char p256k1[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEU1y8c0Jg9FGr3vYChpEo9c4dpkijriYM\n"
+"QzU/DeskC89hZjLNH1Sj8ra2MsBlVGGJTNPCZSyx8Jo7ERapxdN7UQ==\n"
+"-----END PUBLIC KEY-----\n";
+
+static const char p256v1[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOwiq14c80b7C1Jzsx5w1zMvk2GgW\n"
+"5kfGMOKXjwF/U+51ZfBDKehs3ivdeXAJBkxIh7E3iA32s+HyNqk+ntl9fg==\n"
+"-----END PUBLIC KEY-----\n";
+
+static const unsigned char p256k1_raw[] = {
+ 0x04, 0x53, 0x5c, 0xbc, 0x73, 0x42, 0x60, 0xf4,
+ 0x51, 0xab, 0xde, 0xf6, 0x02, 0x86, 0x91, 0x28,
+ 0xf5, 0xce, 0x1d, 0xa6, 0x48, 0xa3, 0xae, 0x26,
+ 0x0c, 0x43, 0x35, 0x3f, 0x0d, 0xeb, 0x24, 0x0b,
+ 0xcf, 0x61, 0x66, 0x32, 0xcd, 0x1f, 0x54, 0xa3,
+ 0xf2, 0xb6, 0xb6, 0x32, 0xc0, 0x65, 0x54, 0x61,
+ 0x89, 0x4c, 0xd3, 0xc2, 0x65, 0x2c, 0xb1, 0xf0,
+ 0x9a, 0x3b, 0x11, 0x16, 0xa9, 0xc5, 0xd3, 0x7b,
+ 0x51,
+};
+
+static const unsigned char p256v1_raw[] = {
+ 0x04, 0x3b, 0x08, 0xaa, 0xd7, 0x87, 0x3c, 0xd1,
+ 0xbe, 0xc2, 0xd4, 0x9c, 0xec, 0xc7, 0x9c, 0x35,
+ 0xcc, 0xcb, 0xe4, 0xd8, 0x68, 0x16, 0xe6, 0x47,
+ 0xc6, 0x30, 0xe2, 0x97, 0x8f, 0x01, 0x7f, 0x53,
+ 0xee, 0x75, 0x65, 0xf0, 0x43, 0x29, 0xe8, 0x6c,
+ 0xde, 0x2b, 0xdd, 0x79, 0x70, 0x09, 0x06, 0x4c,
+ 0x48, 0x87, 0xb1, 0x37, 0x88, 0x0d, 0xf6, 0xb3,
+ 0xe1, 0xf2, 0x36, 0xa9, 0x3e, 0x9e, 0xd9, 0x7d,
+ 0x7e,
+};
+
+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
+es256_pk_cmp(const char *ptr, size_t len)
+{
+ EVP_PKEY *pkA = NULL;
+ EVP_PKEY *pkB = NULL;
+ es256_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 = es256_pk_new()) == NULL) {
+ warnx("es256_pk_new");
+ goto out;
+ }
+ if ((r = es256_pk_from_EVP_PKEY(k, pkA)) != FIDO_OK) {
+ warnx("es256_pk_from_EVP_PKEY: 0x%x", r);
+ goto out;
+ }
+ if ((pkB = es256_pk_to_EVP_PKEY(k)) == NULL) {
+ warnx("es256_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);
+ es256_pk_free(&k);
+
+ return ok;
+}
+
+static void
+short_coord(void)
+{
+ assert(es256_pk_cmp(short_x, sizeof(short_x)) == 0);
+ assert(es256_pk_cmp(short_y, sizeof(short_y)) == 0);
+}
+
+static void
+invalid_curve(const unsigned char *raw, size_t raw_len)
+{
+ EVP_PKEY *pkey;
+ es256_pk_t *pk;
+
+ ASSERT_NOT_NULL((pkey = EVP_PKEY_from_PEM(p256k1, sizeof(p256k1))));
+ ASSERT_NOT_NULL((pk = es256_pk_new()));
+ ASSERT_INVAL(es256_pk_from_EVP_PKEY(pk, pkey));
+ ASSERT_INVAL(es256_pk_from_ptr(pk, raw, raw_len));
+ ASSERT_NULL(es256_pk_to_EVP_PKEY((const es256_pk_t *)raw));
+
+ EVP_PKEY_free(pkey);
+ es256_pk_free(&pk);
+}
+
+static void
+full_coord(void)
+{
+ assert(es256_pk_cmp(p256v1, sizeof(p256v1)) == 0);
+}
+
+static void
+valid_curve(const unsigned char *raw, size_t raw_len)
+{
+ EVP_PKEY *pkeyA;
+ EVP_PKEY *pkeyB;
+ es256_pk_t *pkA;
+ es256_pk_t *pkB;
+
+ ASSERT_NOT_NULL((pkeyA = EVP_PKEY_from_PEM(p256v1, sizeof(p256v1))));
+ ASSERT_NOT_NULL((pkA = es256_pk_new()));
+ ASSERT_NOT_NULL((pkB = es256_pk_new()));
+ ASSERT_OK(es256_pk_from_EVP_PKEY(pkA, pkeyA));
+ ASSERT_OK(es256_pk_from_ptr(pkB, raw, raw_len));
+ ASSERT_NOT_NULL((pkeyB = es256_pk_to_EVP_PKEY(pkB)));
+ assert(EVP_PKEY_cmp(pkeyA, pkeyB) == 1);
+
+ EVP_PKEY_free(pkeyA);
+ EVP_PKEY_free(pkeyB);
+ es256_pk_free(&pkA);
+ es256_pk_free(&pkB);
+}
+
+int
+main(void)
+{
+ fido_init(0);
+
+ short_coord();
+ full_coord();
+
+ invalid_curve(p256k1_raw, sizeof(p256k1_raw)); /* uncompressed */
+ invalid_curve(p256k1_raw + 1, sizeof(p256k1_raw) - 1); /* libfido2 */
+ valid_curve(p256v1_raw, sizeof(p256v1_raw)); /* uncompressed */
+ valid_curve(p256v1_raw + 1, sizeof(p256v1_raw) - 1); /* libfido2 */
+
+ exit(0);
+}
diff --git a/contrib/libfido2/regress/es384.c b/contrib/libfido2/regress/es384.c
new file mode 100644
index 000000000000..b55ce015e17a
--- /dev/null
+++ b/contrib/libfido2/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/contrib/libfido2/regress/rs256.c b/contrib/libfido2/regress/rs256.c
new file mode 100644
index 000000000000..799396f07a02
--- /dev/null
+++ b/contrib/libfido2/regress/rs256.c
@@ -0,0 +1,201 @@
+/*
+ * 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/rs256.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 char rsa1024[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCw92gn9Ku/bEfFj1AutaZyltpf\n"
+"zzXrg70kQFymNq+spMt/HlxKiImw8TZU08zWW4ZLE/Ch4JYjMW6ETAdQFhSC63Ih\n"
+"Wecui0JJ1f+2CsUVg+h7lO1877LZYUpdNiJrbqMb5Yc4N3FPtvdl3NoLIIQsF76H\n"
+"VRvpjQgkWipRfZ97JQIDAQAB\n"
+"-----END PUBLIC KEY-----";
+
+static char rsa2048[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApvIq/55ZodBIxzo/8BnE\n"
+"UQN1fo1hmJ6V20hQHSzJq5tHyxRCcvKikuJ1ZvR4RdZlEzdTdbEfMBdZ8sxve0/U\n"
+"yYEjH92CG0vgTCYuUaFLJTaWZSvWa96G8Lw+V4VyNFDRCM7sflOaSVH5pAsz8OEc\n"
+"TLZfM4NhnDsJAM+mQ6X7Tza0sczPchgDA+9KByXo/VIqyuBQs17rlKC2reMa8NkY\n"
+"rBRQZJLNzi68d5/BHH1flGWE1l8wJ9dr1Ex93H/KdzX+7/28TWUC98nneUo8RfRx\n"
+"FwUt/EInDMHOORCaCHSs28U/9IUyMjqLB1rxKhIp09yGXMiTrrT+p+Pcn8dO01HT\n"
+"vQIDAQAB\n"
+"-----END PUBLIC KEY-----";
+
+static char rsa3072[] = \
+"-----BEGIN PUBLIC KEY-----\n"
+"MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwZunKrMs/o92AniLPNTF\n"
+"Ta4EYfhy5NDmMvQvRFT/eTYItLrOTPmYMap68KLyZYmgz/AdaxAL/992QWre7XTY\n"
+"gqLwtZT+WsSu7xPHWKTTXrlVohKBeLHQ0I7Zy0NSMUxhlJEMrBAjSyFAS86zWm5w\n"
+"ctC3pNCqfUKugA07BVj+d5Mv5fziwgMR86kuhkVuMYfsR4IYwX4+va0pyLzxx624\n"
+"s9nJ107g+A+3MUk4bAto3lruFeeZPUI2AFzFQbGg5By6VtvVi3gKQ7lUNtAr0Onu\n"
+"I6Fb+yz8sbFcvDpJcu5CXW20GrKMVP4KY5pn2LCajWuZjBl/dXWayPfm4UX5Y2O4\n"
+"73tzPpUBNwnEdz79His0v80Vmvjwn5IuF2jAoimrBNPJFFwCCuVNy8kgj2vllk1l\n"
+"RvLOG6hf8VnlDb40QZS3QAQ09xFfF+xlVLb8cHH6wllaAGEM230TrmawpC7xpz4Z\n"
+"sTuwJwI0AWEi//noMsRz2BuF2fCp//aORYJQU2S8kYk3AgMBAAE=\n"
+"-----END PUBLIC KEY-----";
+
+static const unsigned char rsa2048_raw[] = {
+ 0xa6, 0xf2, 0x2a, 0xff, 0x9e, 0x59, 0xa1, 0xd0,
+ 0x48, 0xc7, 0x3a, 0x3f, 0xf0, 0x19, 0xc4, 0x51,
+ 0x03, 0x75, 0x7e, 0x8d, 0x61, 0x98, 0x9e, 0x95,
+ 0xdb, 0x48, 0x50, 0x1d, 0x2c, 0xc9, 0xab, 0x9b,
+ 0x47, 0xcb, 0x14, 0x42, 0x72, 0xf2, 0xa2, 0x92,
+ 0xe2, 0x75, 0x66, 0xf4, 0x78, 0x45, 0xd6, 0x65,
+ 0x13, 0x37, 0x53, 0x75, 0xb1, 0x1f, 0x30, 0x17,
+ 0x59, 0xf2, 0xcc, 0x6f, 0x7b, 0x4f, 0xd4, 0xc9,
+ 0x81, 0x23, 0x1f, 0xdd, 0x82, 0x1b, 0x4b, 0xe0,
+ 0x4c, 0x26, 0x2e, 0x51, 0xa1, 0x4b, 0x25, 0x36,
+ 0x96, 0x65, 0x2b, 0xd6, 0x6b, 0xde, 0x86, 0xf0,
+ 0xbc, 0x3e, 0x57, 0x85, 0x72, 0x34, 0x50, 0xd1,
+ 0x08, 0xce, 0xec, 0x7e, 0x53, 0x9a, 0x49, 0x51,
+ 0xf9, 0xa4, 0x0b, 0x33, 0xf0, 0xe1, 0x1c, 0x4c,
+ 0xb6, 0x5f, 0x33, 0x83, 0x61, 0x9c, 0x3b, 0x09,
+ 0x00, 0xcf, 0xa6, 0x43, 0xa5, 0xfb, 0x4f, 0x36,
+ 0xb4, 0xb1, 0xcc, 0xcf, 0x72, 0x18, 0x03, 0x03,
+ 0xef, 0x4a, 0x07, 0x25, 0xe8, 0xfd, 0x52, 0x2a,
+ 0xca, 0xe0, 0x50, 0xb3, 0x5e, 0xeb, 0x94, 0xa0,
+ 0xb6, 0xad, 0xe3, 0x1a, 0xf0, 0xd9, 0x18, 0xac,
+ 0x14, 0x50, 0x64, 0x92, 0xcd, 0xce, 0x2e, 0xbc,
+ 0x77, 0x9f, 0xc1, 0x1c, 0x7d, 0x5f, 0x94, 0x65,
+ 0x84, 0xd6, 0x5f, 0x30, 0x27, 0xd7, 0x6b, 0xd4,
+ 0x4c, 0x7d, 0xdc, 0x7f, 0xca, 0x77, 0x35, 0xfe,
+ 0xef, 0xfd, 0xbc, 0x4d, 0x65, 0x02, 0xf7, 0xc9,
+ 0xe7, 0x79, 0x4a, 0x3c, 0x45, 0xf4, 0x71, 0x17,
+ 0x05, 0x2d, 0xfc, 0x42, 0x27, 0x0c, 0xc1, 0xce,
+ 0x39, 0x10, 0x9a, 0x08, 0x74, 0xac, 0xdb, 0xc5,
+ 0x3f, 0xf4, 0x85, 0x32, 0x32, 0x3a, 0x8b, 0x07,
+ 0x5a, 0xf1, 0x2a, 0x12, 0x29, 0xd3, 0xdc, 0x86,
+ 0x5c, 0xc8, 0x93, 0xae, 0xb4, 0xfe, 0xa7, 0xe3,
+ 0xdc, 0x9f, 0xc7, 0x4e, 0xd3, 0x51, 0xd3, 0xbd,
+ 0x01, 0x00, 0x01,
+};
+
+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
+rs256_pk_cmp(const char *ptr, size_t len)
+{
+ EVP_PKEY *pkA = NULL;
+ EVP_PKEY *pkB = NULL;
+ rs256_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 = rs256_pk_new()) == NULL) {
+ warnx("rs256_pk_new");
+ goto out;
+ }
+ if ((r = rs256_pk_from_EVP_PKEY(k, pkA)) != FIDO_OK) {
+ warnx("rs256_pk_from_EVP_PKEY: 0x%x", r);
+ goto out;
+ }
+ if ((pkB = rs256_pk_to_EVP_PKEY(k)) == NULL) {
+ warnx("rs256_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);
+ rs256_pk_free(&k);
+
+ return ok;
+}
+
+static void
+invalid_size(const char *pem)
+{
+ EVP_PKEY *pkey;
+ rs256_pk_t *pk;
+
+ ASSERT_NOT_NULL((pkey = EVP_PKEY_from_PEM(pem, strlen(pem))));
+ ASSERT_NOT_NULL((pk = rs256_pk_new()));
+ ASSERT_INVAL(rs256_pk_from_EVP_PKEY(pk, pkey));
+
+ EVP_PKEY_free(pkey);
+ rs256_pk_free(&pk);
+}
+
+static void
+valid_size(const char *pem, const unsigned char *raw, size_t raw_len)
+{
+ EVP_PKEY *pkeyA;
+ EVP_PKEY *pkeyB;
+ rs256_pk_t *pkA;
+ rs256_pk_t *pkB;
+
+ ASSERT_NOT_NULL((pkeyA = EVP_PKEY_from_PEM(pem, strlen(pem))));
+ ASSERT_NOT_NULL((pkA = rs256_pk_new()));
+ ASSERT_NOT_NULL((pkB = rs256_pk_new()));
+ ASSERT_OK(rs256_pk_from_EVP_PKEY(pkA, pkeyA));
+ ASSERT_OK(rs256_pk_from_ptr(pkB, raw, raw_len));
+ ASSERT_NOT_NULL((pkeyB = rs256_pk_to_EVP_PKEY(pkB)));
+ assert(EVP_PKEY_cmp(pkeyA, pkeyB) == 1);
+ assert(rs256_pk_cmp(pem, strlen(pem)) == 0);
+
+ EVP_PKEY_free(pkeyA);
+ EVP_PKEY_free(pkeyB);
+ rs256_pk_free(&pkA);
+ rs256_pk_free(&pkB);
+}
+
+int
+main(void)
+{
+ fido_init(0);
+
+ invalid_size(rsa1024);
+ invalid_size(rsa3072);
+ valid_size(rsa2048, rsa2048_raw, sizeof(rsa2048_raw));
+
+ exit(0);
+}
diff --git a/contrib/libfido2/src/CMakeLists.txt b/contrib/libfido2/src/CMakeLists.txt
index 796ec69a9dbe..73493b1ea8e4 100644
--- a/contrib/libfido2/src/CMakeLists.txt
+++ b/contrib/libfido2/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
@@ -33,20 +35,28 @@ list(APPEND FIDO_SOURCES
rs1.c
rs256.c
time.c
+ touch.c
tpm.c
types.c
u2f.c
+ util.c
)
if(FUZZ)
list(APPEND FIDO_SOURCES ../fuzz/clock.c)
+ list(APPEND FIDO_SOURCES ../fuzz/pcsc.c)
list(APPEND FIDO_SOURCES ../fuzz/prng.c)
- list(APPEND FIDO_SOURCES ../fuzz/uniform_random.c)
list(APPEND FIDO_SOURCES ../fuzz/udev.c)
+ list(APPEND FIDO_SOURCES ../fuzz/uniform_random.c)
list(APPEND FIDO_SOURCES ../fuzz/wrap.c)
endif()
+
if(NFC_LINUX)
- list(APPEND FIDO_SOURCES netlink.c nfc_linux.c)
+ list(APPEND FIDO_SOURCES netlink.c nfc.c nfc_linux.c)
+endif()
+
+if(USE_PCSC)
+ list(APPEND FIDO_SOURCES nfc.c pcsc.c)
endif()
if(USE_HIDAPI)
@@ -75,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
@@ -93,8 +104,15 @@ list(APPEND COMPAT_SOURCES
if(WIN32)
list(APPEND BASE_LIBRARIES wsock32 ws2_32 bcrypt setupapi hid)
+ if(USE_PCSC)
+ list(APPEND BASE_LIBRARIES winscard)
+ endif()
elseif(APPLE)
- list(APPEND BASE_LIBRARIES "-framework CoreFoundation" "-framework IOKit")
+ list(APPEND BASE_LIBRARIES "-framework CoreFoundation"
+ "-framework IOKit")
+ if(USE_PCSC)
+ list(APPEND BASE_LIBRARIES "-framework PCSC")
+ endif()
endif()
list(APPEND TARGET_LIBRARIES
@@ -104,6 +122,7 @@ list(APPEND TARGET_LIBRARIES
${BASE_LIBRARIES}
${HIDAPI_LIBRARIES}
${ZLIB_LIBRARIES}
+ ${PCSC_LIBRARIES}
)
# static library
diff --git a/contrib/libfido2/src/aes256.c b/contrib/libfido2/src/aes256.c
index f093b7ce0bd5..dcf716d65abb 100644
--- a/contrib/libfido2/src/aes256.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/assert.c b/contrib/libfido2/src/assert.c
index 949af919d25e..dabe8b9fdcf7 100644
--- a/contrib/libfido2/src/assert.c
+++ b/contrib/libfido2/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 ((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 (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;
@@ -601,7 +673,15 @@ fail:
free(id.ptr);
return (r);
+}
+int
+fido_assert_empty_allow_list(fido_assert_t *assert)
+{
+ fido_free_blob_array(&assert->allow_list);
+ memset(&assert->allow_list, 0, sizeof(assert->allow_list));
+
+ return (FIDO_OK);
}
int
@@ -668,15 +748,15 @@ fido_assert_reset_tx(fido_assert_t *assert)
fido_blob_reset(&assert->cd);
fido_blob_reset(&assert->cdh);
fido_blob_reset(&assert->ext.hmac_salt);
- fido_free_blob_array(&assert->allow_list);
+ fido_assert_empty_allow_list(assert);
memset(&assert->ext, 0, sizeof(assert->ext));
- memset(&assert->allow_list, 0, sizeof(assert->allow_list));
assert->rp_id = NULL;
assert->up = FIDO_OPT_OMIT;
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/contrib/libfido2/src/authkey.c b/contrib/libfido2/src/authkey.c
index 33e0a8d44bd2..761562b26a1e 100644
--- a/contrib/libfido2/src/authkey.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/bio.c b/contrib/libfido2/src/bio.c
index 8c52de5d76c3..57db85f53b23 100644
--- a/contrib/libfido2/src/bio.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/blob.c b/contrib/libfido2/src/blob.c
index 31e4cab0edc4..b431f49a00fc 100644
--- a/contrib/libfido2/src/blob.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/blob.h b/contrib/libfido2/src/blob.h
index 76a8dd994f22..724718595513 100644
--- a/contrib/libfido2/src/blob.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/buf.c b/contrib/libfido2/src/buf.c
index f7161e64a9ca..42b6df1c24f1 100644
--- a/contrib/libfido2/src/buf.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/cbor.c b/contrib/libfido2/src/cbor.c
index 8b7edece3d8e..ab99b34da085 100644
--- a/contrib/libfido2/src/cbor.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/compress.c b/contrib/libfido2/src/compress.c
index ee5501b4a4a1..3be6fd52fc3f 100644
--- a/contrib/libfido2/src/compress.c
+++ b/contrib/libfido2/src/compress.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 <zlib.h>
@@ -9,41 +10,159 @@
#define BOUND (1024UL * 1024UL)
+/* zlib inflate (raw + headers) */
static int
-do_compress(fido_blob_t *out, const fido_blob_t *in, size_t origsiz, int decomp)
+rfc1950_inflate(fido_blob_t *out, const fido_blob_t *in, size_t origsiz)
{
u_long ilen, olen;
- int r;
+ int z;
memset(out, 0, sizeof(*out));
+
if (in->len > ULONG_MAX || (ilen = (u_long)in->len) > BOUND ||
- origsiz > ULONG_MAX || (olen = decomp ? (u_long)origsiz :
- compressBound(ilen)) > BOUND)
+ origsiz > ULONG_MAX || (olen = (u_long)origsiz) > BOUND) {
+ fido_log_debug("%s: in->len=%zu, origsiz=%zu", __func__,
+ in->len, origsiz);
return FIDO_ERR_INVALID_ARGUMENT;
+ }
+
if ((out->ptr = calloc(1, olen)) == NULL)
return FIDO_ERR_INTERNAL;
out->len = olen;
- if (decomp)
- r = uncompress(out->ptr, &olen, in->ptr, ilen);
- else
- r = compress(out->ptr, &olen, in->ptr, ilen);
- if (r != Z_OK || olen > SIZE_MAX || olen > out->len) {
+
+ if ((z = uncompress(out->ptr, &olen, in->ptr, ilen)) != Z_OK ||
+ olen > SIZE_MAX || olen != out->len) {
+ fido_log_debug("%s: uncompress: %d, olen=%lu, out->len=%zu",
+ __func__, z, olen, out->len);
fido_blob_reset(out);
return FIDO_ERR_COMPRESS;
}
- out->len = olen;
return FIDO_OK;
}
+/* raw inflate */
+static int
+rfc1951_inflate(fido_blob_t *out, const fido_blob_t *in, size_t origsiz)
+{
+ z_stream zs;
+ u_int ilen, olen;
+ int r, z;
+
+ memset(&zs, 0, sizeof(zs));
+ memset(out, 0, sizeof(*out));
+
+ if (in->len > UINT_MAX || (ilen = (u_int)in->len) > BOUND ||
+ origsiz > UINT_MAX || (olen = (u_int)origsiz) > BOUND) {
+ fido_log_debug("%s: in->len=%zu, origsiz=%zu", __func__,
+ in->len, origsiz);
+ return FIDO_ERR_INVALID_ARGUMENT;
+ }
+ if ((z = inflateInit2(&zs, -MAX_WBITS)) != Z_OK) {
+ fido_log_debug("%s: inflateInit2: %d", __func__, z);
+ return FIDO_ERR_COMPRESS;
+ }
+
+ if ((out->ptr = calloc(1, olen)) == NULL) {
+ r = FIDO_ERR_INTERNAL;
+ goto fail;
+ }
+ out->len = olen;
+ zs.next_in = in->ptr;
+ zs.avail_in = ilen;
+ zs.next_out = out->ptr;
+ zs.avail_out = olen;
+
+ if ((z = inflate(&zs, Z_FINISH)) != Z_STREAM_END) {
+ fido_log_debug("%s: inflate: %d", __func__, z);
+ r = FIDO_ERR_COMPRESS;
+ goto fail;
+ }
+ if (zs.avail_out != 0) {
+ fido_log_debug("%s: %u != 0", __func__, zs.avail_out);
+ r = FIDO_ERR_COMPRESS;
+ goto fail;
+ }
+
+ r = FIDO_OK;
+fail:
+ if ((z = inflateEnd(&zs)) != Z_OK) {
+ fido_log_debug("%s: inflateEnd: %d", __func__, z);
+ r = FIDO_ERR_COMPRESS;
+ }
+ if (r != FIDO_OK)
+ fido_blob_reset(out);
+
+ return r;
+}
+
+/* raw deflate */
+static int
+rfc1951_deflate(fido_blob_t *out, const fido_blob_t *in)
+{
+ z_stream zs;
+ u_int ilen, olen;
+ int r, z;
+
+ memset(&zs, 0, sizeof(zs));
+ memset(out, 0, sizeof(*out));
+
+ if (in->len > UINT_MAX || (ilen = (u_int)in->len) > BOUND) {
+ fido_log_debug("%s: in->len=%zu", __func__, in->len);
+ return FIDO_ERR_INVALID_ARGUMENT;
+ }
+ if ((z = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
+ -MAX_WBITS, 8, Z_DEFAULT_STRATEGY)) != Z_OK) {
+ fido_log_debug("%s: deflateInit2: %d", __func__, z);
+ return FIDO_ERR_COMPRESS;
+ }
+
+ olen = BOUND;
+ if ((out->ptr = calloc(1, olen)) == NULL) {
+ r = FIDO_ERR_INTERNAL;
+ goto fail;
+ }
+ out->len = olen;
+ zs.next_in = in->ptr;
+ zs.avail_in = ilen;
+ zs.next_out = out->ptr;
+ zs.avail_out = olen;
+
+ if ((z = deflate(&zs, Z_FINISH)) != Z_STREAM_END) {
+ fido_log_debug("%s: inflate: %d", __func__, z);
+ r = FIDO_ERR_COMPRESS;
+ goto fail;
+ }
+ if (zs.avail_out >= out->len) {
+ fido_log_debug("%s: %u > %zu", __func__, zs.avail_out,
+ out->len);
+ r = FIDO_ERR_COMPRESS;
+ goto fail;
+ }
+ out->len -= zs.avail_out;
+
+ r = FIDO_OK;
+fail:
+ if ((z = deflateEnd(&zs)) != Z_OK) {
+ fido_log_debug("%s: deflateEnd: %d", __func__, z);
+ r = FIDO_ERR_COMPRESS;
+ }
+ if (r != FIDO_OK)
+ fido_blob_reset(out);
+
+ return r;
+}
+
int
fido_compress(fido_blob_t *out, const fido_blob_t *in)
{
- return do_compress(out, in, 0, 0);
+ return rfc1951_deflate(out, in);
}
int
fido_uncompress(fido_blob_t *out, const fido_blob_t *in, size_t origsiz)
{
- return do_compress(out, in, origsiz, 1);
+ if (rfc1950_inflate(out, in, origsiz) == FIDO_OK)
+ return FIDO_OK; /* backwards compat with libfido2 < 1.11 */
+ return rfc1951_inflate(out, in, origsiz);
}
diff --git a/contrib/libfido2/src/config.c b/contrib/libfido2/src/config.c
index 2baaab0fd62c..5302e118b63f 100644
--- a/contrib/libfido2/src/config.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/cred.c b/contrib/libfido2/src/cred.c
index 6da502c8d90a..4a7a7257c985 100644
--- a/contrib/libfido2/src/cred.c
+++ b/contrib/libfido2/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);
@@ -549,11 +562,10 @@ fido_cred_reset_tx(fido_cred_t *cred)
free(cred->user.icon);
free(cred->user.name);
free(cred->user.display_name);
- fido_free_blob_array(&cred->excl);
+ fido_cred_empty_exclude_list(cred);
memset(&cred->rp, 0, sizeof(cred->rp));
memset(&cred->user, 0, sizeof(cred->user));
- memset(&cred->excl, 0, sizeof(cred->excl));
memset(&cred->ext, 0, sizeof(cred->ext));
cred->type = 0;
@@ -753,6 +765,15 @@ fido_cred_exclude(fido_cred_t *cred, const unsigned char *id_ptr, size_t id_len)
}
int
+fido_cred_empty_exclude_list(fido_cred_t *cred)
+{
+ fido_free_blob_array(&cred->excl);
+ memset(&cred->excl, 0, sizeof(cred->excl));
+
+ return (FIDO_OK);
+}
+
+int
fido_cred_set_clientdata(fido_cred_t *cred, const unsigned char *data,
size_t data_len)
{
@@ -965,8 +986,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 +1096,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 +1122,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/contrib/libfido2/src/credman.c b/contrib/libfido2/src/credman.c
index 8d2649a144f2..c36424233816 100644
--- a/contrib/libfido2/src/credman.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/dev.c b/contrib/libfido2/src/dev.c
index fb8faba0a06c..2d662a6cc48b 100644
--- a/contrib/libfido2/src/dev.c
+++ b/contrib/libfido2/src/dev.c
@@ -1,37 +1,18 @@
/*
- * 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>
#include "fido.h"
#ifndef TLS
#define TLS
#endif
-typedef struct dev_manifest_func_node {
- dev_manifest_func_t manifest_func;
- struct dev_manifest_func_node *next;
-} dev_manifest_func_node_t;
-
-static TLS dev_manifest_func_node_t *manifest_funcs = NULL;
static TLS bool disable_u2f_fallback;
-static void
-find_manifest_func_node(dev_manifest_func_t f, dev_manifest_func_node_t **curr,
- dev_manifest_func_node_t **prev)
-{
- *prev = NULL;
- *curr = manifest_funcs;
-
- while (*curr != NULL && (*curr)->manifest_func != f) {
- *prev = *curr;
- *curr = (*curr)->next;
- }
-}
-
#ifdef FIDO_FUZZ
static void
set_random_report_len(fido_dev_t *dev)
@@ -63,13 +44,15 @@ fido_dev_set_option_flags(fido_dev_t *dev, const fido_cbor_info_t *info)
for (size_t i = 0; i < len; i++)
if (strcmp(ptr[i], "clientPin") == 0) {
- dev->flags |= val[i] ? FIDO_DEV_PIN_SET : FIDO_DEV_PIN_UNSET;
+ dev->flags |= val[i] ?
+ FIDO_DEV_PIN_SET : FIDO_DEV_PIN_UNSET;
} else if (strcmp(ptr[i], "credMgmt") == 0 ||
strcmp(ptr[i], "credentialMgmtPreview") == 0) {
if (val[i])
dev->flags |= FIDO_DEV_CREDMAN;
} else if (strcmp(ptr[i], "uv") == 0) {
- dev->flags |= val[i] ? FIDO_DEV_UV_SET : FIDO_DEV_UV_UNSET;
+ dev->flags |= val[i] ?
+ FIDO_DEV_UV_SET : FIDO_DEV_UV_UNSET;
} else if (strcmp(ptr[i], "pinUvAuthToken") == 0) {
if (val[i])
dev->flags |= FIDO_DEV_TOKEN_PERMS;
@@ -257,75 +240,40 @@ fido_dev_open_wait(fido_dev_t *dev, const char *path, int *ms)
return (FIDO_OK);
}
-int
-fido_dev_register_manifest_func(const dev_manifest_func_t f)
-{
- dev_manifest_func_node_t *prev, *curr, *n;
-
- find_manifest_func_node(f, &curr, &prev);
- if (curr != NULL)
- return (FIDO_OK);
-
- if ((n = calloc(1, sizeof(*n))) == NULL) {
- fido_log_debug("%s: calloc", __func__);
- return (FIDO_ERR_INTERNAL);
- }
-
- n->manifest_func = f;
- n->next = manifest_funcs;
- manifest_funcs = n;
-
- return (FIDO_OK);
-}
-
-void
-fido_dev_unregister_manifest_func(const dev_manifest_func_t f)
+static void
+run_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen,
+ const char *type, int (*manifest)(fido_dev_info_t *, size_t, size_t *))
{
- dev_manifest_func_node_t *prev, *curr;
+ size_t ndevs = 0;
+ int r;
- find_manifest_func_node(f, &curr, &prev);
- if (curr == NULL)
+ if (*olen >= ilen) {
+ fido_log_debug("%s: skipping %s", __func__, type);
return;
- if (prev != NULL)
- prev->next = curr->next;
- else
- manifest_funcs = curr->next;
-
- free(curr);
+ }
+ if ((r = manifest(devlist + *olen, ilen - *olen, &ndevs)) != FIDO_OK)
+ fido_log_debug("%s: %s: 0x%x", __func__, type, r);
+ fido_log_debug("%s: found %zu %s device%s", __func__, ndevs, type,
+ ndevs == 1 ? "" : "s");
+ *olen += ndevs;
}
int
fido_dev_info_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
{
- dev_manifest_func_node_t *curr = NULL;
- dev_manifest_func_t m_func;
- size_t curr_olen;
- int r;
-
*olen = 0;
- if (fido_dev_register_manifest_func(fido_hid_manifest) != FIDO_OK)
- return (FIDO_ERR_INTERNAL);
-#ifdef NFC_LINUX
- if (fido_dev_register_manifest_func(fido_nfc_manifest) != FIDO_OK)
- return (FIDO_ERR_INTERNAL);
+ run_manifest(devlist, ilen, olen, "hid", fido_hid_manifest);
+#ifdef USE_NFC
+ run_manifest(devlist, ilen, olen, "nfc", fido_nfc_manifest);
+#endif
+#ifdef USE_PCSC
+ run_manifest(devlist, ilen, olen, "pcsc", fido_pcsc_manifest);
#endif
#ifdef USE_WINHELLO
- if (fido_dev_register_manifest_func(fido_winhello_manifest) != FIDO_OK)
- return (FIDO_ERR_INTERNAL);
+ run_manifest(devlist, ilen, olen, "winhello", fido_winhello_manifest);
#endif
- for (curr = manifest_funcs; curr != NULL; curr = curr->next) {
- curr_olen = 0;
- m_func = curr->manifest_func;
- r = m_func(devlist + *olen, ilen - *olen, &curr_olen);
- if (r != FIDO_OK)
- return (r);
- *olen += curr_olen;
- if (*olen == ilen)
- break;
- }
-
return (FIDO_OK);
}
@@ -345,19 +293,16 @@ fido_dev_open(fido_dev_t *dev, const char *path)
{
int ms = dev->timeout_ms;
-#ifdef NFC_LINUX
- if (strncmp(path, FIDO_NFC_PREFIX, strlen(FIDO_NFC_PREFIX)) == 0) {
- dev->io_own = true;
- dev->io = (fido_dev_io_t) {
- fido_nfc_open,
- fido_nfc_close,
- fido_nfc_read,
- fido_nfc_write,
- };
- dev->transport = (fido_dev_transport_t) {
- fido_nfc_rx,
- fido_nfc_tx,
- };
+#ifdef USE_NFC
+ if (fido_is_nfc(path) && fido_dev_set_nfc(dev) < 0) {
+ fido_log_debug("%s: fido_dev_set_nfc", __func__);
+ return FIDO_ERR_INTERNAL;
+ }
+#endif
+#ifdef USE_PCSC
+ if (fido_is_pcsc(path) && fido_dev_set_pcsc(dev) < 0) {
+ fido_log_debug("%s: fido_dev_set_pcsc", __func__);
+ return FIDO_ERR_INTERNAL;
}
#endif
@@ -387,7 +332,7 @@ fido_dev_set_sigmask(fido_dev_t *dev, const fido_sigset_t *sigmask)
if (dev->io_handle == NULL || sigmask == NULL)
return (FIDO_ERR_INVALID_ARGUMENT);
-#ifdef NFC_LINUX
+#ifdef USE_NFC
if (dev->transport.rx == fido_nfc_rx && dev->io.read == fido_nfc_read)
return (fido_nfc_set_sigmask(dev->io_handle, sigmask));
#endif
@@ -415,106 +360,6 @@ fido_dev_cancel(fido_dev_t *dev)
}
int
-fido_dev_get_touch_begin(fido_dev_t *dev)
-{
- fido_blob_t f;
- cbor_item_t *argv[9];
- const char *clientdata = FIDO_DUMMY_CLIENTDATA;
- const uint8_t user_id = FIDO_DUMMY_USER_ID;
- unsigned char cdh[SHA256_DIGEST_LENGTH];
- fido_rp_t rp;
- fido_user_t user;
- int ms = dev->timeout_ms;
- int r = FIDO_ERR_INTERNAL;
-
- memset(&f, 0, sizeof(f));
- memset(argv, 0, sizeof(argv));
- memset(cdh, 0, sizeof(cdh));
- memset(&rp, 0, sizeof(rp));
- memset(&user, 0, sizeof(user));
-
- if (fido_dev_is_fido2(dev) == false)
- return (u2f_get_touch_begin(dev, &ms));
-
- if (SHA256((const void *)clientdata, strlen(clientdata), cdh) != cdh) {
- fido_log_debug("%s: sha256", __func__);
- return (FIDO_ERR_INTERNAL);
- }
-
- if ((rp.id = strdup(FIDO_DUMMY_RP_ID)) == NULL ||
- (user.name = strdup(FIDO_DUMMY_USER_NAME)) == NULL) {
- fido_log_debug("%s: strdup", __func__);
- goto fail;
- }
-
- if (fido_blob_set(&user.id, &user_id, sizeof(user_id)) < 0) {
- fido_log_debug("%s: fido_blob_set", __func__);
- goto fail;
- }
-
- if ((argv[0] = cbor_build_bytestring(cdh, sizeof(cdh))) == NULL ||
- (argv[1] = cbor_encode_rp_entity(&rp)) == NULL ||
- (argv[2] = cbor_encode_user_entity(&user)) == NULL ||
- (argv[3] = cbor_encode_pubkey_param(COSE_ES256)) == NULL) {
- fido_log_debug("%s: cbor encode", __func__);
- goto fail;
- }
-
- if (fido_dev_supports_pin(dev)) {
- if ((argv[7] = cbor_new_definite_bytestring()) == NULL ||
- (argv[8] = cbor_encode_pin_opt(dev)) == NULL) {
- fido_log_debug("%s: cbor encode", __func__);
- goto fail;
- }
- }
-
- if (cbor_build_frame(CTAP_CBOR_MAKECRED, argv, nitems(argv), &f) < 0 ||
- fido_tx(dev, CTAP_CMD_CBOR, f.ptr, f.len, &ms) < 0) {
- fido_log_debug("%s: fido_tx", __func__);
- r = FIDO_ERR_TX;
- goto fail;
- }
-
- r = FIDO_OK;
-fail:
- cbor_vector_free(argv, nitems(argv));
- free(f.ptr);
- free(rp.id);
- free(user.name);
- free(user.id.ptr);
-
- return (r);
-}
-
-int
-fido_dev_get_touch_status(fido_dev_t *dev, int *touched, int ms)
-{
- int r;
-
- *touched = 0;
-
- if (fido_dev_is_fido2(dev) == false)
- return (u2f_get_touch_status(dev, touched, &ms));
-
- switch ((r = fido_rx_cbor_status(dev, &ms))) {
- case FIDO_ERR_PIN_AUTH_INVALID:
- case FIDO_ERR_PIN_INVALID:
- case FIDO_ERR_PIN_NOT_SET:
- case FIDO_ERR_SUCCESS:
- *touched = 1;
- break;
- case FIDO_ERR_RX:
- /* ignore */
- break;
- default:
- fido_log_debug("%s: fido_rx_cbor_status", __func__);
- return (r);
- }
-
- return (FIDO_OK);
-}
-
-int
fido_dev_set_io_functions(fido_dev_t *dev, const fido_dev_io_t *io)
{
if (dev->io_handle != NULL) {
diff --git a/contrib/libfido2/src/diff_exports.sh b/contrib/libfido2/src/diff_exports.sh
index 9cff0095a201..2e15cd0c5b9b 100755
--- a/contrib/libfido2/src/diff_exports.sh
+++ b/contrib/libfido2/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/contrib/libfido2/src/ecdh.c b/contrib/libfido2/src/ecdh.c
index 9c4f2b99e1a9..878f97615e3f 100644
--- a/contrib/libfido2/src/ecdh.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/eddsa.c b/contrib/libfido2/src/eddsa.c
index a7b4f4f900ce..bdb53b188cdb 100644
--- a/contrib/libfido2/src/eddsa.c
+++ b/contrib/libfido2/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>
@@ -10,7 +11,7 @@
#include "fido.h"
#include "fido/eddsa.h"
-#if defined(LIBRESSL_VERSION_NUMBER)
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3070000f
EVP_PKEY *
EVP_PKEY_new_raw_public_key(int type, ENGINE *e, const unsigned char *key,
size_t keylen)
@@ -122,11 +123,20 @@ eddsa_pk_free(eddsa_pk_t **pkp)
int
eddsa_pk_from_ptr(eddsa_pk_t *pk, const void *ptr, size_t len)
{
+ EVP_PKEY *pkey;
+
if (len < sizeof(*pk))
return (FIDO_ERR_INVALID_ARGUMENT);
memcpy(pk, ptr, sizeof(*pk));
+ if ((pkey = eddsa_pk_to_EVP_PKEY(pk)) == NULL) {
+ fido_log_debug("%s: eddsa_pk_to_EVP_PKEY", __func__);
+ return (FIDO_ERR_INVALID_ARGUMENT);
+ }
+
+ EVP_PKEY_free(pkey);
+
return (FIDO_OK);
}
@@ -147,6 +157,8 @@ eddsa_pk_from_EVP_PKEY(eddsa_pk_t *pk, const EVP_PKEY *pkey)
{
size_t len = 0;
+ if (EVP_PKEY_base_id(pkey) != EVP_PKEY_ED25519)
+ return (FIDO_ERR_INVALID_ARGUMENT);
if (EVP_PKEY_get_raw_public_key(pkey, NULL, &len) != 1 ||
len != sizeof(pk->x))
return (FIDO_ERR_INTERNAL);
diff --git a/contrib/libfido2/src/err.c b/contrib/libfido2/src/err.c
index 8c2ae5ff4170..3a6f3e0a6124 100644
--- a/contrib/libfido2/src/err.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/es256.c b/contrib/libfido2/src/es256.c
index eb4cc63525aa..17efb0ad2c16 100644
--- a/contrib/libfido2/src/es256.c
+++ b/contrib/libfido2/src/es256.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/bn.h>
@@ -11,6 +12,14 @@
#include "fido.h"
#include "fido/es256.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 const int es256_nid = NID_X9_62_prime256v1;
+
static int
decode_coord(const cbor_item_t *item, void *xy, size_t xy_len)
{
@@ -170,7 +179,8 @@ es256_pk_free(es256_pk_t **pkp)
int
es256_pk_from_ptr(es256_pk_t *pk, const void *ptr, size_t len)
{
- const uint8_t *p = ptr;
+ const uint8_t *p = ptr;
+ EVP_PKEY *pkey;
if (len < sizeof(*pk))
return (FIDO_ERR_INVALID_ARGUMENT);
@@ -180,6 +190,14 @@ es256_pk_from_ptr(es256_pk_t *pk, const void *ptr, size_t len)
else
memcpy(pk, ptr, sizeof(*pk)); /* libfido2 x||y format */
+ if ((pkey = es256_pk_to_EVP_PKEY(pk)) == NULL) {
+ fido_log_debug("%s: es256_pk_to_EVP_PKEY", __func__);
+ explicit_bzero(pk, sizeof(*pk));
+ return (FIDO_ERR_INVALID_ARGUMENT);
+ }
+
+ EVP_PKEY_free(pkey);
+
return (FIDO_OK);
}
@@ -208,13 +226,12 @@ es256_sk_create(es256_sk_t *key)
EVP_PKEY *k = NULL;
const EC_KEY *ec;
const BIGNUM *d;
- const int nid = NID_X9_62_prime256v1;
int n;
int ok = -1;
if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) == NULL ||
EVP_PKEY_paramgen_init(pctx) <= 0 ||
- EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, nid) <= 0 ||
+ EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, es256_nid) <= 0 ||
EVP_PKEY_paramgen(pctx, &p) <= 0) {
fido_log_debug("%s: EVP_PKEY_paramgen", __func__);
goto fail;
@@ -258,7 +275,6 @@ es256_pk_to_EVP_PKEY(const es256_pk_t *k)
BIGNUM *x = NULL;
BIGNUM *y = NULL;
const EC_GROUP *g = NULL;
- const int nid = NID_X9_62_prime256v1;
int ok = -1;
if ((bnctx = BN_CTX_new()) == NULL)
@@ -276,7 +292,7 @@ es256_pk_to_EVP_PKEY(const es256_pk_t *k)
goto fail;
}
- if ((ec = EC_KEY_new_by_curve_name(nid)) == NULL ||
+ if ((ec = EC_KEY_new_by_curve_name(es256_nid)) == NULL ||
(g = EC_KEY_get0_group(ec)) == NULL) {
fido_log_debug("%s: EC_KEY init", __func__);
goto fail;
@@ -324,12 +340,15 @@ es256_pk_from_EC_KEY(es256_pk_t *pk, const EC_KEY *ec)
BIGNUM *x = NULL;
BIGNUM *y = NULL;
const EC_POINT *q = NULL;
- const EC_GROUP *g = NULL;
+ EC_GROUP *g = NULL;
+ size_t dx;
+ size_t dy;
int ok = FIDO_ERR_INTERNAL;
- int n;
+ int nx;
+ int ny;
if ((q = EC_KEY_get0_public_key(ec)) == NULL ||
- (g = EC_KEY_get0_group(ec)) == NULL ||
+ (g = EC_GROUP_new_by_curve_name(es256_nid)) == NULL ||
(bnctx = BN_CTX_new()) == NULL)
goto fail;
@@ -339,22 +358,33 @@ es256_pk_from_EC_KEY(es256_pk_t *pk, const EC_KEY *ec)
(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 ||
- (n = BN_num_bytes(x)) < 0 || (size_t)n > sizeof(pk->x) ||
- (n = BN_num_bytes(y)) < 0 || (size_t)n > sizeof(pk->y)) {
+ (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;
}
- if ((n = BN_bn2bin(x, pk->x)) < 0 || (size_t)n > sizeof(pk->x) ||
- (n = BN_bn2bin(y, pk->y)) < 0 || (size_t)n > sizeof(pk->y)) {
+ 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);
@@ -366,10 +396,10 @@ fail:
int
es256_pk_from_EVP_PKEY(es256_pk_t *pk, const EVP_PKEY *pkey)
{
- EC_KEY *ec;
+ const EC_KEY *ec;
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_EC ||
- (ec = EVP_PKEY_get0(pkey)) == NULL)
+ (ec = get0_EC_KEY(pkey)) == NULL)
return (FIDO_ERR_INVALID_ARGUMENT);
return (es256_pk_from_EC_KEY(pk, ec));
@@ -382,7 +412,6 @@ es256_sk_to_EVP_PKEY(const es256_sk_t *k)
EC_KEY *ec = NULL;
EVP_PKEY *pkey = NULL;
BIGNUM *d = NULL;
- const int nid = NID_X9_62_prime256v1;
int ok = -1;
if ((bnctx = BN_CTX_new()) == NULL)
@@ -396,7 +425,7 @@ es256_sk_to_EVP_PKEY(const es256_sk_t *k)
goto fail;
}
- if ((ec = EC_KEY_new_by_curve_name(nid)) == NULL ||
+ if ((ec = EC_KEY_new_by_curve_name(es256_nid)) == NULL ||
EC_KEY_set_private_key(ec, d) == 0) {
fido_log_debug("%s: EC_KEY_set_private_key", __func__);
goto fail;
@@ -435,11 +464,10 @@ es256_derive_pk(const es256_sk_t *sk, es256_pk_t *pk)
EC_KEY *ec = NULL;
EC_POINT *q = NULL;
const EC_GROUP *g = NULL;
- const int nid = NID_X9_62_prime256v1;
int ok = -1;
if ((d = BN_bin2bn(sk->d, (int)sizeof(sk->d), NULL)) == NULL ||
- (ec = EC_KEY_new_by_curve_name(nid)) == NULL ||
+ (ec = EC_KEY_new_by_curve_name(es256_nid)) == NULL ||
(g = EC_KEY_get0_group(ec)) == NULL ||
(q = EC_POINT_new(g)) == NULL) {
fido_log_debug("%s: get", __func__);
diff --git a/contrib/libfido2/src/es384.c b/contrib/libfido2/src/es384.c
new file mode 100644
index 000000000000..013d285ef7f0
--- /dev/null
+++ b/contrib/libfido2/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/contrib/libfido2/src/export.gnu b/contrib/libfido2/src/export.gnu
index 0a8d46a20fad..604741ed7d92 100644
--- a/contrib/libfido2/src/export.gnu
+++ b/contrib/libfido2/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;
@@ -19,6 +25,7 @@
fido_assert_clientdata_hash_len;
fido_assert_clientdata_hash_ptr;
fido_assert_count;
+ fido_assert_empty_allow_list;
fido_assert_flags;
fido_assert_free;
fido_assert_hmac_secret_len;
@@ -82,22 +89,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_maxmsgsiz;
+ fido_cbor_info_fwversion;
fido_cbor_info_maxcredbloblen;
fido_cbor_info_maxcredcntlst;
fido_cbor_info_maxcredidlen;
- fido_cbor_info_fwversion;
+ fido_cbor_info_maxlargeblob;
+ fido_cbor_info_maxmsgsiz;
+ 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;
@@ -109,6 +126,7 @@
fido_cred_clientdata_hash_len;
fido_cred_clientdata_hash_ptr;
fido_cred_display_name;
+ fido_cred_empty_exclude_list;
fido_cred_exclude;
fido_cred_flags;
fido_cred_largeblob_key_len;
diff --git a/contrib/libfido2/src/export.llvm b/contrib/libfido2/src/export.llvm
index 80507346edee..0be829538d7b 100644
--- a/contrib/libfido2/src/export.llvm
+++ b/contrib/libfido2/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
@@ -17,6 +23,7 @@ _fido_assert_blob_ptr
_fido_assert_clientdata_hash_len
_fido_assert_clientdata_hash_ptr
_fido_assert_count
+_fido_assert_empty_allow_list
_fido_assert_flags
_fido_assert_free
_fido_assert_hmac_secret_len
@@ -80,22 +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_maxmsgsiz
+_fido_cbor_info_fwversion
_fido_cbor_info_maxcredbloblen
_fido_cbor_info_maxcredcntlst
_fido_cbor_info_maxcredidlen
-_fido_cbor_info_fwversion
+_fido_cbor_info_maxlargeblob
+_fido_cbor_info_maxmsgsiz
+_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
@@ -107,6 +124,7 @@ _fido_cred_authdata_raw_ptr
_fido_cred_clientdata_hash_len
_fido_cred_clientdata_hash_ptr
_fido_cred_display_name
+_fido_cred_empty_exclude_list
_fido_cred_exclude
_fido_cred_flags
_fido_cred_largeblob_key_len
diff --git a/contrib/libfido2/src/export.msvc b/contrib/libfido2/src/export.msvc
index 14602164fd45..10f8bd14497d 100644
--- a/contrib/libfido2/src/export.msvc
+++ b/contrib/libfido2/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
@@ -18,6 +24,7 @@ fido_assert_blob_ptr
fido_assert_clientdata_hash_len
fido_assert_clientdata_hash_ptr
fido_assert_count
+fido_assert_empty_allow_list
fido_assert_flags
fido_assert_free
fido_assert_hmac_secret_len
@@ -81,22 +88,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_maxmsgsiz
+fido_cbor_info_fwversion
fido_cbor_info_maxcredbloblen
fido_cbor_info_maxcredcntlst
fido_cbor_info_maxcredidlen
-fido_cbor_info_fwversion
+fido_cbor_info_maxlargeblob
+fido_cbor_info_maxmsgsiz
+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
@@ -108,6 +125,7 @@ fido_cred_authdata_raw_ptr
fido_cred_clientdata_hash_len
fido_cred_clientdata_hash_ptr
fido_cred_display_name
+fido_cred_empty_exclude_list
fido_cred_exclude
fido_cred_flags
fido_cred_largeblob_key_len
diff --git a/contrib/libfido2/src/extern.h b/contrib/libfido2/src/extern.h
index 6f86d7642950..1bc95b27805d 100644
--- a/contrib/libfido2/src/extern.h
+++ b/contrib/libfido2/src/extern.h
@@ -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
*/
#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 *);
@@ -118,6 +121,8 @@ size_t fido_hid_report_in_len(void *);
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);
@@ -125,6 +130,17 @@ int fido_nfc_write(void *, const unsigned char *, size_t);
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);
int fido_nfc_set_sigmask(void *, const fido_sigset_t *);
+int fido_dev_set_nfc(fido_dev_t *);
+
+/* pcsc i/o */
+bool fido_is_pcsc(const char *);
+void *fido_pcsc_open(const char *);
+void fido_pcsc_close(void *);
+int fido_pcsc_read(void *, unsigned char *, size_t, int);
+int fido_pcsc_write(void *, const unsigned char *, size_t);
+int fido_pcsc_rx(fido_dev_t *, uint8_t, unsigned char *, size_t, int);
+int fido_pcsc_tx(fido_dev_t *, uint8_t, const unsigned char *, size_t);
+int fido_dev_set_pcsc(fido_dev_t *);
/* windows hello */
int fido_winhello_manifest(fido_dev_info_t *, size_t, size_t *);
@@ -182,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 *);
@@ -200,14 +217,18 @@ int fido_get_random(void *, size_t);
int fido_sha256(fido_blob_t *, const u_char *, size_t);
int fido_time_now(struct timespec *);
int fido_time_delta(const struct timespec *, int *);
+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 *,
@@ -220,11 +241,7 @@ int fido_get_signed_hash_tpm(fido_blob_t *, const fido_blob_t *,
/* device manifest functions */
int fido_hid_manifest(fido_dev_info_t *, size_t, size_t *);
int fido_nfc_manifest(fido_dev_info_t *, size_t, size_t *);
-
-/* device manifest registration */
-typedef int (*dev_manifest_func_t)(fido_dev_info_t *, size_t, size_t *);
-int fido_dev_register_manifest_func(const dev_manifest_func_t);
-void fido_dev_unregister_manifest_func(const dev_manifest_func_t);
+int fido_pcsc_manifest(fido_dev_info_t *, size_t, size_t *);
/* fuzzing instrumentation */
#ifdef FIDO_FUZZ
@@ -250,6 +267,7 @@ uint32_t uniform_random(uint32_t);
#define FIDO_DUMMY_USER_ID 1
#define FIDO_WINHELLO_PATH "windows://hello"
#define FIDO_NFC_PREFIX "nfc:"
+#define FIDO_PCSC_PREFIX "pcsc:"
#ifdef __cplusplus
} /* extern "C" */
diff --git a/contrib/libfido2/src/fallthrough.h b/contrib/libfido2/src/fallthrough.h
new file mode 100644
index 000000000000..bdfd30fd63eb
--- /dev/null
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido.h b/contrib/libfido2/src/fido.h
index 4bd2aeebfccb..607c44fcfd91 100644
--- a/contrib/libfido2/src/fido.h
+++ b/contrib/libfido2/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 *);
@@ -100,6 +124,7 @@ const unsigned char *fido_cred_user_id_ptr(const fido_cred_t *);
const unsigned char *fido_cred_x5c_ptr(const fido_cred_t *);
int fido_assert_allow_cred(fido_assert_t *, const unsigned char *, size_t);
+int fido_assert_empty_allow_list(fido_assert_t *);
int fido_assert_set_authdata(fido_assert_t *, size_t, const unsigned char *,
size_t);
int fido_assert_set_authdata_raw(fido_assert_t *, size_t, const unsigned char *,
@@ -119,6 +144,7 @@ int fido_assert_set_uv(fido_assert_t *, fido_opt_t);
int fido_assert_set_sig(fido_assert_t *, size_t, const unsigned char *, size_t);
int fido_assert_verify(const fido_assert_t *, size_t, int, const void *);
int fido_cbor_info_algorithm_cose(const fido_cbor_info_t *, size_t);
+int fido_cred_empty_exclude_list(fido_cred_t *);
int fido_cred_exclude(fido_cred_t *, const unsigned char *, size_t);
int fido_cred_prot(const fido_cred_t *);
int fido_cred_set_attstmt(fido_cred_t *, const unsigned char *, size_t);
@@ -144,7 +170,9 @@ int fido_cred_set_user(fido_cred_t *, const unsigned char *, size_t,
int fido_cred_set_x509(fido_cred_t *, const unsigned char *, size_t);
int fido_cred_verify(const fido_cred_t *);
int fido_cred_verify_self(const fido_cred_t *);
+#ifdef _FIDO_SIGSET_DEFINED
int fido_dev_set_sigmask(fido_dev_t *, const fido_sigset_t *);
+#endif
int fido_dev_cancel(fido_dev_t *);
int fido_dev_close(fido_dev_t *);
int fido_dev_get_assert(fido_dev_t *, fido_assert_t *, const char *);
@@ -176,6 +204,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 *);
@@ -205,11 +234,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_maxmsgsiz(const fido_cbor_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_fwversion(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_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 *);
@@ -220,6 +255,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/contrib/libfido2/src/fido/bio.h b/contrib/libfido2/src/fido/bio.h
index afe9ca4752b4..f5039e03dc90 100644
--- a/contrib/libfido2/src/fido/bio.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/config.h b/contrib/libfido2/src/fido/config.h
index d8134a3c7b6c..cba286f08f88 100644
--- a/contrib/libfido2/src/fido/config.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/credman.h b/contrib/libfido2/src/fido/credman.h
index 66a966970501..9f9dff1d5f05 100644
--- a/contrib/libfido2/src/fido/credman.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/eddsa.h b/contrib/libfido2/src/fido/eddsa.h
index 083721cc3d3f..5c0b681ee7b0 100644
--- a/contrib/libfido2/src/fido/eddsa.h
+++ b/contrib/libfido2/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
@@ -31,7 +53,7 @@ int eddsa_pk_from_ptr(eddsa_pk_t *, const void *, size_t);
#ifdef _FIDO_INTERNAL
-#if defined(LIBRESSL_VERSION_NUMBER)
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3070000f
#define EVP_PKEY_ED25519 EVP_PKEY_NONE
int EVP_PKEY_get_raw_public_key(const EVP_PKEY *, unsigned char *, size_t *);
EVP_PKEY *EVP_PKEY_new_raw_public_key(int, ENGINE *, const unsigned char *,
diff --git a/contrib/libfido2/src/fido/err.h b/contrib/libfido2/src/fido/err.h
index 74fdf9d2bfe8..7db25f269126 100644
--- a/contrib/libfido2/src/fido/err.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/es256.h b/contrib/libfido2/src/fido/es256.h
index 683494dadfe2..0450de29e831 100644
--- a/contrib/libfido2/src/fido/es256.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/es384.h b/contrib/libfido2/src/fido/es384.h
new file mode 100644
index 000000000000..b4b4ca71ccbe
--- /dev/null
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/param.h b/contrib/libfido2/src/fido/param.h
index 7c6db98cfd5d..511370bca272 100644
--- a/contrib/libfido2/src/fido/param.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/rs256.h b/contrib/libfido2/src/fido/rs256.h
index 039816191783..6f8c78195f8d 100644
--- a/contrib/libfido2/src/fido/rs256.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/fido/types.h b/contrib/libfido2/src/fido/types.h
index 4a216b4b9786..cfb4c7a75315 100644
--- a/contrib/libfido2/src/fido/types.h
+++ b/contrib/libfido2/src/fido/types.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_TYPES_H
@@ -48,10 +70,14 @@ typedef enum {
typedef void fido_log_handler_t(const char *);
+#undef _FIDO_SIGSET_DEFINED
+#define _FIDO_SIGSET_DEFINED
#ifdef _WIN32
typedef int fido_sigset_t;
-#else
+#elif defined(SIG_BLOCK)
typedef sigset_t fido_sigset_t;
+#else
+#undef _FIDO_SIGSET_DEFINED
#endif
#ifdef _FIDO_INTERNAL
@@ -69,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];
@@ -101,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;
@@ -215,19 +248,33 @@ 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 */
- fido_str_array_t transports; /* list of supported transports */
- unsigned char aaguid[16]; /* aaguid */
- fido_opt_array_t options; /* list of supported options */
- uint64_t maxmsgsiz; /* maximum message size */
- fido_byte_array_t protocols; /* supported pin protocols */
- fido_algo_array_t algorithms; /* list of supported algorithms */
- uint64_t maxcredcntlst; /* max number of credentials in list */
- uint64_t maxcredidlen; /* max credential ID length */
- uint64_t fwversion; /* firmware version */
+ fido_str_array_t versions; /* supported versions: fido2|u2f */
+ fido_str_array_t extensions; /* list of supported extensions */
+ fido_str_array_t transports; /* list of supported transports */
+ unsigned char aaguid[16]; /* aaguid */
+ fido_opt_array_t options; /* list of supported options */
+ uint64_t maxmsgsiz; /* maximum message size */
+ fido_byte_array_t protocols; /* supported pin protocols */
+ fido_algo_array_t algorithms; /* list of supported algorithms */
+ uint64_t maxcredcntlst; /* max credentials in list */
+ uint64_t maxcredidlen; /* max credential ID length */
+ uint64_t fwversion; /* firmware version */
uint64_t maxcredbloblen; /* max credBlob length */
+ uint64_t maxlargeblob; /* max largeBlob array length */
+ 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 {
@@ -276,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/contrib/libfido2/src/hid.c b/contrib/libfido2/src/hid.c
index 926272b6b3ed..662bd44adfca 100644
--- a/contrib/libfido2/src/hid.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/hid_freebsd.c b/contrib/libfido2/src/hid_freebsd.c
index 5151690afc0a..2bbe80b5349c 100644
--- a/contrib/libfido2/src/hid_freebsd.c
+++ b/contrib/libfido2/src/hid_freebsd.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/param.h>
diff --git a/contrib/libfido2/src/hid_hidapi.c b/contrib/libfido2/src/hid_hidapi.c
index f6d21711e152..fed6f69a2237 100644
--- a/contrib/libfido2/src/hid_hidapi.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/hid_linux.c b/contrib/libfido2/src/hid_linux.c
index c4ce4fd578a6..841a95b08e41 100644
--- a/contrib/libfido2/src/hid_linux.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/hid_netbsd.c b/contrib/libfido2/src/hid_netbsd.c
index c24c6de7ce29..d5b9fad33412 100644
--- a/contrib/libfido2/src/hid_netbsd.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/hid_openbsd.c b/contrib/libfido2/src/hid_openbsd.c
index d3d3bff0fc8b..2d08aca42aee 100644
--- a/contrib/libfido2/src/hid_openbsd.c
+++ b/contrib/libfido2/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>
@@ -27,14 +28,58 @@ struct hid_openbsd {
const sigset_t *sigmaskp;
};
+static int
+copy_info(fido_dev_info_t *di, const char *path)
+{
+ int fd = -1, ok = -1;
+ struct usb_device_info udi;
+
+ memset(di, 0, sizeof(*di));
+ memset(&udi, 0, sizeof(udi));
+
+ if ((fd = fido_hid_unix_open(path)) == -1)
+ goto fail;
+ if (ioctl(fd, IOCTL_REQ(USB_GET_DEVICEINFO), &udi) == -1) {
+ fido_log_error(errno, "%s: ioctl %s", __func__, path);
+ goto fail;
+ }
+
+ fido_log_debug("%s: %s: bus = 0x%02x, addr = 0x%02x", __func__, path,
+ udi.udi_bus, udi.udi_addr);
+ fido_log_debug("%s: %s: vendor = \"%s\", product = \"%s\"", __func__,
+ path, udi.udi_vendor, udi.udi_product);
+ fido_log_debug("%s: %s: productNo = 0x%04x, vendorNo = 0x%04x, "
+ "releaseNo = 0x%04x", __func__, path, udi.udi_productNo,
+ udi.udi_vendorNo, udi.udi_releaseNo);
+
+ 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);
+}
+
int
fido_hid_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
{
size_t i;
char path[64];
- int fd;
- struct usb_device_info udi;
- fido_dev_info_t *di;
if (ilen == 0)
return (FIDO_OK); /* nothing to do */
@@ -44,50 +89,18 @@ fido_hid_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
for (i = *olen = 0; i < MAX_UHID && *olen < ilen; i++) {
snprintf(path, sizeof(path), "/dev/fido/%zu", i);
- if ((fd = fido_hid_unix_open(path)) == -1)
- continue;
- memset(&udi, 0, sizeof(udi));
- if (ioctl(fd, IOCTL_REQ(USB_GET_DEVICEINFO), &udi) == -1) {
- fido_log_error(errno, "%s: get device info %s",
- __func__, path);
- if (close(fd) == -1)
- fido_log_error(errno, "%s: close", __func__);
- continue;
+ if (copy_info(&devlist[*olen], path) == 0) {
+ devlist[*olen].io = (fido_dev_io_t) {
+ fido_hid_open,
+ fido_hid_close,
+ fido_hid_read,
+ fido_hid_write,
+ };
+ ++(*olen);
}
- if (close(fd) == -1)
- fido_log_error(errno, "%s: close", __func__);
-
- fido_log_debug("%s: %s: bus = 0x%02x, addr = 0x%02x",
- __func__, path, udi.udi_bus, udi.udi_addr);
- fido_log_debug("%s: %s: vendor = \"%s\", product = \"%s\"",
- __func__, path, udi.udi_vendor, udi.udi_product);
- fido_log_debug("%s: %s: productNo = 0x%04x, vendorNo = 0x%04x, "
- "releaseNo = 0x%04x", __func__, path, udi.udi_productNo,
- udi.udi_vendorNo, udi.udi_releaseNo);
-
- di = &devlist[*olen];
- memset(di, 0, sizeof(*di));
- di->io = (fido_dev_io_t) {
- fido_hid_open,
- fido_hid_close,
- fido_hid_read,
- fido_hid_write,
- };
- if ((di->path = strdup(path)) == NULL ||
- (di->manufacturer = strdup(udi.udi_vendor)) == NULL ||
- (di->product = strdup(udi.udi_product)) == NULL) {
- free(di->path);
- free(di->manufacturer);
- free(di->product);
- explicit_bzero(di, sizeof(*di));
- return FIDO_ERR_INTERNAL;
- }
- di->vendor_id = (int16_t)udi.udi_vendorNo;
- di->product_id = (int16_t)udi.udi_productNo;
- (*olen)++;
}
- return FIDO_OK;
+ return (FIDO_OK);
}
/*
diff --git a/contrib/libfido2/src/hid_osx.c b/contrib/libfido2/src/hid_osx.c
index 7f3652e39620..9309762f163c 100644
--- a/contrib/libfido2/src/hid_osx.c
+++ b/contrib/libfido2/src/hid_osx.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>
@@ -374,25 +375,6 @@ disable_sigpipe(int fd)
return (0);
}
-static int
-to_uint64(const char *str, uint64_t *out)
-{
- char *ep;
- unsigned long long ull;
-
- errno = 0;
- ull = strtoull(str, &ep, 10);
- if (str == ep || *ep != '\0')
- return (-1);
- else if (ull == ULLONG_MAX && errno == ERANGE)
- return (-1);
- else if (ull > UINT64_MAX)
- return (-1);
- *out = (uint64_t)ull;
-
- return (0);
-}
-
static io_registry_entry_t
get_ioreg_entry(const char *path)
{
@@ -401,8 +383,8 @@ get_ioreg_entry(const char *path)
if (strncmp(path, IOREG, strlen(IOREG)) != 0)
return (IORegistryEntryFromPath(kIOMainPortDefault, path));
- if (to_uint64(path + strlen(IOREG), &id) == -1) {
- fido_log_debug("%s: to_uint64", __func__);
+ if (fido_to_uint64(path + strlen(IOREG), 10, &id) == -1) {
+ fido_log_debug("%s: fido_to_uint64", __func__);
return (MACH_PORT_NULL);
}
diff --git a/contrib/libfido2/src/hid_unix.c b/contrib/libfido2/src/hid_unix.c
index 946b2dc3b65f..e53882d79e86 100644
--- a/contrib/libfido2/src/hid_unix.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/hid_win.c b/contrib/libfido2/src/hid_win.c
index fe403bcf46f1..bc98a1701b0d 100644
--- a/contrib/libfido2/src/hid_win.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/info.c b/contrib/libfido2/src/info.c
index 167a1d30ecaa..cd30828d7ce9 100644
--- a/contrib/libfido2/src/info.c
+++ b/contrib/libfido2/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) {
@@ -268,12 +312,33 @@ parse_reply_element(const cbor_item_t *key, const cbor_item_t *val, void *arg)
return (decode_string_array(val, &ci->transports));
case 10: /* algorithms */
return (decode_algorithms(val, &ci->algorithms));
+ case 11: /* maxSerializedLargeBlobArray */
+ return (cbor_decode_uint64(val, &ci->maxlargeblob));
+ case 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);
}
}
@@ -296,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
@@ -345,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
@@ -357,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
@@ -462,11 +545,47 @@ fido_cbor_info_maxcredidlen(const fido_cbor_info_t *ci)
}
uint64_t
+fido_cbor_info_maxlargeblob(const fido_cbor_info_t *ci)
+{
+ return (ci->maxlargeblob);
+}
+
+uint64_t
fido_cbor_info_fwversion(const fido_cbor_info_t *ci)
{
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)
{
@@ -502,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);
+}
diff --git a/contrib/libfido2/src/io.c b/contrib/libfido2/src/io.c
index 70f777fb49a0..a9715b5b4bf8 100644
--- a/contrib/libfido2/src/io.c
+++ b/contrib/libfido2/src/io.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"
@@ -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/contrib/libfido2/src/iso7816.c b/contrib/libfido2/src/iso7816.c
index a4902277c6d8..5bba10697ee4 100644
--- a/contrib/libfido2/src/iso7816.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/iso7816.h b/contrib/libfido2/src/iso7816.h
index 9bfad1fbab9d..7545719c6f1b 100644
--- a/contrib/libfido2/src/iso7816.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/largeblob.c b/contrib/libfido2/src/largeblob.c
index c8173170766d..c1f2e62b2a6a 100644
--- a/contrib/libfido2/src/largeblob.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/log.c b/contrib/libfido2/src/log.c
index ab18ae12b4fa..e54f8fca6b90 100644
--- a/contrib/libfido2/src/log.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/netlink.c b/contrib/libfido2/src/netlink.c
index 8f14e2c3bac3..2a9216c39058 100644
--- a/contrib/libfido2/src/netlink.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/netlink.h b/contrib/libfido2/src/netlink.h
index 9b98064ab8e7..c600b522196a 100644
--- a/contrib/libfido2/src/netlink.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/nfc.c b/contrib/libfido2/src/nfc.c
new file mode 100644
index 000000000000..2e97d5fc50da
--- /dev/null
+++ b/contrib/libfido2/src/nfc.c
@@ -0,0 +1,350 @@
+/*
+ * 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>
+#include <string.h>
+
+#include "fido.h"
+#include "fido/param.h"
+#include "iso7816.h"
+
+#define TX_CHUNK_SIZE 240
+
+static const uint8_t aid[] = { 0xa0, 0x00, 0x00, 0x06, 0x47, 0x2f, 0x00, 0x01 };
+static const uint8_t v_u2f[] = { 'U', '2', 'F', '_', 'V', '2' };
+static const uint8_t v_fido[] = { 'F', 'I', 'D', 'O', '_', '2', '_', '0' };
+
+static int
+tx_short_apdu(fido_dev_t *d, const iso7816_header_t *h, const uint8_t *payload,
+ uint8_t payload_len, uint8_t cla_flags)
+{
+ uint8_t apdu[5 + UINT8_MAX + 1];
+ uint8_t sw[2];
+ size_t apdu_len;
+ int ok = -1;
+
+ memset(&apdu, 0, sizeof(apdu));
+ apdu[0] = h->cla | cla_flags;
+ apdu[1] = h->ins;
+ apdu[2] = h->p1;
+ apdu[3] = h->p2;
+ apdu[4] = payload_len;
+ memcpy(&apdu[5], payload, payload_len);
+ apdu_len = (size_t)(5 + payload_len + 1);
+
+ if (d->io.write(d->io_handle, apdu, apdu_len) < 0) {
+ fido_log_debug("%s: write", __func__);
+ goto fail;
+ }
+
+ if (cla_flags & 0x10) {
+ if (d->io.read(d->io_handle, sw, sizeof(sw), -1) != 2) {
+ fido_log_debug("%s: read", __func__);
+ goto fail;
+ }
+ if ((sw[0] << 8 | sw[1]) != SW_NO_ERROR) {
+ fido_log_debug("%s: unexpected sw", __func__);
+ goto fail;
+ }
+ }
+
+ ok = 0;
+fail:
+ explicit_bzero(apdu, sizeof(apdu));
+
+ return ok;
+}
+
+static int
+nfc_do_tx(fido_dev_t *d, const uint8_t *apdu_ptr, size_t apdu_len)
+{
+ iso7816_header_t h;
+
+ if (fido_buf_read(&apdu_ptr, &apdu_len, &h, sizeof(h)) < 0) {
+ fido_log_debug("%s: header", __func__);
+ return -1;
+ }
+ if (apdu_len < 2) {
+ fido_log_debug("%s: apdu_len %zu", __func__, apdu_len);
+ return -1;
+ }
+
+ apdu_len -= 2; /* trim le1 le2 */
+
+ while (apdu_len > TX_CHUNK_SIZE) {
+ if (tx_short_apdu(d, &h, apdu_ptr, TX_CHUNK_SIZE, 0x10) < 0) {
+ fido_log_debug("%s: chain", __func__);
+ return -1;
+ }
+ apdu_ptr += TX_CHUNK_SIZE;
+ apdu_len -= TX_CHUNK_SIZE;
+ }
+
+ if (tx_short_apdu(d, &h, apdu_ptr, (uint8_t)apdu_len, 0) < 0) {
+ fido_log_debug("%s: tx_short_apdu", __func__);
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+fido_nfc_tx(fido_dev_t *d, uint8_t cmd, const unsigned char *buf, size_t count)
+{
+ iso7816_apdu_t *apdu = NULL;
+ const uint8_t *ptr;
+ size_t len;
+ int ok = -1;
+
+ switch (cmd) {
+ case CTAP_CMD_INIT: /* select */
+ if ((apdu = iso7816_new(0, 0xa4, 0x04, sizeof(aid))) == NULL ||
+ iso7816_add(apdu, aid, sizeof(aid)) < 0) {
+ fido_log_debug("%s: iso7816", __func__);
+ goto fail;
+ }
+ break;
+ case CTAP_CMD_CBOR: /* wrap cbor */
+ if (count > UINT16_MAX || (apdu = iso7816_new(0x80, 0x10, 0x00,
+ (uint16_t)count)) == NULL ||
+ iso7816_add(apdu, buf, count) < 0) {
+ fido_log_debug("%s: iso7816", __func__);
+ goto fail;
+ }
+ break;
+ case CTAP_CMD_MSG: /* already an apdu */
+ break;
+ default:
+ fido_log_debug("%s: cmd=%02x", __func__, cmd);
+ goto fail;
+ }
+
+ if (apdu != NULL) {
+ ptr = iso7816_ptr(apdu);
+ len = iso7816_len(apdu);
+ } else {
+ ptr = buf;
+ len = count;
+ }
+
+ if (nfc_do_tx(d, ptr, len) < 0) {
+ fido_log_debug("%s: nfc_do_tx", __func__);
+ goto fail;
+ }
+
+ ok = 0;
+fail:
+ iso7816_free(&apdu);
+
+ return ok;
+}
+
+static int
+rx_init(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
+{
+ fido_ctap_info_t *attr = (fido_ctap_info_t *)buf;
+ uint8_t f[64];
+ int n;
+
+ if (count != sizeof(*attr)) {
+ fido_log_debug("%s: count=%zu", __func__, count);
+ return -1;
+ }
+
+ memset(attr, 0, sizeof(*attr));
+
+ if ((n = d->io.read(d->io_handle, f, sizeof(f), ms)) < 2 ||
+ (f[n - 2] << 8 | f[n - 1]) != SW_NO_ERROR) {
+ fido_log_debug("%s: read", __func__);
+ return -1;
+ }
+
+ n -= 2;
+
+ if (n == sizeof(v_u2f) && memcmp(f, v_u2f, sizeof(v_u2f)) == 0)
+ attr->flags = FIDO_CAP_CBOR;
+ else if (n == sizeof(v_fido) && memcmp(f, v_fido, sizeof(v_fido)) == 0)
+ attr->flags = FIDO_CAP_CBOR | FIDO_CAP_NMSG;
+ else {
+ fido_log_debug("%s: unknown version string", __func__);
+#ifdef FIDO_FUZZ
+ attr->flags = FIDO_CAP_CBOR | FIDO_CAP_NMSG;
+#else
+ return -1;
+#endif
+ }
+
+ memcpy(&attr->nonce, &d->nonce, sizeof(attr->nonce)); /* XXX */
+
+ return (int)count;
+}
+
+static int
+tx_get_response(fido_dev_t *d, uint8_t count)
+{
+ uint8_t apdu[5];
+
+ memset(apdu, 0, sizeof(apdu));
+ apdu[1] = 0xc0; /* GET_RESPONSE */
+ apdu[4] = count;
+
+ if (d->io.write(d->io_handle, apdu, sizeof(apdu)) < 0) {
+ fido_log_debug("%s: write", __func__);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+rx_apdu(fido_dev_t *d, uint8_t sw[2], unsigned char **buf, size_t *count, int *ms)
+{
+ uint8_t f[256 + 2];
+ struct timespec ts;
+ int n, ok = -1;
+
+ if (fido_time_now(&ts) != 0)
+ goto fail;
+
+ if ((n = d->io.read(d->io_handle, f, sizeof(f), *ms)) < 2) {
+ fido_log_debug("%s: read", __func__);
+ goto fail;
+ }
+
+ if (fido_time_delta(&ts, ms) != 0)
+ goto fail;
+
+ if (fido_buf_write(buf, count, f, (size_t)(n - 2)) < 0) {
+ fido_log_debug("%s: fido_buf_write", __func__);
+ goto fail;
+ }
+
+ memcpy(sw, f + n - 2, 2);
+
+ ok = 0;
+fail:
+ explicit_bzero(f, sizeof(f));
+
+ return ok;
+}
+
+static int
+rx_msg(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
+{
+ uint8_t sw[2];
+ const size_t bufsiz = count;
+
+ if (rx_apdu(d, sw, &buf, &count, &ms) < 0) {
+ fido_log_debug("%s: preamble", __func__);
+ return -1;
+ }
+
+ while (sw[0] == SW1_MORE_DATA)
+ if (tx_get_response(d, sw[1]) < 0 ||
+ rx_apdu(d, sw, &buf, &count, &ms) < 0) {
+ fido_log_debug("%s: chain", __func__);
+ return -1;
+ }
+
+ if (fido_buf_write(&buf, &count, sw, sizeof(sw)) < 0) {
+ fido_log_debug("%s: sw", __func__);
+ return -1;
+ }
+
+ if (bufsiz - count > INT_MAX) {
+ fido_log_debug("%s: bufsiz", __func__);
+ return -1;
+ }
+
+ return (int)(bufsiz - count);
+}
+
+static int
+rx_cbor(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
+{
+ int r;
+
+ if ((r = rx_msg(d, buf, count, ms)) < 2)
+ return -1;
+
+ return r - 2;
+}
+
+int
+fido_nfc_rx(fido_dev_t *d, uint8_t cmd, unsigned char *buf, size_t count, int ms)
+{
+ switch (cmd) {
+ case CTAP_CMD_INIT:
+ return rx_init(d, buf, count, ms);
+ case CTAP_CMD_CBOR:
+ return rx_cbor(d, buf, count, ms);
+ case CTAP_CMD_MSG:
+ return rx_msg(d, buf, count, ms);
+ default:
+ fido_log_debug("%s: cmd=%02x", __func__, cmd);
+ return -1;
+ }
+}
+
+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)
+{
+ return strncmp(path, FIDO_NFC_PREFIX, strlen(FIDO_NFC_PREFIX)) == 0;
+}
+
+int
+fido_dev_set_nfc(fido_dev_t *d)
+{
+ if (d->io_handle != NULL) {
+ fido_log_debug("%s: device open", __func__);
+ return -1;
+ }
+ d->io_own = true;
+ d->io = (fido_dev_io_t) {
+ fido_nfc_open,
+ fido_nfc_close,
+ fido_nfc_read,
+ fido_nfc_write,
+ };
+ d->transport = (fido_dev_transport_t) {
+ fido_nfc_rx,
+ fido_nfc_tx,
+ };
+
+ return 0;
+}
+#endif /* USE_NFC */
diff --git a/contrib/libfido2/src/nfc_linux.c b/contrib/libfido2/src/nfc_linux.c
index d5f9ec048052..4b69eb1c54c2 100644
--- a/contrib/libfido2/src/nfc_linux.c
+++ b/contrib/libfido2/src/nfc_linux.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 <sys/types.h>
@@ -22,12 +23,6 @@
#include "netlink.h"
#include "iso7816.h"
-#define TX_CHUNK_SIZE 240
-
-static const uint8_t aid[] = { 0xa0, 0x00, 0x00, 0x06, 0x47, 0x2f, 0x00, 0x01 };
-static const uint8_t v_u2f[] = { 'U', '2', 'F', '_', 'V', '2' };
-static const uint8_t v_fido[] = { 'F', 'I', 'D', 'O', '_', '2', '_', '0' };
-
struct nfc_linux {
int fd;
uint32_t dev;
@@ -37,278 +32,6 @@ struct nfc_linux {
struct fido_nl *nl;
};
-static int
-tx_short_apdu(fido_dev_t *d, const iso7816_header_t *h, const uint8_t *payload,
- uint8_t payload_len, uint8_t cla_flags)
-{
- uint8_t apdu[5 + UINT8_MAX + 1];
- uint8_t sw[2];
- size_t apdu_len;
- int ok = -1;
-
- memset(&apdu, 0, sizeof(apdu));
- apdu[0] = h->cla | cla_flags;
- apdu[1] = h->ins;
- apdu[2] = h->p1;
- apdu[3] = h->p2;
- apdu[4] = payload_len;
- memcpy(&apdu[5], payload, payload_len);
- apdu_len = (size_t)(5 + payload_len + 1);
-
- if (d->io.write(d->io_handle, apdu, apdu_len) < 0) {
- fido_log_debug("%s: write", __func__);
- goto fail;
- }
-
- if (cla_flags & 0x10) {
- if (d->io.read(d->io_handle, sw, sizeof(sw), -1) != 2) {
- fido_log_debug("%s: read", __func__);
- goto fail;
- }
- if ((sw[0] << 8 | sw[1]) != SW_NO_ERROR) {
- fido_log_debug("%s: unexpected sw", __func__);
- goto fail;
- }
- }
-
- ok = 0;
-fail:
- explicit_bzero(apdu, sizeof(apdu));
-
- return (ok);
-}
-
-static int
-nfc_do_tx(fido_dev_t *d, const uint8_t *apdu_ptr, size_t apdu_len)
-{
- iso7816_header_t h;
-
- if (fido_buf_read(&apdu_ptr, &apdu_len, &h, sizeof(h)) < 0) {
- fido_log_debug("%s: header", __func__);
- return (-1);
- }
- if (apdu_len < 2) {
- fido_log_debug("%s: apdu_len %zu", __func__, apdu_len);
- return (-1);
- }
-
- apdu_len -= 2; /* trim le1 le2 */
-
- while (apdu_len > TX_CHUNK_SIZE) {
- if (tx_short_apdu(d, &h, apdu_ptr, TX_CHUNK_SIZE, 0x10) < 0) {
- fido_log_debug("%s: chain", __func__);
- return (-1);
- }
- apdu_ptr += TX_CHUNK_SIZE;
- apdu_len -= TX_CHUNK_SIZE;
- }
-
- if (tx_short_apdu(d, &h, apdu_ptr, (uint8_t)apdu_len, 0) < 0) {
- fido_log_debug("%s: tx_short_apdu", __func__);
- return (-1);
- }
-
- return (0);
-}
-
-int
-fido_nfc_tx(fido_dev_t *d, uint8_t cmd, const unsigned char *buf, size_t count)
-{
- iso7816_apdu_t *apdu = NULL;
- const uint8_t *ptr;
- size_t len;
- int ok = -1;
-
- switch (cmd) {
- case CTAP_CMD_INIT: /* select */
- if ((apdu = iso7816_new(0, 0xa4, 0x04, sizeof(aid))) == NULL ||
- iso7816_add(apdu, aid, sizeof(aid)) < 0) {
- fido_log_debug("%s: iso7816", __func__);
- goto fail;
- }
- break;
- case CTAP_CMD_CBOR: /* wrap cbor */
- if (count > UINT16_MAX || (apdu = iso7816_new(0x80, 0x10, 0x80,
- (uint16_t)count)) == NULL ||
- iso7816_add(apdu, buf, count) < 0) {
- fido_log_debug("%s: iso7816", __func__);
- goto fail;
- }
- break;
- case CTAP_CMD_MSG: /* already an apdu */
- break;
- default:
- fido_log_debug("%s: cmd=%02x", __func__, cmd);
- goto fail;
- }
-
- if (apdu != NULL) {
- ptr = iso7816_ptr(apdu);
- len = iso7816_len(apdu);
- } else {
- ptr = buf;
- len = count;
- }
-
- if (nfc_do_tx(d, ptr, len) < 0) {
- fido_log_debug("%s: nfc_do_tx", __func__);
- goto fail;
- }
-
- ok = 0;
-fail:
- iso7816_free(&apdu);
-
- return (ok);
-}
-
-static int
-rx_init(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
-{
- fido_ctap_info_t *attr = (fido_ctap_info_t *)buf;
- uint8_t f[64];
- int n;
-
- if (count != sizeof(*attr)) {
- fido_log_debug("%s: count=%zu", __func__, count);
- return (-1);
- }
-
- memset(attr, 0, sizeof(*attr));
-
- if ((n = d->io.read(d->io_handle, f, sizeof(f), ms)) < 2 ||
- (f[n - 2] << 8 | f[n - 1]) != SW_NO_ERROR) {
- fido_log_debug("%s: read", __func__);
- return (-1);
- }
-
- n -= 2;
-
- if (n == sizeof(v_u2f) && memcmp(f, v_u2f, sizeof(v_u2f)) == 0)
- attr->flags = FIDO_CAP_CBOR;
- else if (n == sizeof(v_fido) && memcmp(f, v_fido, sizeof(v_fido)) == 0)
- attr->flags = FIDO_CAP_CBOR | FIDO_CAP_NMSG;
- else {
- fido_log_debug("%s: unknown version string", __func__);
-#ifdef FIDO_FUZZ
- attr->flags = FIDO_CAP_CBOR | FIDO_CAP_NMSG;
-#else
- return (-1);
-#endif
- }
-
- memcpy(&attr->nonce, &d->nonce, sizeof(attr->nonce)); /* XXX */
-
- return ((int)count);
-}
-
-static int
-tx_get_response(fido_dev_t *d, uint8_t count)
-{
- uint8_t apdu[5];
-
- memset(apdu, 0, sizeof(apdu));
- apdu[1] = 0xc0; /* GET_RESPONSE */
- apdu[4] = count;
-
- if (d->io.write(d->io_handle, apdu, sizeof(apdu)) < 0) {
- fido_log_debug("%s: write", __func__);
- return (-1);
- }
-
- return (0);
-}
-
-static int
-rx_apdu(fido_dev_t *d, uint8_t sw[2], unsigned char **buf, size_t *count, int *ms)
-{
- uint8_t f[256 + 2];
- struct timespec ts;
- int n, ok = -1;
-
- if (fido_time_now(&ts) != 0)
- goto fail;
-
- if ((n = d->io.read(d->io_handle, f, sizeof(f), *ms)) < 2) {
- fido_log_debug("%s: read", __func__);
- goto fail;
- }
-
- if (fido_time_delta(&ts, ms) != 0)
- goto fail;
-
- if (fido_buf_write(buf, count, f, (size_t)(n - 2)) < 0) {
- fido_log_debug("%s: fido_buf_write", __func__);
- goto fail;
- }
-
- memcpy(sw, f + n - 2, 2);
-
- ok = 0;
-fail:
- explicit_bzero(f, sizeof(f));
-
- return (ok);
-}
-
-static int
-rx_msg(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
-{
- uint8_t sw[2];
- const size_t bufsiz = count;
-
- if (rx_apdu(d, sw, &buf, &count, &ms) < 0) {
- fido_log_debug("%s: preamble", __func__);
- return (-1);
- }
-
- while (sw[0] == SW1_MORE_DATA)
- if (tx_get_response(d, sw[1]) < 0 ||
- rx_apdu(d, sw, &buf, &count, &ms) < 0) {
- fido_log_debug("%s: chain", __func__);
- return (-1);
- }
-
- if (fido_buf_write(&buf, &count, sw, sizeof(sw)) < 0) {
- fido_log_debug("%s: sw", __func__);
- return (-1);
- }
-
- if (bufsiz - count > INT_MAX) {
- fido_log_debug("%s: bufsiz", __func__);
- return (-1);
- }
-
- return ((int)(bufsiz - count));
-}
-
-static int
-rx_cbor(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
-{
- int r;
-
- if ((r = rx_msg(d, buf, count, ms)) < 2)
- return (-1);
-
- return (r - 2);
-}
-
-int
-fido_nfc_rx(fido_dev_t *d, uint8_t cmd, unsigned char *buf, size_t count, int ms)
-{
- switch (cmd) {
- case CTAP_CMD_INIT:
- return (rx_init(d, buf, count, ms));
- case CTAP_CMD_CBOR:
- return (rx_cbor(d, buf, count, ms));
- case CTAP_CMD_MSG:
- return (rx_msg(d, buf, count, ms));
- default:
- fido_log_debug("%s: cmd=%02x", __func__, cmd);
- return (-1);
- }
-}
-
static char *
get_parent_attr(struct udev_device *dev, const char *subsystem,
const char *devtype, const char *attr)
@@ -319,34 +42,15 @@ get_parent_attr(struct udev_device *dev, const char *subsystem,
if ((parent = udev_device_get_parent_with_subsystem_devtype(dev,
subsystem, devtype)) == NULL || (value =
udev_device_get_sysattr_value(parent, attr)) == NULL)
- return (NULL);
+ return NULL;
- return (strdup(value));
+ return strdup(value);
}
static char *
get_usb_attr(struct udev_device *dev, const char *attr)
{
- return (get_parent_attr(dev, "usb", "usb_device", attr));
-}
-
-static int
-to_int(const char *str, int base)
-{
- char *ep;
- long long ll;
-
- ll = strtoll(str, &ep, base);
- if (str == ep || *ep != '\0')
- return (-1);
- else if (ll == LLONG_MIN && errno == ERANGE)
- return (-1);
- else if (ll == LLONG_MAX && errno == ERANGE)
- return (-1);
- else if (ll < 0 || ll > INT_MAX)
- return (-1);
-
- return ((int)ll);
+ return get_parent_attr(dev, "usb", "usb_device", attr);
}
static int
@@ -356,16 +60,22 @@ copy_info(fido_dev_info_t *di, struct udev *udev,
const char *name;
char *str;
struct udev_device *dev = NULL;
- void *ctx = NULL;
- int id, ok = -1;
+ uint64_t id;
+ int ok = -1;
memset(di, 0, sizeof(*di));
if ((name = udev_list_entry_get_name(udev_entry)) == NULL ||
(dev = udev_device_new_from_syspath(udev, name)) == NULL)
goto fail;
- if (asprintf(&di->path, "%s/%s", FIDO_NFC_PREFIX, name) == -1)
+ if (asprintf(&di->path, "%s/%s", FIDO_NFC_PREFIX, name) == -1) {
+ 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)
@@ -374,25 +84,18 @@ copy_info(fido_dev_info_t *di, struct udev *udev,
goto fail;
/* XXX assumes USB for vendor/product info */
if ((str = get_usb_attr(dev, "idVendor")) != NULL &&
- (id = to_int(str, 16)) > 0 && id <= UINT16_MAX)
+ fido_to_uint64(str, 16, &id) == 0 && id <= UINT16_MAX)
di->vendor_id = (int16_t)id;
free(str);
if ((str = get_usb_attr(dev, "idProduct")) != NULL &&
- (id = to_int(str, 16)) > 0 && id <= UINT16_MAX)
+ fido_to_uint64(str, 16, &id) == 0 && id <= UINT16_MAX)
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);
@@ -401,7 +104,7 @@ fail:
explicit_bzero(di, sizeof(*di));
}
- return (ok);
+ return ok;
}
static int
@@ -410,21 +113,21 @@ sysnum_from_syspath(const char *path)
struct udev *udev = NULL;
struct udev_device *dev = NULL;
const char *str;
- int idx;
+ uint64_t idx64;
+ int idx = -1;
- if ((udev = udev_new()) == NULL ||
- (dev = udev_device_new_from_syspath(udev, path)) == NULL ||
- (str = udev_device_get_sysnum(dev)) == NULL)
- idx = -1;
- else
- idx = to_int(str, 10);
+ if ((udev = udev_new()) != NULL &&
+ (dev = udev_device_new_from_syspath(udev, path)) != NULL &&
+ (str = udev_device_get_sysnum(dev)) != NULL &&
+ fido_to_uint64(str, 10, &idx64) == 0 && idx64 < INT_MAX)
+ idx = (int)idx64;
if (dev != NULL)
udev_device_unref(dev);
if (udev != NULL)
udev_unref(udev);
- return (idx);
+ return idx;
}
int
@@ -439,10 +142,10 @@ fido_nfc_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
*olen = 0;
if (ilen == 0)
- return (FIDO_OK);
+ return FIDO_OK;
if (devlist == NULL)
- return (FIDO_ERR_INVALID_ARGUMENT);
+ return FIDO_ERR_INVALID_ARGUMENT;
if ((udev = udev_new()) == NULL ||
(udev_enum = udev_enumerate_new(udev)) == NULL)
@@ -481,7 +184,7 @@ fail:
if (udev != NULL)
udev_unref(udev);
- return (r);
+ return r;
}
static int
@@ -498,17 +201,17 @@ nfc_target_connect(struct nfc_linux *ctx)
if ((ctx->fd = socket(AF_NFC, SOCK_SEQPACKET | SOCK_CLOEXEC,
NFC_SOCKPROTO_RAW)) == -1) {
fido_log_error(errno, "%s: socket", __func__);
- return (-1);
+ return -1;
}
if (connect(ctx->fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
fido_log_error(errno, "%s: connect", __func__);
if (close(ctx->fd) == -1)
fido_log_error(errno, "%s: close", __func__);
ctx->fd = -1;
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
}
static void
@@ -535,13 +238,13 @@ nfc_new(uint32_t dev)
if ((ctx = calloc(1, sizeof(*ctx))) == NULL ||
(ctx->nl = fido_nl_new()) == NULL) {
nfc_free(&ctx);
- return (NULL);
+ return NULL;
}
ctx->fd = -1;
ctx->dev = dev;
- return (ctx);
+ return ctx;
}
void *
@@ -566,10 +269,10 @@ fido_nfc_open(const char *path)
goto fail;
}
- return (ctx);
+ return ctx;
fail:
nfc_free(&ctx);
- return (NULL);
+ return NULL;
}
void
@@ -588,7 +291,7 @@ fido_nfc_set_sigmask(void *handle, const fido_sigset_t *sigmask)
ctx->sigmask = *sigmask;
ctx->sigmaskp = &ctx->sigmask;
- return (FIDO_OK);
+ return FIDO_OK;
}
int
@@ -607,25 +310,25 @@ fido_nfc_read(void *handle, unsigned char *buf, size_t len, int ms)
if (fido_hid_unix_wait(ctx->fd, ms, ctx->sigmaskp) < 0) {
fido_log_debug("%s: fido_hid_unix_wait", __func__);
- return (-1);
+ return -1;
}
if ((r = readv(ctx->fd, iov, nitems(iov))) == -1) {
fido_log_error(errno, "%s: read", __func__);
- return (-1);
+ return -1;
}
if (r < 1) {
fido_log_debug("%s: %zd < 1", __func__, r);
- return (-1);
+ return -1;
}
if (preamble != 0x00) {
fido_log_debug("%s: preamble", __func__);
- return (-1);
+ return -1;
}
r--;
fido_log_xxd(buf, (size_t)r, "%s", __func__);
- return ((int)r);
+ return (int)r;
}
int
@@ -638,16 +341,16 @@ fido_nfc_write(void *handle, const unsigned char *buf, size_t len)
if (len > INT_MAX) {
fido_log_debug("%s: len", __func__);
- return (-1);
+ return -1;
}
if ((r = write(ctx->fd, buf, len)) == -1) {
fido_log_error(errno, "%s: write", __func__);
- return (-1);
+ return -1;
}
if (r < 0 || (size_t)r != len) {
fido_log_debug("%s: %zd != %zu", __func__, r, len);
- return (-1);
+ return -1;
}
- return ((int)r);
+ return (int)r;
}
diff --git a/contrib/libfido2/src/packed.h b/contrib/libfido2/src/packed.h
index 3857c22dd2ba..5f53ae565b75 100644
--- a/contrib/libfido2/src/packed.h
+++ b/contrib/libfido2/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/contrib/libfido2/src/pcsc.c b/contrib/libfido2/src/pcsc.c
new file mode 100644
index 000000000000..d7bd6c65ed60
--- /dev/null
+++ b/contrib/libfido2/src/pcsc.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright (c) 2022 Micro Focus or one of its affiliates.
+ * 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__
+#include <PCSC/wintypes.h>
+#include <PCSC/winscard.h>
+#else
+#include <winscard.h>
+#endif /* __APPLE__ */
+
+#include <errno.h>
+
+#include "fido.h"
+#include "fido/param.h"
+#include "iso7816.h"
+
+#if defined(_WIN32) && !defined(__MINGW32__)
+#define SCardConnect SCardConnectA
+#define SCardListReaders SCardListReadersA
+#endif
+
+#ifndef SCARD_PROTOCOL_Tx
+#define SCARD_PROTOCOL_Tx SCARD_PROTOCOL_ANY
+#endif
+
+#define BUFSIZE 1024 /* in bytes; passed to SCardListReaders() */
+#define APDULEN 264 /* 261 rounded up to the nearest multiple of 8 */
+#define READERS 8 /* maximum number of readers */
+
+struct pcsc {
+ SCARDCONTEXT ctx;
+ SCARDHANDLE h;
+ SCARD_IO_REQUEST req;
+ uint8_t rx_buf[APDULEN];
+ size_t rx_len;
+};
+
+static LONG
+list_readers(SCARDCONTEXT ctx, char **buf)
+{
+ LONG s;
+ DWORD len;
+
+ len = BUFSIZE;
+ if ((*buf = calloc(1, len)) == NULL)
+ goto fail;
+ if ((s = SCardListReaders(ctx, NULL, *buf, &len)) != SCARD_S_SUCCESS) {
+ fido_log_debug("%s: SCardListReaders 0x%lx", __func__, (long)s);
+ goto fail;
+ }
+ /* sanity check "multi-string" */
+ if (len > BUFSIZE || len < 2) {
+ fido_log_debug("%s: bogus len=%u", __func__, (unsigned)len);
+ goto fail;
+ }
+ if ((*buf)[len - 1] != 0 || (*buf)[len - 2] != '\0') {
+ fido_log_debug("%s: bogus buf", __func__);
+ goto fail;
+ }
+ return (LONG)SCARD_S_SUCCESS;
+fail:
+ free(*buf);
+ *buf = NULL;
+
+ return (LONG)SCARD_E_NO_READERS_AVAILABLE;
+}
+
+static char *
+get_reader(SCARDCONTEXT ctx, const char *path)
+{
+ char *reader = NULL, *buf = NULL;
+ const char prefix[] = FIDO_PCSC_PREFIX "//slot";
+ uint64_t n;
+
+ if (path == NULL)
+ goto out;
+ if (strncmp(path, prefix, strlen(prefix)) != 0 ||
+ fido_to_uint64(path + strlen(prefix), 10, &n) < 0 ||
+ n > READERS - 1) {
+ fido_log_debug("%s: invalid path %s", __func__, path);
+ goto out;
+ }
+ if (list_readers(ctx, &buf) != SCARD_S_SUCCESS) {
+ fido_log_debug("%s: list_readers", __func__);
+ goto out;
+ }
+ for (const char *name = buf; *name != 0; name += strlen(name) + 1) {
+ if (n == 0) {
+ reader = strdup(name);
+ goto out;
+ }
+ n--;
+ }
+ fido_log_debug("%s: failed to find reader %s", __func__, path);
+out:
+ free(buf);
+
+ return reader;
+}
+
+static int
+prepare_io_request(DWORD prot, SCARD_IO_REQUEST *req)
+{
+ switch (prot) {
+ case SCARD_PROTOCOL_T0:
+ req->dwProtocol = SCARD_PCI_T0->dwProtocol;
+ req->cbPciLength = SCARD_PCI_T0->cbPciLength;
+ break;
+ case SCARD_PROTOCOL_T1:
+ req->dwProtocol = SCARD_PCI_T1->dwProtocol;
+ req->cbPciLength = SCARD_PCI_T1->cbPciLength;
+ break;
+ default:
+ fido_log_debug("%s: unknown protocol %lu", __func__,
+ (u_long)prot);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+copy_info(fido_dev_info_t *di, SCARDCONTEXT ctx, const char *reader, size_t idx)
+{
+ SCARDHANDLE h = 0;
+ SCARD_IO_REQUEST req;
+ DWORD prot = 0;
+ LONG s;
+ int ok = -1;
+
+ memset(di, 0, sizeof(*di));
+ memset(&req, 0, sizeof(req));
+
+ if ((s = SCardConnect(ctx, reader, SCARD_SHARE_SHARED,
+ SCARD_PROTOCOL_Tx, &h, &prot)) != SCARD_S_SUCCESS) {
+ fido_log_debug("%s: SCardConnect 0x%lx", __func__, (long)s);
+ goto fail;
+ }
+ if (prepare_io_request(prot, &req) < 0) {
+ fido_log_debug("%s: prepare_io_request", __func__);
+ goto fail;
+ }
+ if (asprintf(&di->path, "%s//slot%zu", FIDO_PCSC_PREFIX, idx) == -1) {
+ di->path = NULL;
+ 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;
+
+ ok = 0;
+fail:
+ if (h != 0)
+ SCardDisconnect(h, SCARD_LEAVE_CARD);
+ if (ok < 0) {
+ free(di->path);
+ free(di->manufacturer);
+ free(di->product);
+ explicit_bzero(di, sizeof(*di));
+ }
+
+ return ok;
+}
+
+int
+fido_pcsc_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
+{
+ SCARDCONTEXT ctx = 0;
+ char *buf = NULL;
+ LONG s;
+ size_t idx = 0;
+ int r = FIDO_ERR_INTERNAL;
+
+ *olen = 0;
+
+ if (ilen == 0)
+ return FIDO_OK;
+ if (devlist == NULL)
+ return FIDO_ERR_INVALID_ARGUMENT;
+
+ if ((s = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL,
+ &ctx)) != SCARD_S_SUCCESS || ctx == 0) {
+ fido_log_debug("%s: SCardEstablishContext 0x%lx", __func__,
+ (long)s);
+ if (s == (LONG)SCARD_E_NO_SERVICE ||
+ s == (LONG)SCARD_E_NO_SMARTCARD)
+ r = FIDO_OK; /* suppress error */
+ goto out;
+ }
+ if ((s = list_readers(ctx, &buf)) != SCARD_S_SUCCESS) {
+ fido_log_debug("%s: list_readers 0x%lx", __func__, (long)s);
+ if (s == (LONG)SCARD_E_NO_READERS_AVAILABLE)
+ r = FIDO_OK; /* suppress error */
+ goto out;
+ }
+
+ for (const char *name = buf; *name != 0; name += strlen(name) + 1) {
+ if (idx == READERS) {
+ fido_log_debug("%s: stopping at %zu readers", __func__,
+ idx);
+ r = FIDO_OK;
+ goto out;
+ }
+ if (copy_info(&devlist[*olen], ctx, name, idx++) == 0) {
+ devlist[*olen].io = (fido_dev_io_t) {
+ fido_pcsc_open,
+ fido_pcsc_close,
+ fido_pcsc_read,
+ fido_pcsc_write,
+ };
+ devlist[*olen].transport = (fido_dev_transport_t) {
+ fido_pcsc_rx,
+ fido_pcsc_tx,
+ };
+ if (++(*olen) == ilen)
+ break;
+ }
+ }
+
+ r = FIDO_OK;
+out:
+ free(buf);
+ if (ctx != 0)
+ SCardReleaseContext(ctx);
+
+ return r;
+}
+
+void *
+fido_pcsc_open(const char *path)
+{
+ char *reader = NULL;
+ struct pcsc *dev = NULL;
+ SCARDCONTEXT ctx = 0;
+ SCARDHANDLE h = 0;
+ SCARD_IO_REQUEST req;
+ DWORD prot = 0;
+ LONG s;
+
+ memset(&req, 0, sizeof(req));
+
+ if ((s = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL,
+ &ctx)) != SCARD_S_SUCCESS || ctx == 0) {
+ fido_log_debug("%s: SCardEstablishContext 0x%lx", __func__,
+ (long)s);
+ goto fail;
+
+ }
+ if ((reader = get_reader(ctx, path)) == NULL) {
+ fido_log_debug("%s: get_reader(%s)", __func__, path);
+ goto fail;
+ }
+ if ((s = SCardConnect(ctx, reader, SCARD_SHARE_SHARED,
+ SCARD_PROTOCOL_Tx, &h, &prot)) != SCARD_S_SUCCESS) {
+ fido_log_debug("%s: SCardConnect 0x%lx", __func__, (long)s);
+ goto fail;
+ }
+ if (prepare_io_request(prot, &req) < 0) {
+ fido_log_debug("%s: prepare_io_request", __func__);
+ goto fail;
+ }
+ if ((dev = calloc(1, sizeof(*dev))) == NULL)
+ goto fail;
+
+ dev->ctx = ctx;
+ dev->h = h;
+ dev->req = req;
+ ctx = 0;
+ h = 0;
+fail:
+ if (h != 0)
+ SCardDisconnect(h, SCARD_LEAVE_CARD);
+ if (ctx != 0)
+ SCardReleaseContext(ctx);
+ free(reader);
+
+ return dev;
+}
+
+void
+fido_pcsc_close(void *handle)
+{
+ struct pcsc *dev = handle;
+
+ if (dev->h != 0)
+ SCardDisconnect(dev->h, SCARD_LEAVE_CARD);
+ if (dev->ctx != 0)
+ SCardReleaseContext(dev->ctx);
+
+ explicit_bzero(dev->rx_buf, sizeof(dev->rx_buf));
+ free(dev);
+}
+
+int
+fido_pcsc_read(void *handle, unsigned char *buf, size_t len, int ms)
+{
+ struct pcsc *dev = handle;
+ int r;
+
+ (void)ms;
+ if (dev->rx_len == 0 || dev->rx_len > len ||
+ dev->rx_len > sizeof(dev->rx_buf)) {
+ fido_log_debug("%s: rx_len", __func__);
+ return -1;
+ }
+ fido_log_xxd(dev->rx_buf, dev->rx_len, "%s: reading", __func__);
+ memcpy(buf, dev->rx_buf, dev->rx_len);
+ explicit_bzero(dev->rx_buf, sizeof(dev->rx_buf));
+ r = (int)dev->rx_len;
+ dev->rx_len = 0;
+
+ return r;
+}
+
+int
+fido_pcsc_write(void *handle, const unsigned char *buf, size_t len)
+{
+ struct pcsc *dev = handle;
+ DWORD n;
+ LONG s;
+
+ if (len > INT_MAX) {
+ fido_log_debug("%s: len", __func__);
+ return -1;
+ }
+
+ explicit_bzero(dev->rx_buf, sizeof(dev->rx_buf));
+ dev->rx_len = 0;
+ n = (DWORD)sizeof(dev->rx_buf);
+
+ fido_log_xxd(buf, len, "%s: writing", __func__);
+
+ if ((s = SCardTransmit(dev->h, &dev->req, buf, (DWORD)len, NULL,
+ dev->rx_buf, &n)) != SCARD_S_SUCCESS) {
+ fido_log_debug("%s: SCardTransmit 0x%lx", __func__, (long)s);
+ explicit_bzero(dev->rx_buf, sizeof(dev->rx_buf));
+ return -1;
+ }
+ dev->rx_len = (size_t)n;
+
+ fido_log_xxd(dev->rx_buf, dev->rx_len, "%s: read", __func__);
+
+ return (int)len;
+}
+
+int
+fido_pcsc_tx(fido_dev_t *d, uint8_t cmd, const u_char *buf, size_t count)
+{
+ return fido_nfc_tx(d, cmd, buf, count);
+}
+
+int
+fido_pcsc_rx(fido_dev_t *d, uint8_t cmd, u_char *buf, size_t count, int ms)
+{
+ return fido_nfc_rx(d, cmd, buf, count, ms);
+}
+
+bool
+fido_is_pcsc(const char *path)
+{
+ return strncmp(path, FIDO_PCSC_PREFIX, strlen(FIDO_PCSC_PREFIX)) == 0;
+}
+
+int
+fido_dev_set_pcsc(fido_dev_t *d)
+{
+ if (d->io_handle != NULL) {
+ fido_log_debug("%s: device open", __func__);
+ return -1;
+ }
+ d->io_own = true;
+ d->io = (fido_dev_io_t) {
+ fido_pcsc_open,
+ fido_pcsc_close,
+ fido_pcsc_read,
+ fido_pcsc_write,
+ };
+ d->transport = (fido_dev_transport_t) {
+ fido_pcsc_rx,
+ fido_pcsc_tx,
+ };
+
+ return 0;
+}
diff --git a/contrib/libfido2/src/pin.c b/contrib/libfido2/src/pin.c
index 30eeb086a6ef..c3dd9271ed71 100644
--- a/contrib/libfido2/src/pin.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/random.c b/contrib/libfido2/src/random.c
index f13482bfddf9..9688d35ca945 100644
--- a/contrib/libfido2/src/random.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/reset.c b/contrib/libfido2/src/reset.c
index c5fe6dfe7ac1..4e09dbbca5cf 100644
--- a/contrib/libfido2/src/reset.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/rs1.c b/contrib/libfido2/src/rs1.c
index 37aa9f073bed..03636b5cdf42 100644
--- a/contrib/libfido2/src/rs1.c
+++ b/contrib/libfido2/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>
@@ -9,7 +10,7 @@
#include "fido.h"
-#if defined(LIBRESSL_VERSION_NUMBER)
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050200fL
static EVP_MD *
rs1_get_EVP_MD(void)
{
diff --git a/contrib/libfido2/src/rs256.c b/contrib/libfido2/src/rs256.c
index 29fcedbdee20..59ceb948fa07 100644
--- a/contrib/libfido2/src/rs256.c
+++ b/contrib/libfido2/src/rs256.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/bn.h>
@@ -11,7 +12,13 @@
#include "fido.h"
#include "fido/rs256.h"
-#if defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000
+#define get0_RSA(x) EVP_PKEY_get0_RSA((x))
+#else
+#define get0_RSA(x) EVP_PKEY_get0((x))
+#endif
+
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050200fL
static EVP_MD *
rs256_get_EVP_MD(void)
{
@@ -128,11 +135,20 @@ rs256_pk_free(rs256_pk_t **pkp)
int
rs256_pk_from_ptr(rs256_pk_t *pk, const void *ptr, size_t len)
{
+ EVP_PKEY *pkey;
+
if (len < sizeof(*pk))
return (FIDO_ERR_INVALID_ARGUMENT);
memcpy(pk, ptr, sizeof(*pk));
+ if ((pkey = rs256_pk_to_EVP_PKEY(pk)) == NULL) {
+ fido_log_debug("%s: rs256_pk_to_EVP_PKEY", __func__);
+ return (FIDO_ERR_INVALID_ARGUMENT);
+ }
+
+ EVP_PKEY_free(pkey);
+
return (FIDO_OK);
}
@@ -163,6 +179,11 @@ rs256_pk_to_EVP_PKEY(const rs256_pk_t *k)
n = NULL;
e = NULL;
+ if (RSA_bits(rsa) != 2048) {
+ fido_log_debug("%s: invalid key length", __func__);
+ goto fail;
+ }
+
if ((pkey = EVP_PKEY_new()) == NULL ||
EVP_PKEY_assign_RSA(pkey, rsa) == 0) {
fido_log_debug("%s: EVP_PKEY_assign_RSA", __func__);
@@ -225,10 +246,10 @@ rs256_pk_from_RSA(rs256_pk_t *pk, const RSA *rsa)
int
rs256_pk_from_EVP_PKEY(rs256_pk_t *pk, const EVP_PKEY *pkey)
{
- RSA *rsa;
+ const RSA *rsa;
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA ||
- (rsa = EVP_PKEY_get0(pkey)) == NULL)
+ (rsa = get0_RSA(pkey)) == NULL)
return (FIDO_ERR_INVALID_ARGUMENT);
return (rs256_pk_from_RSA(pk, rsa));
diff --git a/contrib/libfido2/src/time.c b/contrib/libfido2/src/time.c
index b82b61874498..fd0e4e3ca33e 100644
--- a/contrib/libfido2/src/time.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/touch.c b/contrib/libfido2/src/touch.c
new file mode 100644
index 000000000000..6844e2c2dbc0
--- /dev/null
+++ b/contrib/libfido2/src/touch.c
@@ -0,0 +1,109 @@
+/*
+ * 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>
+#include "fido.h"
+
+int
+fido_dev_get_touch_begin(fido_dev_t *dev)
+{
+ fido_blob_t f;
+ cbor_item_t *argv[9];
+ const char *clientdata = FIDO_DUMMY_CLIENTDATA;
+ const uint8_t user_id = FIDO_DUMMY_USER_ID;
+ unsigned char cdh[SHA256_DIGEST_LENGTH];
+ fido_rp_t rp;
+ fido_user_t user;
+ int ms = dev->timeout_ms;
+ int r = FIDO_ERR_INTERNAL;
+
+ memset(&f, 0, sizeof(f));
+ memset(argv, 0, sizeof(argv));
+ memset(cdh, 0, sizeof(cdh));
+ memset(&rp, 0, sizeof(rp));
+ memset(&user, 0, sizeof(user));
+
+ if (fido_dev_is_fido2(dev) == false)
+ return (u2f_get_touch_begin(dev, &ms));
+
+ if (SHA256((const void *)clientdata, strlen(clientdata), cdh) != cdh) {
+ fido_log_debug("%s: sha256", __func__);
+ return (FIDO_ERR_INTERNAL);
+ }
+
+ if ((rp.id = strdup(FIDO_DUMMY_RP_ID)) == NULL ||
+ (user.name = strdup(FIDO_DUMMY_USER_NAME)) == NULL) {
+ fido_log_debug("%s: strdup", __func__);
+ goto fail;
+ }
+
+ if (fido_blob_set(&user.id, &user_id, sizeof(user_id)) < 0) {
+ fido_log_debug("%s: fido_blob_set", __func__);
+ goto fail;
+ }
+
+ if ((argv[0] = cbor_build_bytestring(cdh, sizeof(cdh))) == NULL ||
+ (argv[1] = cbor_encode_rp_entity(&rp)) == NULL ||
+ (argv[2] = cbor_encode_user_entity(&user)) == NULL ||
+ (argv[3] = cbor_encode_pubkey_param(COSE_ES256)) == NULL) {
+ fido_log_debug("%s: cbor encode", __func__);
+ goto fail;
+ }
+
+ if (fido_dev_supports_pin(dev)) {
+ if ((argv[7] = cbor_new_definite_bytestring()) == NULL ||
+ (argv[8] = cbor_encode_pin_opt(dev)) == NULL) {
+ fido_log_debug("%s: cbor encode", __func__);
+ goto fail;
+ }
+ }
+
+ if (cbor_build_frame(CTAP_CBOR_MAKECRED, argv, nitems(argv), &f) < 0 ||
+ fido_tx(dev, CTAP_CMD_CBOR, f.ptr, f.len, &ms) < 0) {
+ fido_log_debug("%s: fido_tx", __func__);
+ r = FIDO_ERR_TX;
+ goto fail;
+ }
+
+ r = FIDO_OK;
+fail:
+ cbor_vector_free(argv, nitems(argv));
+ free(f.ptr);
+ free(rp.id);
+ free(user.name);
+ free(user.id.ptr);
+
+ return (r);
+}
+
+int
+fido_dev_get_touch_status(fido_dev_t *dev, int *touched, int ms)
+{
+ int r;
+
+ *touched = 0;
+
+ if (fido_dev_is_fido2(dev) == false)
+ return (u2f_get_touch_status(dev, touched, &ms));
+
+ switch ((r = fido_rx_cbor_status(dev, &ms))) {
+ case FIDO_ERR_PIN_AUTH_INVALID:
+ case FIDO_ERR_PIN_INVALID:
+ case FIDO_ERR_PIN_NOT_SET:
+ case FIDO_ERR_SUCCESS:
+ *touched = 1;
+ break;
+ case FIDO_ERR_RX:
+ /* ignore */
+ break;
+ default:
+ fido_log_debug("%s: fido_rx_cbor_status", __func__);
+ return (r);
+ }
+
+ return (FIDO_OK);
+}
diff --git a/contrib/libfido2/src/tpm.c b/contrib/libfido2/src/tpm.c
index 74244f8cbf08..3e09bca00ffb 100644
--- a/contrib/libfido2/src/tpm.c
+++ b/contrib/libfido2/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
*/
/*
@@ -47,7 +48,7 @@ struct tpm_sha256_digest {
/* Part 2, 10.4.3: TPM2B_DATA */
PACKED_TYPE(tpm_sha1_data_t,
struct tpm_sha1_data {
- uint16_t size; /* sizeof(body */
+ uint16_t size; /* sizeof(body) */
uint8_t body[20];
})
diff --git a/contrib/libfido2/src/types.c b/contrib/libfido2/src/types.c
index 54c0ca582865..f31f8da12952 100644
--- a/contrib/libfido2/src/types.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/u2f.c b/contrib/libfido2/src/u2f.c
index 6ebfcc7bb848..b1f7bce3b7ab 100644
--- a/contrib/libfido2/src/u2f.c
+++ b/contrib/libfido2/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/contrib/libfido2/src/util.c b/contrib/libfido2/src/util.c
new file mode 100644
index 000000000000..25281bb51b28
--- /dev/null
+++ b/contrib/libfido2/src/util.c
@@ -0,0 +1,31 @@
+/*
+ * 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>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "fido.h"
+
+int
+fido_to_uint64(const char *str, int base, uint64_t *out)
+{
+ char *ep;
+ unsigned long long ull;
+
+ errno = 0;
+ ull = strtoull(str, &ep, base);
+ if (str == ep || *ep != '\0')
+ return -1;
+ else if (ull == ULLONG_MAX && errno == ERANGE)
+ return -1;
+ else if (ull > UINT64_MAX)
+ return -1;
+ *out = (uint64_t)ull;
+
+ return 0;
+}
diff --git a/contrib/libfido2/src/webauthn.h b/contrib/libfido2/src/webauthn.h
index 22bf6e346a73..e64236a0f6fe 100644
--- a/contrib/libfido2/src/webauthn.h
+++ b/contrib/libfido2/src/webauthn.h
@@ -92,6 +92,9 @@ extern "C" {
// - WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS : 5
// - WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS : 6
// - WEBAUTHN_ASSERTION : 3
+// APIs:
+// - WebAuthNGetPlatformCredentialList
+// - WebAuthNFreePlatformCredentialList
//
#define WEBAUTHN_API_CURRENT_VERSION WEBAUTHN_API_VERSION_4
@@ -283,11 +286,64 @@ typedef struct _WEBAUTHN_CREDENTIAL_LIST {
typedef const WEBAUTHN_CREDENTIAL_LIST *PCWEBAUTHN_CREDENTIAL_LIST;
//+------------------------------------------------------------------------------------------
+// Credential Information for WebAuthNGetPlatformCredentialList API
+//-------------------------------------------------------------------------------------------
+
+#define WEBAUTHN_CREDENTIAL_DETAILS_VERSION_1 1
+#define WEBAUTHN_CREDENTIAL_DETAILS_CURRENT_VERSION WEBAUTHN_CREDENTIAL_DETAILS_VERSION_1
+
+typedef struct _WEBAUTHN_CREDENTIAL_DETAILS {
+ // Version of this structure, to allow for modifications in the future.
+ DWORD dwVersion;
+
+ // Size of pbCredentialID.
+ DWORD cbCredentialID;
+ _Field_size_bytes_(cbCredentialID)
+ PBYTE pbCredentialID;
+
+ // RP Info
+ PWEBAUTHN_RP_ENTITY_INFORMATION pRpInformation;
+
+ // User Info
+ PWEBAUTHN_USER_ENTITY_INFORMATION pUserInformation;
+} WEBAUTHN_CREDENTIAL_DETAILS, *PWEBAUTHN_CREDENTIAL_DETAILS;
+typedef const WEBAUTHN_CREDENTIAL_DETAILS *PCWEBAUTHN_CREDENTIAL_DETAILS;
+
+typedef struct _WEBAUTHN_CREDENTIAL_DETAILS_LIST {
+ DWORD cCredentialDetails;
+ _Field_size_(cCredentialDetails)
+ PWEBAUTHN_CREDENTIAL_DETAILS *ppCredentialDetails;
+} WEBAUTHN_CREDENTIAL_DETAILS_LIST, *PWEBAUTHN_CREDENTIAL_DETAILS_LIST;
+typedef const WEBAUTHN_CREDENTIAL_DETAILS_LIST *PCWEBAUTHN_CREDENTIAL_DETAILS_LIST;
+
+#define WEBAUTHN_GET_CREDENTIALS_OPTIONS_VERSION_1 1
+#define WEBAUTHN_GET_CREDENTIALS_OPTIONS_CURRENT_VERSION WEBAUTHN_GET_CREDENTIALS_OPTIONS_VERSION_1
+
+typedef struct _WEBAUTHN_GET_CREDENTIALS_OPTIONS {
+ // Version of this structure, to allow for modifications in the future.
+ DWORD dwVersion;
+
+ // RPID
+ LPCWSTR pwszRpId;
+
+ // Optional. BrowserInPrivate Mode. Defaulting to FALSE.
+ BOOL bBrowserInPrivateMode;
+} WEBAUTHN_GET_CREDENTIALS_OPTIONS, *PWEBAUTHN_GET_CREDENTIALS_OPTIONS;
+typedef const WEBAUTHN_GET_CREDENTIALS_OPTIONS *PCWEBAUTHN_GET_CREDENTIALS_OPTIONS;
+
+//+------------------------------------------------------------------------------------------
// PRF values.
//-------------------------------------------------------------------------------------------
#define WEBAUTHN_CTAP_ONE_HMAC_SECRET_LENGTH 32
+// SALT values below by default are converted into RAW Hmac-Secret values as per PRF extension.
+// - SHA-256(UTF8Encode("WebAuthn PRF") || 0x00 || Value)
+//
+// Set WEBAUTHN_CTAP_HMAC_SECRET_VALUES_FLAG in dwFlags in WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS,
+// if caller wants to provide RAW Hmac-Secret SALT values directly. In that case,
+// values if provided MUST be of WEBAUTHN_CTAP_ONE_HMAC_SECRET_LENGTH size.
+
typedef struct _WEBAUTHN_HMAC_SECRET_SALT {
// Size of pbFirst.
DWORD cbFirst;
@@ -545,6 +601,12 @@ typedef const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS *PCWEBAUTHN_AUTHENT
#define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_6 6
#define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_CURRENT_VERSION WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_6
+/*
+ Information about flags.
+*/
+
+#define WEBAUTHN_AUTHENTICATOR_HMAC_SECRET_VALUES_FLAG 0x00100000
+
typedef struct _WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS {
// Version of this structure, to allow for modifications in the future.
DWORD dwVersion;
@@ -565,7 +627,7 @@ typedef struct _WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS {
// User Verification Requirement.
DWORD dwUserVerificationRequirement;
- // Reserved for future Use
+ // Flags
DWORD dwFlags;
//
@@ -879,6 +941,17 @@ WINAPI
WebAuthNCancelCurrentOperation(
_In_ const GUID* pCancellationId);
+HRESULT
+WINAPI
+WebAuthNGetPlatformCredentialList(
+ _In_ PCWEBAUTHN_GET_CREDENTIALS_OPTIONS pGetCredentialsOptions,
+ _Outptr_result_maybenull_ PWEBAUTHN_CREDENTIAL_DETAILS_LIST *ppCredentialDetailsList);
+
+void
+WINAPI
+WebAuthNFreePlatformCredentialList(
+ _In_ PWEBAUTHN_CREDENTIAL_DETAILS_LIST pCredentialDetailsList);
+
//
// Returns the following Error Names:
// L"Success" - S_OK
diff --git a/contrib/libfido2/src/winhello.c b/contrib/libfido2/src/winhello.c
index 9de6c6c9b983..efc7dc22f851 100644
--- a/contrib/libfido2/src/winhello.c
+++ b/contrib/libfido2/src/winhello.c
@@ -1,7 +1,8 @@
/*
- * 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
*/
#include <sys/types.h>
@@ -84,7 +85,7 @@ webauthn_load(void)
fido_log_debug("%s: already loaded", __func__);
return -1;
}
- if ((webauthn_handle = LoadLibrary("webauthn.dll")) == NULL) {
+ if ((webauthn_handle = LoadLibrary(TEXT("webauthn.dll"))) == NULL) {
fido_log_debug("%s: LoadLibrary", __func__);
return -1;
}
@@ -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;
@@ -428,16 +432,48 @@ pack_cred_ext(WEBAUTHN_EXTENSIONS *out, const fido_cred_ext_t *in)
}
static int
-unpack_assert_authdata(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
+pack_assert_ext(WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS *out,
+ const fido_assert_ext_t *in)
{
- int r;
+ WEBAUTHN_HMAC_SECRET_SALT_VALUES *v;
+ WEBAUTHN_HMAC_SECRET_SALT *s;
- if (wa->cbAuthenticatorData > SIZE_MAX) {
- fido_log_debug("%s: cbAuthenticatorData", __func__);
+ if (in->mask == 0) {
+ return 0; /* nothing to do */
+ }
+ if (in->mask != FIDO_EXT_HMAC_SECRET) {
+ fido_log_debug("%s: mask 0x%x", __func__, in->mask);
+ return -1;
+ }
+ if (in->hmac_salt.ptr == NULL ||
+ in->hmac_salt.len != WEBAUTHN_CTAP_ONE_HMAC_SECRET_LENGTH) {
+ fido_log_debug("%s: salt %p/%zu", __func__,
+ (const void *)in->hmac_salt.ptr, in->hmac_salt.len);
return -1;
}
+ if ((v = calloc(1, sizeof(*v))) == NULL ||
+ (s = calloc(1, sizeof(*s))) == NULL) {
+ free(v);
+ fido_log_debug("%s: calloc", __func__);
+ return -1;
+ }
+ s->cbFirst = (DWORD)in->hmac_salt.len;
+ s->pbFirst = in->hmac_salt.ptr;
+ v->pGlobalHmacSalt = s;
+ out->pHmacSecretSaltValues = v;
+ out->dwFlags |= WEBAUTHN_AUTHENTICATOR_HMAC_SECRET_VALUES_FLAG;
+ out->dwVersion = WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_6;
+
+ return 0;
+}
+
+static int
+unpack_assert_authdata(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
+{
+ int r;
+
if ((r = fido_assert_set_authdata_raw(assert, 0, wa->pbAuthenticatorData,
- (size_t)wa->cbAuthenticatorData)) != FIDO_OK) {
+ wa->cbAuthenticatorData)) != FIDO_OK) {
fido_log_debug("%s: fido_assert_set_authdata_raw: %s", __func__,
fido_strerr(r));
return -1;
@@ -451,12 +487,8 @@ unpack_assert_sig(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
{
int r;
- if (wa->cbSignature > SIZE_MAX) {
- fido_log_debug("%s: cbSignature", __func__);
- return -1;
- }
if ((r = fido_assert_set_sig(assert, 0, wa->pbSignature,
- (size_t)wa->cbSignature)) != FIDO_OK) {
+ wa->cbSignature)) != FIDO_OK) {
fido_log_debug("%s: fido_assert_set_sig: %s", __func__,
fido_strerr(r));
return -1;
@@ -468,12 +500,8 @@ unpack_assert_sig(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
static int
unpack_cred_id(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
{
- if (wa->Credential.cbId > SIZE_MAX) {
- fido_log_debug("%s: Credential.cbId", __func__);
- return -1;
- }
if (fido_blob_set(&assert->stmt[0].id, wa->Credential.pbId,
- (size_t)wa->Credential.cbId) < 0) {
+ wa->Credential.cbId) < 0) {
fido_log_debug("%s: fido_blob_set", __func__);
return -1;
}
@@ -486,12 +514,40 @@ unpack_user_id(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
{
if (wa->cbUserId == 0)
return 0; /* user id absent */
- if (wa->cbUserId > SIZE_MAX) {
- fido_log_debug("%s: cbUserId", __func__);
+ if (fido_blob_set(&assert->stmt[0].user.id, wa->pbUserId,
+ wa->cbUserId) < 0) {
+ fido_log_debug("%s: fido_blob_set", __func__);
return -1;
}
- if (fido_blob_set(&assert->stmt[0].user.id, wa->pbUserId,
- (size_t)wa->cbUserId) < 0) {
+
+ return 0;
+}
+
+static int
+unpack_hmac_secret(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
+{
+ if (wa->dwVersion != WEBAUTHN_ASSERTION_VERSION_3) {
+ fido_log_debug("%s: dwVersion %u", __func__,
+ (unsigned)wa->dwVersion);
+ return 0; /* proceed without hmac-secret */
+ }
+ if (wa->pHmacSecret == NULL ||
+ wa->pHmacSecret->cbFirst == 0 ||
+ wa->pHmacSecret->pbFirst == NULL) {
+ fido_log_debug("%s: hmac-secret absent", __func__);
+ return 0; /* proceed without hmac-secret */
+ }
+ if (wa->pHmacSecret->cbSecond != 0 ||
+ wa->pHmacSecret->pbSecond != NULL) {
+ fido_log_debug("%s: 64-byte hmac-secret", __func__);
+ return 0; /* proceed without hmac-secret */
+ }
+ if (!fido_blob_is_empty(&assert->stmt[0].hmac_secret)) {
+ fido_log_debug("%s: fido_blob_is_empty", __func__);
+ return -1;
+ }
+ if (fido_blob_set(&assert->stmt[0].hmac_secret,
+ wa->pHmacSecret->pbFirst, wa->pHmacSecret->cbFirst) < 0) {
fido_log_debug("%s: fido_blob_set", __func__);
return -1;
}
@@ -510,11 +566,6 @@ translate_fido_assert(struct winhello_assert *ctx, const fido_assert_t *assert,
fido_log_debug("%s: up %d", __func__, assert->up);
return FIDO_ERR_UNSUPPORTED_OPTION;
}
- /* not implemented */
- if (assert->ext.mask) {
- fido_log_debug("%s: ext 0x%x", __func__, assert->ext.mask);
- return FIDO_ERR_UNSUPPORTED_EXTENSION;
- }
if ((ctx->rp_id = to_utf16(assert->rp_id)) == NULL) {
fido_log_debug("%s: rp_id", __func__);
return FIDO_ERR_INTERNAL;
@@ -531,6 +582,10 @@ translate_fido_assert(struct winhello_assert *ctx, const fido_assert_t *assert,
fido_log_debug("%s: pack_credlist", __func__);
return FIDO_ERR_INTERNAL;
}
+ if (pack_assert_ext(opt, &assert->ext) < 0) {
+ fido_log_debug("%s: pack_assert_ext", __func__);
+ return FIDO_ERR_UNSUPPORTED_EXTENSION;
+ }
if (set_assert_uv(&opt->dwUserVerificationRequirement, assert->uv,
pin) < 0) {
fido_log_debug("%s: set_assert_uv", __func__);
@@ -570,6 +625,11 @@ translate_winhello_assert(fido_assert_t *assert, const WEBAUTHN_ASSERTION *wa)
fido_log_debug("%s: unpack_user_id", __func__);
return FIDO_ERR_INTERNAL;
}
+ if (assert->ext.mask & FIDO_EXT_HMAC_SECRET &&
+ unpack_hmac_secret(assert, wa) < 0) {
+ fido_log_debug("%s: unpack_hmac_secret", __func__);
+ return FIDO_ERR_INTERNAL;
+ }
return FIDO_OK;
}
@@ -675,13 +735,12 @@ translate_winhello_cred(fido_cred_t *cred,
struct cbor_load_result cbor;
int r = FIDO_ERR_INTERNAL;
- if (att->pbAttestationObject == NULL ||
- att->cbAttestationObject > SIZE_MAX) {
+ if (att->pbAttestationObject == NULL) {
fido_log_debug("%s: pbAttestationObject", __func__);
goto fail;
}
if ((item = cbor_load(att->pbAttestationObject,
- (size_t)att->cbAttestationObject, &cbor)) == NULL) {
+ att->cbAttestationObject, &cbor)) == NULL) {
fido_log_debug("%s: cbor_load", __func__);
goto fail;
}
@@ -742,6 +801,9 @@ winhello_assert_free(struct winhello_assert *ctx)
free(ctx->rp_id);
free(ctx->opt.CredentialList.pCredentials);
+ if (ctx->opt.pHmacSecretSaltValues != NULL)
+ free(ctx->opt.pHmacSecretSaltValues->pGlobalHmacSalt);
+ free(ctx->opt.pHmacSecretSaltValues);
free(ctx);
}
@@ -883,7 +945,7 @@ fido_winhello_get_cbor_info(fido_dev_t *dev, fido_cbor_info_t *ci)
const char *v[3] = { "U2F_V2", "FIDO_2_0", "FIDO_2_1_PRE" };
const char *e[2] = { "credProtect", "hmac-secret" };
const char *t[2] = { "nfc", "usb" };
- const char *o[4] = { "rk", "up", "plat", "clientPin" };
+ const char *o[4] = { "rk", "up", "uv", "plat" };
(void)dev;
diff --git a/contrib/libfido2/tools/CMakeLists.txt b/contrib/libfido2/tools/CMakeLists.txt
index f37aa1d87c97..e1f4366c4ef3 100644
--- a/contrib/libfido2/tools/CMakeLists.txt
+++ b/contrib/libfido2/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
@@ -65,13 +66,6 @@ add_executable(fido2-token
${COMPAT_SOURCES}
)
-# set the library to link against
-if(BUILD_SHARED_LIBS)
- set(_FIDO2_LIBRARY fido2_shared)
-else()
- set(_FIDO2_LIBRARY fido2)
-endif()
-
target_link_libraries(fido2-cred ${CRYPTO_LIBRARIES} ${_FIDO2_LIBRARY})
target_link_libraries(fido2-assert ${CRYPTO_LIBRARIES} ${_FIDO2_LIBRARY})
target_link_libraries(fido2-token ${CRYPTO_LIBRARIES} ${_FIDO2_LIBRARY})
diff --git a/contrib/libfido2/tools/assert_get.c b/contrib/libfido2/tools/assert_get.c
index c38040253520..8260fb8359f5 100644
--- a/contrib/libfido2/tools/assert_get.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/assert_verify.c b/contrib/libfido2/tools/assert_verify.c
index 7985e95042c5..4cc2e86bff13 100644
--- a/contrib/libfido2/tools/assert_verify.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/base64.c b/contrib/libfido2/tools/base64.c
index e13119823c98..2cfa98ddb254 100644
--- a/contrib/libfido2/tools/base64.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/bio.c b/contrib/libfido2/tools/bio.c
index 1ce1041c30c6..7a1406d70de5 100644
--- a/contrib/libfido2/tools/bio.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/config.c b/contrib/libfido2/tools/config.c
index 3eea4c9b6cf6..49253e83f3b7 100644
--- a/contrib/libfido2/tools/config.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/cred_make.c b/contrib/libfido2/tools/cred_make.c
index 7955fa2b7f9f..a6239ec27aec 100644
--- a/contrib/libfido2/tools/cred_make.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/cred_verify.c b/contrib/libfido2/tools/cred_verify.c
index d622ed7369bd..3eae435899df 100644
--- a/contrib/libfido2/tools/cred_verify.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/credman.c b/contrib/libfido2/tools/credman.c
index d7fb15580f87..a0a3149d5dfb 100644
--- a/contrib/libfido2/tools/credman.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/extern.h b/contrib/libfido2/tools/extern.h
index 8b25dadd45ac..ed4b348cfe46 100644
--- a/contrib/libfido2/tools/extern.h
+++ b/contrib/libfido2/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/contrib/libfido2/tools/fido2-assert.c b/contrib/libfido2/tools/fido2-assert.c
index c363d9a49927..d05c541651cb 100644
--- a/contrib/libfido2/tools/fido2-assert.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/fido2-attach.sh b/contrib/libfido2/tools/fido2-attach.sh
index d4bc44989f2b..ef02db6b9ff0 100755
--- a/contrib/libfido2/tools/fido2-attach.sh
+++ b/contrib/libfido2/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/contrib/libfido2/tools/fido2-cred.c b/contrib/libfido2/tools/fido2-cred.c
index 9463cd591e75..965dbf9ef1ad 100644
--- a/contrib/libfido2/tools/fido2-cred.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/fido2-detach.sh b/contrib/libfido2/tools/fido2-detach.sh
index 9cd2e64bbe31..140278fc6993 100755
--- a/contrib/libfido2/tools/fido2-detach.sh
+++ b/contrib/libfido2/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/contrib/libfido2/tools/fido2-token.c b/contrib/libfido2/tools/fido2-token.c
index e6d9f9f96381..412c2f9016c5 100644
--- a/contrib/libfido2/tools/fido2-token.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/fido2-unprot.sh b/contrib/libfido2/tools/fido2-unprot.sh
index 44b28b8d06b8..7d8c77936ee9 100755
--- a/contrib/libfido2/tools/fido2-unprot.sh
+++ b/contrib/libfido2/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/contrib/libfido2/tools/include_check.sh b/contrib/libfido2/tools/include_check.sh
index e684d0b6f12d..70abada1640d 100755
--- a/contrib/libfido2/tools/include_check.sh
+++ b/contrib/libfido2/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/contrib/libfido2/tools/largeblob.c b/contrib/libfido2/tools/largeblob.c
index fc2584ce8bdf..78b97ab1e96b 100644
--- a/contrib/libfido2/tools/largeblob.c
+++ b/contrib/libfido2/tools/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 <sys/types.h>
@@ -24,6 +25,8 @@
#include "../openbsd-compat/openbsd-compat.h"
#include "extern.h"
+#define BOUND (1024UL * 1024UL)
+
struct rkmap {
fido_credman_rp_t *rp; /* known rps */
fido_credman_rk_t **rk; /* rk per rp */
@@ -302,35 +305,57 @@ out:
}
static int
-decompress(const struct blob *plaintext, uint64_t origsiz)
+try_decompress(const struct blob *in, uint64_t origsiz, int wbits)
{
- struct blob inflated;
- u_long ilen, plen;
+ struct blob out;
+ z_stream zs;
+ u_int ilen, olen;
int ok = -1;
- memset(&inflated, 0, sizeof(inflated));
+ memset(&zs, 0, sizeof(zs));
+ memset(&out, 0, sizeof(out));
- if (plaintext->len > ULONG_MAX)
+ if (in->len > UINT_MAX || (ilen = (u_int)in->len) > BOUND)
return -1;
- if (origsiz > ULONG_MAX || origsiz > SIZE_MAX)
+ if (origsiz > SIZE_MAX || origsiz > UINT_MAX ||
+ (olen = (u_int)origsiz) > BOUND)
return -1;
- plen = (u_long)plaintext->len;
- ilen = (u_long)origsiz;
- inflated.len = (size_t)origsiz;
- if ((inflated.ptr = calloc(1, inflated.len)) == NULL)
+ if (inflateInit2(&zs, wbits) != Z_OK)
return -1;
- if (uncompress(inflated.ptr, &ilen, plaintext->ptr, plen) != Z_OK ||
- ilen > SIZE_MAX || (size_t)ilen != (size_t)origsiz)
- goto out;
- ok = 0; /* success */
-out:
- freezero(inflated.ptr, inflated.len);
+ if ((out.ptr = calloc(1, olen)) == NULL)
+ goto fail;
+
+ out.len = olen;
+ zs.next_in = in->ptr;
+ zs.avail_in = ilen;
+ zs.next_out = out.ptr;
+ zs.avail_out = olen;
+
+ if (inflate(&zs, Z_FINISH) != Z_STREAM_END)
+ goto fail;
+ if (zs.avail_out != 0)
+ goto fail;
+
+ ok = 0;
+fail:
+ if (inflateEnd(&zs) != Z_OK)
+ ok = -1;
+
+ freezero(out.ptr, out.len);
return ok;
}
static int
+decompress(const struct blob *plaintext, uint64_t origsiz)
+{
+ if (try_decompress(plaintext, origsiz, MAX_WBITS) == 0) /* rfc1950 */
+ return 0;
+ return try_decompress(plaintext, origsiz, -MAX_WBITS); /* rfc1951 */
+}
+
+static int
decode(const struct blob *ciphertext, const struct blob *nonce,
uint64_t origsiz, const fido_cred_t *cred)
{
diff --git a/contrib/libfido2/tools/pin.c b/contrib/libfido2/tools/pin.c
index f342347d1ff5..8b2697ed8e1e 100644
--- a/contrib/libfido2/tools/pin.c
+++ b/contrib/libfido2/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/contrib/libfido2/tools/test.sh b/contrib/libfido2/tools/test.sh
index 02d82d5a18cd..67b757e80a8d 100755
--- a/contrib/libfido2/tools/test.sh
+++ b/contrib/libfido2/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/contrib/libfido2/tools/token.c b/contrib/libfido2/tools/token.c
index 3d165623fdbf..366d5a15ab04 100644
--- a/contrib/libfido2/tools/token.c
+++ b/contrib/libfido2/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);
@@ -156,6 +176,107 @@ print_maxcredidlen(uint64_t maxcredidlen)
}
static void
+print_maxlargeblob(uint64_t maxlargeblob)
+{
+ printf("maxlargeblob: %d\n", (int)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);
@@ -250,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));
@@ -259,8 +388,17 @@ token_info(int argc, char **argv, char *path)
/* print maximum length of a credential ID */
print_maxcredidlen(fido_cbor_info_maxcredidlen(ci));
- /* print firmware version */
- print_fwversion(fido_cbor_info_fwversion(ci));
+ /* print maximum length of serialized largeBlob array */
+ print_maxlargeblob(fido_cbor_info_maxlargeblob(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),
@@ -271,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/contrib/libfido2/tools/util.c b/contrib/libfido2/tools/util.c
index 612d81b2000c..0e518bbc5ce2 100644
--- a/contrib/libfido2/tools/util.c
+++ b/contrib/libfido2/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/contrib/libfido2/udev/70-u2f.rules b/contrib/libfido2/udev/70-u2f.rules
index 0dfc3e276c7a..c443f7524a08 100644
--- a/contrib/libfido2/udev/70-u2f.rules
+++ b/contrib/libfido2/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"
@@ -106,6 +129,9 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct
# SatoshiLabs TREZOR by pid.codes
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c1", TAG+="uaccess", GROUP="plugdev", MODE="0660"
+# SoloKeys v2 by pid.codes
+KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="beee", TAG+="uaccess", GROUP="plugdev", MODE="0660"
+
# Google Titan U2F by Google Inc.
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="5026", TAG+="uaccess", GROUP="plugdev", MODE="0660"
@@ -190,6 +216,9 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2ccf", ATTRS{idProduct
# TrustKey Solutions FIDO2 G310 by eWBM Co., Ltd.
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="311f", ATTRS{idProduct}=="4a1a", TAG+="uaccess", GROUP="plugdev", MODE="0660"
+# TrustKey Solutions FIDO2 G310H/G320H by eWBM Co., Ltd.
+KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="311f", ATTRS{idProduct}=="4a2a", TAG+="uaccess", GROUP="plugdev", MODE="0660"
+
# TrustKey Solutions FIDO2 G320 by eWBM Co., Ltd.
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="311f", ATTRS{idProduct}=="4c2a", TAG+="uaccess", GROUP="plugdev", MODE="0660"
diff --git a/contrib/libfido2/udev/CMakeLists.txt b/contrib/libfido2/udev/CMakeLists.txt
index 29a9d41fe37d..abddb80f4d82 100644
--- a/contrib/libfido2/udev/CMakeLists.txt
+++ b/contrib/libfido2/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/contrib/libfido2/udev/check.sh b/contrib/libfido2/udev/check.sh
index 97bbb97b26c8..804a8843b378 100755
--- a/contrib/libfido2/udev/check.sh
+++ b/contrib/libfido2/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/contrib/libfido2/udev/fidodevs b/contrib/libfido2/udev/fidodevs
index cea60a0be9fb..196e92f0b100 100644
--- a/contrib/libfido2/udev/fidodevs
+++ b/contrib/libfido2/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
@@ -72,6 +73,7 @@ product SILICON 0x8acf U2F Zero
product PIDCODES 0x5070 SoloKeys SoloHacker
product PIDCODES 0x50b0 SoloKeys SoloBoot
product PIDCODES 0x53c1 SatoshiLabs TREZOR
+product PIDCODES 0xbeee SoloKeys v2
product GOOGLE 0x5026 Google Titan U2F
@@ -113,6 +115,7 @@ product LEDGER 0x4015 Ledger Nano X Legacy
product HYPERSECU 0x0880 Hypersecu HyperFIDO
product EWBM 0x4a1a TrustKey Solutions FIDO2 G310
+product EWBM 0x4a2a TrustKey Solutions FIDO2 G310H/G320H
product EWBM 0x4c2a TrustKey Solutions FIDO2 G320
product EWBM 0x5c2f eWBM FIDO2 Goldengate G500
product EWBM 0xa6e9 TrustKey Solutions FIDO2 T120
diff --git a/contrib/libfido2/udev/genrules.awk b/contrib/libfido2/udev/genrules.awk
index 2a85c7cbf98f..3dad667da923 100755
--- a/contrib/libfido2/udev/genrules.awk
+++ b/contrib/libfido2/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/contrib/libfido2/windows/build.ps1 b/contrib/libfido2/windows/build.ps1
index 56302444c80b..52a1d6692de4 100644
--- a/contrib/libfido2/windows/build.ps1
+++ b/contrib/libfido2/windows/build.ps1
@@ -1,6 +1,7 @@
-# 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
param(
[string]$CMakePath = "C:\Program Files\CMake\bin\cmake.exe",
@@ -162,8 +163,8 @@ try {
& $CMake ..\..\..\${LIBCBOR} -A "${Arch}" `
-DWITH_EXAMPLES=OFF `
-DBUILD_SHARED_LIBS="${SHARED}" `
- -DCMAKE_C_FLAGS_DEBUG="${CFLAGS_DEBUG}" `
- -DCMAKE_C_FLAGS_RELEASE="${CFLAGS_RELEASE}" `
+ -DCMAKE_C_FLAGS_DEBUG="${CFLAGS_DEBUG} /wd4703" `
+ -DCMAKE_C_FLAGS_RELEASE="${CFLAGS_RELEASE} /wd4703" `
-DCMAKE_INSTALL_PREFIX="${PREFIX}" "${CMAKE_SYSTEM_VERSION}"; `
ExitOnError
& $CMake --build . --config ${Config} --verbose; ExitOnError
@@ -187,17 +188,15 @@ try {
& $CMake --build . --config ${Config} --verbose; ExitOnError
& $CMake --build . --config ${Config} --target install --verbose; `
ExitOnError
- # Patch up zlib's resulting names when built with --config Debug.
- if ("${Config}" -eq "Debug") {
- if ("${Type}" -eq "Dynamic") {
- Copy-Item "${PREFIX}/lib/zlibd.lib" `
- -Destination "${PREFIX}/lib/zlib.lib" -Force
- Copy-Item "${PREFIX}/bin/zlibd1.dll" `
- -Destination "${PREFIX}/bin/zlib1.dll" -Force
- } else {
- Copy-Item "${PREFIX}/lib/zlibstaticd.lib" `
- -Destination "${PREFIX}/lib/zlib.lib" -Force
- }
+ # Patch up zlib's various names.
+ if ("${Type}" -eq "Dynamic") {
+ ((Get-ChildItem -Path "${PREFIX}/lib") -Match "zlib[d]?.lib") |
+ Copy-Item -Destination "${PREFIX}/lib/zlib1.lib" -Force
+ ((Get-ChildItem -Path "${PREFIX}/bin") -Match "zlibd1.dll") |
+ Copy-Item -Destination "${PREFIX}/bin/zlib1.dll" -Force
+ } else {
+ ((Get-ChildItem -Path "${PREFIX}/lib") -Match "zlibstatic[d]?.lib") |
+ Copy-item -Destination "${PREFIX}/lib/zlib1.lib" -Force
}
} catch {
throw "Failed to build zlib"
@@ -220,16 +219,19 @@ try {
-DCRYPTO_INCLUDE_DIRS="${PREFIX}\include" `
-DCRYPTO_LIBRARY_DIRS="${PREFIX}\lib" `
-DCRYPTO_BIN_DIRS="${PREFIX}\bin" `
+ -DCRYPTO_LIBRARIES="${CRYPTO_LIBRARIES}" `
-DCMAKE_C_FLAGS_DEBUG="${CFLAGS_DEBUG} ${Fido2Flags}" `
-DCMAKE_C_FLAGS_RELEASE="${CFLAGS_RELEASE} ${Fido2Flags}" `
-DCMAKE_INSTALL_PREFIX="${PREFIX}" "${CMAKE_SYSTEM_VERSION}"; `
ExitOnError
& $CMake --build . --config ${Config} --verbose; ExitOnError
+ & $CMake --build . --config ${Config} --target regress --verbose; `
+ ExitOnError
& $CMake --build . --config ${Config} --target install --verbose; `
ExitOnError
# Copy DLLs.
if ("${SHARED}" -eq "ON") {
- "cbor.dll", "crypto-47.dll", "zlib1.dll" | `
+ "cbor.dll", "${CRYPTO_LIBRARIES}.dll", "zlib1.dll" | `
%{ Copy-Item "${PREFIX}\bin\$_" `
-Destination "examples\${Config}" }
}
diff --git a/contrib/libfido2/windows/const.ps1 b/contrib/libfido2/windows/const.ps1
index 4aac8bb2853e..f657846def5e 100644
--- a/contrib/libfido2/windows/const.ps1
+++ b/contrib/libfido2/windows/const.ps1
@@ -1,22 +1,24 @@
-# Copyright (c) 2021 Yubico AB. All rights reserved.
+# Copyright (c) 2021-2023 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.4.2' -Option Constant
+New-Variable -Name 'LIBRESSL' -Value 'libressl-3.6.2' -Option Constant
+New-Variable -Name 'CRYPTO_LIBRARIES' -Value 'crypto-50' -Option Constant
# libcbor coordinates.
-New-Variable -Name 'LIBCBOR' -Value 'libcbor-0.9.0' -Option Constant
-New-Variable -Name 'LIBCBOR_BRANCH' -Value 'v0.9.0' -Option Constant
+New-Variable -Name 'LIBCBOR' -Value 'libcbor-0.10.1' -Option Constant
+New-Variable -Name 'LIBCBOR_BRANCH' -Value 'v0.10.1' -Option Constant
New-Variable -Name 'LIBCBOR_GIT' -Value 'https://github.com/pjk/libcbor' `
-Option Constant
# zlib coordinates.
-New-Variable -Name 'ZLIB' -Value 'zlib-1.2.11' -Option Constant
-New-Variable -Name 'ZLIB_BRANCH' -Value 'v1.2.11' -Option Constant
+New-Variable -Name 'ZLIB' -Value 'zlib-1.2.13' -Option Constant
+New-Variable -Name 'ZLIB_BRANCH' -Value 'v1.2.13' -Option Constant
New-Variable -Name 'ZLIB_GIT' -Value 'https://github.com/madler/zlib' `
-Option Constant
diff --git a/contrib/libfido2/windows/cygwin.ps1 b/contrib/libfido2/windows/cygwin.ps1
index aada60b6f06f..0681830a911d 100755
--- a/contrib/libfido2/windows/cygwin.ps1
+++ b/contrib/libfido2/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",
@@ -66,3 +67,4 @@ Start-Process "${Cygwin}\${Setup}" -Wait -NoNewWindow `
$Env:PATH = "${Root}\bin\;" + $Env:PATH
cmake "-DCMAKE_BUILD_TYPE=${Config}" -B "build-${Config}"
make -C "build-${Config}"
+make -C "build-${Config}" regress
diff --git a/contrib/libfido2/windows/release.ps1 b/contrib/libfido2/windows/release.ps1
index 9221bcaa3413..cc5f635b8faa 100644
--- a/contrib/libfido2/windows/release.ps1
+++ b/contrib/libfido2/windows/release.ps1
@@ -1,13 +1,13 @@
-# 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
$ErrorActionPreference = "Stop"
$Architectures = @('x64', 'Win32', 'ARM64', 'ARM')
$InstallPrefixes = @('Win64', 'Win32', 'ARM64', 'ARM')
$Types = @('dynamic', 'static')
$Config = 'Release'
-$LibCrypto = '47'
$SDK = '143'
. "$PSScriptRoot\const.ps1"
@@ -34,39 +34,39 @@ Function Package-Dynamic(${SRC}, ${DEST}) {
Copy-Item "${SRC}\bin\cbor.dll" "${DEST}"
Copy-Item "${SRC}\lib\cbor.lib" "${DEST}"
Copy-Item "${SRC}\bin\zlib1.dll" "${DEST}"
- Copy-Item "${SRC}\lib\zlib.lib" "${DEST}"
- Copy-Item "${SRC}\bin\crypto-${LibCrypto}.dll" "${DEST}"
- Copy-Item "${SRC}\lib\crypto-${LibCrypto}.lib" "${DEST}"
+ Copy-Item "${SRC}\lib\zlib1.lib" "${DEST}"
+ Copy-Item "${SRC}\bin\${CRYPTO_LIBRARIES}.dll" "${DEST}"
+ Copy-Item "${SRC}\lib\${CRYPTO_LIBRARIES}.lib" "${DEST}"
Copy-Item "${SRC}\bin\fido2.dll" "${DEST}"
Copy-Item "${SRC}\lib\fido2.lib" "${DEST}"
}
Function Package-Static(${SRC}, ${DEST}) {
Copy-Item "${SRC}/lib/cbor.lib" "${DEST}"
- Copy-Item "${SRC}/lib/zlib.lib" "${DEST}"
- Copy-Item "${SRC}/lib/crypto-${LibCrypto}.lib" "${DEST}"
+ Copy-Item "${SRC}/lib/zlib1.lib" "${DEST}"
+ Copy-Item "${SRC}/lib/${CRYPTO_LIBRARIES}.lib" "${DEST}"
Copy-Item "${SRC}/lib/fido2_static.lib" "${DEST}/fido2.lib"
}
Function Package-PDBs(${SRC}, ${DEST}) {
Copy-Item "${SRC}\${LIBRESSL}\crypto\crypto_obj.dir\${Config}\crypto_obj.pdb" `
- "${DEST}\crypto-${LibCrypto}.pdb"
+ "${DEST}\${CRYPTO_LIBRARIES}.pdb"
Copy-Item "${SRC}\${LIBCBOR}\src\cbor.dir\${Config}\vc${SDK}.pdb" `
"${DEST}\cbor.pdb"
Copy-Item "${SRC}\${ZLIB}\zlib.dir\${Config}\vc${SDK}.pdb" `
- "${DEST}\zlib.pdb"
+ "${DEST}\zlib1.pdb"
Copy-Item "${SRC}\src\fido2_shared.dir\${Config}\vc${SDK}.pdb" `
"${DEST}\fido2.pdb"
}
Function Package-StaticPDBs(${SRC}, ${DEST}) {
- Copy-Item "${SRC}\${LIBRESSL}\crypto\Release\crypto-${LibCrypto}.pdb" `
- "${DEST}\crypto-${LibCrypto}.pdb"
- Copy-Item "${SRC}\${LIBCBOR}\src\Release\cbor.pdb" `
+ Copy-Item "${SRC}\${LIBRESSL}\crypto\crypto_obj.dir\${Config}\crypto_obj.pdb" `
+ "${DEST}\${CRYPTO_LIBRARIES}.pdb"
+ Copy-Item "${SRC}\${LIBCBOR}\src\${Config}\cbor.pdb" `
"${DEST}\cbor.pdb"
- Copy-Item "${SRC}\${ZLIB}\Release\zlibstatic.pdb" `
- "${DEST}\zlib.pdb"
- Copy-Item "${SRC}\src\Release\fido2_static.pdb" `
+ Copy-Item "${SRC}\${ZLIB}\${Config}\zlibstatic.pdb" `
+ "${DEST}\zlib1.pdb"
+ Copy-Item "${SRC}\src\${Config}\fido2_static.pdb" `
"${DEST}\fido2.pdb"
}
diff --git a/lib/libfido2/Makefile b/lib/libfido2/Makefile
index 86ac1153f384..dc985e2797ed 100644
--- a/lib/libfido2/Makefile
+++ b/lib/libfido2/Makefile
@@ -21,6 +21,7 @@ SRCS+= ecdh.c
SRCS+= eddsa.c
SRCS+= err.c
SRCS+= es256.c
+SRCS+= es384.c
SRCS+= hid_freebsd.c
SRCS+= hid_unix.c
SRCS+= hid.c
@@ -35,9 +36,11 @@ SRCS+= reset.c
SRCS+= rs1.c
SRCS+= rs256.c
SRCS+= time.c
+SRCS+= touch.c
SRCS+= tpm.c
SRCS+= types.c
SRCS+= u2f.c
+SRCS+= util.c
SRCS+= openbsd-compat/freezero.c
SRCS+= openbsd-compat/recallocarray.c
@@ -45,6 +48,7 @@ SRCS+= openbsd-compat/recallocarray.c
CFLAGS+= -I ${DIST}/src -I${SRCTOP}/contrib/libcbor/src -I${.CURDIR}/../libcbor
CFLAGS+= -D_FIDO_INTERNAL
CFLAGS+= -DHAVE_ARC4RANDOM_BUF
+CFLAGS+= -DHAVE_ASPRINTF
CFLAGS+= -DHAVE_CLOCK_GETTIME
CFLAGS+= -DHAVE_DEV_URANDOM
CFLAGS+= -DHAVE_ERR_H
@@ -67,7 +71,7 @@ CFLAGS+= -DHAVE_UNISTD_H
CFLAGS+= -DOPENSSL_API_COMPAT=0x10100000L
CFLAGS+= -DTLS=__thread
CFLAGS+= -D_FIDO_MAJOR=1
-CFLAGS+= -D_FIDO_MINOR=10
+CFLAGS+= -D_FIDO_MINOR=13
CFLAGS+= -D_FIDO_PATCH=0
LIBADD= crypto z