yubikit
Rust SDK for interacting with YubiKey devices.
yubikit provides a complete API for communicating with YubiKeys over USB (CCID/SmartCard, FIDO HID, OTP HID) and NFC. It covers the full range of YubiKey applications:
- OATH — TOTP/HOTP credential management
- PIV — Smart card certificates, key management, signing
- OpenPGP — PGP key operations
- FIDO2/CTAP2 — WebAuthn credential creation and assertion
- YubiOTP — Yubico OTP configuration
- HSM Auth — YubiHSM authentication credentials
- Management — Device configuration, firmware info, interfaces
Getting started
Requires Rust 1.88 or later. Add the beta explicitly to your Cargo.toml:
[]
= "1.0.0-beta.0"
Install the native prerequisites below before building with the default features.
use list_devices;
use UsbInterface;
use OathSession;
// 1. Discover connected YubiKeys
let all = CCID | OTP | FIDO;
let devices = list_devices.expect;
let dev = devices.first.expect;
// 2. Open a SmartCard (CCID) connection
let conn = dev.open_smartcard.expect;
// 3. Create an OATH session and list accounts
let mut session = new.expect;
let creds = session.list_credentials.expect;
for cred in &creds
Features
The default feature set enables both physical-device transport backends:
pcsc(default) — Enables PC/SC smart card transport for CCID over USB and NFC readers.hid(default) — Enables HID transport for FIDO and OTP over USB.
Disable default features for environments where only custom transports are needed, or enable only the transport backend required by your application.
Platform support
| Platform | Transport |
|---|---|
| Linux | PC/SC (pcsclite), HID (hidraw) |
| macOS | PC/SC (CryptoTokenKit), HID |
| Windows | PC/SC (WinSCard), HID |
Native prerequisites
On Debian/Ubuntu, install a C toolchain, pkg-config, and the development
libraries for the enabled transports:
On Fedora:
pcsc requires PC/SC development libraries; hid uses libudev on Linux.
At runtime, CCID and NFC access require pcscd to be running or socket-activated.
HID access requires suitable udev permissions. Install your distribution's
YubiKey udev rules and reconnect the device after changing the rules.
On macOS, install the Xcode Command Line Tools (xcode-select --install).
On Windows, use the Rust MSVC toolchain with Visual Studio Build Tools,
including the Desktop development with C++ workload and Windows SDK.
PC/SC and HID support use system libraries on both platforms.
With default-features = false, device discovery and platform transport
modules are unavailable; provide your own connection implementations instead.
On Linux, libudev remains a build dependency even with both transport features
disabled.
License
Apache-2.0; see the bundled LICENSE file.