Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReseedingRng: fix doc comment on reseeding behavior after UNIX fork #1317

Merged
merged 1 commit into from
Jun 4, 2023
Merged

ReseedingRng: fix doc comment on reseeding behavior after UNIX fork #1317

merged 1 commit into from
Jun 4, 2023

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
9 of 12 checks passed
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.

None yet

2 participants