Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Posted Sep 18, 2015 19:20 UTC (Fri) by david.a.wheeler (subscriber, #72896)Parent article: Python and crypto-strength random numbers by default
E.G., in Java, SecureRandom provides a cryptographically strong random number generator (RNG), while Random does not. See: http://docs.oracle.com/javase/7/docs/api/java/security/Se...
Posted Sep 18, 2015 22:36 UTC (Fri)
by wahern (subscriber, #37304)
[Link] (7 responses)
Theo did his homework before arriving at his decision: "I have spent the last week researching all the uses of the srand(), srandom(), and srand48() subsystems in the ports tree." (https://lwn.net/Articles/625562/). So he had a better idea than most about the potential impact.
Posted Sep 19, 2015 0:14 UTC (Sat)
by anselm (subscriber, #2796)
[Link] (6 responses)
If people are sloppy about random numbers in their cryptographic code, why would anyone want to assume that they are not just as sloppy about the rest of their cryptographic code? Sure, we can arrange for the RNG to get “upgraded” to fix this, but this may end up being the least of our worries.
Posted Sep 19, 2015 2:51 UTC (Sat)
by wahern (subscriber, #37304)
[Link] (2 responses)
2) Similar to #1, sometimes even if your task doesn't require cryptographic resilience it's still a bad idea to use random, et al. The seeding functions often leak state about your process (see jimparis' first 1st). I never use non-CSPRNGs when the results will leak directly or indirectly (e.g. sorting order) over the network. But most people don't even think about this, even experienced engineers. Leaking your PID, system time, etc, is not smart, particularly when it's trivial to avoid doing so.
3) You could make this argument about anything--we can't do it perfectly, so let's do nothing. In this case it's a trivial solution with minimal costs that could offer much benefit. Reasonable people can disagree, of course. But at the end of the day opinions should give way to empirical data. Theo compiled some empirical data and made a decision. Furthermore, implementing this doesn't preclude taking other measures in other contexts.
Posted Sep 19, 2015 11:12 UTC (Sat)
by kleptog (subscriber, #1183)
[Link]
Posted Sep 20, 2015 16:57 UTC (Sun)
by apoelstra (subscriber, #75205)
[Link]
4) Failure modes for RNGs are often undetectable by testing. You can (and should) look for really specific failure modes, like always outputting the same value, but in general if you use a bad RNG the rest of your program's performance and correctness will not be affected in the least. Just security.
5) The output of a bad RNG can stick around forever. If you've got a long-lived private key, if it turns out it was generated poorly then you are screwed, even if this was years ago. (Now that I think about it, I have no recollection of what software or version I used to generate my PGP keys. So in principle any RNG failure in the news could be affecting me.) Combine this with #4 and you have a very dangerous situation indeed.
Compare this to other crypto failure modes, like leaving secure data in memory, timing side-channels, etc., which go away once the software is fixed (or even when the software stops running).
Posted Sep 20, 2015 5:29 UTC (Sun)
by njs (subscriber, #40338)
[Link] (2 responses)
Obviously you and I know that computer "random numbers" are this weird thing that are almost-like-random but with extremely subtle failures that only matter in certain obscure but high-stakes contexts... but it's not really newbie programmers' fault that they don't automatically know this. (Sure, there's a warning in the docs, but if you don't know to look for it...)
Posted Sep 23, 2015 1:35 UTC (Wed)
by dvdeug (guest, #10998)
[Link] (1 responses)
* E.g. exists a, b, i, j such that (a > 0.0) && (b + a == b) or (i > 0) && (j > 0) && (i + j < 0).
Posted Sep 23, 2015 15:26 UTC (Wed)
by apoelstra (subscriber, #75205)
[Link]
CSPRNGs are also deterministic. Determinism is not what burns cryptographically-inexperienced programmers.
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate
Random vs. Cryptographically random are typically separate