-
Notifications
You must be signed in to change notification settings - Fork 86
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
syscall to set the seed of the random number generator #98
Conversation
stlankes
commented
Sep 11, 2020
- using the core library to create a random number
- removing inline assembly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to hermit-os/hermit-rs#63
unsafe { | ||
llvm_asm!("rdrand $0" : "=r"(value) ::: "volatile"); | ||
unsafe { | ||
if SUPPORTS_RDRAND { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a log message in case we have fall back to pseudo random values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a debug message in src/syscalls/random.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these printed every time a random number is generated? Can we print an info message at startup saying we are using either the hardware random generator or park miller lehmer software random generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge after you have removed the superfluous debug!
src/syscalls/random.rs
Outdated
value | ||
} else { | ||
debug!("Fallback to a software-based random number generator"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have missed this one 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I fixed it
- this function isn't cryptographicly secure - use sys_sys_secure_rand32/sys_secure_rand64 to cryptographicly secure random number
…os#98) * add syscall to set the seed of the pseudo random number generator * use function to create cryptographicly secure random numbers * remove obsolete GitHub Action workflow "build" * add comments to explain the functions