Skip to content

Commit fa687be

Browse files
committed
doc: document crypto RNG behaviour across snapshot/checkpoint restore
Signed-off-by: Fuma2514 <fuma2514@users.noreply.github.com>
1 parent ae353ec commit fa687be

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎doc/api/crypto.md‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6181,6 +6181,17 @@ changes:
61816181
Generates cryptographically strong pseudorandom data. The `size` argument
61826182
is a number indicating the number of bytes to generate.
61836183

6184+
> [!NOTE]
6185+
> The random data is drawn from OpenSSL's DRBG inside the process. After a
6186+
> snapshot or checkpoint restore (for example a VM restore, Firecracker
6187+
> snapshot, or CRIU checkpoint), the DRBG continues from the saved state until
6188+
> its next scheduled reseed, and output may repeat across the two continuations
6189+
> of a restored process. Applications resumed from a saved image should reseed
6190+
> (or draw fresh randomness via their own restore signal) before relying on
6191+
> further output from `crypto.randomBytes()`, `crypto.randomInt()`,
6192+
> `crypto.randomFill()`, `crypto.randomUUID()`, and
6193+
> `crypto.getRandomValues()`. See #66880 for measurements.
6194+
61846195
If a `callback` function is provided, the bytes are generated asynchronously
61856196
and the `callback` function is invoked with two arguments: `err` and `buf`.
61866197
If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The
@@ -6594,7 +6605,10 @@ added:
65946605
* Returns: {string}
65956606

65966607
Generates a random [RFC 4122][] version 4 UUID. The UUID is generated using a
6597-
cryptographic pseudorandom number generator.
6608+
cryptographic pseudorandom number generator. Because of the entropy cache,
6609+
after a snapshot or checkpoint restore up to 128 UUIDs may repeat across the
6610+
restored process's continuations unless `disableEntropyCache: true` is used or
6611+
fresh randomness is drawn after the restore.
65986612

65996613
### `crypto.randomUUIDv7([options])`
66006614

0 commit comments

Comments
 (0)