#security-key #u2f #fido #ctap2 #usb-hid #webauthn

authenticator

Library for interacting with CTAP1/2 security keys for Web Authentication. Used by Firefox.

36 releases

0.4.0-alpha.24 Nov 29, 2023
0.4.0-alpha.22 Sep 19, 2023
0.4.0-alpha.18 Jun 20, 2023
0.4.0-alpha.11 Mar 30, 2023
0.2.6 May 22, 2019

#27 in Hardware support

Download history 1007/week @ 2023-12-15 308/week @ 2023-12-22 351/week @ 2023-12-29 291/week @ 2024-01-05 690/week @ 2024-01-12 424/week @ 2024-01-19 409/week @ 2024-01-26 475/week @ 2024-02-02 675/week @ 2024-02-09 1205/week @ 2024-02-16 1190/week @ 2024-02-23 1285/week @ 2024-03-01 1247/week @ 2024-03-08 1387/week @ 2024-03-15 953/week @ 2024-03-22 947/week @ 2024-03-29

4,919 downloads per month
Used in 2 crates

MPL-2.0 license

1MB
17K SLoC

A Rust library for interacting with CTAP1/CTAP2 Security Keys

Build Status Maturity Level

This is a cross-platform library for interacting with Security Key-type devices via Rust.

  • Supported Platforms: Windows, Linux, FreeBSD, NetBSD, OpenBSD, and macOS.
  • Supported Transports: USB HID.
  • Supported Protocols: FIDO U2F over USB. CTAP2 support is forthcoming, with work being done in the unstable ctap2 branch.

This library currently focuses on USB security keys, but is expected to be extended to support additional transports.

Usage

There's only a simple example function that tries to register and sign right now. It uses env_logger for logging, which you configure with the RUST_LOG environment variable:

cargo build --example main
RUST_LOG=debug cargo run --example main

Proper usage should be to call into this library from something else - e.g., Firefox. There are some C headers exposed for the purpose.

Tests

There are some tests of the cross-platform runloop logic and the protocol decoder:

cargo test

Fuzzing

There are fuzzers for the USB protocol reader, basically fuzzing inputs from the HID layer. There are not (yet) fuzzers for the C API used by callers (such as Gecko).

To fuzz, you will need cargo-fuzz (the latest version from GitHub) as well as Rust Nightly.

rustup install nightly
cargo install cargo-fuzz

cargo +nightly fuzz run u2f_read -- -max_len=512
cargo +nightly fuzz run u2f_read_write -- -max_len=512

Dependencies

~2–4.5MB
~83K SLoC