Fix signature counter to improve spec compliance#66
Open
robin-nitrokey wants to merge 7 commits into
Open
Conversation
This ensures that all fields are reset and makes it possible to use a custom reset value that is different than the Default implementation.
Returning the signature counter 0 would indicate that we don’t support signature counters or that a counter error occured.
As described in Requirement 2.3.2 of the Security Requirements v1.5, a signature counter value of zero indicates an error. If the authenticator returns zero once, it may not return a non-zero value in subsequent calls, so we have to stay in the error state if an overflow occurs.
As defined in Requirement 2.3.2 of the Security Requirements v1.5, we have to use a random (positive) increment for a global signature counter. This patch uses a random u8 + 1. As the signature counter is a u32, this still gives us more than 16 million operations until the counter can potentially overflow.
239e084 to
92f3642
Compare
0x0ece
approved these changes
May 31, 2026
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.
The current signature counter implementation has three major problems: it starts at zero, it always increments the counter by 1 and it does not handle overflows. But Requirement 2.3.2 of the FIDO Security Requirements v1.5 requires that zero is only used to indicate missing support for signature counters or an error state, that a global signature counter is incremented by a random non-zero value to increase privacy and that the counter does not overflow.
This PR changes the signature counter implementation to accommodate these requirements. The increment is set to
1 + 0..255. As the counter is au32, this still leaves us more than 16 million operations in the worst case until the counter overflows.