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

Add additional, sharper tests for checking RNG quality #304

Merged
merged 3 commits into from
Oct 22, 2022
Merged

Conversation

josephlr
Copy link
Member

This PR adds some tests which make sure calls to getrandom (for both small and large buffers) "look" random.

While we could certainly add more complicated randomness tests, these simple tests are:

  • Very easy to understand
  • Don't require any external crates
  • Makes sure we aren't doing something obviously stupid like
    • forgetting these lines
    • failing to initialize every other byte
    • initializing some significant fraction of bytes with a constant

As this tests all buffer sizes from 1 to 64, it also fixes #290.

@josephlr josephlr requested a review from newpavlov October 22, 2022 10:12
We can be much stricter without risking inadvertant failure.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr merged commit 2ec38ad into master Oct 22, 2022
@josephlr josephlr deleted the rng_tests branch October 22, 2022 21:21
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.

All test cases use buffers that are multiples of the word size
2 participants