3 ms·
Here's all you really need to know about randomness: 1. You need two things: an entropy source, and a whitener. No entropy source is perfect, so you need a w
by lisper 10y ago
Here's all you really need to know about randomness:
1. You need two things: an entropy source, and a whitener. No entropy source is perfect, so you need a whitener no matter what. You don't have to do anything fancy in your whitener. Any cryptographically secure hash function (like SHA512) will do.
2. Since you need a whitener no matter what, it doesn't really matter how good your entropy source is, except insofar as it might take a long time to collect enough entropy from a very poor source. All that matters is that you have an accurate lower bound for how much entropy your source actually provides, and this is the case no matter how good (or bad) your source actually is. As long as you feed >N bits of entropy into your whitener, you can safely extract N bits of true randomness out of it.
3. You don't need more than a few hundred bits of randomness. 128 bits is enough, 256 is a comfortable margin, 512 is serious overkill. Seed a cryptographically secure PRNG with a few hundred bits of entropy and you can safely extract gigabytes of key material out of it.
4. Because of 1-4, putting a lot of effort into designing and tuning a HWRNG is pointless. Such a device provides no value over a poor entropy source fed through a whitener provided you have an accurate lower bound on the entropy content so you can be sure you have seeded your PRNG with enough initial entropy.
- tptacek 10y agoWhich, in case anyone reads this and gets excited about designing their own CSPRNG, is pretty much exactly what you get from /dev/urandom (or whatever the kernel CSPRNG is on your platform).
- lisper 10y agoOnly if you trust your platform devs to get it right. On Linux that's probably a good bet (and on FreeBSD it's probably an even better bet). But on MacOS or Windows? There's no way to tell whether a CSPRNG has been compromised by looking at its output, so you don't have to put on a very thick tinfoil hat to believe that the probability that these might be compromised somehow is greater than zero, in which case knowing how to roll your own CSPRNG can be very handy. At the very least, knowing these things can help you detect snake oil (like the "measured performance" at http://moonbaseotago.com/onerng/theory.html http://moonbaseotago.com/onerng/theory.html)
- tptacek 10y agoOSX's kernel CSPRNG is Yarrow. Window's CryptGenRandom and derivatives are one of the more well-studied OS CSPRNGs.
- lisper 10y agoAnd you know this how? Have you actually decompiled the kernel to make sure that the /dev/urandom driver actually does what the documentation says it does? If you haven't (and I know that you might actually have done this, but most people would not have) then you're back to trusting the manufacturer. BTW, the most likely threat model is not Apple or Microsoft making a stupid mistake in their PRNG, but rather having made a back-room deal with (say) the NSA to intentionally back-door /dev/urandom.
- hannob 10y agoSome people actually do decompile things to make sure they don't contain security vulns. However, if your threat model includes Apple or Microsoft hiding a backdoor in the OS then you can't use their OS. Designing your own CSPRNG doesn't help you. If you want that level of security you need to switch to an operating system you can trust (what that means is a complicated question which probably includes free software, reproducible builds, transparency logs and then you'll still end up with hardware you can't trust).
- lisper 10y ago> Some people actually do decompile things to make sure they don't contain security vulns. Of course, and tptacek might even be one of them. But most people don't do this. And if you don't do it yourself, if you rely on someone else who says that they did it, how do you know you can trust them? This rabbit hole is, of course, as deep as you care to dig it. It's not possible to function without trusting someone. All I'm saying is that if you choose to go down this particular branch of the rabbit hole, it is possible to learn the essentials more expeditiously than reading a 40 page document. > Designing your own CSPRNG doesn't help you That depends on what kind of back door it is. If it's just /dev/urandom which is compromised then rolling your own CSPRNG does help. And a backdoored /dev/urandom is not a completely unreasonable threat model. It's a lot easier to hide a backdoor in a CSPRNG than in just about any other part of the system because the I/O behavior of a compromised CSPRNG can be indistinguishable from a reliable one. But yes, if you're approaching this level of paranoia then switching to an open-source OS is probably more bang for the buck. But even there, are you sure that the code for /dev/urandom has been properly audited?