{"id":20,"date":"2013-09-23T22:05:15","date_gmt":"2013-09-23T22:05:15","guid":{"rendered":"http:\/\/www.lapsedordinary.net\/?p=20"},"modified":"2013-09-23T22:05:15","modified_gmt":"2013-09-23T22:05:15","slug":"how-the-nsa-cheated-cryptography","status":"publish","type":"post","link":"http:\/\/lapsed.ordinary\/2013\/09\/23\/how-the-nsa-cheated-cryptography\/","title":{"rendered":"How the NSA cheated cryptography"},"content":{"rendered":"

Of all the revelations made by Edward Snowden, I find the recent one about Dual_EC_DRBG<\/i> definitely the most intriguing and possibly the most shocking – even if it wasn’t really news.
\nIt intrigues me because it is about elliptic curves. I love elliptic curves. I studied them quite extensively when I worked as a mathematician and although I don’t use them anymore, I still feel a fondness for them.
\nBut more importantly, it intrigues me because initially I didn’t realise what had really happened – and judging from comments and articles I’ve seen, I wasn’t the only one.
\nThe NSA didn’t weaken a crypto standard. Rather, it put a backdoor inside the standard. There’s an important difference. As a consequence, if you use Dual_EC_DRBG<\/i>, you’re still well-protected if the adversary you’re defending against isn’t the NSA. But if it is, you’re pretty much stuffed.
\nDual_EC_DRBG<\/i> is a pseudorandom number generator (or deterministic random bit generator; hence the name). It is one of four of its kind that were defined in the 2006 NIST standard SP 800-90A (PDF<\/a>). The standard was written with the help of some people at the NSA. As we now know*, the NSA effectively wrote the standard.
\n

\"nsa-ack\"
Well, this is awkward.<\/i><\/center>
\nRandomness is an essential part of any crypto system. It is also where many crypto systems have weaknesses, so if you’re implementing cryptography, it makes sense to use a standard provided by a reputable organisation like NIST.
\nWhat pseudorandom number generators do is turn a small ‘seed’ of proper random data into a constant stream of random numbers, which enables you to get such a number with arbitrarily high entropy. Entropy is usually defined as a way to measure randomness, but here (and possibly in general) it is best to see it as a way to measure surprise to an adversary. A high entropy means the adversary will know very little about the random numbers the system generates.
\nDual_EC_DRBG<\/i> uses a given elliptic curve. Elliptic curves come with an extra structure, called a
group structure<\/a>. For the purpose of this post, it suffices to say that this allows you to walk along the curve but, rather than simply following the shape of the curve, your walk makes you seemingly go all over the place. It is this all-over-the-placeness which makes them useful to generate pseudorandom numbers (and for cryptography in general).
\n
\"Elliptic
The group structure on an elliptic curve. Don’t worry if it doesn’t make sense.<\/i><\/center>
\nApart from the curve, the algorithm also uses two given points P<\/i> and Q<\/i> on this curve. Like the curve, they are given in an appendix to the NIST standard.
\nNow there exists a relationship between these points P<\/i> and Q<\/i>: if you start at Q<\/i> and you continue walking, then, for some large number e<\/i>, after e<\/i> steps you end up at P<\/i>. This is not a secret: it is a simple property of the group structure of elliptic curves. But if the curve is large (which the one used in this standard is), it will take you a long time to compute e<\/i>. Think in terms of millions of years. So no one knows e<\/i> and no one can know e<\/i>.
\nNo one? Well, if you simply choose a point P<\/i> on the curve and choose a (very large) number e<\/i>, you can use that to compute a point Q<\/i>. If you then give out these P<\/i> and Q<\/i> to someone, they<\/i> will still need a million years to compute e<\/i>. But you<\/i> know it.
\nAnd that’s exactly what the NSA did. They provided the P<\/i> and the Q<\/i> in the standard. They, as has become clear from Snowden’s documents, know e<\/i>. We don’t. And we can’t even compute it.
\nDoes this matter?
\nIt does. In 2007, Dan Shumow and Niels Ferguson, two researchers then working for Microsoft<\/i>, showed (
pdf<\/a>) that, if you know e<\/i>, cracking the pseudorandom number generation becomes a little easier. A little easier? Actually, it becomes almost child’s play. They effectively showed that to the NSA, your high-entropy pseudorandom number generator, generates output with very few surprises.
\nIn practise this means that, by knowing e<\/i>, can read almost all TLS-traffic (which includes HTTPS) that is encrypted using a algorithm based on Dual_EC_DRBG<\/i>.
\nAfter the likely backdoor was found in 2007, NIST actually updated the standard. It now shows you a method to choose ‘good’ P<\/i> and Q<\/i> yourself (for you can’t just choose arbitrary points). But it still says that if you want your crypto to be
FIPS 140<\/a>-certified, you need to choose the points they’ve chosen for you. “Trust us,” you read between the lines, “we know they work.”
\nSo why would anyone trust them, especially after it was shown that someone could likely have inserted a backdoor? That is beyond me. But the standard is used in
quite a few implementations<\/a>.
\nWhat makes this even more strange is that, as Matthew Green pointed out in an excellent
blog post<\/a>, the algorithm is pretty flawed in a number of other ways too. No wonder the crypto world suddenly finds itself in an existential crisis.
\nNow it would have been bad if the NSA had somehow managed to make us all use weaker cryptography. Still, the playing field would have remained level, albeit with lower security for everyone.
\nIt would have been a little worse if the NSA knew of a secret algorithm that enabled them to break cryptography. (It is possibly that one of the future revelations that Bruce Schneier
hinted at<\/a> will show they can do that for certain crypto standards.) Still, ultimately that is just beating your opponent by being more clever.
\nBut what the NSA did was plain cheating. The crypto remains secure against any of us. But they can crack it. Because they wrote it. And they put a backdoor into it. And even though we know (and have known for some time) there was such a backdoor, it still doesn’t help us.
\nCheating with the privacy of billions of Internet users is nothing but very, very wrong.
\n(Apart from the linked blog post by Matthew Green, there is
this<\/a> Wired<\/i> piece on Dual_EC_DRBG<\/i> that the aforementioned Bruce Schneier wrote back in 2007, when Edward Snowden was but a junior employee at the CIA working in Switzerland. As just about anything Schneier has written on cryptography, it is well worth a read.)
\n* The NSA hasn’t owned up and it is unlikely they ever will. While no one doubts that the NSA planted a backdoor into Dual_EC_DRBG<\/i>, we can’t prove it. Throughout the blog post, I have assumed we are sure. It made for easier reading. And, frankly, we are quite sure.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

Of all the revelations made by Edward Snowden, I find the recent one about Dual_EC_DRBG definitely the most intriguing and possibly the most shocking – even if it wasn’t really news. It intrigues me because it is about elliptic curves. I love elliptic curves. I studied them quite extensively when I worked as a mathematician […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[44,55,103,104,127,132],"_links":{"self":[{"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/posts\/20"}],"collection":[{"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lapsed.ordinary\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}