| 1 |
# A Rust library for interacting with CTAP1/CTAP2 Security Keys |
| 2 |
|
| 3 |
[](https://travis-ci.org/mozilla/authenticator-rs) |
| 4 |
 |
| 5 |
|
| 6 |
This is a cross-platform library for interacting with Security Key-type devices via Rust. |
| 7 |
|
| 8 |
* **Supported Platforms**: Windows, Linux, FreeBSD, NetBSD, OpenBSD, and macOS. |
| 9 |
* **Supported Transports**: USB HID. |
| 10 |
* **Supported Protocols**: [FIDO U2F over USB](https://fidoalliance.org/specs/fido-u2f-v1.1-id-20160915/fido-u2f-raw-message-formats-v1.1-id-20160915.html). [CTAP2 support](https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html) is forthcoming, with work being done in the **unstable** [`ctap2` branch](https://github.com/mozilla/authenticator-rs/tree/ctap2). |
| 11 |
|
| 12 |
This library currently focuses on USB security keys, but is expected to be extended to |
| 13 |
support additional transports. |
| 14 |
|
| 15 |
## Usage |
| 16 |
|
| 17 |
There's only a simple example function that tries to register and sign right now. It uses |
| 18 |
[env_logger](http://rust-lang-nursery.github.io/log/env_logger/) for logging, which you |
| 19 |
configure with the `RUST_LOG` environment variable: |
| 20 |
|
| 21 |
``` |
| 22 |
cargo build --example main |
| 23 |
RUST_LOG=debug cargo run --example main |
| 24 |
``` |
| 25 |
|
| 26 |
Proper usage should be to call into this library from something else - e.g., Firefox. There are |
| 27 |
some [C headers exposed for the purpose](./src/u2fhid-capi.h). |
| 28 |
|
| 29 |
## Tests |
| 30 |
|
| 31 |
There are some tests of the cross-platform runloop logic and the protocol decoder: |
| 32 |
|
| 33 |
``` |
| 34 |
cargo test |
| 35 |
``` |
| 36 |
|
| 37 |
## Fuzzing |
| 38 |
|
| 39 |
There are fuzzers for the USB protocol reader, basically fuzzing inputs from the HID layer. |
| 40 |
There are not (yet) fuzzers for the C API used by callers (such as Gecko). |
| 41 |
|
| 42 |
To fuzz, you will need cargo-fuzz (the latest version from GitHub) as well as Rust Nightly. |
| 43 |
|
| 44 |
``` |
| 45 |
rustup install nightly |
| 46 |
cargo install cargo-fuzz |
| 47 |
|
| 48 |
cargo +nightly fuzz run u2f_read -- -max_len=512 |
| 49 |
cargo +nightly fuzz run u2f_read_write -- -max_len=512 |
| 50 |
``` |