News for hackers. Stuff that matters.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by yarou on Tuesday May 03, 2016 @08:51PM (#11625414)
I've used Mersenne Twister[0] in the past.

[0] http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

If you're talking about an RNG library for cryptographic purposes, then it depends on your use case.

Re:Ruby Bug: SecureRandom should try /dev/urandom first by tptacek on Tuesday May 03, 2016 @09:59PM (#11625645)
It does not depend on your use case. The answer, in all cases, is just to use /dev/urandom.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by sibrahim on Tuesday May 03, 2016 @10:19PM (#11625711)
I had a rather specialized case where it was the pragmatic choice (note, not technically required): running a lottery with potentially litigious losers.

If you used a CSPRNG with a seed space smaller than the set of possible lottery outcomes, losers could argue (misleadingly, since we still couldn't feasibly bias the result) that not all outcomes were equally probable and try to get the results thrown out. That is, the fact that there are widespread misconceptions about /dev/random can very rarely be a reason to use it :P

However, I agree that the rule is that you should just use /dev/urandom.

Re:Ruby Bug: SecureRandom should try /dev/urandom first by Thiez on Wednesday May 04, 2016 @02:14AM (#11626560)
Why not use a hardware rng in that case? Seems a lot safer if you have to deal with litigious people.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by sibrahim on Wednesday May 04, 2016 @09:49AM (#11628300)
We did, in a way. One of the sources used was random.org (uses radio receivers tuned to static from atmospheric noise: hardware RNG as a service). I also had less than 3 weeks to take it from proposal to production.

Combining two independent sources obtained by different people and using a cryptographic commitment scheme ensured that 1) no one person could fix the results or make it nonrandom (protection against Eddie Tipton-style attacks), 2) if at least one of the independent sources was random, the result would be.

Re:Ruby Bug: SecureRandom should try /dev/urandom first by netheril96 on Tuesday May 03, 2016 @10:38PM (#11625790)
Then what CSPRNG do you use? Any that has seeds larger than 256-bit?
Re:Ruby Bug: SecureRandom should try /dev/urandom first by sibrahim on Tuesday May 03, 2016 @11:26PM (#11625941)
Anything that reseeds during operation can qualify. In fact, if the CSPRNG's internal state isn't large enough, you need to periodically reseed or face the same objection.

But a CSPRNG which you need to explicitly seed with random bits as big as your output isn't providing much value (simply whitening) since generating the seed is the same problem you had before adding the CSPRNG. So you end up looking at a TRNG.

Re:Ruby Bug: SecureRandom should try /dev/urandom first by lmm on Wednesday May 04, 2016 @07:01AM (#11627477)
Are there not cases where blocking if there is insufficient entropy is the correct thing to do? Particularly if we're talking about important random numbers like long-lived private keys.
Re:Ruby Bug: SecureRandom should try /dev/urandom first by kevhito on Wednesday May 04, 2016 @10:12AM (#11628462)
Re:Ruby Bug: SecureRandom should try /dev/urandom first by lmm on Wednesday May 04, 2016 @10:33AM (#11628617)
It must be possible for a computer to simply not have an adequate supply of randomness though, no? Sure, urandom will use hardware sources of randomness if they're available - but what if they're not?
Re:Ruby Bug: SecureRandom should try /dev/urandom first by tptacek on Wednesday May 04, 2016 @11:33AM (#11629058)
No, this is a misconception. Once the LRNG is seeded, it can generate a more or less unbounded amount of high-quality random bytes from that seed. Entropy can't be "depleted".
Re:Ruby Bug: SecureRandom should try /dev/urandom first by lmm on Thursday May 05, 2016 @03:49AM (#11634559)
Then how can a 4096-byte key be meaningfully safer than a 1024-byte key? Couldn't you just use the 1024-byte key to seed a RNG, generate a 4096-byte key from that, and have 4096-byte safety?

(Also what if the linux RNG isn't seeded e.g. in a VM scenario? Or is the answer just "don't do that"?)

Re:Ruby Bug: SecureRandom should try /dev/urandom first by PeCaN on Wednesday May 04, 2016 @01:48AM (#11626486)
mt19937 (or preferably SFMT¹) is a great library (and fine for cryptographic purposes if you have a sufficiently random entropy source with which to seed it, and reseed it frequently from your entropy source), but you still have to seed it somehow which is where /dev/(u)random comes in. So it really doesn't solve anything.

--

¹ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.h...

Re:Ruby Bug: SecureRandom should try /dev/urandom first by 0x0 on Wednesday May 04, 2016 @01:00AM (#11626299)
Have you seen the php mt_rand cracker?

http://www.openwall.com/php_mt_seed/

Re:Ruby Bug: SecureRandom should try /dev/urandom first by viraptor on Tuesday May 03, 2016 @08:59PM (#11625446)
That one needs manual seeding too, which may lead to more issues.