-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
Make unpredictableSeed
use getrandom
(syscall) on Linux
#10623
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @0xEAB! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#10623" |
That function needs a warning. It is possible that the kernel may not have enough entropy stored to give a value. You want to call it sparingly and only after the system has been booted fully. |
I don’t think this is accurate.
And also:
|
Yes, during booting it may be empty. Once initialized the chance of it to be empty depends upon if it has been misused. In any case, a warning is needed ;) |
6fc083d
to
e1ace22
Compare
e1ace22
to
20b2d00
Compare
@rikkimax
|
20b2d00
to
83cb01f
Compare
You have gone above and beyond what I was wanting! Good job. |
std/random.d
Outdated
/** | ||
A "good" seed for initializing random number engines. Initializing | ||
with $(D_PARAM unpredictableSeed) makes engines generate different | ||
random number sequences every run. | ||
|
||
This function utilizes the system (CS-)PRNG where available and implemented |
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.
Use "(cryptographically secure) pseudo-random number generator" and introduce the acronym, and then use it throughout (rather than using the acronym first, and then spelling it out later).
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.
Updated to:
This function utilizes the system cryptographically-secure pseudo-random
number generator (CSPRNG) or pseudo-random number generator (PRNG)
where available and implemented (currentlyarc4random
on applicable BSD
systems orgetrandom
on Linux) to generate “high quality” pseudo-random
numbers – if possible.
83cb01f
to
d7c61f3
Compare
This patch changes
unpredictableSeed
to use thegetrandom
syscall on Linux.Currently,
unpredictableSeed
callsarc4random()
on applicable BSD systems;for everything else it executes
RDRAND
onInlineAsm_X86_Any
-compatible targets or falls back to a homebrew solution.