Skip to content

Yubikit transaction#390

Closed
DennisDyallo wants to merge 93 commits intoyubikitfrom
yubikit-transaction
Closed

Yubikit transaction#390
DennisDyallo wants to merge 93 commits intoyubikitfrom
yubikit-transaction

Conversation

@DennisDyallo
Copy link
Collaborator

No description provided.

- accepts protocolConfiguration
- partial classes for Scp03, Scp11
…on and improve exception handling in SCP initialization
- 15 tasks covering CTAP HID protocol implementation
- Uses build.cs for all build and test operations
- Includes packet construction, channel init, APDU transmission
- Integration with ManagementSession
- Complete code examples and verification steps
- Ready for execution with test-driven-development skill
- Added support for building specific projects using --project option.
- Updated usage instructions to clarify the use of -- separator.
- Improved feedback for no matching projects during build.
- Added section on using `--` separator for argument passing
- Clarified usage examples for building specific projects
- Updated help message instructions and added new options
- Added integration test project discovery.
- Renamed variable for unit test projects for clarity.
- Updated Bullseye argument filtering to support project and filter options.
Refactor HID architecture to match Java yubikit-android patterns:

Connection Types (matching Java):
- IFidoConnection: 64-byte CTAP HID packets for FIDO interface
- IOtpConnection: 8-byte feature reports for OTP/Keyboard interface
- Separate FidoConnection and OtpConnection implementations

Protocol Layer:
- FidoProtocol: CTAP HID framing + vendor commands (0xC2 READ_CONFIG)
- Extract firmware version from CTAPHID_INIT response
- Channel management with nonce verification
- CtapConstants: vendor command definitions (0xC0, 0xC2, 0xC3)

ManagementSession:
- Accepts IFidoConnection for HID-based Management
- Routes to CTAP vendor commands instead of APDUs for FIDO
- Type-safe: Management over HID requires FIDO interface

Architecture Benefits:
- Clear separation: FIDO (IO reports) vs OTP (feature reports)
- Type safety: Can't use OTP connection for FIDO operations
- Matches Java yubikit-android architecture exactly
- Prepares for OtpProtocol implementation

Fixed:
- HidUsagePage enum: use 0xF1D0 (61904) not signed short cast
- Tests filter for FIDO devices by DeviceId pattern

Test Results:
- 18 CCID/SmartCard tests passing ✅
- Build successful with new abstractions
- HID tests connect to FIDO interface correctly
- Known issue: HID ReceiveAsync hangs (needs legacy code review)

Next steps:
- Review legacy C# HID implementation for IOKit interaction patterns
- Debug CTAP HID packet receive timeout/blocking issue
- Verify CTAPHID_INIT response handling
Critical fix discovered through Java yubikit-android comparison:
- Page payload should be single byte: [page]
- Was incorrectly sending two bytes: [0, page]
- This caused infinite loop reading same page repeatedly

Result: HID Management tests now passing! ✅

Test Results:
- 20 tests passing (up from 18)
- Both HID-specific Management tests now work:
  * CreateManagementSession_with_Hid_CreateAsync ✅
  * CreateManagementSession_Hid_with_CreateAsync ✅
- GetDeviceInfo over FIDO HID working correctly
- Proper page iteration with CTAP vendor command 0xC2

Architecture validated:
- IFidoConnection for FIDO HID (64-byte packets)
- IOtpConnection for OTP HID (8-byte reports)
- FidoProtocol with CTAP HID framing + vendor commands
- ManagementSession routes correctly based on connection type

Remaining failures (5):
- Unrelated CCID/SCP03 hardware-specific issues
- Not related to HID implementation
… branching

- Create IManagementBackend interface with four operations:
  ReadConfigAsync, WriteConfigAsync, SetModeAsync, DeviceResetAsync
- Implement SmartCardBackend (encodes as APDUs)
- Implement FidoBackend (encodes as CTAP vendor commands)
- Refactor ManagementSession to use single _backend field
- Remove protocol-specific branching (if _fidoProtocol / _smartCardProtocol)
- Reduce ManagementSession complexity by 83 lines
- Matches Java yubikit-android Backend pattern

Result: Zero protocol-specific branching in public API methods.
All operations delegate to backend: backend.ReadConfigAsync(page).

Tests: 17 passing (2 HID tests included), 4 failing (hardware/SCP03 baseline issues)
Issue: When SCP03 was initialized, we disposed the old backend which
disposed the protocol and underlying connection, breaking the SCP-wrapped
protocol.

Fix: Backend is now a stateless translator that doesn't own the protocol.
ManagementSession maintains ownership and handles disposal of _protocol.

This allows SCP wrapping to work correctly:
1. Create initial backend with base protocol
2. Wrap protocol with SCP
3. Create new backend with SCP-wrapped protocol
4. Original connection remains alive

Result: SCP03 test should now pass (CreateManagementSession_with_SCP03_DefaultKeys)
- Added architecture section for Backend pattern in CLAUDE.md
- Updated README.md to include connection examples for SmartCard and HID
Updated both HID implementation plans with completion status:

2026-01-09-hid-protocol-implementation.md:
- Marked as COMPLETED with summary of what was implemented
- Documented FIDO/OTP connection abstractions
- Documented CTAP HID protocol implementation
- Documented Backend pattern refactoring
- Noted OTP protocol as future work (not critical)
- Added test results and validation status

2026-01-09-add-hid-devices.md:
- Marked core tasks as COMPLETED
- Noted Tasks 1-3 were historical (already existed)
- Validated Tasks 4-8 during January 2026 work
- Updated verification checklist to reflect completion
- Added architecture refactoring notes
- Documented known gaps (OTP protocol, native event listener)
- Enhanced future work section with priorities

Key accomplishment: Management over HID (FIDO) fully operational
with Backend pattern providing clean protocol abstraction.
@DennisDyallo DennisDyallo deleted the yubikit-transaction branch January 27, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments