Skip to content

Conversation

@LiosK
Copy link
Contributor

@LiosK LiosK commented Jun 4, 2023

The BlockRngCore::Results of ChaCha8Core, ChaCha12Core and ChaCha20Core have been Array64<u32> since rand_chacha v0.2.0, and they actually consume up to 63 u32 values before reseeding, but the document currently reads:

When a process is forked on UNIX, the RNGs in both the parent and child processes will be reseeded just before the next call to BlockRngCore::generate, i.e. “soon”. For ChaCha and Hc128 this is a maximum of fifteen u32 values before reseeding.

This comment used to be correct because the BlockRngCore::Results was [u32; 16] in rand_chacha v0.1.

It reads "For ChaCha and Hc128 this is a maximum of fifteen `u32` values before
reseeding" while rand_chacha v0.2.0 or higher actually consumes 63 `u32` values
before reseeding.
@LiosK
Copy link
Contributor Author

LiosK commented Jun 4, 2023

Here is a quick example demonstrating that ChaCha12Core used by ThreadRng requires 63 u32 values before reseeding after a fork call: https://gist.github.com/LiosK/ea424481fb84df162a0afaabe042eedb

Copy link
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the correction.

This is a problem with the code and documentation being in different crates, but I don't see a good alternative here.

@dhardy dhardy merged commit 51d27a9 into rust-random:master Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants