-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
SecureRandom: use getrandom (linux) and /dev/urandom #2959
SecureRandom: use getrandom (linux) and /dev/urandom #2959
Conversation
return buf | ||
end | ||
|
||
ifdef !without_openssl |
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.
Should use {% if !flag?(:without_openssl) %}
already.
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 checked and we don't use the flag?
macro method but ifdef
everywhere in the core/stdlib.
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.
Until bd01fb2 ;)
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.
Damn, it got merged just after I branched!
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.
It sill has some gotchas:
class variable '@@getrandom_available' of SecureRandom must be Bool, not Nil
I can't restrict the class variable to only exist for linux
targets anymore.
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.
Errata: 0.18.7 failed, but master
was capable to compile it.
86a3e7b
to
a985671
Compare
It seems that the CI build fail because |
Bet that's 104c9b9 Time to rebase! ;) |
a985671
to
3f75853
Compare
Rebased to use the |
The implementation follows libsodium's sysrandom implementation, but limited to `getrandom(2)` (linux) and `/dev/urandom` since we don't support the other platforms yet (Windows, OpenBSD) and the `arc4random` functions don't seem safe on FreeBSD (?). closes crystal-lang#2792
3f75853
to
e776bce
Compare
Green :) |
Before merging this please let @waj take a look at this. Thanks! |
# implementation and uses `getrandom` on Linux (when provided by the kernel), | ||
# then tries to read from `/dev/urandom`. | ||
# | ||
# Unlike libsodium, this implementation eventually falls back to using the RNG |
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.
See https://twitter.com/jedisct1/status/750980890340237313:
But why?
@waj bump. I'd love to have this in 0.19 :-) |
I reviewed this and it looks good (plus travis passes). Let's merge. Thank you! |
Woot! |
The implementation follows libsodium's sysrandom implementation, but limited to
getrandom(2)
(linux) and/dev/urandom
since we don't support the other platforms yet (Windows, OpenBSD) and thearc4random
functions don't seem safe on FreeBSD (?).closes #2792