Skip to content

rdrand: Remove checking for 0 and !0 and instead check CPU family and do a self-test - #335

Merged
josephlr merged 6 commits into
masterfrom
rdrand
Feb 9, 2023
Merged

rdrand: Remove checking for 0 and !0 and instead check CPU family and do a self-test#335
josephlr merged 6 commits into
masterfrom
rdrand

Conversation

@josephlr

@josephlrjosephlr commented Feb 2, 2023

Copy link
Copy Markdown
Member

Fixes#228

This is essentially the plan discussed in #228 (comment)

I changed the rdrand function to return Option<u64> as that makes reusing it in the self-test much nicer.

The main complexity here comes from:

There are also some minor commits which:

Comment threadsrc/rdrand.rs Outdated
Comment threadsrc/rdrand.rs Outdated
The flag name is +rdrand not +rdrnd
Signed-off-by: Joe Richey <joerichey@google.com>
Also makes rdrand() return an integer instead of an array of bytes. This
will make the self-test implementation easier. As we can just return a
`usize` we no longer need the `WORD_SIZE` constant.
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
We could use core::usize::MAX, but that is deprecated.
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 8e46d0c into masterFeb 9, 2023
@josephlr
josephlr deleted the rdrand branch February 9, 2023 00:24
@newpavlovnewpavlov mentioned this pull request Apr 2, 2023
takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
rdrand: Remove checking for 0 and !0 and instead check CPU family and do a self-test
Sign up for freeto 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.

RDRAND-based output is (too) biased

2 participants

@josephlr@newpavlov