Add YubiKey HMAC-SHA1 challenge-response via usb4java - #4
Open
kwsantiago wants to merge 1 commit into
Open
kwsantiago wants to merge 1 commit into
kwsantiago wants to merge 1 commit into
Conversation
kwsantiago
force-pushed
the
yubikey-hmac-challenge-response
branch
from
September 8, 2026 13:53
0b80b7e to
c6e4901
Compare
Implements ChallengeResponseProvider for YubiKey slot 2 HMAC-SHA1 using raw USB control transfers, the same protocol ykpers and KeePassXC use. Validates the response CRC, zeroes intermediate buffers, waits for a button press where the slot requires one, and can be cancelled while waiting.
kwsantiago
force-pushed
the
yubikey-hmac-challenge-response
branch
from
September 8, 2026 14:01
c6e4901 to
0ec86fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
YubiKeyHmacProvider, implementing drongo'sChallengeResponseProviderwith HMAC-SHA1 challenge-response over the YubiKey OTP HID interface (slot 2).setOnWaitingForTouch/setOnCompletefor UI promptingcancel()interrupts a pending touch waitcom.sparrowwallet.lark.yubikeyinmodule-infoTests
YubiKeyHmacProviderTestcovers the protocol logic without hardware:crc16against the CRC-16/X-25 check value, the device CRC residual and rejection of a corrupted response, and the challenge frame layout including padding, slot byte, CRC placement, filler and truncation of an oversized challenge.The USB transport needs a device and is not covered.
Challenge padding
The challenge is padded to the full 64-byte block with a byte differing from the last challenge byte (
0x00, or0x01where the challenge already ends in0x00), matchingykman. A slot programmed for variable-length challenges (HMAC_LT64, whichykmansets unconditionally) locates the end of the challenge by stripping the trailing padding, so padding with a byte that could be part of the challenge would make the boundary ambiguous.Note this differs from KeePassXC, which uses PKCS7 padding, so responses for the same secret and challenge are not comparable between the two.
Dependents