88 points · by pmoriarty · 10y ago · 68 comments
Not /dev/random, not rand(), not something you found in a library. Just bytes, read from /dev/urandom.
Here is my CCC talk about why that is, which includes everything from kernel sources to authoritative quotes: https://media.ccc.de/v/32c3-7441-the_plain_simple_reality_of...
EDIT: the talk is in English, but you have to select it from the video UI, in the bottom right.
1. Easier to trust one based on physics with decades of verification of its behavior vs mathematical constructions with vastly less certainty or verification of correctness.
2. Bit-flips or EMI on internal state might affect a software algorithm's randomness. Won't happen with certain types of analog noise with carefully tuned and measured circuits.
3. Can verify the circuits do exactly what I expect by eye and hand with a logic analyzer. No speculation due to No 1. Can then trust that circuit as a pluggable component in any other system without further evaluation.
4. Building on above, a compromise of the host PC requires me to recover the host but not dedicated chips like the TRNG or proper HSM. I can still trust them if they have no firmware (eg analog TRNG) or it's not write-able.
5. Using Nizza Architecture, I can put Linux in an untrusted partition with crypto/CRNG/secure-storage directly on microkernel in dedicated, isolated partition. TRNG HW or dedicated crypto SOC gives me this plus benefits above.
So, the difference between high-assurance setup with HW support for security-critical functions and software on an untrustworthy box... probably x86 with its vPro backdoor circuitry... is pretty astounding in capabilities. Seeing the differences & how cheap you can do that stuff should make anyone wonder why it's not standard in security-focused projects.
- the "uncertain mathematical constructions" are hashes. More precisely, in Linux case, SHA-1 preimage (not collision) security. No civilian cryptosystem would survive the fall of hashes.
- all other points are void as soon as you use that randomness from a regular application running on regular CPUs, as all the bit-flips, compromises and backdoors can simply happen there.
- having the keys on hardware DOES make compromise recovery much easier, but there we are speaking of HSM capable of doing the private key operations themselves, not simply providing randomness.
The fall of a RNG by biasing its bits is more likely than a full, second-preimage attack on a hash. So, a failure of hash function in one app != failure in all apps. You're certainly right that it would have bigger implications but might still be useful as MD5 is if collisions are out of scope.
"all other points are void as soon as you use that randomness from a regular application running on regular CPUs, as all the bit-flips, compromises and backdoors can simply happen there."
There's a lot of CPU's to choose from to reduce that risk. There's systems like Gaisler's Leon3-FT that are open-source, have resistance to bitflips, support mods like TRNG's, and run Linux. At this point, they have to subvert your ASIC process, mask manufacturing, or supply chain. Harder than a purchasing a Linux 0-day if target has decent OPSEC and avoids spy-friendly jurisdictions. ;)
If it's on Intel/AMD/IBM, your comment is true in most cases.
"but there we are speaking of HSM capable of doing the private key operations themselves, not simply providing randomness."
I was speaking of both. One problem I have is bootstrapping randomness. I do it by hand with cards whose entropy feeds into a CRNG unless I have a trustworthy TRNG. A plug-in, analog source with dumb, interface chip isn't going to be compromise by hackers... probably. Likewise, I can go further with a simple, coprocessor w/ ROM, memory protection, dumb interface, and onboard TRNG. Many available from many vendors of varying trustworthiness. Still safer than base system w/ kernel RNG and can even monitor (or restore) host system if I choose.
"let me spell out why this all does not apply to the 99% of us developing for consumer processor architectures"
I still agree with that, though. Main reason is nobody in 99% is going to use anything high-security because it will cost more, be inconvenient, and lack feature/app X, Y, or Z. Always was the case. :)
Anyway, Linux urandom is backtracking safe as long as SHA-1 preimage security holds.
If only the Linux kernel used as entropy everything that was available to it. That's the pitch of haveged(8) I think. There are significantly more timing events the kernel could use for input entropy that it's not. It would be great to see these timing events land in random.c, but they're not there.
Lastly, slightly off-topic, but the Linux CSPRNG is poorly designed. In reality, while preimage SHA-1 might still have a sufficient security margin, it suffers from poor performance due to ad-hoc design. Instead, using AES-128 CTR_DRBG with AES-NI would give the kernel CSPRNG a much needed performance boost, provide backtracking resistence, and remain secure. Current testing shows it could improve from 20 MiBps to 2 GiBps.
Or the getrandom() syscall, once it has trickled into all mainstream distributions' libcs. Which is basically /dev/random, but without the need to open() and close() the device first and after you've consumed your entropy.
[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
You have to include ntsecapi.h with some fixing definitions[3] to use RtlGenRandom.
[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
[2] https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
[3] https://boringssl.googlesource.com/boringssl/+/master/crypto...
http://ubld.it/products/truerng-hardware-random-number-gener...
In actual reality, the generator won't be influenced, because it will require a strong signal, close by, likely transmitting illegally on the frequency you are listening to (of course, the attacker would need to know the frequency you're tuned to). Simple monitoring tools and scripts can be used to test the quality of the generator output. If the quality of the randomness begins to fail, as would happen with deliberate RF interference, then the script would stop outputting bits, and alert the administrator. Or, even better, switch to a different frequency, chosen at random by the kernel CSPRNG.
What's great about using the RTL-SDR as an RNG, is these devices are cheap (about $20) and can output 3 MiBps, which vastly out performs any USB HWRNG that I have personally tested for the value (bits per second per dollar).
FWIW, random.org uses RF noise as the basis for delivering random numbers to the Internet.
Anyway, FYI.
http://www.bitbabbler.org/index.html
Needs more peer review and independent testing anyway. It's designed so you can do it yourself with a logic analyzer or whatever.
EDIT: I should add that, quite interesting to me, BitBabbler folks are building this for people who already know why a TRNG or analog source is important. They're not interested in evangelizing or winning anyone over: just people already wanting one buying it and preferably analyzing it to give them feedback on esoteric failure modes they haven't thought of. Only contact them if you're serious.
"If you want to know more about the company where this all started, the Voicetronix website can tell you all about that, in all its only slightly updated since the mid 90's glory. We're engineers who build great hardware and provide exceptional support for it ... Web 2.0 bling isn't quite our favourite thing to spend time on :) " (source: bottom of Buy page)
Haha. Anyway, I tried to find price but couldn't. If you want one, just email them at the address in BitBabbler Buy tab for a price quote. That's how they typically work. Here's the company if you're curious:
Their differentiator, per their lead engineer, was quality hardware with free as in speech software and custom service/support. I found that interesting esp given it's a 90's era business that predates the OSS HW fads. A model worth copying perhaps.
Note: I haven't hands on reviewed a BitBabbler or their other products. Not endorsing them. Just like what I saw and heard vs what I usually see and hear. Suggesting others review, test, or use the products to see if they live up.
fwiw, I'm a programmer but don't know anything about random number generation (other than I'm not supposed to rely on the built-in random functions of most languages/libraries for security purposes because they're not truly random).
A similar circuit is explained in more technical detail here: http://www.nutsvolts.com/magazine/article/bipolar_transistor... (look for the "WHITE NOISE GENERATORS" chapter title)
[1]: https://en.wikipedia.org/wiki/Noise_generator#Zener_diode
Here's some information I had from a while ago. (Not all of this is about hardware RNGs) https://news.ycombinator.com/item?id=6060636
https://en.wikipedia.org/wiki/Noise_generator
http://holdenc.altervista.org/avalanche/
http://freenrg.info/Physics/Scalar_Vector_Pot_And_Rick_Ander...
You don't usually want to use truly random numbers for cryptography though; /dev/random is more appropriate. I've never understood why, exactly, but that's generally the advice.
There's no reason why you wouldn't want to use truly random numbers for cryptography. That's what /dev/random is supposed to provide.
On most systems, urandom and random are the exact same thing. Only Linux does this weird "blocking random" thing, based on some weird estimate of "running out of entropy" which is not an actual thing.
(u)random is powered by a CSPRNG which is seeded by "truly random numbers" gathered from multiple hardware sources.
Radiation sources really are random. You get a nice strong signal from each decay sensed, and the time between those events is random.
Further, not all noise is RF-based. Thermal noise, for example, is not influenced by RF intereferrence.
Here's a cheap way to generate 800 bits per second from radioactive decay. https://www.fourmilab.ch/hotbits/
Why aren't 800 honest-to-goodness random bits per second enough for all practical purposes? If you need more than that, you should be playing in the big leagues, where using a little USB fob is not the answer!
For seeding the system CSPRNG, that's fine. For securely destroying data, such as wiping hard drives, or creating underlying noise for encrypted filesystems, 800 Bps is going to take you years to work through a 4 TB hard drive.
It's useful to take the output of the noise generator and run it into a spectrum analyzer while using electric motors and walkie-talkies close to the device. If the noise spectrum change shape when you do that, it's not random.
I'd love to get my hands on one of these and do some statistics on a lot of data pulled off of these.
To be honest, I think that at certain controlled temperatures, I'd bet you could start to weight numbers for prediction if you are trying to break crypto keys generated by these.
I see a few hardware RNGs, and they're usually uncased. I think I'd want it in a good quality shielded case.
I'd wonder what big data analysis of this data would show us (IE occurrences of certain samples of 1 TB of data polled).
http://www.idquantique.com/random-number-generation/quantis-...
[1]: http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6...
Choice bits:
>> RDRAND is available in Ivy Bridge processors
Theodore Ts'o:
>> Relying solely on the hardware random number generator which is using an implementation sealed inside a chip which is impossible to audit is a BAD idea.
A purely paranoid person would really prefer something with an antenna (to get some noise by detection), some RLC, a defective/chaotic oscillator on the dye of an a SOC that makes it embedded and you can verify by looking with a microscope that you shield in a Faraday cage.
And no, deciphering logic of a microchip with a microscope is not that hard ; almost anyone can do it with a tad of training and some education.
A question: Is there value in cryopto-signing the random numbers this emits ?
https://www.schneier.com/blog/archives/2013/10/insecurities_...