Skip to content

Commit 1e9bb5c

Browse files
committed
Extend FIDO2 BLE support also for Linux
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.
1 parent 335e447 commit 1e9bb5c

File tree

11 files changed

+894
-5
lines changed

11 files changed

+894
-5
lines changed

.github/workflows/alpine_builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
apk -q update
2929
apk add build-base clang clang-analyzer cmake coreutils eudev-dev
3030
apk add git linux-headers openssl-dev sudo zlib-dev pcsc-lite-dev \
31-
libcbor-dev
31+
libcbor-dev elogind-dev
3232
- name: fix permissions on workdir
3333
run: chown root:wheel "${GITHUB_WORKSPACE}"
3434
- name: checkout libfido2

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: |
3737
sudo apt -q update
3838
sudo apt install -q -y libcbor-dev libudev-dev libz-dev original-awk \
39-
libpcsclite-dev
39+
libpcsclite-dev libsystemd-dev
4040
./.actions/build-linux-gcc
4141
- name: perform codeql analysis
4242
uses: github/codeql-action/analyze@v3

.github/workflows/linux_builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
sudo apt -q update
3939
sudo apt install -q -y libcbor-dev libudev-dev libz-dev \
40-
original-awk mandoc libpcsclite-dev
40+
original-awk mandoc libpcsclite-dev libsystemd-dev
4141
- name: compiler
4242
env:
4343
CC: ${{ matrix.cc }}

.github/workflows/linux_fuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: dependencies
2929
run: |
3030
sudo apt -q update
31-
sudo apt install -q -y libudev-dev libpcsclite-dev
31+
sudo apt install -q -y libudev-dev libpcsclite-dev libsystemd-dev
3232
- name: compiler
3333
env:
3434
CC: ${{ matrix.cc }}

.github/workflows/openssl3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
sudo apt -q update
3737
sudo apt install -q -y libcbor-dev libudev-dev libz-dev \
38-
original-awk mandoc libpcsclite-dev
38+
original-awk mandoc libpcsclite-dev libsystemd-dev
3939
sudo apt remove -y libssl-dev
4040
if [ "${CC%-*}" == "clang" ]; then
4141
sudo ./.actions/setup_clang "${CC}"

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ option(USE_HIDAPI "Use hidapi as the HID backend" OFF)
4646
option(USE_PCSC "Enable experimental PCSC support" ON)
4747
option(USE_WINHELLO "Abstract Windows Hello as a FIDO device" ON)
4848
option(NFC_LINUX "Enable NFC support on Linux" ON)
49+
option(BLE_LINUX "Enable Bluetooth support on Linux" ON)
4950

5051
add_definitions(-D_FIDO_MAJOR=${FIDO_MAJOR})
5152
add_definitions(-D_FIDO_MINOR=${FIDO_MINOR})
@@ -221,6 +222,7 @@ if(MSVC)
221222
add_definitions(-DUSE_WINHELLO)
222223
endif()
223224
set(NFC_LINUX OFF)
225+
set(BLE_LINUX OFF)
224226
else()
225227
include(FindPkgConfig)
226228
pkg_search_module(CBOR libcbor)
@@ -260,6 +262,7 @@ else()
260262
endif()
261263
else()
262264
set(NFC_LINUX OFF)
265+
set(BLE_LINUX OFF)
263266
endif()
264267

265268
if(MINGW)
@@ -290,6 +293,11 @@ else()
290293
add_definitions(-DUSE_NFC)
291294
endif()
292295

296+
if(BLE_LINUX)
297+
add_definitions(-DUSE_BLE)
298+
pkg_search_module(BLE libsystemd REQUIRED)
299+
endif()
300+
293301
if(WIN32)
294302
if(USE_WINHELLO)
295303
add_definitions(-DUSE_WINHELLO)
@@ -397,13 +405,15 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
397405
include_directories(${CBOR_INCLUDE_DIRS})
398406
include_directories(${CRYPTO_INCLUDE_DIRS})
399407
include_directories(${HIDAPI_INCLUDE_DIRS})
408+
include_directories(${BLE_INCLUDE_DIRS})
400409
include_directories(${PCSC_INCLUDE_DIRS})
401410
include_directories(${UDEV_INCLUDE_DIRS})
402411
include_directories(${ZLIB_INCLUDE_DIRS})
403412

404413
link_directories(${CBOR_LIBRARY_DIRS})
405414
link_directories(${CRYPTO_LIBRARY_DIRS})
406415
link_directories(${HIDAPI_LIBRARY_DIRS})
416+
link_directories(${BLE_LIBRARY_DIRS})
407417
link_directories(${PCSC_LIBRARY_DIRS})
408418
link_directories(${UDEV_LIBRARY_DIRS})
409419
link_directories(${ZLIB_LIBRARY_DIRS})
@@ -476,6 +486,7 @@ message(STATUS "USE_HIDAPI: ${USE_HIDAPI}")
476486
message(STATUS "USE_PCSC: ${USE_PCSC}")
477487
message(STATUS "USE_WINHELLO: ${USE_WINHELLO}")
478488
message(STATUS "NFC_LINUX: ${NFC_LINUX}")
489+
message(STATUS "BLE_LINUX: ${BLE_LINUX}")
479490

480491
if(BUILD_TESTS)
481492
enable_testing()

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ if(FUZZ)
5151
list(APPEND FIDO_SOURCES ../fuzz/wrap.c)
5252
endif()
5353

54+
if(BLE_LINUX)
55+
list(APPEND FIDO_SOURCES ble.c ble_linux.c)
56+
endif()
57+
5458
if(NFC_LINUX)
5559
list(APPEND FIDO_SOURCES netlink.c nfc.c nfc_linux.c)
5660
endif()
@@ -123,6 +127,7 @@ list(APPEND TARGET_LIBRARIES
123127
${HIDAPI_LIBRARIES}
124128
${ZLIB_LIBRARIES}
125129
${PCSC_LIBRARIES}
130+
${BLE_LIBRARIES}
126131
)
127132

128133
# static library

0 commit comments

Comments
 (0)