Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden constant-time equality on arrays and slices #120

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

AaronFeickert
Copy link
Contributor

@AaronFeickert AaronFeickert commented Feb 12, 2024

The current implementation of ConstantTimeEquality for arrays and slices will short-circuit if the lengths are different. This PR does a constant-time length check before the componentwise check, and then uses a constant-time BitAnd for the final result.

This still strikes me as controversial, since both the existing implementation and this update leak something about length:

  • The existing implementation leaks if the slices/arrays have different lengths, as well as the length itself via timing.
  • The updated implementation leaks only the length via timing.

This seems like at worst no improvement, and at best a reasonable improvement.

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.

1 participant