Conversation
Bit 0x10 is what OpenSC sets for sc-hsm-tool --require-pka-and-pin, and cmd_initialize stores the options wholesale in EF_DEVOPS. HSM_OPT_COMBINED_AUTH was defined in sc_hsm.h and referenced nowhere else, so the bit was accepted, persisted, and reported back -- sc-hsm-tool prints "Public Key Authentication and PIN verification enforced" from it -- while key access was granted on the quorum alone. Either half of the pair can complete last: the quorum may be reached before the user PIN is verified, or after it. Neither EXTERNAL AUTHENTICATE nor check_pin can decide alone, so both now call hsm_update_user_auth(), which grants access only when the quorum is met and, when the bit is set, a user PIN has been verified in the same session. Measured on Pico 2 / RP2350. Same device, same EF_DEVOPS, same registered key across all three runs; the card reported "PIN verification enforced" throughout. The probe is GENERATE KEY PAIR with an empty body, which checks the flag before parsing, so 6700 (wrong length) means access was granted and 6982 means it was withheld: before, no PIN -> 6700 access granted after, no PIN -> 6982 access withheld after, with PIN -> 6700 access granted
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
Bug fix, security-relevant.
HSM_OPT_COMBINED_AUTH(bit0x10) is defined insc_hsm.hand referencednowhere in the firmware.
cmd_initializestores device options wholesale, sothe bit is accepted and persisted, and OpenSC reads it back and prints
Public Key Authentication and PIN verification enforced.Nothing enforces it. A device initialised with
sc-hsm-tool --require-pka-and-pinreports that PIN verification is required and thengrants full private-key access to the quorum alone, with no PIN presented at
any point.
Details / Impact
fa3fd433.apply. This makes bit
0x10mean what the card already claims it means. Itcannot loosen anything -- when the bit is clear, behaviour is unchanged.
isUserAuthenticatedis granted onlyonce the quorum is met and a user PIN has been verified in the same
session. Because either can complete last,
EXTERNAL AUTHENTICATEandcheck_pinboth re-evaluate through one helper rather than setting the flagdirectly.
Testing
Same device, same
EF_DEVOPS, same registered key; only the firmware differs.Probe is
GENERATE KEY PAIRwith an empty body, which tests the flag beforeparsing anything and cannot create a key:
fa3fd433670069826700The card reported
Public Key Authentication and PIN verification enforcedinall three runs.
Reproducing requires the PKA exchange, which OpenSC cannot perform
(OpenSC/OpenSC#594); I drove it directly over PC/SC. It also requires the curve
fix in my other PR, without which
EXTERNAL AUTHENTICATEfails at6985before this code is reached. The two changes are independent in code -- only
the reproduction needs both.
Anything else?
If enforcing dual control is unwelcome for the AGPLv3 tree, the minimum
acceptable alternative is to reject the option at
INITIALIZErather thanaccept, store and report a control that is not applied.