Skip to main content

Module hmac_drbg

Module hmac_drbg 

Source
Expand description

NIST SP 800-90A Rev. 1 HMAC_DRBG(SHA-256) with SP 800-90C reseed-budget enforcement.

Implements SP 800-90A Rev. 1 Section 10.1.2 (HMAC_DRBG_Update, HMAC_DRBG_Instantiate, HMAC_DRBG_Reseed, HMAC_DRBG_Generate) and Section 11.3 health-check KATs in pure #![no_std] Rust with zero external dependencies and zero heap allocation.

§SP 800-90A / SP 800-90C Alignment

  • For 256-bit security strength (RBG2), initialization requires at least 384 bits (48 bytes) of min-entropy (HmacDrbgSha256::instantiate_rbg2_in_place) or >= 32 bytes entropy plus a >= 16 byte nonce satisfying SP 800-90A Section 8.6.7 uniqueness/entropy requirements (HmacDrbgSha256::instantiate_in_place).
  • Reseeding requires at least 256 bits (32 bytes) of fresh min-entropy.
  • After emitting 2^17 bits (16,384 bytes) since the last instantiation or reseed, the DRBG returns [Error::DrbgReseedRequired] before any subsequent generate call until reseeded (SP 800-90C §§5.2.3–5.3). A single request crossing the threshold completes (up to MAX_BYTES_PER_REQUEST), and the following generate call requires a reseed first.
  • Zero-byte generate requests follow SP 800-90A §10.1.2.5: they still check preconditions, reseed when prediction resistance is enabled, advance (K, V) via backtracking-resistant Update, and increment reseed_counter.
  • Once [Zeroize::zeroize] is called, the instance transitions to the uninitialized state and rejects all generate, generate_with_prediction_resistance, and reseed calls until explicitly re-instantiated in place.

Structs§

HmacDrbgSha256
NIST SP 800-90A Rev. 1 HMAC_DRBG(SHA-256) state (K, V, counters, lifecycle flag).