head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.6
	netbsd-11-0-RC3:1.1.1.6
	netbsd-11-0-RC2:1.1.1.6
	netbsd-11-0-RC1:1.1.1.6
	perseant-exfatfs-base-20250801:1.1.1.6
	netbsd-11:1.1.1.6.0.2
	netbsd-11-base:1.1.1.6
	libfido2-1-16-0:1.1.1.6
	netbsd-10-1-RELEASE:1.1.1.4.2.1
	perseant-exfatfs-base-20240630:1.1.1.5
	perseant-exfatfs:1.1.1.5.0.2
	perseant-exfatfs-base:1.1.1.5
	netbsd-10-0-RELEASE:1.1.1.4.2.1
	netbsd-10-0-RC6:1.1.1.4.2.1
	netbsd-10-0-RC5:1.1.1.4.2.1
	netbsd-10-0-RC4:1.1.1.4.2.1
	netbsd-10-0-RC3:1.1.1.4.2.1
	netbsd-10-0-RC2:1.1.1.4.2.1
	netbsd-10-0-RC1:1.1.1.4.2.1
	libfido2-1-13-0:1.1.1.5
	netbsd-10:1.1.1.4.0.2
	netbsd-10-base:1.1.1.4
	libfido2-1-8-0:1.1.1.4
	libfido2-1-7-0:1.1.1.3
	cjep_sun2x-base1:1.1.1.2
	cjep_sun2x:1.1.1.2.0.4
	cjep_sun2x-base:1.1.1.2
	cjep_staticlib_x-base1:1.1.1.2
	cjep_staticlib_x:1.1.1.2.0.2
	cjep_staticlib_x-base:1.1.1.2
	libfido2-1-5-0:1.1.1.2
	phil-wifi-20200421:1.1.1.1
	phil-wifi:1.1.1.1.0.2
	phil-wifi-20200411:1.1.1.1
	phil-wifi-20200406:1.1.1.1
	libfido2-f6ab2ce65745f7f3b1bee7481623de5eaac28bb0:1.1.1.1
	YUBICO:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2020.03.03.00.11.43;	author christos;	state Exp;
branches
	1.1.1.1;
next	;
commitid	C3h02fnbEJ614TYB;

1.1.1.1
date	2020.03.03.00.11.43;	author christos;	state Exp;
branches
	1.1.1.1.2.1;
next	1.1.1.2;
commitid	C3h02fnbEJ614TYB;

1.1.1.2
date	2020.12.04.18.09.13;	author christos;	state Exp;
branches;
next	1.1.1.3;
commitid	NXNOgGFBKmoV8syC;

1.1.1.3
date	2021.06.17.00.38.06;	author christos;	state Exp;
branches;
next	1.1.1.4;
commitid	lSpmBnkrCXrM3qXC;

1.1.1.4
date	2021.09.24.12.43.28;	author christos;	state Exp;
branches
	1.1.1.4.2.1;
next	1.1.1.5;
commitid	eXrO77i4D6SPTcaD;

1.1.1.5
date	2023.08.11.22.58.18;	author christos;	state Exp;
branches
	1.1.1.5.2.1;
next	1.1.1.6;
commitid	J0htdkgUi8KBfqAE;

1.1.1.6
date	2025.06.02.13.59.53;	author christos;	state Exp;
branches;
next	;
commitid	egKRHPpEJiaY0kXF;

1.1.1.1.2.1
date	2020.03.03.00.11.43;	author martin;	state dead;
branches;
next	1.1.1.1.2.2;
commitid	X01YhRUPVUDaec4C;

1.1.1.1.2.2
date	2020.04.13.07.46.06;	author martin;	state Exp;
branches;
next	;
commitid	X01YhRUPVUDaec4C;

1.1.1.4.2.1
date	2023.09.05.17.11.35;	author martin;	state Exp;
branches;
next	;
commitid	8EjKQJ0WqKD2xBDE;

1.1.1.5.2.1
date	2025.08.02.05.21.50;	author perseant;	state Exp;
branches;
next	;
commitid	23j6GFaDws3O875G;


desc
@@


1.1
log
@Initial revision
@
text
@# 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.

# detect AppleClang; needs to come before project()
cmake_policy(SET CMP0025 NEW)

project(libfido2 C)
cmake_minimum_required(VERSION 3.0)

include(CheckCCompilerFlag)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckTypeSize)
include(GNUInstallDirs)

set(CMAKE_COLOR_MAKEFILE off)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(FIDO_MAJOR "1")
set(FIDO_MINOR "3")
set(FIDO_PATCH "1")
set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH})

add_definitions(-D_FIDO_MAJOR=${FIDO_MAJOR})
add_definitions(-D_FIDO_MINOR=${FIDO_MINOR})
add_definitions(-D_FIDO_PATCH=${FIDO_PATCH})

if(CYGWIN OR MSYS)
	set(WIN32 1)
	add_definitions(-DWINVER=0x0a00)
endif()

if(WIN32)
	add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()

if(APPLE)
	set(CMAKE_INSTALL_NAME_DIR
		"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()

# Observe OpenBSD's library versioning scheme.
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
	set(LIB_VERSION ${FIDO_MAJOR}.${FIDO_MINOR})
	set(LIB_SOVERSION ${LIB_VERSION})
else()
	set(LIB_VERSION ${FIDO_VERSION})
	set(LIB_SOVERSION ${FIDO_MAJOR})
endif()

if(MSVC)
	if((NOT CBOR_INCLUDE_DIRS) OR (NOT CBOR_LIBRARY_DIRS) OR
	   (NOT CRYPTO_INCLUDE_DIRS) OR (NOT CRYPTO_LIBRARY_DIRS))
		message(FATAL_ERROR "please provide definitions for "
		    "{CBOR,CRYPTO}_{INCLUDE,LIBRARY}_DIRS when building "
		    "under msvc")
	endif()
	set(CBOR_LIBRARIES cbor)
	set(CRYPTO_LIBRARIES crypto-45)
	set(MSVC_DISABLED_WARNINGS_LIST
		"C4200" # nonstandard extension used: zero-sized array in
			# struct/union;
		"C4204" # nonstandard extension used: non-constant aggregate
			# initializer;
		"C4706" # assignment within conditional expression;
		"C4996" # The POSIX name for this item is deprecated. Instead,
			# use the ISO C and C++ conformant name
		)
	# The construction in the following 3 lines was taken from LibreSSL's
	# CMakeLists.txt.
	string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
		${MSVC_DISABLED_WARNINGS_LIST})
	string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 ${MSVC_DISABLED_WARNINGS_STR}")
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7")
	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
else()
	include(FindPkgConfig)
	pkg_search_module(CBOR libcbor)
	pkg_search_module(CRYPTO libcrypto)

	# XXX workaround libcbor's missing .pc file
	if(NOT CBOR_FOUND)
		check_include_files(cbor.h HAVE_CBOR_H)
		if(NOT HAVE_CBOR_H)
			message(FATAL_ERROR "could not find cbor header files")
		endif()
		set(CBOR_LIBRARIES "cbor")
	endif()

	# XXX workaround libcrypto's missing .pc file
	if(NOT CRYPTO_FOUND)
		check_include_files(openssl/opensslv.h HAVE_OPENSSLV_H)
		if(NOT HAVE_OPENSSLV_H)
			message(FATAL_ERROR "could not find crypto header files")
		endif()
		set(CRYPTO_LIBRARIES "crypto")
	endif()

	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
		pkg_search_module(UDEV libudev REQUIRED)
		set(UDEV_NAME "udev")
		# Define be32toh().
		add_definitions(-D_GNU_SOURCE)
		# If using hidapi, use hidapi-hidraw.
		set(HIDAPI_SUFFIX -hidraw)
	elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
	       CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
		set(BASE_LIBRARIES usbhid)
	endif()

	if(MINGW)
		# MinGW is stuck with a flavour of C89.
		add_definitions(-DFIDO_NO_DIAGNOSTIC)
		add_definitions(-DWC_ERR_INVALID_CHARS=0x80)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
	endif()

	if(USE_HIDAPI)
		add_definitions(-DUSE_HIDAPI)
		pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED)
		if(HIDAPI_FOUND)
			set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX})
		endif()
	endif()

	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wbad-function-cast")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors")
	check_c_compiler_flag("-fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)
	if(HAVE_STACK_PROTECTOR_ALL)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
	endif()

	add_definitions(-D_DEFAULT_SOURCE)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g2")
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer")

	if(FUZZ)
		if(LIBFUZZER)
			set(FUZZ_LDFLAGS "-fsanitize=fuzzer")
			set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
		endif()
		add_definitions(-DFIDO_FUZZ)
	endif()

	if(ASAN)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,leak")
	endif()

	if(MSAN)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-track-origins")
	endif()

	if(UBSAN)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-trap=undefined")
	endif()

	if(COVERAGE)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
	endif()
endif()

# Use -Wshorten-64-to-32 if available.
check_c_compiler_flag("-Wshorten-64-to-32" HAVE_SHORTEN_64_TO_32)
if(HAVE_SHORTEN_64_TO_32)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshorten-64-to-32")
endif()

# Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
if(CMAKE_COMPILER_IS_GNUCC)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result")
endif()

# Decide which keyword to use for thread-local storage.
if(CMAKE_COMPILER_IS_GNUCC OR
   CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
   CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
	set(TLS "__thread")
elseif(WIN32)
	set(TLS "__declspec(thread)")
endif()

add_definitions(-DTLS=${TLS})

# endian.h
check_include_files(endian.h HAVE_ENDIAN_H)
if(HAVE_ENDIAN_H)
	add_definitions(-DHAVE_ENDIAN_H)
endif()

# err.h
check_include_files(err.h HAVE_ERR_H)
if(HAVE_ERR_H)
	add_definitions(-DHAVE_ERR_H)
endif()

# unistd.h
check_include_files(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
	add_definitions(-DHAVE_UNISTD_H)
endif()

# signal.h
check_include_files(signal.h HAVE_SIGNAL_H)
if(HAVE_SIGNAL_H)
	add_definitions(-DHAVE_SIGNAL_H)
endif()

# sys/random.h
check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
if(HAVE_SYS_RANDOM_H)
	add_definitions(-DHAVE_SYS_RANDOM_H)
endif()

# strlcpy
check_function_exists(strlcpy HAVE_STRLCPY)
if(HAVE_STRLCPY)
	add_definitions(-DHAVE_STRLCPY)
endif()

# strlcat
check_function_exists(strlcpy HAVE_STRLCAT)
if(HAVE_STRLCAT)
	add_definitions(-DHAVE_STRLCAT)
endif()

# recallocarray
check_function_exists(recallocarray HAVE_RECALLOCARRAY)
if(HAVE_RECALLOCARRAY)
	add_definitions(-DHAVE_RECALLOCARRAY)
endif()

# XXX getpagesize is incorrectly detected when cross-compiling
# with mingw on Linux. Avoid.
if(NOT WIN32)
	check_function_exists(getpagesize HAVE_GETPAGESIZE)
endif()
if(HAVE_GETPAGESIZE)
	add_definitions(-DHAVE_GETPAGESIZE)
endif()

# sysconf
check_function_exists(sysconf HAVE_SYSCONF)
if(HAVE_SYSCONF)
	add_definitions(-DHAVE_SYSCONF)
endif()

# memset_s
if(APPLE)
	add_definitions(-D__STDC_WANT_LIB_EXT1__=1)
endif()
check_function_exists(memset_s HAVE_MEMSET_S)
if(HAVE_MEMSET_S)
	add_definitions(-DHAVE_MEMSET_S)
endif()

# explicit_bzero
if(NOT LIBFUZZER)
	check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
	if(HAVE_EXPLICIT_BZERO)
		add_definitions(-DHAVE_EXPLICIT_BZERO)
	endif()
endif()

# timingsafe_bcmp
check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
if(HAVE_TIMINGSAFE_BCMP)
	add_definitions(-DHAVE_TIMINGSAFE_BCMP)
endif()

# readpassphrase
check_function_exists(readpassphrase HAVE_READPASSPHRASE)
if(HAVE_READPASSPHRASE)
	add_definitions(-DHAVE_READPASSPHRASE)
endif()

# getline
check_function_exists(getline HAVE_GETLINE)
if(HAVE_GETLINE)
	add_definitions(-DHAVE_GETLINE)
endif()

# getopt
check_function_exists(getopt HAVE_GETOPT)
if(HAVE_GETOPT)
	add_definitions(-DHAVE_GETOPT)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
else()
	if(CMAKE_COMPILER_IS_GNUCC)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-discarded-qualifiers")
	endif()
	if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types-discards-qualifiers")
	endif()
endif()

# usable sigaction
set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
check_function_exists(sigaction HAVE_SIGACTION)
check_type_size("sig_atomic_t" HAVE_SIG_ATOMIC_T)
if(HAVE_SIGACTION AND (NOT HAVE_SIG_ATOMIC_T STREQUAL ""))
	add_definitions(-DSIGNAL_EXAMPLE)
endif()
set(CMAKE_EXTRA_INCLUDE_FILES)

# arc4random_buf
check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF)
if(HAVE_ARC4RANDOM_BUF)
	add_definitions(-DHAVE_ARC4RANDOM_BUF)
endif()

# getrandom
check_function_exists(getrandom HAVE_GETRANDOM)
if(HAVE_GETRANDOM)
	add_definitions(-DHAVE_GETRANDOM)
endif()

# /dev/urandom
if(UNIX)
	add_definitions(-DHAVE_DEV_URANDOM)
endif()

# export list
if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
   CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
	# clang + lld
	string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
	    " -exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/src/export.llvm")
elseif(NOT MSVC)
	# clang/gcc + gnu ld
	if(FUZZ)
		string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
                    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/fuzz/export.gnu")
	else()
		string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
                    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/export.gnu")
	endif()
	if(NOT WIN32)
		string(CONCAT CMAKE_SHARED_LINKER_FLAGS
		    ${CMAKE_SHARED_LINKER_FLAGS}
		    " -Wl,-z,noexecstack -Wl,-z,relro,-z,now")
		string(CONCAT CMAKE_EXE_LINKER_FLAGS
		    ${CMAKE_EXE_LINKER_FLAGS}
		    " -Wl,-z,noexecstack -Wl,-z,relro,-z,now")
		if(FUZZ)
			file(STRINGS fuzz/wrapped.sym WRAPPED_SYMBOLS)
			foreach(s ${WRAPPED_SYMBOLS})
				string(CONCAT CMAKE_SHARED_LINKER_FLAGS
				    ${CMAKE_SHARED_LINKER_FLAGS}
				    " -Wl,--wrap=${s}")
			endforeach()
		endif()
	endif()
else()
	string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
		" /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"")
endif()

include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CBOR_INCLUDE_DIRS})
include_directories(${CRYPTO_INCLUDE_DIRS})

link_directories(${CBOR_LIBRARY_DIRS})
link_directories(${CRYPTO_LIBRARY_DIRS})

message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}")
message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}")
message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}")
message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}")
message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}")
message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}")
message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}")
message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}")
message(STATUS "VERSION: ${FIDO_VERSION}")
message(STATUS "LIB_VERSION: ${LIB_VERSION}")
message(STATUS "LIB_SOVERSION: ${LIB_SOVERSION}")
message(STATUS "FUZZ: ${FUZZ}")
message(STATUS "AFL: ${AFL}")
message(STATUS "LIBFUZZER: ${LIBFUZZER}")
message(STATUS "ASAN: ${ASAN}")
message(STATUS "MSAN: ${MSAN}")
message(STATUS "COVERAGE: ${COVERAGE}")
message(STATUS "TLS: ${TLS}")
message(STATUS "USE_HIDAPI: ${USE_HIDAPI}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
	message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}")
	message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}")
	message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}")
	message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}")
endif()

subdirs(src)
subdirs(examples)
subdirs(tools)
subdirs(man)

if(NOT WIN32)
	if(CMAKE_BUILD_TYPE STREQUAL "Debug")
		if(NOT MSAN AND NOT LIBFUZZER)
			subdirs(regress)
		endif()
	endif()
	if(FUZZ)
		subdirs(fuzz)
	endif()

	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
		subdirs(udev)
	endif()
endif()
@


1.1.1.1
log
@Import Yubico's libfido2 from https://github.com/Yubico/libfido2.git
@
text
@@


1.1.1.2
log
@Version 1.5.0 (2020-09-01)
    hid_linux: return FIDO_OK if no devices are found.
    hid_osx:
        repair communication with U2F tokens, gh#166;
        reliability fixes.
    fido2-{assert,cred}: new options to explicitly toggle UP, UV.
    Support for configurable report lengths.
    New API calls:
        fido_cbor_info_maxcredcntlst;
        fido_cbor_info_maxcredidlen;
        fido_cred_aaguid_len;
        fido_cred_aaguid_ptr;
        fido_dev_get_touch_begin;
        fido_dev_get_touch_status.
    Use COSE_ECDH_ES256 with CTAP_CBOR_CLIENT_PIN; gh#154.
    Allow CTAP messages up to 2048 bytes; gh#171.
    Ensure we only list USB devices by default.
Version 1.4.0 (2020-04-15)
    hid_hidapi: hidapi backend; enable with -DUSE_HIDAPI=1.
    Fall back to U2F if the key claims to, but does not support FIDO2.
    FIDO2 credential protection (credprot) support.
    New API calls:
        fido_cbor_info_fwversion;
        fido_cred_prot;
        fido_cred_set_prot;
        fido_dev_set_transport_functions;
        fido_set_log_handler.
    Support for FreeBSD.
    Support for C++.
    Support for MSYS.
    Fixed EdDSA and RSA self-attestation.
Version 1.3.1 (2020-02-19)
    fix zero-ing of le1 and le2 when talking to a U2F device.
    dropping sk-libfido2 middleware, please find it in the openssh tree.
@
text
@a12 2
include(CheckLibraryExists)
include(CheckSymbolExists)
d22 2
a23 2
set(FIDO_MINOR "5")
set(FIDO_PATCH "0")
d36 1
a36 1
	add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600)
d41 10
a50 1
	    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
d61 1
a61 1
	set(CRYPTO_LIBRARIES crypto-46)
d74 1
a74 1
	    ${MSVC_DISABLED_WARNINGS_LIST})
d76 1
a76 1
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}")
a104 2
		include_directories(${UDEV_INCLUDE_DIRS})
		link_directories(${UDEV_LIBRARY_DIRS})
d109 3
a111 6
		# Look for clock_gettime in librt.
		check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
		if(HAVE_CLOCK_GETTIME)
			set(BASE_LIBRARIES ${BASE_LIBRARIES} rt)
			add_definitions(-DHAVE_CLOCK_GETTIME)
		endif()
a124 2
			include_directories(${HIDAPI_INCLUDE_DIRS})
			link_directories(${HIDAPI_LIBRARY_DIRS})
d156 18
a335 14
# clock_gettime
if(NOT HAVE_CLOCK_GETTIME)
	check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
	if(HAVE_CLOCK_GETTIME)
		add_definitions(-DHAVE_CLOCK_GETTIME)
	endif()
endif()

# timespecsub
check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB)
if(HAVE_TIMESPECSUB)
	add_definitions(-DHAVE_TIMESPECSUB)
endif()

d369 1
a369 1
	    " /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"")
a378 5
message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}")
message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}")
message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}")
message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
d381 1
d383 4
a386 1
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
d388 1
d390 5
a394 2
message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}")
message(STATUS "FIDO_VERSION: ${FIDO_VERSION}")
d396 1
a396 5
if(USE_HIDAPI)
	message(STATUS "HIDAPI_INCLUDE_DIRS: ${HIDAPI_INCLUDE_DIRS}")
	message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}")
	message(STATUS "HIDAPI_LIBRARY_DIRS: ${HIDAPI_LIBRARY_DIRS}")
endif()
d398 3
a401 4
message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}")
message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}")
message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}")
message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}")
d404 7
d418 1
a418 1
		if(NOT LIBFUZZER AND NOT FUZZ)
@


1.1.1.3
log
@Import libfido2 1.7.0; changes:

Version 1.7.0 (2021-03-29)
- New dependency on zlib.
- Fixed musl build; gh#259.
- hid_win: detect devices with vendor or product IDs > 0x7fff; gh#264.
- Support for FIDO 2.1 authenticator configuration.
- Support for FIDO 2.1 UV token permissions.
- Support for FIDO 2.1 "credBlobs" and "largeBlobs" extensions.
- New API calls:
    fido_assert_blob_len;
    fido_assert_blob_ptr;
    fido_assert_largeblob_key_len;
    fido_assert_largeblob_key_ptr;
    fido_assert_set_hmac_secret;
    fido_cbor_info_maxcredbloblen;
    fido_cred_largeblob_key_len;
    fido_cred_largeblob_key_ptr;
    fido_cred_set_blob;
    fido_dev_enable_entattest;
    fido_dev_force_pin_change;
    fido_dev_has_uv;
    fido_dev_largeblob_get;
    fido_dev_largeblob_get_array;
    fido_dev_largeblob_remove;
    fido_dev_largeblob_set;
    fido_dev_largeblob_set_array;
    fido_dev_set_pin_minlen;
    fido_dev_set_sigmask;
    fido_dev_supports_credman;
    fido_dev_supports_permissions;
    fido_dev_supports_uv;
    fido_dev_toggle_always_uv.
- New fido_init flag to disable fido_dev_open's U2F fallback; gh#282.
- Experimental NFC support on Linux; enable with -DNFC_LINUX.

Version 1.6.0 (2020-12-22)
- Fix OpenSSL 1.0 and Cygwin builds.
- hid_linux: fix build on 32-bit systems.
- hid_osx: allow reads from spawned threads.
- Documentation and reliability fixes.
- New API calls:
    fido_cred_authdata_raw_len;
    fido_cred_authdata_raw_ptr;
    fido_cred_sigcount;
    fido_dev_get_uv_retry_count;
    fido_dev_supports_credman.
- Hardened Windows build.
- Native FreeBSD and NetBSD support.
- Use CTAP2 canonical CBOR when combining hmac-secret and credProtect.
@
text
@a9 4
# Set PIE flags for POSITION_INDEPENDENT_CODE targets, added in CMake 3.14.
if(POLICY CMP0083)
  cmake_policy(SET CMP0083 NEW)
endif()
a17 4
include(CheckPIESupported OPTIONAL RESULT_VARIABLE CHECK_PIE_SUPPORTED)
if(CHECK_PIE_SUPPORTED)
  check_pie_supported(LANGUAGES C)
endif()
d19 2
d22 1
a22 2
set(CMAKE_COLOR_MAKEFILE OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
d24 1
a24 1
set(FIDO_MINOR "7")
a27 10
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_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(NFC_LINUX         "Experimental NFC support on Linux"  OFF)

a45 100
if(NOT MSVC)
	set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_POSIX_C_SOURCE=200809L")
	set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_BSD_SOURCE")
	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")
		set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_GNU_SOURCE")
		set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DEFAULT_SOURCE")
	elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
		set(FIDO_CFLAGS "${FIDO_CFLAGS} -D__BSD_VISIBLE=1")
	endif()
	set(FIDO_CFLAGS "${FIDO_CFLAGS} -std=c99")
	set(CMAKE_C_FLAGS "${FIDO_CFLAGS} ${CMAKE_C_FLAGS}")
endif()

check_c_compiler_flag("-Wshorten-64-to-32" HAVE_SHORTEN_64_TO_32)
check_c_compiler_flag("-fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)

check_include_files(cbor.h HAVE_CBOR_H)
check_include_files(endian.h HAVE_ENDIAN_H)
check_include_files(err.h HAVE_ERR_H)
check_include_files(openssl/opensslv.h HAVE_OPENSSLV_H)
check_include_files(signal.h HAVE_SIGNAL_H)
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(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)
check_symbol_exists(getline stdio.h HAVE_GETLINE)
check_symbol_exists(getopt unistd.h HAVE_GETOPT)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(getrandom sys/random.h HAVE_GETRANDOM)
check_symbol_exists(memset_s string.h HAVE_MEMSET_S)
check_symbol_exists(readpassphrase readpassphrase.h HAVE_READPASSPHRASE)
check_symbol_exists(recallocarray stdlib.h HAVE_RECALLOCARRAY)
check_symbol_exists(sigaction signal.h HAVE_SIGACTION)
check_symbol_exists(strlcat string.h HAVE_STRLCAT)
check_symbol_exists(strlcpy string.h HAVE_STRLCPY)
check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB)
check_symbol_exists(timingsafe_bcmp string.h HAVE_TIMINGSAFE_BCMP)

set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
check_type_size("sig_atomic_t" HAVE_SIG_ATOMIC_T)
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
try_compile(HAVE_POSIX_IOCTL
    "${CMAKE_CURRENT_BINARY_DIR}/posix_ioctl_check.o"
    "${CMAKE_CURRENT_SOURCE_DIR}/openbsd-compat/posix_ioctl_check.c"
    COMPILE_DEFINITIONS "-Werror -Woverflow -Wsign-conversion")

list(APPEND CHECK_VARIABLES
	HAVE_ARC4RANDOM_BUF
	HAVE_CBOR_H
	HAVE_CLOCK_GETTIME
	HAVE_ENDIAN_H
	HAVE_ERR_H
	HAVE_FREEZERO
	HAVE_GETLINE
	HAVE_GETOPT
	HAVE_GETPAGESIZE
	HAVE_GETRANDOM
	HAVE_MEMSET_S
	HAVE_OPENSSLV_H
	HAVE_POSIX_IOCTL
	HAVE_READPASSPHRASE
	HAVE_RECALLOCARRAY
	HAVE_SIGACTION
	HAVE_SIGNAL_H
	HAVE_STRLCAT
	HAVE_STRLCPY
	HAVE_SYSCONF
	HAVE_SYS_RANDOM_H
	HAVE_TIMESPECSUB
	HAVE_TIMINGSAFE_BCMP
	HAVE_UNISTD_H
)

foreach(v ${CHECK_VARIABLES})
	if (${v})
		add_definitions(-D${v})
	endif()
endforeach()

if(HAVE_EXPLICIT_BZERO AND NOT LIBFUZZER)
	add_definitions(-DHAVE_EXPLICIT_BZERO)
endif()

if(HAVE_SIGACTION AND (NOT HAVE_SIG_ATOMIC_T STREQUAL ""))
	add_definitions(-DSIGNAL_EXAMPLE)
endif()

if(UNIX)
	add_definitions(-DHAVE_DEV_URANDOM)
endif()

d48 1
a48 2
	   (NOT CRYPTO_INCLUDE_DIRS) OR (NOT CRYPTO_LIBRARY_DIRS) OR
	   (NOT ZLIB_INCLUDE_DIRS) OR (NOT ZLIB_LIBRARY_DIRS))
d50 1
a50 1
		   "{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY}_DIRS when building "
a53 1
	set(ZLIB_LIBRARIES zlib)
d70 2
a71 2
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7 /guard:cf /sdl /RTCcsu")
	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi /guard:cf /sdl")
a75 1
	pkg_search_module(ZLIB zlib)
d77 7
a83 2
	if(NOT CBOR_FOUND AND NOT HAVE_CBOR_H)
		message(FATAL_ERROR "could not find libcbor")
d85 8
a92 5
	if(NOT CRYPTO_FOUND AND NOT HAVE_OPENSSLV_H)
		message(FATAL_ERROR "could not find libcrypto")
	endif()
	if(NOT ZLIB_FOUND)
		message(FATAL_ERROR "could not find zlib")
a94 3
	set(CBOR_LIBRARIES "cbor")
	set(CRYPTO_LIBRARIES "crypto")

d98 4
d104 5
a108 8
		if(NOT HAVE_CLOCK_GETTIME)
			# Look for clock_gettime in librt.
			check_library_exists(rt clock_gettime "time.h"
			    HAVE_CLOCK_GETTIME)
			if (HAVE_CLOCK_GETTIME)
				add_definitions(-DHAVE_CLOCK_GETTIME)
				set(BASE_LIBRARIES ${BASE_LIBRARIES} rt)
			endif()
d116 1
a116 1
		add_compile_options(-Wno-unused-parameter)
d122 5
a126 1
		set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX})
d129 12
a140 6
	if(FUZZ)
		set(NFC_LINUX ON)
	endif()

	if(NFC_LINUX)
		add_definitions(-DNFC_LINUX)
d143 2
a144 17
	add_compile_options(-Wall)
	add_compile_options(-Wextra)
	add_compile_options(-Werror)
	add_compile_options(-Wshadow)
	add_compile_options(-Wcast-qual)
	add_compile_options(-Wwrite-strings)
	add_compile_options(-Wmissing-prototypes)
	add_compile_options(-Wbad-function-cast)
	add_compile_options(-pedantic)
	add_compile_options(-pedantic-errors)

	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()
a147 1
	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
d150 4
d156 6
a161 3
	if(LIBFUZZER)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
	endif()
d166 1
a166 1
	add_compile_options(-Wno-unused-result)
d177 1
d180 152
a370 3
include_directories(${HIDAPI_INCLUDE_DIRS})
include_directories(${UDEV_INCLUDE_DIRS})
include_directories(${ZLIB_INCLUDE_DIRS})
a373 3
link_directories(${HIDAPI_LIBRARY_DIRS})
link_directories(${UDEV_LIBRARY_DIRS})
link_directories(${ZLIB_LIBRARY_DIRS})
a375 5
message(STATUS "BUILD_EXAMPLES: ${BUILD_EXAMPLES}")
message(STATUS "BUILD_MANPAGES: ${BUILD_MANPAGES}")
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
message(STATUS "BUILD_STATIC_LIBS: ${BUILD_STATIC_LIBS}")
message(STATUS "BUILD_TOOLS: ${BUILD_TOOLS}")
a378 1
message(STATUS "CBOR_VERSION: ${CBOR_VERSION}")
a381 1
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
a386 1
message(STATUS "CRYPTO_VERSION: ${CRYPTO_VERSION}")
a388 4
message(STATUS "ZLIB_INCLUDE_DIRS: ${ZLIB_INCLUDE_DIRS}")
message(STATUS "ZLIB_LIBRARIES: ${ZLIB_LIBRARIES}")
message(STATUS "ZLIB_LIBRARY_DIRS: ${ZLIB_LIBRARY_DIRS}")
message(STATUS "ZLIB_VERSION: ${ZLIB_VERSION}")
a392 1
	message(STATUS "HIDAPI_VERSION: ${HIDAPI_VERSION}")
a399 1
message(STATUS "UDEV_VERSION: ${UDEV_VERSION}")
a400 1
message(STATUS "NFC_LINUX: ${NFC_LINUX}")
d403 3
a405 9
if(BUILD_EXAMPLES)
	subdirs(examples)
endif()
if(BUILD_TOOLS)
	subdirs(tools)
endif()
if(BUILD_MANPAGES)
	subdirs(man)
endif()
d416 1
@


1.1.1.4
log
@Import libfido2 1.8.0

* Version 1.8.0 (2021-07-22)
 ** Dropped 'Requires.private' entry from pkg-config file.
 ** Better support for FIDO 2.1 authenticators.
 ** Support for Windows's native webauthn API.
 ** Support for attestation format 'none'.
 ** New API calls:
  - fido_assert_set_clientdata;
  - fido_cbor_info_algorithm_cose;
  - fido_cbor_info_algorithm_count;
  - fido_cbor_info_algorithm_type;
  - fido_cbor_info_transports_len;
  - fido_cbor_info_transports_ptr;
  - fido_cred_set_clientdata;
  - fido_cred_set_id;
  - fido_credman_set_dev_rk;
  - fido_dev_is_winhello.
 ** fido2-token: new -Sc option to update a resident credential.
 ** Documentation and reliability fixes.
 ** HID access serialisation on Linux.
@
text
@d31 1
a31 1
set(FIDO_MINOR "8")
d35 9
a43 10
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_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_WINHELLO      "Abstract Windows Hello as a FIDO device" OFF)
option(NFC_LINUX         "Experimental NFC support on Linux"       OFF)
a69 1
		set(NFC_LINUX OFF)
a88 1
check_include_files("windows.h;webauthn.h" HAVE_WEBAUTHN_H)
a142 1
	HAVE_WEBAUTHN_H
d181 1
a181 2
			# use the ISO C and C++ conformant name;
		"C6287" # redundant code: the left and right subexpressions are identical
a190 4
	if (HAVE_WEBAUTHN_H)
		add_definitions(-DUSE_WINHELLO)
		set(USE_WINHELLO ON)
	endif()
a356 2
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
a380 1
message(STATUS "USE_WINHELLO: ${USE_WINHELLO}")
@


1.1.1.4.2.1
log
@Pull up following revision(s) (requested by riastradh in ticket #345):

	external/bsd/libfido2/dist/fuzz/clock.c         up to 1.1.1.1
	external/bsd/libfido2/dist/fuzz/fuzz_pcsc.c     up to 1.1.1.1
	external/bsd/libfido2/dist/fuzz/pcsc.c          up to 1.1.1.1
	external/bsd/libfido2/dist/man/check.sh         up to 1.1.1.1
	external/bsd/libfido2/dist/man/es384_pk_new.3   up to 1.1.1.1
	external/bsd/libfido2/dist/openbsd-compat/bsd-asprintf.c up to 1.1.1.1
	external/bsd/libfido2/dist/openbsd-compat/strsep.c up to 1.1.1.1
	external/bsd/libfido2/dist/regress/compress.c   up to 1.1.1.1
	external/bsd/libfido2/dist/regress/eddsa.c      up to 1.1.1.1
	external/bsd/libfido2/dist/regress/es256.c      up to 1.1.1.1
	external/bsd/libfido2/dist/regress/es384.c      up to 1.1.1.1
	external/bsd/libfido2/dist/regress/rs256.c      up to 1.1.1.1
	external/bsd/libfido2/dist/src/fido/es384.h     up to 1.1.1.1
	external/bsd/libfido2/dist/src/es384.c          up to 1.1.1.1
	external/bsd/libfido2/dist/src/fallthrough.h    up to 1.1.1.1
	external/bsd/libfido2/dist/src/nfc.c            up to 1.1.1.1
	external/bsd/libfido2/dist/src/pcsc.c           up to 1.1.1.1
	external/bsd/libfido2/dist/src/rs1.c            up to 1.1.1.1
	external/bsd/libfido2/dist/src/time.c           up to 1.1.1.1
	external/bsd/libfido2/dist/src/touch.c          up to 1.1.1.1
	external/bsd/libfido2/dist/src/tpm.c            up to 1.1.1.1
	external/bsd/libfido2/dist/src/types.c          up to 1.1.1.1
	external/bsd/libfido2/dist/src/util.c           up to 1.1.1.1
	external/bsd/libfido2/dist/src/webauthn.h       up to 1.1.1.1
	external/bsd/libfido2/dist/windows/const.ps1    up to 1.1.1.1
	external/bsd/libfido2/dist/windows/cygwin.gpg   up to 1.1.1.1
	external/bsd/libfido2/dist/windows/cygwin.ps1   up to 1.1.1.1
	external/bsd/libfido2/dist/windows/release.ps1  up to 1.1.1.1
	external/bsd/libfido2/dist/SECURITY.md          up to 1.1.1.1
	external/bsd/libfido2/dist/openbsd-compat/hkdf.c delete
	external/bsd/libfido2/dist/openbsd-compat/hkdf.h delete
	external/bsd/libfido2/dist/CMakeLists.txt       up to 1.1.1.5
	external/bsd/libfido2/dist/LICENSE              up to 1.1.1.3
	external/bsd/libfido2/dist/NEWS                 up to 1.1.1.5
	external/bsd/libfido2/dist/README.adoc          up to 1.1.1.5
	external/bsd/libfido2/dist/examples/CMakeLists.txt up to 1.1.1.4
	external/bsd/libfido2/dist/examples/README.adoc up to 1.1.1.5
	external/bsd/libfido2/dist/examples/assert.c    up to 1.1.1.4
	external/bsd/libfido2/dist/examples/cred.c      up to 1.1.1.5
	external/bsd/libfido2/dist/examples/extern.h    up to 1.1.1.3
	external/bsd/libfido2/dist/examples/info.c      up to 1.1.1.5
	external/bsd/libfido2/dist/examples/manifest.c  up to 1.1.1.4
	external/bsd/libfido2/dist/examples/reset.c     up to 1.1.1.4
	external/bsd/libfido2/dist/examples/retries.c   up to 1.1.1.4
	external/bsd/libfido2/dist/examples/select.c    up to 1.1.1.3
	external/bsd/libfido2/dist/examples/setpin.c    up to 1.1.1.4
	external/bsd/libfido2/dist/examples/util.c      up to 1.1.1.4
	external/bsd/libfido2/dist/fuzz/CMakeLists.txt  up to 1.1.1.4
	external/bsd/libfido2/dist/fuzz/Dockerfile      up to 1.1.1.4
	external/bsd/libfido2/dist/fuzz/Makefile        up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/README          up to 1.1.1.4
	external/bsd/libfido2/dist/fuzz/build-coverage  up to 1.1.1.4
	external/bsd/libfido2/dist/fuzz/dummy.h         up to 1.1.1.3
	external/bsd/libfido2/dist/fuzz/export.gnu      up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/functions.txt   up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/fuzz_assert.c   up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/fuzz_bio.c      up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/fuzz_cred.c     up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/fuzz_credman.c  up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/fuzz_hid.c      up to 1.1.1.3
	external/bsd/libfido2/dist/fuzz/fuzz_largeblob.c up to 1.1.1.2
	external/bsd/libfido2/dist/fuzz/fuzz_mgmt.c     up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/fuzz_netlink.c  up to 1.1.1.2
	external/bsd/libfido2/dist/fuzz/libfuzzer.c     up to 1.1.1.3
	external/bsd/libfido2/dist/fuzz/mutator_aux.c   up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/mutator_aux.h   up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/preload-fuzz.c  up to 1.1.1.2
	external/bsd/libfido2/dist/fuzz/preload-snoop.c up to 1.1.1.2
	external/bsd/libfido2/dist/fuzz/report.tgz      up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/summary.txt     up to 1.1.1.5
	external/bsd/libfido2/dist/fuzz/udev.c          up to 1.1.1.2
	external/bsd/libfido2/dist/fuzz/wiredata_fido2.h up to 1.1.1.3
	external/bsd/libfido2/dist/fuzz/wiredata_u2f.h  up to 1.1.1.2
	external/bsd/libfido2/dist/fuzz/wrap.c          up to 1.1.1.3
	external/bsd/libfido2/dist/fuzz/wrapped.sym     up to 1.1.1.4
	external/bsd/libfido2/dist/man/CMakeLists.txt   up to 1.1.1.5
	external/bsd/libfido2/dist/man/eddsa_pk_new.3   up to 1.1.1.2
	external/bsd/libfido2/dist/man/es256_pk_new.3   up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido2-assert.1   up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido2-cred.1     up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido2-token.1    up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido_assert_allow_cred.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_assert_new.3 up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido_assert_set_authdata.3 up to 1.1.1.4
	external/bsd/libfido2/dist/man/fido_assert_verify.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_bio_dev_get_info.3 up to 1.1.1.4
	external/bsd/libfido2/dist/man/fido_bio_enroll_new.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_bio_info_new.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_bio_template.3 up to 1.1.1.4
	external/bsd/libfido2/dist/man/fido_cbor_info_new.3 up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido_cred_exclude.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_cred_new.3  up to 1.1.1.4
	external/bsd/libfido2/dist/man/fido_cred_set_authdata.3 up to 1.1.1.4
	external/bsd/libfido2/dist/man/fido_cred_verify.3 up to 1.1.1.4
	external/bsd/libfido2/dist/man/fido_credman_metadata_new.3 up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido_dev_enable_entattest.3 up to 1.1.1.3
	external/bsd/libfido2/dist/man/fido_dev_get_assert.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_dev_get_touch_begin.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_dev_info_manifest.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_dev_largeblob_get.3 up to 1.1.1.2
	external/bsd/libfido2/dist/man/fido_dev_make_cred.3 up to 1.1.1.3
	external/bsd/libfido2/dist/man/fido_dev_open.3  up to 1.1.1.5
	external/bsd/libfido2/dist/man/fido_dev_set_io_functions.3 up to 1.1.1.3
	external/bsd/libfido2/dist/man/fido_dev_set_pin.3 up to 1.1.1.3
	external/bsd/libfido2/dist/man/fido_init.3      up to 1.1.1.3
	external/bsd/libfido2/dist/man/fido_strerr.3    up to 1.1.1.2
	external/bsd/libfido2/dist/man/rs256_pk_new.3   up to 1.1.1.2
	external/bsd/libfido2/dist/openbsd-compat/clock_gettime.c up to 1.1.1.2
	external/bsd/libfido2/dist/openbsd-compat/endian_win32.c up to 1.1.1.2
	external/bsd/libfido2/dist/openbsd-compat/openbsd-compat.h up to 1.1.1.4
	external/bsd/libfido2/dist/regress/CMakeLists.txt up to 1.1.1.2
	external/bsd/libfido2/dist/regress/assert.c     up to 1.1.1.4
	external/bsd/libfido2/dist/regress/cred.c       up to 1.1.1.5
	external/bsd/libfido2/dist/regress/dev.c        up to 1.1.1.3
	external/bsd/libfido2/dist/src/CMakeLists.txt   up to 1.1.1.5
	external/bsd/libfido2/dist/src/aes256.c         up to 1.1.1.3
	external/bsd/libfido2/dist/src/assert.c         up to 1.3
	external/bsd/libfido2/dist/src/authkey.c        up to 1.1.1.3
	external/bsd/libfido2/dist/src/bio.c            up to 1.1.1.4
	external/bsd/libfido2/dist/src/blob.c           up to 1.1.1.3
	external/bsd/libfido2/dist/src/blob.h           up to 1.1.1.3
	external/bsd/libfido2/dist/src/buf.c            up to 1.1.1.3
	external/bsd/libfido2/dist/src/cbor.c           up to 1.1.1.5
	external/bsd/libfido2/dist/src/compress.c       up to 1.1.1.2
	external/bsd/libfido2/dist/src/config.c         up to 1.1.1.3
	external/bsd/libfido2/dist/src/cred.c           up to 1.3
	external/bsd/libfido2/dist/src/credman.c        up to 1.1.1.5
	external/bsd/libfido2/dist/src/dev.c            up to 1.1.1.5
	external/bsd/libfido2/dist/src/diff_exports.sh  up to 1.1.1.3
	external/bsd/libfido2/dist/src/ecdh.c           up to 1.1.1.3
	external/bsd/libfido2/dist/src/eddsa.c          up to 1.1.1.4
	external/bsd/libfido2/dist/src/err.c            up to 1.1.1.4
	external/bsd/libfido2/dist/src/es256.c          up to 1.1.1.4
	external/bsd/libfido2/dist/src/export.gnu       up to 1.1.1.5
	external/bsd/libfido2/dist/src/export.llvm      up to 1.1.1.5
	external/bsd/libfido2/dist/src/export.msvc      up to 1.1.1.5
	external/bsd/libfido2/dist/src/extern.h         up to 1.1.1.5
	external/bsd/libfido2/dist/src/fido.h           up to 1.1.1.5
	external/bsd/libfido2/dist/src/hid.c            up to 1.1.1.4
	external/bsd/libfido2/dist/src/hid_freebsd.c    up to 1.1.1.2
	external/bsd/libfido2/dist/src/hid_hidapi.c     up to 1.1.1.4
	external/bsd/libfido2/dist/src/hid_linux.c      up to 1.1.1.5
	external/bsd/libfido2/dist/src/hid_netbsd.c     up to 1.4
	external/bsd/libfido2/dist/src/hid_openbsd.c    up to 1.1.1.4
	external/bsd/libfido2/dist/src/hid_osx.c        up to 1.1.1.4
	external/bsd/libfido2/dist/src/hid_unix.c       up to 1.1.1.2
	external/bsd/libfido2/dist/src/hid_win.c        up to 1.1.1.4
	external/bsd/libfido2/dist/src/info.c           up to 1.1.1.5
	external/bsd/libfido2/dist/src/io.c             up to 1.1.1.5
	external/bsd/libfido2/dist/src/iso7816.c        up to 1.1.1.4
	external/bsd/libfido2/dist/src/iso7816.h        up to 1.1.1.3
	external/bsd/libfido2/dist/src/largeblob.c      up to 1.1.1.3
	external/bsd/libfido2/dist/src/log.c            up to 1.1.1.4
	external/bsd/libfido2/dist/src/netlink.c        up to 1.1.1.2
	external/bsd/libfido2/dist/src/netlink.h        up to 1.1.1.2
	external/bsd/libfido2/dist/src/nfc_linux.c      up to 1.1.1.2
	external/bsd/libfido2/dist/src/packed.h         up to 1.1.1.2
	external/bsd/libfido2/dist/src/pin.c            up to 1.1.1.5
	external/bsd/libfido2/dist/src/random.c         up to 1.1.1.2
	external/bsd/libfido2/dist/src/reset.c          up to 1.1.1.3
	external/bsd/libfido2/dist/src/rs256.c          up to 1.1.1.3
	external/bsd/libfido2/dist/src/u2f.c            up to 1.1.1.5
	external/bsd/libfido2/dist/src/winhello.c       up to 1.1.1.2
	external/bsd/libfido2/dist/src/fido/bio.h       up to 1.1.1.2
	external/bsd/libfido2/dist/src/fido/config.h    up to 1.1.1.2
	external/bsd/libfido2/dist/src/fido/credman.h   up to 1.1.1.3
	external/bsd/libfido2/dist/src/fido/eddsa.h     up to 1.1.1.2
	external/bsd/libfido2/dist/src/fido/err.h       up to 1.1.1.4
	external/bsd/libfido2/dist/src/fido/es256.h     up to 1.1.1.2
	external/bsd/libfido2/dist/src/fido/param.h     up to 1.1.1.4
	external/bsd/libfido2/dist/src/fido/rs256.h     up to 1.1.1.2
	external/bsd/libfido2/dist/src/fido/types.h     up to 1.1.1.5
	external/bsd/libfido2/dist/tools/CMakeLists.txt up to 1.1.1.4
	external/bsd/libfido2/dist/tools/assert_get.c   up to 1.1.1.4
	external/bsd/libfido2/dist/tools/assert_verify.c up to 1.1.1.4
	external/bsd/libfido2/dist/tools/base64.c       up to 1.1.1.3
	external/bsd/libfido2/dist/tools/bio.c          up to 1.1.1.3
	external/bsd/libfido2/dist/tools/config.c       up to 1.1.1.2
	external/bsd/libfido2/dist/tools/cred_make.c    up to 1.1.1.4
	external/bsd/libfido2/dist/tools/cred_verify.c  up to 1.1.1.3
	external/bsd/libfido2/dist/tools/credman.c      up to 1.1.1.5
	external/bsd/libfido2/dist/tools/extern.h       up to 1.1.1.5
	external/bsd/libfido2/dist/tools/fido2-assert.c up to 1.1.1.4
	external/bsd/libfido2/dist/tools/fido2-attach.sh up to 1.1.1.2
	external/bsd/libfido2/dist/tools/fido2-cred.c   up to 1.1.1.4
	external/bsd/libfido2/dist/tools/fido2-detach.sh up to 1.1.1.2
	external/bsd/libfido2/dist/tools/fido2-token.c  up to 1.1.1.5
	external/bsd/libfido2/dist/tools/fido2-unprot.sh up to 1.1.1.2
	external/bsd/libfido2/dist/tools/include_check.sh up to 1.1.1.3
	external/bsd/libfido2/dist/tools/largeblob.c    up to 1.1.1.2
	external/bsd/libfido2/dist/tools/pin.c          up to 1.1.1.3
	external/bsd/libfido2/dist/tools/test.sh        up to 1.1.1.4
	external/bsd/libfido2/dist/tools/token.c        up to 1.1.1.5
	external/bsd/libfido2/dist/tools/util.c         up to 1.4
	external/bsd/libfido2/dist/udev/70-u2f.rules    up to 1.1.1.4
	external/bsd/libfido2/dist/udev/CMakeLists.txt  up to 1.1.1.2
	external/bsd/libfido2/dist/udev/check.sh        up to 1.1.1.2
	external/bsd/libfido2/dist/udev/fidodevs        up to 1.1.1.3
	external/bsd/libfido2/dist/udev/genrules.awk    up to 1.1.1.2
	external/bsd/libfido2/dist/windows/build.ps1    up to 1.1.1.5
	distrib/sets/lists/man/mi: revision 1.1763
	distrib/sets/lists/debug/shl.mi: revision 1.321
	external/bsd/libfido2/lib/Makefile: revision 1.11
	distrib/sets/lists/comp/mi: revision 1.2447
	distrib/sets/lists/comp/mi: revision 1.2448
	distrib/sets/lists/base/shl.mi: revision 1.960

libfido2: Update from 1.8.0 to 1.13.0.
@
text
@d1 1
a1 1
# Copyright (c) 2018-2022 Yubico AB. All rights reserved.
a3 1
# SPDX-License-Identifier: BSD-2-Clause
d12 1
a12 1
	cmake_policy(SET CMP0083 NEW)
d24 1
a24 1
	check_pie_supported(LANGUAGES C)
d31 1
a31 1
set(FIDO_MINOR "13")
a34 1
option(BUILD_TESTS       "Build the regress tests"                 ON)
d37 2
a38 2
option(BUILD_SHARED_LIBS "Build a shared library"                  ON)
option(BUILD_STATIC_LIBS "Build a static library"                  ON)
d41 1
d43 2
a44 3
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)
d50 1
a50 9
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)
d52 1
d70 2
a71 1
	elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR MINGW OR CYGWIN)
d74 1
a74 2
	elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
	    CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
a75 2
	elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
		set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_NETBSD_SOURCE")
d82 1
a82 1
check_c_compiler_flag("-Werror -fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)
d91 1
a93 1
check_symbol_exists(asprintf stdio.h HAVE_ASPRINTF)
d104 1
a106 1
check_symbol_exists(strsep string.h HAVE_STRSEP)
d111 4
a122 1
	HAVE_ASPRINTF
d137 1
a140 1
	HAVE_STRSEP
d146 1
d155 1
a155 1
if(HAVE_EXPLICIT_BZERO AND NOT FUZZ)
d159 4
a166 1

d171 7
a177 19
		message(FATAL_ERROR "please define "
		   "{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY}_DIRS when "
		   "building under msvc")
	endif()
	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()

a178 2
		"C4152" # nonstandard extension used: function/data pointer
			# conversion in expression;
a180 1
		"C4201" # nonstandard extension used: nameless struct/union;
d194 1
a194 1
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od /Z7 /guard:cf /sdl /RTCcsu")
d196 1
a196 1
	if(USE_WINHELLO)
d198 1
a199 1
	set(NFC_LINUX OFF)
d216 2
a217 6
	if(NOT CBOR_LIBRARIES)
		set(CBOR_LIBRARIES "cbor")
	endif()
	if(NOT CRYPTO_LIBRARIES)
		set(CRYPTO_LIBRARIES "crypto")
	endif()
a232 2
	else()
		set(NFC_LINUX OFF)
a241 11
	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()

d248 2
a249 2
	if(NFC_LINUX)
		add_definitions(-DUSE_NFC)
d252 2
a253 6
	if(WIN32)
		if(USE_WINHELLO)
			add_definitions(-DUSE_WINHELLO)
		endif()
	else()
		set(USE_WINHELLO OFF)
a263 1
	add_compile_options(-Wimplicit-fallthrough)
a266 7
	set(EXTRA_CFLAGS "-Wconversion -Wsign-conversion")

	if(WIN32)
		add_compile_options(-Wno-type-limits)
		add_compile_options(-Wno-cast-function-type)
	endif()

a269 1

d278 2
a279 2
	if(CRYPTO_VERSION VERSION_GREATER_EQUAL 3.0)
		add_definitions(-DOPENSSL_API_COMPAT=0x10100000L)
d281 2
a282 3

	if(NOT FUZZ)
		set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wframe-larger-than=2047")
a300 4
if(USE_PCSC)
	add_definitions(-DUSE_PCSC)
endif()

d311 1
a311 1
		    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/fuzz/export.gnu")
d314 1
a314 1
		    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/export.gnu")
d337 1
a337 1
include_directories(${PROJECT_SOURCE_DIR}/src)
a340 1
include_directories(${PCSC_INCLUDE_DIRS})
a346 1
link_directories(${PCSC_LIBRARY_DIRS})
a358 3
if(BUILD_TESTS)
	message(STATUS "CBOR_BIN_DIRS: ${CBOR_BIN_DIRS}")
endif()
a363 4
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}")
a366 1
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
a370 3
if(BUILD_TESTS)
	message(STATUS "CRYPTO_BIN_DIRS: ${CRYPTO_BIN_DIRS}")
endif()
a373 3
if(FUZZ)
	message(STATUS "FUZZ_LDFLAGS: ${FUZZ_LDFLAGS}")
endif()
a376 3
if(BUILD_TESTS)
	message(STATUS "ZLIB_BIN_DIRS: ${ZLIB_BIN_DIRS}")
endif()
d384 1
a384 4
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}")
a391 1
message(STATUS "USE_PCSC: ${USE_PCSC}")
d395 1
a395 9
if(BUILD_TESTS)
	enable_testing()
endif()

add_subdirectory(src)

if(BUILD_TESTS)
	add_subdirectory(regress)
endif()
d397 1
a397 1
	add_subdirectory(examples)
d400 1
a400 1
	add_subdirectory(tools)
d403 1
a403 1
	add_subdirectory(man)
d407 5
d413 1
a413 1
		add_subdirectory(fuzz)
d416 1
a416 1
		add_subdirectory(udev)
@


1.1.1.5
log
@Import libfido2 1.13.0 (old one was 1.8.0)

* 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.
 ** winhello: fallback to GetTopWindow() if GetForegroundWindow() fails.
 ** winhello: fallback to hid_win.c if webauthn.dll isn't available.
 ** New API calls:
  - fido_dev_info_set;
  - fido_dev_io_handle;
  - fido_dev_new_with_info;
  - fido_dev_open_with_info.
 ** Cygwin and NetBSD build fixes.
 ** Documentation and reliability fixes.
 ** Support for TPM 2.0 attestation of COSE_ES256 credentials.

* Version 1.9.0 (2021-10-27)
 ** Enabled NFC support on Linux.
 ** Added OpenSSL 3.0 compatibility.
 ** Removed OpenSSL 1.0 compatibility.
 ** Support for FIDO 2.1 "minPinLength" extension.
 ** Support for COSE_EDDSA, COSE_ES256, and COSE_RS1 attestation.
 ** Support for TPM 2.0 attestation.
 ** Support for device timeouts; see fido_dev_set_timeout().
 ** New API calls:
  - es256_pk_from_EVP_PKEY;
  - fido_cred_attstmt_len;
  - fido_cred_attstmt_ptr;
  - fido_cred_pin_minlen;
  - fido_cred_set_attstmt;
  - fido_cred_set_pin_minlen;
  - fido_dev_set_pin_minlen_rpid;
  - fido_dev_set_timeout;
  - rs256_pk_from_EVP_PKEY.
 ** Reliability and portability fixes.
 ** Better handling of HID devices without identification strings; gh#381.
 ** Fixed detection of Windows's native webauthn API; gh#382.
@
text
@d1 1
a1 1
# Copyright (c) 2018-2022 Yubico AB. All rights reserved.
a3 1
# SPDX-License-Identifier: BSD-2-Clause
d12 1
a12 1
	cmake_policy(SET CMP0083 NEW)
d24 1
a24 1
	check_pie_supported(LANGUAGES C)
d31 1
a31 1
set(FIDO_MINOR "13")
a34 1
option(BUILD_TESTS       "Build the regress tests"                 ON)
d37 2
a38 2
option(BUILD_SHARED_LIBS "Build a shared library"                  ON)
option(BUILD_STATIC_LIBS "Build a static library"                  ON)
d41 1
d43 2
a44 3
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)
d50 1
a50 9
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)
d52 1
d70 2
a71 1
	elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR MINGW OR CYGWIN)
d74 1
a74 2
	elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
	    CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
a75 2
	elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
		set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_NETBSD_SOURCE")
d82 1
a82 1
check_c_compiler_flag("-Werror -fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)
d91 1
a93 1
check_symbol_exists(asprintf stdio.h HAVE_ASPRINTF)
d104 1
a106 1
check_symbol_exists(strsep string.h HAVE_STRSEP)
d111 4
a122 1
	HAVE_ASPRINTF
d137 1
a140 1
	HAVE_STRSEP
d146 1
d155 1
a155 1
if(HAVE_EXPLICIT_BZERO AND NOT FUZZ)
d159 4
a166 1

d171 7
a177 19
		message(FATAL_ERROR "please define "
		   "{CBOR,CRYPTO,ZLIB}_{INCLUDE,LIBRARY}_DIRS when "
		   "building under msvc")
	endif()
	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()

a178 2
		"C4152" # nonstandard extension used: function/data pointer
			# conversion in expression;
a180 1
		"C4201" # nonstandard extension used: nameless struct/union;
d194 1
a194 1
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od /Z7 /guard:cf /sdl /RTCcsu")
d196 1
a196 1
	if(USE_WINHELLO)
d198 1
a199 1
	set(NFC_LINUX OFF)
d216 2
a217 6
	if(NOT CBOR_LIBRARIES)
		set(CBOR_LIBRARIES "cbor")
	endif()
	if(NOT CRYPTO_LIBRARIES)
		set(CRYPTO_LIBRARIES "crypto")
	endif()
a232 2
	else()
		set(NFC_LINUX OFF)
a241 11
	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()

d248 2
a249 2
	if(NFC_LINUX)
		add_definitions(-DUSE_NFC)
d252 2
a253 6
	if(WIN32)
		if(USE_WINHELLO)
			add_definitions(-DUSE_WINHELLO)
		endif()
	else()
		set(USE_WINHELLO OFF)
a263 1
	add_compile_options(-Wimplicit-fallthrough)
a266 7
	set(EXTRA_CFLAGS "-Wconversion -Wsign-conversion")

	if(WIN32)
		add_compile_options(-Wno-type-limits)
		add_compile_options(-Wno-cast-function-type)
	endif()

a269 1

d278 2
a279 2
	if(CRYPTO_VERSION VERSION_GREATER_EQUAL 3.0)
		add_definitions(-DOPENSSL_API_COMPAT=0x10100000L)
d281 2
a282 3

	if(NOT FUZZ)
		set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wframe-larger-than=2047")
a300 4
if(USE_PCSC)
	add_definitions(-DUSE_PCSC)
endif()

d311 1
a311 1
		    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/fuzz/export.gnu")
d314 1
a314 1
		    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/export.gnu")
d337 1
a337 1
include_directories(${PROJECT_SOURCE_DIR}/src)
a340 1
include_directories(${PCSC_INCLUDE_DIRS})
a346 1
link_directories(${PCSC_LIBRARY_DIRS})
a358 3
if(BUILD_TESTS)
	message(STATUS "CBOR_BIN_DIRS: ${CBOR_BIN_DIRS}")
endif()
a363 4
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}")
a366 1
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
a370 3
if(BUILD_TESTS)
	message(STATUS "CRYPTO_BIN_DIRS: ${CRYPTO_BIN_DIRS}")
endif()
a373 3
if(FUZZ)
	message(STATUS "FUZZ_LDFLAGS: ${FUZZ_LDFLAGS}")
endif()
a376 3
if(BUILD_TESTS)
	message(STATUS "ZLIB_BIN_DIRS: ${ZLIB_BIN_DIRS}")
endif()
d384 1
a384 4
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}")
a391 1
message(STATUS "USE_PCSC: ${USE_PCSC}")
d395 1
a395 9
if(BUILD_TESTS)
	enable_testing()
endif()

add_subdirectory(src)

if(BUILD_TESTS)
	add_subdirectory(regress)
endif()
d397 1
a397 1
	add_subdirectory(examples)
d400 1
a400 1
	add_subdirectory(tools)
d403 1
a403 1
	add_subdirectory(man)
d407 5
d413 1
a413 1
		add_subdirectory(fuzz)
d416 1
a416 1
		add_subdirectory(udev)
@


1.1.1.5.2.1
log
@Sync with HEAD
@
text
@a4 1
cmake_minimum_required(VERSION 3.7)
d10 1
a30 2
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

d32 1
a32 1
set(FIDO_MINOR "16")
a192 3
	if(NOT CRYPTO_DLL)
		set(CRYPTO_DLL crypto)
	endif()
a437 3
if(MSVC)
	message(STATUS "CRYPTO_DLL: ${CRYPTO_DLL}")
endif()
d487 1
a487 1
if(BUILD_MANPAGES AND NOT MSVC)
@


1.1.1.6
log
@Import libfido2-1.16.0 (previous was 1.13.0)
Changes:

Version 1.16.0 (2025-05-06)

    Added support for enterprise attestation.
    Improved handling of invalid key handles in U2F key lookup; gh#819.
    Fixed issue where storing small CTAP 2.1 largeBlobs failed; gh#826.
    Fixed APDU chaining issues for certain authenticators; gh#818, gh#855.
    Improved documentation and examples.

    New API calls:
	fido_cred_entattest;
	fido_cred_set_entattest.

Version 1.15.0 (2024-06-13)

    1.15.0 will be the last release to support OpenSSL 1.1.

    bio, credman: improved CTAP 2.1 support.
    hid_osx: fix issue where fido_hid_read() may block unnecessarily; gh#757.
    fido2-token -I: print maxcredbloblen.
    hid_linux: improved support for uhid devices.

    New API calls:
	fido_cred_set_attobj;
	fido_cred_x5c_list_count;
	fido_cred_x5c_list_len;
	fido_cred_x5c_list_ptr.

Version 1.14.0 (2023-11-13)

    fido2-cred -M, fido2-token -G: support raw client data via -w flag.

    winhello: support U2F AppID extension for assertions.
    winhello: fix restrictive parsing of the hmac-secret on assertions.
    winhello: translate NTE_USER_CANCELLED to FIDO_ERR_OPERATION_DENIED; gh#685.

    New API calls:
	fido_assert_authdata_raw_len;
	fido_assert_authdata_raw_ptr;
	fido_assert_set_winhello_appid.
@
text
@a4 1
cmake_minimum_required(VERSION 3.7)
d10 1
a30 2
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

d32 1
a32 1
set(FIDO_MINOR "16")
a192 3
	if(NOT CRYPTO_DLL)
		set(CRYPTO_DLL crypto)
	endif()
a437 3
if(MSVC)
	message(STATUS "CRYPTO_DLL: ${CRYPTO_DLL}")
endif()
d487 1
a487 1
if(BUILD_MANPAGES AND NOT MSVC)
@


1.1.1.1.2.1
log
@file CMakeLists.txt was added on branch phil-wifi on 2020-04-13 07:46:06 +0000
@
text
@d1 429
@


1.1.1.1.2.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@a0 429
# 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.

# detect AppleClang; needs to come before project()
cmake_policy(SET CMP0025 NEW)

project(libfido2 C)
cmake_minimum_required(VERSION 3.0)

include(CheckCCompilerFlag)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckTypeSize)
include(GNUInstallDirs)

set(CMAKE_COLOR_MAKEFILE off)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(FIDO_MAJOR "1")
set(FIDO_MINOR "3")
set(FIDO_PATCH "1")
set(FIDO_VERSION ${FIDO_MAJOR}.${FIDO_MINOR}.${FIDO_PATCH})

add_definitions(-D_FIDO_MAJOR=${FIDO_MAJOR})
add_definitions(-D_FIDO_MINOR=${FIDO_MINOR})
add_definitions(-D_FIDO_PATCH=${FIDO_PATCH})

if(CYGWIN OR MSYS)
	set(WIN32 1)
	add_definitions(-DWINVER=0x0a00)
endif()

if(WIN32)
	add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()

if(APPLE)
	set(CMAKE_INSTALL_NAME_DIR
		"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()

# Observe OpenBSD's library versioning scheme.
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
	set(LIB_VERSION ${FIDO_MAJOR}.${FIDO_MINOR})
	set(LIB_SOVERSION ${LIB_VERSION})
else()
	set(LIB_VERSION ${FIDO_VERSION})
	set(LIB_SOVERSION ${FIDO_MAJOR})
endif()

if(MSVC)
	if((NOT CBOR_INCLUDE_DIRS) OR (NOT CBOR_LIBRARY_DIRS) OR
	   (NOT CRYPTO_INCLUDE_DIRS) OR (NOT CRYPTO_LIBRARY_DIRS))
		message(FATAL_ERROR "please provide definitions for "
		    "{CBOR,CRYPTO}_{INCLUDE,LIBRARY}_DIRS when building "
		    "under msvc")
	endif()
	set(CBOR_LIBRARIES cbor)
	set(CRYPTO_LIBRARIES crypto-45)
	set(MSVC_DISABLED_WARNINGS_LIST
		"C4200" # nonstandard extension used: zero-sized array in
			# struct/union;
		"C4204" # nonstandard extension used: non-constant aggregate
			# initializer;
		"C4706" # assignment within conditional expression;
		"C4996" # The POSIX name for this item is deprecated. Instead,
			# use the ISO C and C++ conformant name
		)
	# The construction in the following 3 lines was taken from LibreSSL's
	# CMakeLists.txt.
	string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
		${MSVC_DISABLED_WARNINGS_LIST})
	string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 ${MSVC_DISABLED_WARNINGS_STR}")
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7")
	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
else()
	include(FindPkgConfig)
	pkg_search_module(CBOR libcbor)
	pkg_search_module(CRYPTO libcrypto)

	# XXX workaround libcbor's missing .pc file
	if(NOT CBOR_FOUND)
		check_include_files(cbor.h HAVE_CBOR_H)
		if(NOT HAVE_CBOR_H)
			message(FATAL_ERROR "could not find cbor header files")
		endif()
		set(CBOR_LIBRARIES "cbor")
	endif()

	# XXX workaround libcrypto's missing .pc file
	if(NOT CRYPTO_FOUND)
		check_include_files(openssl/opensslv.h HAVE_OPENSSLV_H)
		if(NOT HAVE_OPENSSLV_H)
			message(FATAL_ERROR "could not find crypto header files")
		endif()
		set(CRYPTO_LIBRARIES "crypto")
	endif()

	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
		pkg_search_module(UDEV libudev REQUIRED)
		set(UDEV_NAME "udev")
		# Define be32toh().
		add_definitions(-D_GNU_SOURCE)
		# If using hidapi, use hidapi-hidraw.
		set(HIDAPI_SUFFIX -hidraw)
	elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
	       CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
		set(BASE_LIBRARIES usbhid)
	endif()

	if(MINGW)
		# MinGW is stuck with a flavour of C89.
		add_definitions(-DFIDO_NO_DIAGNOSTIC)
		add_definitions(-DWC_ERR_INVALID_CHARS=0x80)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
	endif()

	if(USE_HIDAPI)
		add_definitions(-DUSE_HIDAPI)
		pkg_search_module(HIDAPI hidapi${HIDAPI_SUFFIX} REQUIRED)
		if(HIDAPI_FOUND)
			set(HIDAPI_LIBRARIES hidapi${HIDAPI_SUFFIX})
		endif()
	endif()

	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wbad-function-cast")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors")
	check_c_compiler_flag("-fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)
	if(HAVE_STACK_PROTECTOR_ALL)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
	endif()

	add_definitions(-D_DEFAULT_SOURCE)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g2")
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer")

	if(FUZZ)
		if(LIBFUZZER)
			set(FUZZ_LDFLAGS "-fsanitize=fuzzer")
			set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
		endif()
		add_definitions(-DFIDO_FUZZ)
	endif()

	if(ASAN)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,leak")
	endif()

	if(MSAN)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-track-origins")
	endif()

	if(UBSAN)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-trap=undefined")
	endif()

	if(COVERAGE)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
	endif()
endif()

# Use -Wshorten-64-to-32 if available.
check_c_compiler_flag("-Wshorten-64-to-32" HAVE_SHORTEN_64_TO_32)
if(HAVE_SHORTEN_64_TO_32)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshorten-64-to-32")
endif()

# Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
if(CMAKE_COMPILER_IS_GNUCC)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result")
endif()

# Decide which keyword to use for thread-local storage.
if(CMAKE_COMPILER_IS_GNUCC OR
   CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
   CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
	set(TLS "__thread")
elseif(WIN32)
	set(TLS "__declspec(thread)")
endif()

add_definitions(-DTLS=${TLS})

# endian.h
check_include_files(endian.h HAVE_ENDIAN_H)
if(HAVE_ENDIAN_H)
	add_definitions(-DHAVE_ENDIAN_H)
endif()

# err.h
check_include_files(err.h HAVE_ERR_H)
if(HAVE_ERR_H)
	add_definitions(-DHAVE_ERR_H)
endif()

# unistd.h
check_include_files(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
	add_definitions(-DHAVE_UNISTD_H)
endif()

# signal.h
check_include_files(signal.h HAVE_SIGNAL_H)
if(HAVE_SIGNAL_H)
	add_definitions(-DHAVE_SIGNAL_H)
endif()

# sys/random.h
check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
if(HAVE_SYS_RANDOM_H)
	add_definitions(-DHAVE_SYS_RANDOM_H)
endif()

# strlcpy
check_function_exists(strlcpy HAVE_STRLCPY)
if(HAVE_STRLCPY)
	add_definitions(-DHAVE_STRLCPY)
endif()

# strlcat
check_function_exists(strlcpy HAVE_STRLCAT)
if(HAVE_STRLCAT)
	add_definitions(-DHAVE_STRLCAT)
endif()

# recallocarray
check_function_exists(recallocarray HAVE_RECALLOCARRAY)
if(HAVE_RECALLOCARRAY)
	add_definitions(-DHAVE_RECALLOCARRAY)
endif()

# XXX getpagesize is incorrectly detected when cross-compiling
# with mingw on Linux. Avoid.
if(NOT WIN32)
	check_function_exists(getpagesize HAVE_GETPAGESIZE)
endif()
if(HAVE_GETPAGESIZE)
	add_definitions(-DHAVE_GETPAGESIZE)
endif()

# sysconf
check_function_exists(sysconf HAVE_SYSCONF)
if(HAVE_SYSCONF)
	add_definitions(-DHAVE_SYSCONF)
endif()

# memset_s
if(APPLE)
	add_definitions(-D__STDC_WANT_LIB_EXT1__=1)
endif()
check_function_exists(memset_s HAVE_MEMSET_S)
if(HAVE_MEMSET_S)
	add_definitions(-DHAVE_MEMSET_S)
endif()

# explicit_bzero
if(NOT LIBFUZZER)
	check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
	if(HAVE_EXPLICIT_BZERO)
		add_definitions(-DHAVE_EXPLICIT_BZERO)
	endif()
endif()

# timingsafe_bcmp
check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
if(HAVE_TIMINGSAFE_BCMP)
	add_definitions(-DHAVE_TIMINGSAFE_BCMP)
endif()

# readpassphrase
check_function_exists(readpassphrase HAVE_READPASSPHRASE)
if(HAVE_READPASSPHRASE)
	add_definitions(-DHAVE_READPASSPHRASE)
endif()

# getline
check_function_exists(getline HAVE_GETLINE)
if(HAVE_GETLINE)
	add_definitions(-DHAVE_GETLINE)
endif()

# getopt
check_function_exists(getopt HAVE_GETOPT)
if(HAVE_GETOPT)
	add_definitions(-DHAVE_GETOPT)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
else()
	if(CMAKE_COMPILER_IS_GNUCC)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-discarded-qualifiers")
	endif()
	if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types-discards-qualifiers")
	endif()
endif()

# usable sigaction
set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
check_function_exists(sigaction HAVE_SIGACTION)
check_type_size("sig_atomic_t" HAVE_SIG_ATOMIC_T)
if(HAVE_SIGACTION AND (NOT HAVE_SIG_ATOMIC_T STREQUAL ""))
	add_definitions(-DSIGNAL_EXAMPLE)
endif()
set(CMAKE_EXTRA_INCLUDE_FILES)

# arc4random_buf
check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF)
if(HAVE_ARC4RANDOM_BUF)
	add_definitions(-DHAVE_ARC4RANDOM_BUF)
endif()

# getrandom
check_function_exists(getrandom HAVE_GETRANDOM)
if(HAVE_GETRANDOM)
	add_definitions(-DHAVE_GETRANDOM)
endif()

# /dev/urandom
if(UNIX)
	add_definitions(-DHAVE_DEV_URANDOM)
endif()

# export list
if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
   CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
	# clang + lld
	string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
	    " -exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/src/export.llvm")
elseif(NOT MSVC)
	# clang/gcc + gnu ld
	if(FUZZ)
		string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
                    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/fuzz/export.gnu")
	else()
		string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
                    " -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/export.gnu")
	endif()
	if(NOT WIN32)
		string(CONCAT CMAKE_SHARED_LINKER_FLAGS
		    ${CMAKE_SHARED_LINKER_FLAGS}
		    " -Wl,-z,noexecstack -Wl,-z,relro,-z,now")
		string(CONCAT CMAKE_EXE_LINKER_FLAGS
		    ${CMAKE_EXE_LINKER_FLAGS}
		    " -Wl,-z,noexecstack -Wl,-z,relro,-z,now")
		if(FUZZ)
			file(STRINGS fuzz/wrapped.sym WRAPPED_SYMBOLS)
			foreach(s ${WRAPPED_SYMBOLS})
				string(CONCAT CMAKE_SHARED_LINKER_FLAGS
				    ${CMAKE_SHARED_LINKER_FLAGS}
				    " -Wl,--wrap=${s}")
			endforeach()
		endif()
	endif()
else()
	string(CONCAT CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
		" /def:\"${CMAKE_CURRENT_SOURCE_DIR}/src/export.msvc\"")
endif()

include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CBOR_INCLUDE_DIRS})
include_directories(${CRYPTO_INCLUDE_DIRS})

link_directories(${CBOR_LIBRARY_DIRS})
link_directories(${CRYPTO_LIBRARY_DIRS})

message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CBOR_INCLUDE_DIRS: ${CBOR_INCLUDE_DIRS}")
message(STATUS "CBOR_LIBRARY_DIRS: ${CBOR_LIBRARY_DIRS}")
message(STATUS "CBOR_LIBRARIES: ${CBOR_LIBRARIES}")
message(STATUS "CRYPTO_INCLUDE_DIRS: ${CRYPTO_INCLUDE_DIRS}")
message(STATUS "CRYPTO_LIBRARY_DIRS: ${CRYPTO_LIBRARY_DIRS}")
message(STATUS "CRYPTO_LIBRARIES: ${CRYPTO_LIBRARIES}")
message(STATUS "BASE_LIBRARIES: ${BASE_LIBRARIES}")
message(STATUS "HIDAPI_LIBRARIES: ${HIDAPI_LIBRARIES}")
message(STATUS "VERSION: ${FIDO_VERSION}")
message(STATUS "LIB_VERSION: ${LIB_VERSION}")
message(STATUS "LIB_SOVERSION: ${LIB_SOVERSION}")
message(STATUS "FUZZ: ${FUZZ}")
message(STATUS "AFL: ${AFL}")
message(STATUS "LIBFUZZER: ${LIBFUZZER}")
message(STATUS "ASAN: ${ASAN}")
message(STATUS "MSAN: ${MSAN}")
message(STATUS "COVERAGE: ${COVERAGE}")
message(STATUS "TLS: ${TLS}")
message(STATUS "USE_HIDAPI: ${USE_HIDAPI}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
	message(STATUS "UDEV_INCLUDE_DIRS: ${UDEV_INCLUDE_DIRS}")
	message(STATUS "UDEV_LIBRARY_DIRS: ${UDEV_LIBRARY_DIRS}")
	message(STATUS "UDEV_LIBRARIES: ${UDEV_LIBRARIES}")
	message(STATUS "UDEV_RULES_DIR: ${UDEV_RULES_DIR}")
endif()

subdirs(src)
subdirs(examples)
subdirs(tools)
subdirs(man)

if(NOT WIN32)
	if(CMAKE_BUILD_TYPE STREQUAL "Debug")
		if(NOT MSAN AND NOT LIBFUZZER)
			subdirs(regress)
		endif()
	endif()
	if(FUZZ)
		subdirs(fuzz)
	endif()

	if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
		subdirs(udev)
	endif()
endif()
@


