From fa687be068883f3d0934cd92a17d0121c75ac7a2 Mon Sep 17 00:00:00 2001 From: Fuma2514 Date: Sun, 8 Nov 2026 17:50:34 +0800 Subject: [PATCH] doc: document crypto RNG behaviour across snapshot/checkpoint restore Signed-off-by: Fuma2514 --- doc/api/crypto.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index b14c4876884f..50c549318219 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -6181,6 +6181,17 @@ changes: Generates cryptographically strong pseudorandom data. The `size` argument is a number indicating the number of bytes to generate. +> [!NOTE] +> The random data is drawn from OpenSSL's DRBG inside the process. After a +> snapshot or checkpoint restore (for example a VM restore, Firecracker +> snapshot, or CRIU checkpoint), the DRBG continues from the saved state until +> its next scheduled reseed, and output may repeat across the two continuations +> of a restored process. Applications resumed from a saved image should reseed +> (or draw fresh randomness via their own restore signal) before relying on +> further output from `crypto.randomBytes()`, `crypto.randomInt()`, +> `crypto.randomFill()`, `crypto.randomUUID()`, and +> `crypto.getRandomValues()`. See #66880 for measurements. + If a `callback` function is provided, the bytes are generated asynchronously and the `callback` function is invoked with two arguments: `err` and `buf`. If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The @@ -6594,7 +6605,10 @@ added: * Returns: {string} Generates a random [RFC 4122][] version 4 UUID. The UUID is generated using a -cryptographic pseudorandom number generator. +cryptographic pseudorandom number generator. Because of the entropy cache, +after a snapshot or checkpoint restore up to 128 UUIDs may repeat across the +restored process's continuations unless `disableEntropyCache: true` is used or +fresh randomness is drawn after the restore. ### `crypto.randomUUIDv7([options])`