Moving Ephemeral Key Exchange from ECDH to Hybrid ML-KEM Without Losing Availability
Generating an ML-KEM keypair consumes two independent seeds, d and z, and each one must come from an approved random bit generator. This is where most migrations from an ECDH stack seeded by an operating system pool break down. The KEM math is the easy part. The real budget goes into the entropy path, how the seeds are stored and wiped from memory, and what the system does when one of those layers fails at 3 a.m.
What the old stack was hiding
An X25519 deployment usually takes 32 bytes from the kernel pool, clamps them and moves on, so nobody had to reason about where those bytes came from or how long they stayed in memory. ML-KEM key generation spells this out. The seed d goes through SHA3-512 to produce the public matrix seed and the noise seed, the matrix is sampled with SHAKE128, the secret and error vectors come from a SHAKE256 PRF, and z is held back for implicit rejection during decapsulation. Each seed is 32 bytes, and they must be drawn separately: if z is derived from d, or reused across keys, the implicit rejection defence turns into an oracle an attacker can query. For the budget this means the work moves away from the cryptography team and onto whoever owns the entropy source and the memory model, and that is a different line item. You pay to make an implicit dependency explicit, and what you get back is a keygen path an auditor can actually trace end to end.
Entropy that fails loudly
The failure mode that matters is a hardware TRNG that drifts or sticks while the continuous health tests in NIST's entropy-source and DRBG guidance are running, so the repetition or proportion checks trip and the conditioner stops releasing output. A naive integration ties keygen straight to the TRNG, and every handshake stalls the moment the source goes quiet. The design that stays up puts an approved DRBG between the two, seeds it from the TRNG, reseeds it on a schedule, and keeps serving (d, z) from DRBG output for a bounded window after a health failure while raising an alarm. Use this decision rule: if the entropy source and the DRBG do not sit inside the same validated boundary, or the DRBG cannot prove when it last reseeded successfully, fail closed and refuse keygen. If both conditions hold, degrade gracefully and page someone. The cost of that DRBG layer is state that has to be protected and scrubbed, and in exchange a sensor fault no longer becomes an outage.
Where the migration hurts
Hybrid X25519 plus ML-KEM is what keeps confidentiality intact if either component turns out to be broken, but it inflates the handshake by something on the order of one to two kilobytes (an estimate that depends on the parameter set), and that is enough to split a ClientHello across packets and expose middleboxes that never expected fragmentation. Budget for a period of measurement in which handshake failures are logged by network path before anything is enforced, because the breakage shows up as dropped connections that look like flaky clients, not as cryptographic errors. The second pain point is zero-trace memory. Seeds, the expanded decapsulation key and the intermediate polynomial vectors all have to be overwritten once you are done with them, and garbage-collected runtimes copy buffers in ways you cannot control, so in practice the sensitive path ends up in a native module with explicit wiping and locked pages. Our estimate is that the scrubbing audit will take more engineering time than the KEM integration itself. Storing only the 64-byte seed pair and regenerating the expanded key when it is needed cuts down what has to be wiped, and costs one keygen worth of latency on every reload.
Ephemeral keys do not need persistence at all, so keep the seed storage question for long-lived static keys and let ephemeral (d, z) live only in locked memory for the duration of one handshake.
Technical FAQ: Can we keep the kernel pool and skip the dedicated TRNG?
Yes, if the kernel's generator sits inside your validation boundary and you can show it reseeds from a health-tested source. If you cannot show that, you are relying on an entropy path you cannot audit for every post-quantum key you issue, and the money saved on hardware comes back as audit risk.