Rust library to interact with U2F Security Keys over USB HID
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples Bug 1459174 - Web Authentication - Use sha2 crate instead of rust-cry… May 4, 2018
fuzz Bug 1400513 - u2f-hid-rs: fuzzers should use a deterministic cmd byte… Sep 17, 2017
src Update to rustfmt-preview for travis. Update `rustfmt` Jun 12, 2018
.gitignore Rewrite macOS IOHIDManager communication and state machine r=jcj Nov 14, 2017
.travis.yml
Cargo.toml Update to 0.2.0 to signify FreeBSD Jun 12, 2018
LICENSE
README.md rustfmt Jun 12, 2018
rustfmt.toml Run rustfmt, and configure Travis to enforce rustfmt. Jul 27, 2017

README.md

A Rust HID library for interacting with U2F Security Keys

Build Status Maturity Level

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

  • Supported Platforms: Windows, Linux, FreeBSD, and macOS.
  • Supported HID Transports: USB.
  • Supported Protocols: FIDO U2F over USB.

This library currently focuses on U2F security keys, but is expected to be extended to support additional protocols and 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 --git https://github.com/rust-fuzz/cargo-fuzz/

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