{"id":688,"date":"2008-10-02T15:07:13","date_gmt":"2008-10-02T15:07:13","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2008\/10\/02\/differential-cryptanalysis\/"},"modified":"2008-10-02T15:07:13","modified_gmt":"2008-10-02T15:07:13","slug":"differential-cryptanalysis","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2008\/10\/02\/differential-cryptanalysis\/","title":{"rendered":"Differential Cryptanalysis"},"content":{"rendered":"<p> Now, we&#8217;re finally reaching the point where the block-cipher stuff gets really fun: block cryptanalysis. <\/p>\n<p> As I&#8217;ve explained before, the key properties of a really good<br \/>\nencryption system are:<\/p>\n<ol>\n<li> It&#8217;s easy to compute the ciphertext given the plaintext and the key;<\/li>\n<li> It&#8217;s easy to compute the plaintext given the ciphertext and the key;<\/li>\n<li> It&#8217;s hard to compute the plaintext given the ciphertext<br \/>\nbut not the key;<\/li>\n<li> It&#8217;s hard to compute the key.\n<\/ol>\n<p> That last property is actually a bit of a weasel. There are really a wide variety of attacks that try to crack an encryption<br \/>\nsystem &#8211; meaning, basically, to discover the key. What makes that<br \/>\nstatement of the property so weasely is that it omits the information available to the person trying to crack it. In the first three properties, I clearly stated what information you had available to produce a result. In the last, I didn&#8217;t.<\/p>\n<p> There&#8217;s a reason that I weaseled that. Partly, it&#8217;s because a correct statement of it would be ridiculously long and incomprehensible; and partly because it&#8217;s often <em>deliberately<\/em> set up differently for different encryption systems. You can design systems that are extremely strong against certain attacks, but not so good against others. There&#8217;s no universally ideal encryption system: it&#8217;s always a matter of tradeoffs, where you can handle some scenarios better than others.<\/p>\n<p> Today we&#8217;re going to look at one particularly fascinating attack that&#8217;s used against block ciphers. It&#8217;s called <em>differential cryptanalysis<\/em>. <\/p>\n<p><!--more--><\/p>\n<p> So what is differential cryptanalysis? It&#8217;s a technique that looks at how making specific changes in the plaintext input to the cipher produce changes in the output from that cipher. The basic idea, in its simplest form, is that you&#8217;re able to select a collection of plaintexts, and encrypt them. Then based on the results of doing<br \/>\nthat, you try to compute the key.<\/p>\n<p> Differential cryptanalysis is a form of the basic <em>chosen plaintext attack<\/em>.  What makes it a differential attack is that you use related families of plaintext. That is, you&#8217;ve got a family of texts T<sub>0<\/sub>, T<sub>1<\/sub>, T<sub>2<\/sub>, &#8230;, where each text T<sub>i<\/sub> is equal to T<sub>0<\/sub> plus some small difference. For many differential attacks, that small difference is <em>one bit<\/em>.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"differential.png\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_331.png?resize=203%2C320\" width=\"203\" height=\"320\" class=\"inset right\" \/><\/p>\n<p> How can you crack a cipher this way? To start, we assume that you know what cipher we&#8217;re using. For example, you know that we&#8217;re using DES with a 56 bit key. So you take your initial plaintext,<br \/>\nT<sub>0<\/sub>, and you encrypt it, giving you a ciphertext, C<sub>0<\/sub>. Then you change one bit of T<sub>0<\/sub>, giving you T<sub>1<\/sub>, and you encrypt that, giving you C<sub>1<\/sub>.<\/p>\n<p> C<sub>1<\/sub> differs from C<sub>0<\/sub> in some number of bits. Now, you&#8217;ve reduced the problem from &#8220;What key could produce the plaintext\/ciphertext pair (T<sub>0<\/sub>, C<sub>0<\/sub>)?&#8221; to<br \/>\n&#8220;What set of keys could produce the <em>variation<\/em> C<sub>0<\/sub> to C<sub>1<\/sub> by changing one bit of T<sub>0<\/sub>?&#8221;. I&#8217;ve drawn an outline of this process in a diagram to the right.<\/p>\n<p> This reduction can be dramatic. For example, in one of the early proposal rivals to DES, caled FEAL, it turned out that you could crack it with a set of 8 one-block (plaintext,ciphertext) pairs. The problem is reduced from a blind search of a search-space of 2<sup>64<\/sup> possible keys to utter triviality by a set of 8 chosen plaintexts!<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"extract-diff.png\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_332.png?resize=240%2C285\" width=\"240\" height=\"285\" class=\"inset right\" \/><\/p>\n<p> The subtlety of this attack is in how you choose the<br \/>\nset of plaintexts to use. For a typical Feistel network block<br \/>\ncipher, you need to do a very delicate analysis of the S-blocks. You trace out the possible paths of each bit through the network,<br \/>\nand using that, you can work out a set of <em>probable<\/em> differences &#8211; that is, bit patterns that are likely to be able to produce an <em>informative<\/em> difference in the ciphertexts. These probable patterns are called <em>differential characteristics<\/em>. Once you&#8217;ve worked out a large enough set of probably characteristics, you can use them to assemble a set of informative plaintexts that should provide you with what you need to determine the key.<\/p>\n<p> It can get even more subtle than that. Since you <em>know<\/em> the algorithm, you can isolate a single stage of the cipher (as illustrated to the right), and throw bit-blocks at it in differential style. From that, you can work out the set of subkeys that could produce the observed differential result for that stage. If you do that for all of the stages, you&#8217;ll get a set of keys for each stage. Figure out which subkeys keys from each stage are mutually compatible, and then combine them, and you get a very small (usually one) key that could produce valid subkeys for each stage. <\/p>\n<p> You can even repeat this process on multiple levels. If you&#8217;ve got a block cipher like DES, and you know the structure, you can do the differential analysis of a single stage by decomposing it into its individual S-boxes. Analyze each S-box, and come up with a set of potential subkey-fragments, and then combine those to create a set of potential subkeys for the stage. Then combine the stage results.<\/p>\n<p> Differential analysis also reveals something fascinating about<br \/>\nDES. Most texts attribute the invention of this attack to Shamir in<br \/>\nthe late 1980s, when he published a set of papers describing<br \/>\ndifferential attacks. But when you analyze DES, you find that it&#8217;s<br \/>\n<em>not<\/em> very susceptible to differential attacks! In fact, it<br \/>\ntakes 2<sup>55<\/sup> chosen plaintexts to crack 56-bit DES &#8211; so differential analysis is effectively no better than simple brute force. But if you make some very minor changes to S-boxes in the algorithm, it becomes nearly as susceptible as FEAL. <\/p>\n<p> So how is DES so resistant to an attack that wasn&#8217;t discovered<br \/>\nuntil almost 15 years after DES was first published? It turns out<br \/>\nthat the IBM team that designed DES had figured out differential<br \/>\nattacks before they designed DES in 1974. They knew about that attack and its properties, and specifically designed DES to <em>not<\/em> be susceptible to it. But at the time, they were working with the NSA to produce an official standard encryption system, and the NSA requested that they <em>not<\/em> tell anyone about the attack they&#8217;d discovered.<\/p>\n<p> This, naturally, has driven a lot of interesting discussion. Why did the NSA want to keep that secret? They claim that they did it because revealing the differential attack and how DES protected against it would &#8220;weaken the competitive advantage that the US enjoyed over other countries in the field of cryptography&#8221;. But<br \/>\na lot of people (to be honest including me) believe that the real<br \/>\nadvantage they wanted to maintain was the ability of the US<br \/>\nintelligence community to crack encryption systems used by other countries.<\/p>\n<p> One last comment, and I&#8217;ll wrap up this post. Things like differential cryptanalysis are one of the <em>many<\/em> reasons not to roll your own cryptographic cipher. Some of the best cryptographers in the world &#8211; people who spent all of their time working on designing secure cryptosystems &#8211; designed systems that were <em>easy<\/em> to break using this technique. If you don&#8217;t know about every technique that could be used against your system, and you haven&#8217;t considered how your system will behave under probing by those techniques, then you have close to no chance of designing something unbreakable. Over time, so many cryptosystems have failed, because someone didn&#8217;t notice one tiny little problem, or didn&#8217;t think about one obscure technique, or didn&#8217;t notice one tiny little bug in their implementation. Those things are fatal to a good cryptosystem. Many of us who are math geeks have tried designing a cipher for the heck of it; how many of us who&#8217;ve done it are able to say that we&#8217;re sure that it couldn&#8217;t be cracked in five minutes of differential analysis? I&#8217;d wager that the answer is zero.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now, we&#8217;re finally reaching the point where the block-cipher stuff gets really fun: block cryptanalysis. As I&#8217;ve explained before, the key properties of a really good encryption system are: It&#8217;s easy to compute the ciphertext given the plaintext and the key; It&#8217;s easy to compute the plaintext given the ciphertext and the key; It&#8217;s hard [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[84],"tags":[],"class_list":["post-688","post","type-post","status-publish","format-standard","hentry","category-encryption"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-b6","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/688","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=688"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/688\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=688"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}