News for hackers. Stuff that matters.
Re:The getrandom(2) system call was requested by the LibreSS... by agwa on Thursday July 17, 2014 @03:29PM (#8049672)
/dev/urandom never blocks, even if it means returning randomness before the system has gathered enough entropy to safely seed a CSPRNG.

/dev/random blocks whenever the system's "entropy count" is too low, even if the system has previously gathered enough entropy to produce secure randomness. The frequent blocking of /dev/random makes it unsuitable for practical use while providing questionable security benefit.

getrandom() blocks only until the system has gathered enough entropy to safely seed a CSPRNG, and then never blocks again. (Assuming the GRND_BLOCK flag and not the GRND_RANDOM flag.)

An in-depth explanation: http://www.2uo.de/myths-about-urandom/

Re:The getrandom(2) system call was requested by the LibreSS... by tptacek on Thursday July 17, 2014 @03:44PM (#8049754)
I'm not really thrilled with the idea that you should use urandom to seed a CSPRNG; urandom should be your only CSPRNG. This most recent libressl kerfuffle is an illustration of why userspace CSPRNGs are a bad idea.
Re:The getrandom(2) system call was requested by the LibreSS... by agwa on Thursday July 17, 2014 @03:53PM (#8049799)
When I said "seed a CSPRNG" I was talking about the kernel seeding its own CSPRNG. I agree that just using the kernel's CSPRNG is the sanest solution to this mess.
Re:The getrandom(2) system call was requested by the LibreSS... by giovannibajo1 on Friday July 18, 2014 @03:58AM (#8052093)
> I agree that just using the kernel's CSPRNG is the sanest solution to this mess.

well, you agree up to the point you actually need to convert your words into facts, at that point you don't agree anymore :)

https://github.com/AGWA/git-crypt/commit/34432e915e8415b112c...

Re:The getrandom(2) system call was requested by the LibreSS... by agwa on Friday July 18, 2014 @08:04PM (#8056190)
Oh boy, I should have seen this one coming :-)

By "this mess" I meant the LibreSSL fork/chroot mess. I think crypto libraries should just use whatever the OS provides and not try to implement their own CSPRNGs. But git-crypt is a cross-platform application, not a crypto library. Implementing my own cross-platform wrapper around OS CSPRNGs would be decidedly less sane (and more error-prone) than just using the crypto library's CSPRNG, even if I disagree with how the library has done things.

Re:The getrandom(2) system call was requested by the LibreSS... by Terr_ on Thursday July 17, 2014 @07:38PM (#8050874)
I know you said "CS-", but seed-able PRNGs in user-space can be immensely useful in tons of other situations, allowing things to be debugged, replayed, and synchronized.

So even if you convince to use urandom for their crypto needs on *nix platforms, it'll still have to be easy to seed one in userspace if someone really wanted to.

Re:The getrandom(2) system call was requested by the LibreSS... by derefr on Thursday July 17, 2014 @08:16PM (#8051011)
What about a non-global blocks-until-seeded CS-PRNG character device? I.e. you open an rw file descriptor to /dev/csprng, write(2) your seed to it, and then read(2) bytes from it. Open another file descriptor, and you get another CSPRNG that wants a separate seed.

This way, you could, say, somewhat simulate the behaviour of ZeroVM with Docker containers, by having the CSPRNG seed be a configuration parameter passed to `docker run`.

Re:The getrandom(2) system call was requested by the LibreSS... by flaviu1 on Thursday July 17, 2014 @08:33PM (#8051072)
What if you want reproducible random numbers, such as in, I dunno, AES? That limitation would prevent any sort of decrypting things.
Re:The getrandom(2) system call was requested by the LibreSS... by nitrogen on Friday July 18, 2014 @01:57AM (#8051870)
That's not what tptacek means when he says "[user space] CSPRNG", and is more appropriately called a keystream generator, not a CSPRNG, and the input is more appropriately called a key, not a seed.
Re:The getrandom(2) system call was requested by the LibreSS... by sillysaurus3 on Thursday July 17, 2014 @03:44PM (#8049747)
From your link:

/dev/urandom is insecure. Always use /dev/random for cryptographic purposes.

Fact: /dev/urandom is the preferred source of cryptographic randomness on UNIX-like systems.

This seems to contradict your first point, which is that /dev/urandom is insecure in some situations. (Returning randomness without sufficient entropy is a security problem.)

Can urandom ever be used insecurely? Tptacek has said many times that you should just seed /dev/urandom from /dev/random, then never use /dev/random again: http://hn.algolia.com/#!/comment/forever/prefix/0/author%3At...

Is LibreSSL's situation different? If so, why?

Re:The getrandom(2) system call was requested by the LibreSS... by agwa on Thursday July 17, 2014 @03:51PM (#8049790)
Further down, under "Not everything is perfect," the author addresses the problem with /dev/urandom never blocking.

Seeding /dev/urandom from /dev/random is a trick that can be used early in the boot sequence to ensure that /dev/urandom is henceforth secure. (In practice, distros carry over a seed from the previous boot which accomplishes the same effect.)

Re:The getrandom(2) system call was requested by the LibreSS... by derefr on Thursday July 17, 2014 @08:11PM (#8050981)
I know that we need to support old programs that expect these behaviours of these device nodes. However, how about a workaround like "udev only creates /dev/urandom once /dev/random has been seeded"?