Skip to content

fix: use subtle for constant-time comparison#784

Open
nanookclaw wants to merge 1 commit into
cloudflare:mainfrom
nanookclaw:fix/use-subtle-constant-time
Open

fix: use subtle for constant-time comparison#784
nanookclaw wants to merge 1 commit into
cloudflare:mainfrom
nanookclaw:fix/use-subtle-constant-time

Conversation

@nanookclaw
Copy link
Copy Markdown

Summary

Replace Daphne's hand-rolled constant_time_eq() helper with subtle::ConstantTimeEq, which is already available through the workspace and daphne crate dependencies. The public helper keeps the same &[u8] -> bool API, so existing bearer-token and request-body comparison call sites do not need to change.

This also addresses the related Prio3 count TODO by converting valid count measurements to bool with ConstantTimeEq before sharding. Non-binary count measurements still follow the existing rejection path.

Tests

  • cargo fmt --check
  • cargo test -p daphne constant_time_eq_matches_slice_equality
  • cargo test -p daphne count_rejects_non_binary_measurement
  • cargo test -p daphne --lib
  • git diff --check

Closes #247.

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.

Use subtle for constant-time compare

1 participant