How can a deterministic calculation produce hard-to-predict bytes?
Key generation needs bytes that are hard for an outsider to predict. On initialization, HMAC_DRBG incorporates unpredictable input (entropy) into a secret state, then uses that state to generate pseudorandom bytes on request. The same state and inputs give the same output, so known test inputs can help verify the implementation. The entropy source provides the initial unpredictability. NIST SP 800-90A Rev. 1 §10.1.2
How many HMAC calls produce 48 bytes of output?
HMAC_DRBG(SHA-256) keeps a secret key K and a secret value V, each 32 bytes long. At initialization, it starts with K filled with zeros and V filled with 0x01 bytes, then updates both using seed material that includes entropy.
-
Secret state The 32-byte
KandVfrom initialization.Request 48 bytes with no additional input or reseed. - Generate the first block
V₁ = HMAC(K, V) - Generate the second block
V₂ = HMAC(K, V₁) -
Take 48 output bytes Join all 32 bytes of
V₁and the first 16 bytes ofV₂.Advance the secret state Use all 32 bytes ofV₂.- Update the key.
K′ = HMAC(K, V₂ || 0x00) - Update the value with the new key.
V′ = HMAC(K′, V₂)
- Update the key.
- Advance the counters Count one more request. QuantAegis also adds 48 to the byte count since initialization or the last reseed.
- Return 48 bytes The caller gets the selected bytes, and the generator retains
K′andV′for the next request.
This request uses four HMAC calls in total. Two generate the output, one updates K, and one updates V.
The second HMAC computation requires both the preceding output and the secret K. Predicting the rest of the sequence from the returned bytes alone is therefore difficult. How HMAC works
How does reseeding differ from updating the state?
An update computes the new K by applying HMAC under the current K to V || 0x00 || input material. It then uses the new K to update V. If there is input material, it performs another pair of updates using 0x01 as the separator. The generator also advances its state at the end of each request. Requesting 32 bytes and then 16 bytes introduces an intervening state update that changes the final 16 bytes compared with a single 48-byte request.
Reseeding incorporates fresh entropy from an external source. Someone who knows the current state can compute the future sequence through ordinary deterministic updates. Once the total output of HmacDrbgSha256 since initialization or the most recent reseed reaches or exceeds 16 KiB, the next generation request requires a reseed. Ordinary SDK key generation uses the operating system’s randomness source. The Rust API for using this generator directly provides operations to initialize it, generate bytes, and reseed it. Using the random bit generator and its limits · Rust API