yubico/yubikit-swift
Swift SDK for YubiKey integration on iOS and macOS.
Overview
YubiKit provides a native Swift interface with async/await for YubiKey hardware devices.
let connection = try await NFCSmartCardConnection()
// let connection = try await USBSmartCardConnection()
let session = try await OATHSession.makeSession(connection: connection)
let codes = try await session.calculateCredentialCodes()About
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.
Supported Applications
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
FIDO2/CTAP2 - WebAuthn credential creation, authentication, and device management
Secure Channel Protocol - SCP03 and SCP11 for encrypted communication
Installation
Swift Package Manager
https://github.com/Yubico/yubikit-swiftDocumentation
Sample Apps
Learn by example:
- OATHSample - SwiftUI authenticator app
- PIVTool - Command-line PIV operations
- WebAuthnInterceptorSample - FIDO2/WebAuthn in WKWebView
Requirements
- iOS 16.0+ / macOS 13.0+
Security Notice
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.
Support
License
Apache License 2.0
Package Metadata
Repository: yubico/yubikit-swift
Default branch: main
README: README.md