Libu2f-emu, provides a C Library for the U2F device emulations.
The API is described in src/u2f-emu.h
and src/u2f-emu-type.h
.
It gives the possibility to create virtual emulated U2F devices with transport specific considerations. Four transports are available:
- USB
- NFC
- BLUETOOTH
- APDU
Once create, it is possible to interact with the devices by sending and receiving transport specific data through the API.
Each virtual device, for its configuration requires:
- an EC x509 certificate
- its EC private key
- 48 bits of entropy
- a global counter
All the files are grouped inside a setup_dir that can be created through the setup.sh
script.
$ ./setup.sh <setup_dir>
For each transport, a code example is available and can be built:
$ make examples
Software that emulates U2F through a virtual USB device using UHID system API on Linux and the libu2f-emu
.
$ ./examples/usb/u2f-emu-usb <setup_dir>
You can easily test the virtual device my registering it on websites or by playing with it on https://webauthn.io/.
The project support two build systems:
- Autotools
- CMake
- Meson
Setup the build system:
# Autotools
$ ./autogen.sh
$ ./configure
# CMake
$ mkdir build && cd build
$ cmake ..
# Meson
$ meson build && cd build
Build and install the library:
$ make
$ make install
The doc is generated using doxygen
:
$ make doc
The doc can be accessed here: doc/html/index.html
.
Somes testsuites come with the project, these can be generated and run: gtest
is required:
$ make check
The coverage and its html report can be easily generated: gcov
, gcovr
and gtest
are required.
# Autotools
$ ./configure --enable-coverage
$ make coverage
# CMake
$ cmake -DCMAKE_BUILD_TYPE=Coverage ..
$ make coverage
# Meson
$ meson -Dcoverage=true build && cd build
$ make test && make coverage
The coverage html report can be accessed here: coverage/index.html
.
After the installation, the pkg-config informations are set:
$ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkgconf u2f-emu --libs --cflags
This project is licensed under GPL-2.0.
César MattGorko
Belley cesar.belley@lse.epita.fr