Skip to content

use constant-time comparison for srp-6a evidence messages - #2406

Closed
rootvector2 wants to merge 1 commit into
bcgit:mainfrom
rootvector2:srp-evidence-constant-time
Closed

use constant-time comparison for srp-6a evidence messages#2406
rootvector2 wants to merge 1 commit into
bcgit:mainfrom
rootvector2:srp-evidence-constant-time

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

SRP6Server.verifyClientEvidenceMessage and SRP6Client.verifyServerEvidenceMessage check the peer's evidence message (M1/M2, a keyed authenticator derived from the shared secret S) with BigInteger.equals, which walks the magnitude words and returns at the first difference, so the compare time depends on how many leading bytes match a value the unauthenticated peer is trying to guess. Switched both to Arrays.constantTimeAreEqual over the fixed encodings, matching the sibling JPAKEUtil MacTag check, in the lightweight crypto.agreement.srp package and the BCTLS tls.crypto.impl.jcajce.srp copies. Found while auditing the SRP path after the recent createBlindedExponent modPow hardening in these same classes; the accept/reject result is unchanged and SRP6Test now covers the evidence-verification path.

@dghgit dghgit self-assigned this Aug 27, 2026
@dghgit

dghgit commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR. Now merged and up on https://www.bouncycastle.org/betas code should sync up here shortly.

@dghgit dghgit closed this Aug 28, 2026
hubot pushed a commit that referenced this pull request Aug 28, 2026
…t time over fixed-width encodings rather than with BigInteger.equals, keeping each expected value in the digest's own output form so its length cannot vary with the secret, and sign-extending the J-PAKE tag, which is read signed, incorporating github PR #2406, relates to github #2406.
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