4 ms·
That, and the article, seems like sort of a tangent though. In practice, /dev/urandom advocacy has won for almost all apps. That's what everything uses, and i
by ajross 7y ago
That, and the article, seems like sort of a tangent though. In practice, /dev/urandom advocacy has won for almost all apps. That's what everything uses, and it meets the requirements desired by you and Pornin AFAICT. People who want crypto-backed non-blocking kernel RNGs have a very high quality one in linux. Most of this is just an argument about defaults, whether "/dev/random" should be non-blocking by default and whether it should be renamed to something else.
The more interesting question, and one I think is very poorly served by this article, is whether or not Linux's entropy pool engine is a useful feature or not (and tangentially whether or not we should trust RDRAND). And... I mean, in a world where we have known backdoors in both hardware and crypto algorithms, it seems like having a system that defaults to not trusting them might not be the worst thing...
Basically, this argument seems really fragile to me. All it takes is one paper showing a likely backdoor in RDRAND and everyone is going to be laughing like crazy at what-in-hindsight-would-seem the ridiculous naivete in this article.
- tptacek 7y agoThe point of this article is not that we should exclusively trust RDRAND.
- ajross 7y agoNo, but that's the focal argument that IMHO makes it fragile. Again I repeat the point: if tomorrow someone published a paper showing evidence of a backdoor in RDRAND, would you still cite this article as good advice? The point of the article is that the Linux entropy architecture is bad, mostly because it's over-engineered and unnecessary (and that it's the default, I guess). Which only makes sense in a world where we can trust our PRNG entropy sources and the algorithms used to generate the stream. And there is an uncomfortable amount of actual evidence that that is not the world we live in.
- xenadu02 7y agoA Cryptographically Secure Random Number Generator relies on cryptography being correct and not breakable in a useful amount of time. If that doesn’t hold what in the world are you using the random numbers for?? If it does hold then the whole idea of an “entropy pool” is useless cruft. Think of it this way: AES has to look like random noise. If there is any correlation to the input detectable by someone without the key it would be useless for crypto. A CSRNG isn’t quite the same thing but you can think of it the same way: it only needs some initial entropy, just like AES needs a key. Thereafter it must be able to generate random bytes faster than they could possibly be consumed (TB/s or more) without disclosing any information about its internal state or it is a useless CSRNG whether the entropy pool exists or not.
- ajross 7y ago> AES has to look like random noise. If there is any correlation to the input detectable by someone without the key it would be useless for crypto. Uh... AES (to pick your particular example) is a symmetric algorithm. By definition there is a 1:1 correlation to the input. If you have the key and know the input you can compute the output, and vice versa. The question at hand is not whether the algorithm is breakable but whether someone can find the key (or more generally the PRNG state). And that's what the entropy pool does: it seeds the PRNG state with values that are derived at runtime by the kernel and not under the control of an attacker, even one embedded in the system. There are side arguments about whether the entropy pool's estimates are good ones, about whether it should block by default when empty, etc... But I don't see any reasonable arguments that this isn't a useful feature for an OS kernel to provide.
- dependenttypes 7y ago> By definition there is a 1:1 correlation to the input But it is still not detectable without the key.
- tytso 7y agoYou still need some way to securely seed a CSRNG. That's what we use the entropy pool for in Linux. The idea is that we mix multiple sources, and hopefully at least one can't be guessed by a particular attacker. For example, you might use three hardware random number generators; one might be compromised by the Chinese MSS, and one might be compromised by the KGB, and the third might be compromised by the NSA --- but hopefully they won't be all compromised, and even if they are, hopefully they aren't working together. Or maybe we're mixing randomness from the UEFI and the TPM. Neither can be audited, and we know that many firmware engieners are incompentent. But hopefully, if the UEFI BIOS has some terrible bug, or can be remotely compromised because Intel snuck in a Minux OS with a web server without telling us in their CPU's, maybe the TPM provider didn't make a similar mistake.
- clarry 7y ago> In practice, /dev/urandom advocacy has won for almost all apps. Which is a shame, because the thing that should've won is arc4random_buf or something similar that always works (empty chroot with no /dev/ under it, isolated user with no read access to anything on the filesystem, and no free file descriptors? still works!) and can't give an error.
- acqq 7y agogetrandom should be used: https://lwn.net/Articles/606141/ https://lwn.net/Articles/606141/ for most user code it's already good enough, the breakage happened in some early use cases: https://lwn.net/Articles/800509/ https://lwn.net/Articles/800509/
- ajross 7y agoFor clarity: I'm using "/dev/urandom" as shorthand for "the non-blocking interface to the kernel entropy pool" and not the literal device node interface. As others have pointed out there is a syscall to get that for you if you can't use the device.
- tytso 7y agoTo be completely correct: On modern kernels, /dev/urandom is not an interface to the kernel entropy pool. It is rather a ChaCha20 Cryptographic Random Number Generator which is periodically seeded from the kernel entropy pool. getrandom(2) uses the same ChaCha20-based CRNG. The main advantage is that it doesn't require that you be able to open a file descriptor. (There were some obscure attacks on some userspace where the attacker would exhaust the number of file descriptors, and the sloppy userspace code wasn't checking error returns, and so it wasn't actually reading from /dev/urandom. Getrandom(2) is supposed to be foolproof --- which is hard, given how ingenious fools can be, but at least it's harder to screw up using getrandom(2). It also works in the completely empty chroot scenario referenced in the grandparent of this post.