Skip to content

Conversation

@radik878
Copy link
Contributor

The update_n() implementation propagated carry only through limbs 1..6, effectively making n a 448-bit counter. According to GOST R 34.11-2012 (RFC 6986), the total processed bit-length must be tracked modulo 2^512. This change extends the loop to include limb 7 so carry ripples through all eight 64-bit words and any further carry is discarded, thus restoring correct modulo 2^512 semantics. Although this bug only manifests for astronomically large inputs, it is a correctness issue and brings the implementation in line with the specification and the behavior of similar counters in this codebase.

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I wonder why 1..7 was used initially.

Thank you for noticing this!

@newpavlov newpavlov merged commit 401887a into RustCrypto:master Nov 26, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants