$ show solokeys/solo2-cli
This repository contains a CLI tool for interacting with SoloKeys Solo 2 security keys. The application enables users to list connected devices, interact with various onboard applications (Admin, FIDO2, NDEF, OATH, PIV, Provision, QA), update firmware, and switch between regular and bootloader modes. The architecture features a clean separation of concerns with distinct layers for CLI parsing, library functionality, transport abstraction (CTAP/PCSC), device management, and application-specific implementations. The code demonstrates solid Rust engineering practices with proper error handling, user experience considerations, and adherence to security best practices.
The LLM identified 3 files worth highlighting for reuse:
Defines a clean Transport trait that abstracts over different smart card communication protocols (CTAPHID and PCSC). The trait provides a unified interface for sending commands and selecting applications, while allowing protocol-specific implementations to handle differences in API capabilities. This abstraction layer demonstrates excellent separation of concerns and could be easily adapted for other smart card projects with minimal modification.
Provides reusable patterns for working with applications on smart cards that use AID-based selection. Includes macros for creating app wrapper structs and traits for selecting applications using standard or PCSC-specific methods. Defines constants for well-known RIDs and PIXs (Application Identifiers). This middleware showcases a clean, extensible pattern for smart card application interaction that could be extracted and used in other projects with little modification.
Implements a complete OATH (Initiative for Open Authentication) authenticator for smart cards, supporting both HOTP and TOTP protocols. Correctly handles BER-TLV encoding/decoding using flexiber, proper secret processing (base32 decoding, hash-based shortening to block size), and RFC 6238-compliant TOTP calculation. Demonstrates non-obvious skill in implementing authentication standards correctly while maintaining separation from transport-layer concerns. The core OATH logic could be extracted as a reusable library with some adaptation for transport independence.