Skip to content

Const time equal params order#1028

Open
Chenjp wants to merge 2 commits into
apache:mainfrom
Chenjp:ConstTimeEqualParams
Open

Const time equal params order#1028
Chenjp wants to merge 2 commits into
apache:mainfrom
Chenjp:ConstTimeEqualParams

Conversation

@Chenjp

@Chenjp Chenjp commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Ensure the first one is from server-side, and the 2nd is came from user input.

Chenjp added 2 commits June 26, 2026 11:42
Ensure the server-side confidential was placed as the 1st parameter - align with digesta of MessageDigest.isEqual
@markt-asf

Copy link
Copy Markdown
Contributor

Please provide a justification for this change.

@ChristopherSchultz

Copy link
Copy Markdown
Contributor

I actually had this backward in my mind, thinking that user-input-first was better because it would mean that runtime is based upon the user's input, which they already know and wouldn't learn anything about the secret. But I think that constant-time across calls is actually better, where regardless of the user-input, the comparison always takes the same amount of time.

It also means that the attacker can't send unreasonably-large values and cause equals() to run longer than necessary.

@markt-asf

Copy link
Copy Markdown
Contributor

You could argue it either way. I think, on balance, time based on user input is marginally lower risk (assuming sensible per request limits).

I'm not seeing a strong argument in favour of either approach which for me suggests retaining the status quo.

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.

3 participants