Skip to content

Add set_reseed_interval to support tighter reseed cadences (#1523)#1541

Open
Arul-Sujith wants to merge 2 commits into
celabshq:mainfrom
Arul-Sujith:fix-reseed-interval
Open

Add set_reseed_interval to support tighter reseed cadences (#1523)#1541
Arul-Sujith wants to merge 2 commits into
celabshq:mainfrom
Arul-Sujith:fix-reseed-interval

Conversation

@Arul-Sujith

Copy link
Copy Markdown
Contributor

This PR adds support for configuring a custom reseed interval in libcrux-hmac-drbg, directly addressing the feature request in issue #1523. It enables consumers to enforce a tighter, application-defined reseed cadence (e.g., reseeding from the OS every N bytes) as a defense-in-depth measure, independent of the DRBG's default global interval.

Changes

  • Per-Instance Configuration: Expanded HmacDrbg state to maintain a local reseed_interval, which defaults to the SP 800-90A maximum (1 << 48).
  • New Setters: Added pub fn set_reseed_interval(&mut self, interval: u64) to HmacDrbg and the rand-featured HmacDrbgRng wrapper.
  • NIST Compliance (Clamping): The setter strictly bounds the input to the global RESEED_INTERVAL. A custom interval can force earlier reseeding, but it can never exceed the maximum interval allowed by the spec.
  • Dynamic Logic: Updated the internal bounds checks in generate() and needs_reseed() to utilize self.reseed_interval.
  • Hax Proofs: Updated the F* preconditions/postconditions to correctly target self.reseed_interval in place of the global constant, ensuring proofs remain sound.
  • Testing: Added explicit test coverage (custom_reseed_interval and custom_reseed_interval_clamping) inside src/tests.rs to verify the early reseed triggering and the hard-cap logic.

Fixes #1523

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.

hmac-drbg: allow configuring the reseed interval

1 participant