gecko-dev/dom/webauthn/u2f-hid-rs/README.md
Greg V 6efd24a566 Bug 1468349 - Web Authentication - Add FreeBSD Support r=jcj
Summary:
Upstream PR: https://github.com/jcjones/u2f-hid-rs/pull/62

* Extract hidproto module from linux::hidraw
Make the protocol parts independent of Linux code, in preparation for
adding FreeBSD support.

* Add FreeBSD (uhid + devd) support
Tested with a YubiKey 4.

Tags: #secure-revision

Bug #: 1468349

Differential Revision: https://phabricator.services.mozilla.com/D1636

MozReview-Commit-ID: 8NNWRgTEMn2

--HG--
extra : rebase_source : edf774f0a993a18b59b5f8aa10e0977d94ea1de8
2018-06-12 09:55:30 -07:00

1.8 KiB

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