Skip to content

Commit

Permalink
Extend FIDO2 BLE support also for Linux
Browse files Browse the repository at this point in the history
For Windows it was already added via gh#336,
so let's also add it for Linux.
Unpaired devices are ignored, the user has to pair independently
of libfido use using the bluetooth manager provided by the desktop
environment.
  • Loading branch information
akemnade committed Jul 6, 2023
1 parent 854053f commit 7e34f64
Show file tree
Hide file tree
Showing 11 changed files with 873 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alpine_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
apk -q update
apk add build-base clang clang-analyzer cmake coreutils eudev-dev
apk add git linux-headers openssl-dev sudo zlib-dev pcsc-lite-dev \
libcbor-dev
libcbor-dev elogind-dev
- name: fix permissions on workdir
run: chown root:wheel "${GITHUB_WORKSPACE}"
- name: checkout libfido2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: |
sudo apt -q update
sudo apt install -q -y libcbor-dev libudev-dev libz-dev original-awk \
libpcsclite-dev
libpcsclite-dev libsystemd-dev
./.actions/build-linux-gcc
- name: perform codeql analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
sudo apt -q update
sudo apt install -q -y libcbor-dev libudev-dev libz-dev \
original-awk mandoc libpcsclite-dev
original-awk mandoc libpcsclite-dev libsystemd-dev
- name: compiler
env:
CC: ${{ matrix.cc }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux_fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: dependencies
run: |
sudo apt -q update
sudo apt install -q -y libudev-dev libpcsclite-dev
sudo apt install -q -y libudev-dev libpcsclite-dev libsystemd-dev
- name: compiler
env:
CC: ${{ matrix.cc }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openssl3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
sudo apt -q update
sudo apt install -q -y libcbor-dev libudev-dev libz-dev \
original-awk mandoc libpcsclite-dev
original-awk mandoc libpcsclite-dev libsystemd-dev
sudo apt remove -y libssl-dev
if [ "${CC%-*}" == "clang" ]; then
sudo ./.actions/setup_clang "${CC}"
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ option(USE_HIDAPI "Use hidapi as the HID backend" OFF)
option(USE_PCSC "Enable experimental PCSC support" ON)
option(USE_WINHELLO "Abstract Windows Hello as a FIDO device" ON)
option(NFC_LINUX "Enable NFC support on Linux" ON)
option(BLE_LINUX "Enable Bluetooth support on Linux" ON)

add_definitions(-D_FIDO_MAJOR=${FIDO_MAJOR})
add_definitions(-D_FIDO_MINOR=${FIDO_MINOR})
Expand Down Expand Up @@ -216,6 +217,7 @@ if(MSVC)
add_definitions(-DUSE_WINHELLO)
endif()
set(NFC_LINUX OFF)
set(BLE_LINUX OFF)
else()
include(FindPkgConfig)
pkg_search_module(CBOR libcbor)
Expand Down Expand Up @@ -255,6 +257,7 @@ else()
endif()
else()
set(NFC_LINUX OFF)
set(BLE_LINUX OFF)
endif()

if(MINGW)
Expand Down Expand Up @@ -285,6 +288,11 @@ else()
add_definitions(-DUSE_NFC)
endif()

if(BLE_LINUX)
add_definitions(-DUSE_BLE)
pkg_search_module(BLE libsystemd REQUIRED)
endif()

if(WIN32)
if(USE_WINHELLO)
add_definitions(-DUSE_WINHELLO)
Expand Down Expand Up @@ -392,13 +400,15 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${CBOR_INCLUDE_DIRS})
include_directories(${CRYPTO_INCLUDE_DIRS})
include_directories(${HIDAPI_INCLUDE_DIRS})
include_directories(${BLE_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(${BLE_LIBRARY_DIRS})
link_directories(${PCSC_LIBRARY_DIRS})
link_directories(${UDEV_LIBRARY_DIRS})
link_directories(${ZLIB_LIBRARY_DIRS})
Expand Down Expand Up @@ -468,6 +478,7 @@ message(STATUS "USE_HIDAPI: ${USE_HIDAPI}")
message(STATUS "USE_PCSC: ${USE_PCSC}")
message(STATUS "USE_WINHELLO: ${USE_WINHELLO}")
message(STATUS "NFC_LINUX: ${NFC_LINUX}")
message(STATUS "BLE_LINUX: ${BLE_LINUX}")

if(BUILD_TESTS)
enable_testing()
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ if(FUZZ)
list(APPEND FIDO_SOURCES ../fuzz/wrap.c)
endif()

if(BLE_LINUX)
list(APPEND FIDO_SOURCES ble.c ble_linux.c)
endif()

if(NFC_LINUX)
list(APPEND FIDO_SOURCES netlink.c nfc.c nfc_linux.c)
endif()
Expand Down Expand Up @@ -123,6 +127,7 @@ list(APPEND TARGET_LIBRARIES
${HIDAPI_LIBRARIES}
${ZLIB_LIBRARIES}
${PCSC_LIBRARIES}
${BLE_LIBRARIES}
)

# static library
Expand Down
Loading

0 comments on commit 7e34f64

Please sign in to comment.