News for hackers. Stuff that matters.
Re:USB Random Number Generator by dspillett on Monday September 30, 2013 @09:34AM (#6469499)
Rolling your own random number generator should be considered the same as rolling your own crypto: by all means have a play in order to help understand the concepts, but unless you are an expert in the relevant mathematics+electronics don't every use your own in production.

Designing a reliably fair and balanced RNG is not as easy a task as it may seem at first glance.

For those wanting a cheap HWRNG, a growing number of CPUs include them now. The SoC around which the rPi is based includes one that in my tests reliably pumps out 550+kbit/sec and passes the test I've thrown its output at - getting at it is easy so you just need a secure+reliable method for passing the bits to where you need them. Newer Intel chips also include a HWRNG, though I don't know if is as easy to expose (with the rPi just enable the relevant kernel module and read from /dev/hwrng).

[I did add notes on this to the "comparison of random number generators" page on Wikipedia but "User:Trinitresque" deemed the info not worthy and reverted the lot, I disagree of course but my day job and other commitments don't allow time for arguing the toss with Wikipedia editors!]

Re:USB Random Number Generator by Osmium on Monday September 30, 2013 @10:33AM (#6469801)
> Rolling your own random number generator should be considered the same as rolling your own crypto: by all means have a play in order to help understand the concepts, but unless you are an expert in the relevant mathematics+electronics don't every use your own in production.

I'm not sure it's quite as bad as rolling your own crypto. If you have a RNG you can run it through statistical tests, e.g. NIST's DIEHARD tests. If you know the physical principles on which your device works, I can't imagine a scenario where you'd be getting randomly-distributed bits that aren't actually random. And if you add those bits to your system's entropy pool, rather than using them directly, then it should be fine. That said, I agree that you still shouldn't use it in a production environment!

Your suggestion for e.g. the RPi RNG is problematic because (last I checked) there wasn't information online about how that actually works. For RNGs, I'd much prefer trusting my own design than a black box which could be outputting an AES-encoded string of all 0s for all I know!

Re:USB Random Number Generator by mistercow on Monday September 30, 2013 @10:40AM (#6469845)
>That said, I agree that you still shouldn't use it in a production environment!

I wonder though. There's a possibility that you'll screw something up and miss it during testing, but I've also seen some scary analyses of expensive off the shelf RNG hardware.

I'd say that if you're in a position of highly restricted capital that requires generation of tons and tons of secure random numbers, the ugly truth is that an open source DIY solution for generating your own entropy (especially if you can use multiple designs that are separately tested) might be safer than dumping your limited resources on proprietary unknowns.

Re:USB Random Number Generator by oakwhiz on Monday September 30, 2013 @12:39PM (#6470573)
Many crypto algorithms depend on good random numbers. Even if generating a key using a poor RNG is not a problem, some protocols create nonces which must be randomly selected or the security of the algorithm is greatly compromised.

I'm not totally sure as to which algorithms fit this definition but some suggestions might be DSA/ECDSA, Diffie-Hellman, SRP, etc.

Re:USB Random Number Generator by mistercow on Monday September 30, 2013 @10:30AM (#6469787)
You certainly shouldn't use its output directly, but as I understand it, if you were to push the output into the OS's entropy pool, it will get automatically whitened, combined with other entropy, and fed into something like Yarrow.

The end result should almost certainly be at least as secure as the default entropy sources of keyboard timing, hard drive read/write latency, etc. If you're using a lot of random numbers, then /dev/urandom would become far more secure, and /dev/random would become far faster, since the entropy pool wouldn't drain as quickly.

Re:USB Random Number Generator by nwh on Monday September 30, 2013 @12:05PM (#6470327)
That's just it really. On its own ou wouldn't trust it, but mixed in with /dev/random can't hurt. XOR random bytes with a constant stream and it's still just as random.
Re:USB Random Number Generator by raverbashing on Monday September 30, 2013 @10:16AM (#6469716)
> Rolling your own random number generator should be considered the same as rolling your own crypto

Yes. However, running your own entropy generator looks ok to me (which is then fed to a random number generator)

Unless your entropy generator is only generating "nothing" this shouldn't be a problem beyond possible attacks to reading of the data

Re:USB Random Number Generator by mistercow on Monday September 30, 2013 @10:35AM (#6469818)
That's not quite true, but I think it should hold for this in particular. Some other counterexamples besides "nothing" would be if it generated a regular pattern like "101010101" or if it picked up some kind of mostly predictable input, like a radio station or GPS data. You definitely don't want to dilute your entropy pool with something that can be predicted.
Re:USB Random Number Generator by mikeash on Monday September 30, 2013 @11:44AM (#6470180)
Is "dilute" really what happens? I'm not an expert on this, but my understanding was that you cannot do any harm by feeding predictable data into your entropy pool. The absolute worst case is no improvement over what you had before. In other words, keyboard/mouse/HD/IO/etc. timings plus GPS data is at least no LESS secure than just keyboard/mouse/HD/IO/etc. timings. Is that wrong?
Re:USB Random Number Generator by Ellipsis753 on Monday September 30, 2013 @12:37PM (#6470548)
You're correct. You can't dilute it by adding anything to the pool. However if you also increase the amount of entropy that the system thinks is in the pool this can cause issues. The system keeps a log of the amount of entropy that it thinks the pool has. This is reduced when in some cases for example when urandom is used. When the entropy remaining runs out urandom will have to wait for more. You can specifically tell the system "I've added lots of entropy" and then urandom will not stall but may make some not-very-random random numbers. So adding to the pool is a good thing but don't tell the system it has more entropy and don't expect to get random numbers faster.
Re:USB Random Number Generator by mistercow on Monday September 30, 2013 @07:51PM (#6473099)
That is what I meant by "dilute", yes. Not a perfect metaphor, I guess. In point of fact, only /dev/random would be affected by that. /dev/urandom does not stall when it runs out of entropy; it just reuses the entropy in the pool and hopes for the best.
Re:USB Random Number Generator by Ellipsis753 on Tuesday October 01, 2013 @12:52PM (#6477355)
OOps, You're quite right. I got urandom and random the mixed up in my head.
Re:USB Random Number Generator by dbaupp on Monday September 30, 2013 @10:05AM (#6469658)
The RDRAND instruction on the Intel chips has been a source of much uproar recently. (Concerns that it has been back-doored by the NSA, etc.)
Re:USB Random Number Generator by balabaster on Monday September 30, 2013 @11:16AM (#6470038)
You know what? I'll take an open source/open hardware implementation of that over a closed source CPU implementation that the NSA may have had their hands in.

In this sense, rolling your own is a good start. It may not be a perfect implementation yet, this version may not even be secure but the fact that someone is making a start on an open source/open hardware version is commendable.

I hope this initiative pans out to something great!

Re:USB Random Number Generator by tiatia on Monday September 30, 2013 @10:19AM (#6469733)
"For those wanting a cheap HWRNG, a growing number of CPUs include them now."

Sure they do. I just read a paper how you could make a bias to this hwrng. I think it was even here on HN.

Re:USB Random Number Generator by dspillett on Monday September 30, 2013 @12:01PM (#6470295)
Any chance of a link? It doesn't come up after a cursory search and that would most probably be an interesting read.
Re:USB Random Number Generator by ademarre on Monday September 30, 2013 @07:45PM (#6473079)
You're the one that added that bit about the Raspberry Pi to the RNG comparison page on Wikipedia? Thanks for the tip! That helped me with a project I was working on at the time. I've since learned that there is also a HW RNG on the AM335x that comes on the BeagleBone Black.