Critical PRNG Bug in NetBSD Kernel
ftp.netbsd.org
ftp.netbsd.org
Due to a misplaced parenthesis, if insufficient GOOD
bits were available to satisfy a request, the
keying/rekeying code requested either 32 or 64 ANY bits,
rather than the balance of bits required to key the
stream generator.
I think this paragraph is a nice reminder, how hard crypto can be.I think it's because the concept of "cryptographically secure" is essentially trying to prove a negative. That's hard enough in general, but especially hard to do about an intelligent adversary whom you may not even know anything about. You're trying to prove that no present or future attacker will be able to obtain any information which can allow him to unravel your secrets.
Crypto is about building sky castles full of really really long secrets floating on foundations of really small ones, and then tossing them all up in the air to yourself as you run down the street backwards with rabid weasels chasing you.
This is also why CSPRNGs are a great place to hide backdoors.
And is there a case in the wild ( except the PS3 hack?)?
Ron was wrong, Whit is right Arjen K. Lenstra and James P. Hughes and Maxime Augier and Joppe W. Bos and Thorsten Kleinjung and Christophe Wachter http://eprint.iacr.org/2012/064
To be clear, the PS3 problem was not a problem of randomness quality or a PRNG backdoor. It was illegal nonce reuse in the zero-knowledge proof-of-key-possession protocol embedded in DSA signatures.
Thor Lancelot Simon for causing, finding and fixing the bugConsequently, system boot scripts are just about the worst possible place to generate new keys if they didn't already exist.
I also seem to recall host keys being generated on first boot. Perhaps some installers are smart enough to prime that seed file.
Boot up naturally involves starting network services and daemons which need their keys, right? It's a reasonable thing to want to do. The hard thing here is if we say "you can't have any output from the system CSPRNG until we're totally sure it's fully preheated", we end up with a few inevitable situations.
Blocking read: "BUG: System hangs noticeably on boot" "If I change /dev/random to /dev/urandom my system boots 5 seconds faster! Woot!" and "So how long do I have to wait then? Why does boot take longer on some networks than others?"
Nonblocking: If the kernel returns 0 bytes of data from read(), some apps will just continue on processing with their uninitialized or zeroed buffer.
It's not so much that gathering entropy is hard, it's that making an accurate estimate of the entropy you gathered is hard (it's basically writing embedded code which attempts to estimate the capabilities of some unknown future black swan). Getting a platform full of developers to write code that correctly handles an error condition that never appears on their own developer workstation seems basically impossible.
I know this isn't the (main) take away message, but it does make me feel a little better about some errors I've made in the past to know that even heavily vetted code can have these types of errors.
Fix a security issue: when we are reseeding a PRNG seeded early in boot
before we had ever had any entropy, if something else has consumed the
entropy that triggered the immediate reseed, we can reseed with as little
as sizeof(int) bytes of entropy. rnd_extract_data(key + r, sizeof(key - r), RND_EXTRACT_ANY);There's also some info and some plugins listed here: http://vim.wikia.com/wiki/VimTip630
Although, a misplaced parentheses could still be balanced. For example,
if ((!x < y))
...
versus if (!(x < y))
...Rookie mistake!
a = malloc(sizeof(*a));
It's also useful for various hacks (stuff like compile-time assert macros), since it doesn't evaluate the expression, only its type.But it perhaps it could be useful for those following the NetBSD style. :-)
Without getting into typing, a simple
warning: arithmetic inside sizeof
would catch this. I don't think it would catch much noise, I don't see any useful uses of pointer arithmetic immediately inside a sizeof. It's a bit specific though, are there more functions that would benefit as well?Is this RNG written in Lisp!?
Sorry, couldn't resist ; ) (big fan of Clojure and elisp here btw)
ERROR: LINE 3, COLUMN 26
ERROR: UNMATCHED RIGHT PARENTHESIS ENCOUNTERED.
ERROR: WHILE PROCESSING INPUT:
1 2 3 4 5 6 7
123456789012345678901234567890123456789012345678901234567890123456789012
Sorry, couldn't resist ; ) (big fan of Clojure and elisp here btw)
^
|
ERROR: PROCESSING WILL CONTINUE WITH THE NEXT AVAILABLE INPUT TOKEN.
ERROR: ALL YOUR BASE ARE BELONG TO US.