Live data from Hacker News

An Analysis of OpenSSL's Random Number Generator

eprint.iacr.org

21–30 of 37 posts

Re: An Analysis of OpenSSL's Random Number Generator

#21
post #15
post #13

Earlier quoted context omitted.

"/dev/urandom and CryptGenRandom which are known to be good" Check out "A good idea with bad usage: /dev/urandom" : http://insanecoding.blogspot.com/2014/05/a-good-idea-with-ba... Just stumbled onto it in the new submissions queue: https://news.ycombinator.com/item?id=11485876

... I'm not sure I can take an article seriously that suggests "but what if the attacker can modify files in /dev?". In any case, the meaningful concerns from that article have been addressed with the getrandom syscall on Linux, introduced a few months after this article was written: https://lwn.net/Articles/606141/ Perhaps we should start saying "getrandom" / "getentropy" instead of "/dev/urandom", but they're the s…

I forgot about the new getrandom syscall but yes that would be preferred if supported.

Re: An Analysis of OpenSSL's Random Number Generator

#22
post #5
post #4

I can't understand Why OpenSSL continues to use it's own PRNG implimentation when we have /dev/urandom and CryptGenRandom which are known to be good. This is basically what BoringSSL does (although if you have rdrand then it will get filtered through a ChaCha20 instance). I'm pretty sure OpenSSL doesn't even reseed its PRNG on Windows unless the calling application does it so I'm not sure how that's safe either. If y…

I think you mean /dev/random. On unixes, /dev/urandom produces a stream of random bytes that may not have high entropy, while /dev/random will block on reads until there's enough entropy in the pool.

No I definitly mean /dev/urandom[1] or the getrandom syscall which would be equal to /dev/urandom.

[1] http://sockpuppet.org/blog/2014/02/25/safely-generate-random...

Re: An Analysis of OpenSSL's Random Number Generator

#23

Earlier quoted context omitted.

That link appears to confirm cyphar's assertion that /dev/urandom may produce a low-entropy output stream in certain circumstances. > Linux's /dev/urandom happily gives you not-so-random numbers before the kernel even had the chance to gather entropy. When is that? At system start, booting the computer.

The part of this myth is down to what those circumstances are. What's generally accepted is that, early during first boot, urandom still produces 'random' data without enough entropy for it to be sufficiently random. What's a myth is that 'entropy can run out' and somehow a sufficiently seeded CSPRNG needs to block after a few reads while it gathers more entropy. The problem in these discussions is that one, edge cas…

Which is was exactly described in this paper. It's not cargo cult, it's the exact technical explanation what happens when the entropy runs out, while it should be blocking or in the OpenSSL case just use a proper API to avoid the exact same confusion (this is low entropy as with /dev/urandom ) or add more mixing rounds.

The cargo cult you are describing is exactly the cargo cult trap you are falling into.

Re: An Analysis of OpenSSL's Random Number Generator

#24
post #4

I can't understand Why OpenSSL continues to use it's own PRNG implimentation when we have /dev/urandom and CryptGenRandom which are known to be good. This is basically what BoringSSL does (although if you have rdrand then it will get filtered through a ChaCha20 instance). I'm pretty sure OpenSSL doesn't even reseed its PRNG on Windows unless the calling application does it so I'm not sure how that's safe either. If y…

/dev/urandom isn't reliable; it fails in a chroot, if file handles are exhausted, etc.

Re: An Analysis of OpenSSL's Random Number Generator

#25
post #8

I actually have several TB of OpenSSL PRNG output (256 bit len) that I've been analyzing. A fairly modest sample size, but I've come across some interesting patterns at the bit level. It's kind of a pain in the ass to write efficient analytics for a binary 256 bit pattern as a matter of fact.

10^9 out of 10^25 different combinations is a significant sample size? Wouldn't the law of small numbers apply in this case?

Re: An Analysis of OpenSSL's Random Number Generator

#26
post #6

Reminds me of one of my favorite commit logs from the LibreSSL project: "Do not feed RSA private key information to the random subsystem as entropy. It might be fed to a pluggable random subsystem…. What were they thinking?!" http://opensslrampage.org/post/83007010531/well-even-if-time...

that sounds unsafe

A hash of the private key isn't actually bad to use for entropy. It's what's done in deterministic EC signatures, deriving the k value from the private key + message.

Re: An Analysis of OpenSSL's Random Number Generator

#27
post #23

Earlier quoted context omitted.

The part of this myth is down to what those circumstances are. What's generally accepted is that, early during first boot, urandom still produces 'random' data without enough entropy for it to be sufficiently random. What's a myth is that 'entropy can run out' and somehow a sufficiently seeded CSPRNG needs to block after a few reads while it gathers more entropy. The problem in these discussions is that one, edge cas…

Which is was exactly described in this paper. It's not cargo cult, it's the exact technical explanation what happens when the entropy runs out, while it should be blocking or in the OpenSSL case just use a proper API to avoid the exact same confusion (this is low entropy as with /dev/urandom ) or add more mixing rounds. The cargo cult you are describing is exactly the cargo cult trap you are falling into.

Entropy doesn't run out if your CSPRNG is good

Re: An Analysis of OpenSSL's Random Number Generator

#28
post #23

Earlier quoted context omitted.

The part of this myth is down to what those circumstances are. What's generally accepted is that, early during first boot, urandom still produces 'random' data without enough entropy for it to be sufficiently random. What's a myth is that 'entropy can run out' and somehow a sufficiently seeded CSPRNG needs to block after a few reads while it gathers more entropy. The problem in these discussions is that one, edge cas…

Which is was exactly described in this paper. It's not cargo cult, it's the exact technical explanation what happens when the entropy runs out, while it should be blocking or in the OpenSSL case just use a proper API to avoid the exact same confusion (this is low entropy as with /dev/urandom ) or add more mixing rounds. The cargo cult you are describing is exactly the cargo cult trap you are falling into.

Question 4 specifically discusses the point tat entropy does not "run out".

Re: An Analysis of OpenSSL's Random Number Generator

#29
post #4

I can't understand Why OpenSSL continues to use it's own PRNG implimentation when we have /dev/urandom and CryptGenRandom which are known to be good. This is basically what BoringSSL does (although if you have rdrand then it will get filtered through a ChaCha20 instance). I'm pretty sure OpenSSL doesn't even reseed its PRNG on Windows unless the calling application does it so I'm not sure how that's safe either. If y…

Seeding a userspace CSPRNG from /dev/urandom or getrandom(2) is actually the right approach. The kernel pool is a resource shared among all processes, with the locking and therefore scalability constraints that implies.

Re: An Analysis of OpenSSL's Random Number Generator

#30
post #4

I can't understand Why OpenSSL continues to use it's own PRNG implimentation when we have /dev/urandom and CryptGenRandom which are known to be good. This is basically what BoringSSL does (although if you have rdrand then it will get filtered through a ChaCha20 instance). I'm pretty sure OpenSSL doesn't even reseed its PRNG on Windows unless the calling application does it so I'm not sure how that's safe either. If y…

/dev/urandom isn't reliable; it fails in a chroot, if file handles are exhausted, etc.

It fails in a poorly set up chroot, not any old chroot.

It also fails in a poorly set up root file system in the same way. No chroot needed.

I can't remember ever running out of file descriptors unless a program had a leak. But if you want to argue that position too, make sure you mention that cputime and memory could also be exhausted, leading to... well... any other method failing in a similar fashion.

A system call definitely has some minor benefits over a file in /dev, bit the reverse is also true (access from shells, or any language really, with no built in support).

But calling /dev/urandom unreliable is a little bit intellectually dishonest.

Post reply on HN