-
Notifications
You must be signed in to change notification settings - Fork 708
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
Replace use of crypto/rand with more direct use of OS RNG #58
Comments
One problem is that |
I've started a new implementation of It is now possible to explicitly manage when the file handle for Most applications should only have a single implementation of rand::SystemRandom instantiated to avoid the waste of having multiple file descriptors to /dev/urandom open and to avoid the overhead of opening/closing /dev/urandom. That was effectively how BoringSSL works and how ring worked before these changes. However, I didn't implement that because, generally, we shouldn't be using /dev/urandom anyway. Instead, we should be using RDRAND (or equivalents on ARM and other platforms) + PRP (e.g. ChaCha20), or I also dropped the RDRAND+ChaCha20 implementation. So, we should:
As far as the RDRAND + PRP implementation goes: The BoringSSL implementation was kinda-sorta-fork/vm-duplication-safe, but in some ways it actually makes that kind of problem worse. Instead, we should encourage applications to use safer patterns. For example, it seems like applications would be best off using |
Here's the relevant comment from #147:
|
My thoughts:
|
If one doesn't trust
Without agreeing or disagreeing, now the only way we get random numbers if from the OS, so we're good here.
This is being fixed now in Linux kernels after 4.7 (I don't remember the exact version). It is unclear that we have any need for a faster RNG anyway. Would like to see use cases before we worry about it.
Agreed. Anyway, I believe everything actionable here was already done and/or has its own issue. Please file new issues if something has been overlooked. |
Also, thanks for the comments! |
In particular, consider
rand::os::OsRng
. Ifrand::os::OsRng
is insufficient in some way then try to fix it.rand::os::OsRng
is preferable because other Rust code is likely using it, and we can avoid duplicate code. Also, crypto/rand is pretty complicated and has a weird interface. To the extent that that complication is useful, we should implement it as a layer overrand::os::OsRng
.The text was updated successfully, but these errors were encountered: