r/linux • • Mar 01 '22

Linux 5.18 will likely have a blocking /dev/urandom such that calls to the RNG will *always* return secure bytes after initial seeding, which takes no more than 1s after boot. After decades of confusion, all random interfaces will finally be identical.

https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git/commit/?id=2ad310f93ec3d7062bdb73f06743aa56879a0a28
1.5k Upvotes

236 comments sorted by

View all comments

Show parent comments

5

u/bik1230 Mar 02 '22

Random and urandom have both always been based on a CSPRNG, just that random would subtract from the entropy estimate in a way that doesn't really make sense.

Urandom has always been the recommended source of cryptographically secure random numbers, with the caveat that it'll only be secure after enough entropy has been gathered post boot.

This new change ensures that all programs always get fully secure numbers without blocking, except perhaps 1 second of blocking right after boot.

-4

u/LordRybec Mar 02 '22

Um, no? /dev/urandom is unblocking random (that's what the "u" at the beginning means). /dev/random has always been the recommended source of crytopgraphically secure random numbers. This explains where there's so much confusion. People are convinced that the opposite of the truth is correct.

And it doesn't even look like that last statement is true. Based on comments from others (the OP especially), it sounds like they've just made it all unblocking (making random as unsecure as urandom), by never reseeding the PRNG after the initial seeding at boot.

So no, this new change ensures that all programs always get insecure numbers, if what I am hearing is correct. (The OP also says they are still using a 25 year old CSPRNG they started using in 1995, which is another serious red flag in terms of security.) They aren't getting rid of urandom and rolling into random. They've already made random as insecure as urandom, making urandom obsolete, because random no longer blocks when it runs out of entropy, but instead it just keeps running without ever adding entropy, letting security continue to degrade forever, after the first 256 bits are used to seed it at boot.

4

u/bik1230 Mar 02 '22

Um, no? /dev/urandom is unblocking random (that's what the "u" at the beginning means). /dev/random has always been the recommended source of crytopgraphically secure random numbers. This explains where there's so much confusion. People are convinced that the opposite of the truth is correct.

Cryptographers have always recommend urandom. Other people with less understanding have recommended random.

And it doesn't even look like that last statement is true. Based on comments from others (the OP especially), it sounds like they've just made it all unblocking (making random as unsecure as urandom), by never reseeding the PRNG after the initial seeding at boot.

Once it has gathered 256 bits, it's definitely secure. But also, it does still reseed. It just doesn't subtract from the entropy estimate.

So no, this new change ensures that all programs always get insecure numbers, if what I am hearing is correct. (The OP also says they are still using a 25 year old CSPRNG they started using in 1995, which is another serious red flag in terms of security.)

No, OP is saying that they're still using the same overall architecture. Linux used to use MD5, later SHA1, and now a combination of Blake2s and ChaCha20, the former for creating a key for the latter from the entropy pool.

They aren't getting rid of urandom and rolling into random. They've already made random as insecure as urandom, making urandom obsolete, because random no longer blocks when it runs out of entropy, but instead it just keeps running without ever adding entropy, letting security continue to degrade forever, after the first 256 bits are used to seed it at boot.

You can't run out of entropy. Think about it for a second. If we can trust a 256 bit key to encrypt terabytes of data securely, then how can we not trust 256 bits to give us terabytes of random data? With a stream chipher, like ChaCha20 or AES in counter mode, encryption and making random numbers is literally the same operation. If you cannot trust this design decision, you also cannot trust any cryptography in the world, and thus have much bigger problems to worry about.

And as I mentioned above, it will reseed periodically.

-2

u/LordRybec Mar 02 '22

Really, cryptographers? Like me? Because no, I certainly don't! How about these:

https://linuxhint.com/dev_random_vs_dev_urandom/

The main differences between /dev/random, /dev/urandom and /dev/arandom is that /dev/random blocks if the entropy is not indicating sufficient randomness, /dev/urandom does not block ever, even when the pseudo random number generator is not fully seeded when booted and lastly /dev/arandom blocks only when pseudo random number generator is not yet fully seeded.

https://bt4p.com/dev-random-vs-dev-urandom-and-are-they-safe/

In short, /dev/random is the most secure of them all, then comes /dev/arandom and the least secure is /dev/urandom.

There are plenty more where these come from.

You are wrong. You are arguing that you are right, without doing your research. You are part of the problem. You don't know how annoying it is when people on Reddit start thinking they know everything and don't even bother to make sure they are right before shooting on their mouths. This is the reason security is so problematic. "Eight characters with at least one number, one lower case character, one upper case character, and one special character is a secure password." You've heard it all your life. You probably believe it. It's wrong. It's something some place used at some point in time, and everyone just assumed it was secure, and they are all wrong, because some people at some point didn't bother to check if what they had heard was right.

You are saying a lot of stuff I already know, and most of it is completely irrelevant. (This is Reddit, so I don't expect you to believe me, but I'm am actually a cryptography researcher.
I spent two years developing a CSPRNG as part of my Master's Thesis. I have a published paper on that CSPRNG (and several more papers on PRNGs waiting to be submitted for publication and another I am currently working on). And right now, one of my tasks is working on a program to break AES, based on math developed proving it can be done fairly easily, from my boss's PhD thesis. Also, I've been using Linux since the early 2000s, as my primary desktop OS and for developing and serving a number of web applications where security was a high priority and picking the right source for cryptographic keys was critical.) PRNGs, cryptographically secure or otherwise, decrease in quality as more and more values are used. If they aren't periodically reseeded, they will eventually become more predictable than an LCG, one of the lowest quality types of PRNGs. If it reseeds periodically but it doesn't block if it can't reseed, then there will always be an opportunity for something to go wrong that prevents it from reseeding, leading to a situation where too much entropy has been consumed, and the PRNG starts to become predictable. If /dev/random doesn't block if it can't reseed, it is impossible to guarantee that it is secure. And this makes it no better than a non-blocking random source that continues even when the entropy has been depleted. In other words, /dev/random has been reduced to the same quality as /dev/urandom, not the other way around. Sure, modern systems are faster and have better sources of entropy, so the odds of hitting a point where isn't enough entropy is much lower than in the past. But, they've still fundamentally reduced the quality of random to the same as urandom, not the other way around.

And no, we can't trust a 256 bit key to encrypt terabytes of data securely. If you believe that, I've got a bridge and a timeshare you might be interested in. 256 bits is far too few to securely encrypt anywhere near that much data. Just because people do do it, does not mean it actually works the way they claim it does.