Swift SDK for YubiKey integration on iOS and macOS.
YubiKit provides a native Swift interface with async/await for YubiKey hardware devices.
let connection = try await NFCSmartCardConnection.makeConnection()
let session = try await OATHSession.makeSession(connection: connection)
let codes = try await session.calculateCodes()
await connection.close(message: "Done")YubiKit uses a layered architecture where the connection layer handles communication via NFC, Lightning, and USB-C, while application-specific sessions are built on top of these connections. All APIs use modern Swift async/await concurrency patterns for clean, readable code.
OATH - Configure and use TOTP/HOTP credentials for two-factor authentication
PIV - Smart card functionality including X.509 certificate management, key generation (RSA, ECDSA, Curve25519), and cryptographic operations
Management - Read YubiKey metadata (serial number, firmware version) and configure device settings
Secure Channel Protocol - SCP03 and SCP11 for encrypted communication
https://github.com/Yubico/yubikit-swift
Learn by example:
- OATHSample - SwiftUI authenticator app
- PIVTool - Command-line PIV operations
- iOS 16.0+ / macOS 13.0+
This SDK does not perform zeroization of sensitive data in memory. Cryptographic keys, PIN tokens, and other secrets are not securely erased when no longer in use. This is currently out of scope but may be addressed in a future release.
Apache License 2.0