slides.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="pandoc">
  6. <meta name="author" content="Robin Dietrich &amp; Marius Schwarz">
  7. <title>CPA Angriff auf Speck</title>
  8. <meta name="apple-mobile-web-app-capable" content="yes">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
  11. <link rel="stylesheet" href="./reveal.js/dist/reset.css">
  12. <link rel="stylesheet" href="./reveal.js/dist/reveal.css">
  13. <style>
  14. code{white-space: pre-wrap;}
  15. span.smallcaps{font-variant: small-caps;}
  16. span.underline{text-decoration: underline;}
  17. div.column{display: inline-block; vertical-align: top; width: 50%;}
  18. div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
  19. ul.task-list{list-style: none;}
  20. pre > code.sourceCode { white-space: pre; position: relative; }
  21. pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
  22. pre > code.sourceCode > span:empty { height: 1.2em; }
  23. .sourceCode { overflow: visible; }
  24. code.sourceCode > span { color: inherit; text-decoration: inherit; }
  25. div.sourceCode { margin: 1em 0; }
  26. pre.sourceCode { margin: 0; }
  27. @media screen {
  28. div.sourceCode { overflow: auto; }
  29. }
  30. @media print {
  31. pre > code.sourceCode { white-space: pre-wrap; }
  32. pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
  33. }
  34. pre.numberSource code
  35. { counter-reset: source-line 0; }
  36. pre.numberSource code > span
  37. { position: relative; left: -4em; counter-increment: source-line; }
  38. pre.numberSource code > span > a:first-child::before
  39. { content: counter(source-line);
  40. position: relative; left: -1em; text-align: right; vertical-align: baseline;
  41. border: none; display: inline-block;
  42. -webkit-touch-callout: none; -webkit-user-select: none;
  43. -khtml-user-select: none; -moz-user-select: none;
  44. -ms-user-select: none; user-select: none;
  45. padding: 0 4px; width: 4em;
  46. color: #aaaaaa;
  47. }
  48. pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
  49. div.sourceCode
  50. { }
  51. @media screen {
  52. pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
  53. }
  54. code span.al { color: #ff0000; font-weight: bold; } /* Alert */
  55. code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
  56. code span.at { color: #7d9029; } /* Attribute */
  57. code span.bn { color: #40a070; } /* BaseN */
  58. code span.bu { } /* BuiltIn */
  59. code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
  60. code span.ch { color: #4070a0; } /* Char */
  61. code span.cn { color: #880000; } /* Constant */
  62. code span.co { color: #60a0b0; font-style: italic; } /* Comment */
  63. code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
  64. code span.do { color: #ba2121; font-style: italic; } /* Documentation */
  65. code span.dt { color: #902000; } /* DataType */
  66. code span.dv { color: #40a070; } /* DecVal */
  67. code span.er { color: #ff0000; font-weight: bold; } /* Error */
  68. code span.ex { } /* Extension */
  69. code span.fl { color: #40a070; } /* Float */
  70. code span.fu { color: #06287e; } /* Function */
  71. code span.im { } /* Import */
  72. code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
  73. code span.kw { color: #007020; font-weight: bold; } /* Keyword */
  74. code span.op { color: #666666; } /* Operator */
  75. code span.ot { color: #007020; } /* Other */
  76. code span.pp { color: #bc7a00; } /* Preprocessor */
  77. code span.sc { color: #4070a0; } /* SpecialChar */
  78. code span.ss { color: #bb6688; } /* SpecialString */
  79. code span.st { color: #4070a0; } /* String */
  80. code span.va { color: #19177c; } /* Variable */
  81. code span.vs { color: #4070a0; } /* VerbatimString */
  82. code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
  83. .display.math{display: block; text-align: center; margin: 0.5rem auto;}
  84. </style>
  85. <link rel="stylesheet" href="./reveal.js/dist/theme/night.css" id="theme">
  86. <link rel="stylesheet" href="./css/custom.css"/>
  87. </head>
  88. <body>
  89. <div class="reveal">
  90. <div class="slides">
  91. <section id="title-slide">
  92. <h1 class="title">CPA Angriff auf Speck</h1>
  93. <p class="author">Robin Dietrich &amp; Marius Schwarz</p>
  94. </section>
  95. <section id="agenda" class="slide level1">
  96. <h1>Agenda</h1>
  97. <ul>
  98. <li>Speck Chiffre</li>
  99. <li>CPA Angriffe</li>
  100. <li>CPA auf Speck</li>
  101. <li>Gegenmaßnahmen</li>
  102. <li>Hiding</li>
  103. </ul>
  104. </section>
  105. <section id="speck" class="slide level1">
  106. <h1>Speck</h1>
  107. <ul>
  108. <li>Symmentrische ARX Chiffre
  109. <ul>
  110. <li>Add/Rotate/XOR</li>
  111. <li>Effizient und einfach umzusetzen</li>
  112. </ul></li>
  113. <li>Entworfen von der NSA (Zusammen mit der Chiffre Simon)</li>
  114. <li>Performant in Hard-/Software</li>
  115. <li>Speck bietet mehrere mögliche Modis
  116. <ul>
  117. <li>Anzahl Runden, Schlüssellänge, Blocklänge</li>
  118. </ul></li>
  119. <li>Paper: <a href="https://csrc.nist.gov/csrc/media/events/lightweight-cryptography-workshop-2015/documents/papers/session1-shors-paper.pdf">Simon and Speck: Block Ciphers for the Internet of Things</a></li>
  120. </ul>
  121. </section>
  122. <section id="speck---setups" class="slide level1">
  123. <h1>Speck - Setups</h1>
  124. <table>
  125. <thead>
  126. <tr class="header">
  127. <th>Speck</th>
  128. <th>Blocklänge</th>
  129. <th>Schlüssellänge</th>
  130. <th>Runden</th>
  131. </tr>
  132. </thead>
  133. <tbody>
  134. <tr class="odd">
  135. <td><span style="color:#d08a1d"><strong>Speck3264</strong></span></td>
  136. <td><span style="color:#d08a1d"><strong>32 Bit</strong></span></td>
  137. <td><span style="color:#d08a1d"><strong>64 Bit</strong></span></td>
  138. <td><span style="color:#d08a1d"><strong>22</strong></span></td>
  139. </tr>
  140. <tr class="even">
  141. <td>Speck4872</td>
  142. <td>48 Bit</td>
  143. <td>72 Bit</td>
  144. <td>22</td>
  145. </tr>
  146. <tr class="odd">
  147. <td>Speck4896</td>
  148. <td>48 Bit</td>
  149. <td>96 Bit</td>
  150. <td>23</td>
  151. </tr>
  152. <tr class="even">
  153. <td>Speck6496</td>
  154. <td>64 Bit</td>
  155. <td>96 Bit</td>
  156. <td>26</td>
  157. </tr>
  158. <tr class="odd">
  159. <td>Speck64128</td>
  160. <td>64 Bit</td>
  161. <td>128 Bit</td>
  162. <td>27</td>
  163. </tr>
  164. <tr class="even">
  165. <td>Speck9696</td>
  166. <td>96 Bit</td>
  167. <td>96 Bit</td>
  168. <td>28</td>
  169. </tr>
  170. <tr class="odd">
  171. <td>Speck96144</td>
  172. <td>96 Bit</td>
  173. <td>144 Bit</td>
  174. <td>29</td>
  175. </tr>
  176. <tr class="even">
  177. <td>Speck128128</td>
  178. <td>128 Bit</td>
  179. <td>128 Bit</td>
  180. <td>32</td>
  181. </tr>
  182. <tr class="odd">
  183. <td>Speck128192</td>
  184. <td>128 Bit</td>
  185. <td>192 Bit</td>
  186. <td>33</td>
  187. </tr>
  188. <tr class="even">
  189. <td>Speck1281256</td>
  190. <td>128 Bit</td>
  191. <td>256 Bit</td>
  192. <td>34</td>
  193. </tr>
  194. </tbody>
  195. </table>
  196. </section>
  197. <section id="speck---rundenfunktion" class="slide level1">
  198. <h1>Speck - Rundenfunktion</h1>
  199. <p><img data-src="img/rundenfunktion.png" width="400" /></p>
  200. <ul>
  201. <li>Wird für die Generierung des Rundenschlüssels aufgerufen</li>
  202. <li>Wird bei der Verschlüsselung des Klartextes aufgerufen</li>
  203. <li>Arbeitet auf zwei geteiltem Input</li>
  204. </ul>
  205. </section>
  206. <section id="speck---pseudocode" class="slide level1">
  207. <h1>Speck - Pseudocode</h1>
  208. <div class="sourceCode" id="cb1"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>pt <span class="op">=</span> Plaintext Bytes Pt <span class="op">=</span> Plaintext as <span class="dv">16</span> Bit Words</span>
  209. <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>ct <span class="op">=</span> Ciphertext Bytes Ct <span class="op">=</span> Ciphertext as <span class="dv">16</span> Bit Words</span>
  210. <span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>k <span class="op">=</span> Key as Bytes K <span class="op">=</span> Key as <span class="dv">16</span> Bit Words</span>
  211. <span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
  212. <span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co">// Key Schedule</span></span>
  213. <span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>D<span class="op">=</span>K<span class="op">[</span><span class="dv">3</span><span class="op">],</span> C<span class="op">=</span>K<span class="op">[</span><span class="dv">2</span><span class="op">],</span> B<span class="op">=</span>K<span class="op">[</span><span class="dv">1</span><span class="op">],</span> A<span class="op">=</span>K<span class="op">[</span><span class="dv">0</span><span class="op">]</span></span>
  214. <span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a></span>
  215. <span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i in <span class="fl">0.</span><span class="er">.</span><span class="op">&lt;</span><span class="dv">22</span></span>
  216. <span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> rk<span class="op">[</span>i<span class="op">]=</span>A</span>
  217. <span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> ER16<span class="op">(</span>B<span class="op">,</span> A<span class="op">,</span> i<span class="op">++)</span></span>
  218. <span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> rk<span class="op">[</span>i<span class="op">]=</span>A</span>
  219. <span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> ER16<span class="op">(</span>C<span class="op">,</span> A<span class="op">,</span> i<span class="op">++)</span></span>
  220. <span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> rk<span class="op">[</span>i<span class="op">]=</span>A</span>
  221. <span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a> ER16<span class="op">(</span>D<span class="op">,</span> A<span class="op">,</span> i<span class="op">++)</span></span>
  222. <span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a></span>
  223. <span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="co">// Encryption</span></span>
  224. <span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a>Ct<span class="op">[</span><span class="dv">0</span><span class="op">]=</span>Pt<span class="op">[</span><span class="dv">0</span><span class="op">];</span> Ct<span class="op">[</span><span class="dv">1</span><span class="op">]=</span>Pt<span class="op">[</span><span class="dv">1</span><span class="op">];</span></span>
  225. <span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a></span>
  226. <span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i in <span class="fl">0.</span><span class="er">.</span><span class="op">&lt;</span><span class="dv">22</span></span>
  227. <span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a> ER16<span class="op">(</span>Ct<span class="op">[</span><span class="dv">1</span><span class="op">],</span> Ct<span class="op">[</span><span class="dv">0</span><span class="op">],</span> rk<span class="op">[</span>i<span class="op">++])</span></span></code></pre></div>
  228. </section>
  229. <section id="speck---möglicher-angriff" class="slide level1">
  230. <h1>Speck - Möglicher Angriff</h1>
  231. <ul>
  232. <li>Angriff der Rundenfunktion</li>
  233. <li>ADD/XOR/ROT Operationen</li>
  234. </ul>
  235. <div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> FuncER16<span class="op">(</span>u16 <span class="op">*</span>x<span class="op">,</span> u16 <span class="op">*</span>y<span class="op">,</span> u16 k<span class="op">)</span></span>
  236. <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
  237. <span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> u16 tmp_x <span class="op">=</span> <span class="op">*</span>x<span class="op">;</span></span>
  238. <span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> u16 tmp_y <span class="op">=</span> <span class="op">*</span>y<span class="op">;</span></span>
  239. <span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
  240. <span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>x <span class="op">=</span> <span class="op">(((</span>tmp_x<span class="op">)&gt;&gt;(</span><span class="dv">7</span><span class="op">))</span> <span class="op">|</span> <span class="op">((</span>tmp_x<span class="op">)&lt;&lt;(</span><span class="dv">16</span><span class="op">-(</span><span class="dv">7</span><span class="op">))));</span> <span class="co">// ROR(7)</span></span>
  241. <span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>x <span class="op">+=</span> <span class="op">*</span>y<span class="op">;</span></span>
  242. <span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a></span>
  243. <span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>x <span class="op">=</span> <span class="op">*</span>x <span class="op">^</span> k<span class="op">;</span></span>
  244. <span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a></span>
  245. <span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>y <span class="op">=</span> <span class="op">(((</span>tmp_y<span class="op">)&lt;&lt;(</span><span class="dv">2</span><span class="op">))</span> <span class="op">|</span> <span class="op">(</span>tmp_y<span class="op">&gt;&gt;(</span><span class="dv">16</span><span class="op">-(</span><span class="dv">2</span><span class="op">))));</span> <span class="co">// ROL(2)</span></span>
  246. <span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>y <span class="op">=</span> <span class="op">*</span>y <span class="op">^</span> <span class="op">*</span>x<span class="op">;</span></span>
  247. <span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
  248. </section>
  249. <section id="speck---möglicher-angriff-1" class="slide level1">
  250. <h1>Speck - Möglicher Angriff</h1>
  251. <ul>
  252. <li>Der Rundenschlüssel steckt in der XOR Operation:</li>
  253. </ul>
  254. <p><img data-src="img/er16_enc_rk.png" /> <img data-src="img/er16_annot.png" /></p>
  255. </section>
  256. <section id="correlation-power-analysis" class="slide level1">
  257. <h1>Correlation Power Analysis</h1>
  258. <ul>
  259. <li>Variante von Differential Power Analysis (DPA)</li>
  260. <li>Nutzt Pearson Correlation Coefficient (PCC)</li>
  261. <li><strong>Bei Speck:</strong> Korrelation zwischen Power-Trace und Rundenschlüssel</li>
  262. <li>Vorgehen:
  263. <ul>
  264. <li>Modell erstellen</li>
  265. <li>Finden der Korrelationen im Modell</li>
  266. <li>Anwenden auf Hardware Implementierung</li>
  267. </ul></li>
  268. </ul>
  269. </section>
  270. <section id="hamming-weight" class="slide level1">
  271. <h1>Hamming Weight</h1>
  272. <ul>
  273. <li>Passendes Modell zum ‘bewerten’ des Stromverbrauchs</li>
  274. <li>Chip hat ein gewissen Basisverbrauch (IDLE)</li>
  275. <li>Werden Bytes im Chip verändert (<span class="math inline">0 → 1; 1 → 0</span>), wird Strom benötigt</li>
  276. <li>Verhalten kann durch die Hamming-Distanz simuliert werden</li>
  277. <li><strong>Hamming Distanz:</strong> Anzahl der veränderten Bits:</li>
  278. </ul>
  279. <p><span class="math display"><em>H</em><em>D</em>(0100101,0010101) = 2</span></p>
  280. <p>Der Unterschied zweier per XOR verknüpfter Daten, wird als Hamming-Gewicht bezeichnet:</p>
  281. <p><span class="math display"><em>H</em><em>a</em><em>m</em><em>m</em><em>i</em><em>n</em><em>g</em><em>D</em><em>i</em><em>s</em><em>t</em><em>a</em><em>n</em><em>c</em><em>e</em>(0100101,0010101) = <em>H</em><em>a</em><em>m</em><em>m</em><em>i</em><em>n</em><em>g</em><em>W</em><em>e</em><em>i</em><em>g</em><em>h</em><em>t</em>(0100101⊕0010101)</span></p>
  282. </section>
  283. <section id="speck---modell" class="slide level1">
  284. <h1>Speck - Modell</h1>
  285. <ul>
  286. <li>Einfaches Modell der Speck Verschlüsselung</li>
  287. <li>Kann für die ersten 2 Byte des Rundenschlüssels genutzt werden:</li>
  288. </ul>
  289. <div class="sourceCode" id="cb3"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> simple_speck(plaintext, key):</span>
  290. <span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> Ct_0 <span class="op">=</span> (<span class="bu">int</span>(plaintext[<span class="dv">1</span>]) <span class="op">&lt;&lt;</span> <span class="dv">8</span>) <span class="op">+</span> <span class="bu">int</span>(plaintext[<span class="dv">0</span>]) <span class="co"># RIGHT Key</span></span>
  291. <span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> Ct_1 <span class="op">=</span> (<span class="bu">int</span>(plaintext[<span class="dv">3</span>]) <span class="op">&lt;&lt;</span> <span class="dv">8</span>) <span class="op">+</span> <span class="bu">int</span>(plaintext[<span class="dv">2</span>]) <span class="co"># LEFT Key</span></span>
  292. <span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span>
  293. <span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> Ct_1, Ct_0 <span class="op">=</span> ER16(Ct_1, Ct_0, key) <span class="co"># Calculate Roundfunction</span></span>
  294. <span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
  295. <span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> popcount((Ct_1 <span class="op">&lt;&lt;</span> <span class="dv">8</span>) <span class="op">+</span> Ct_0) <span class="co"># Return Hamming Weight (aka Popcount)</span></span></code></pre></div>
  296. </section>
  297. <section id="speck---simulation" class="slide level1">
  298. <h1>Speck - Simulation</h1>
  299. <ol type="1">
  300. <li>Simulation anhand des Modells mit <span class="math inline"><em>n</em></span> traces</li>
  301. <li>Generieren von <span class="math inline"><em>n</em></span> zufälligen Klartexten mit <strong>fixem</strong> Keybyte (+ noise)</li>
  302. <li>Simulation aller möglichen Keybytes per Hamming Weight</li>
  303. <li>Berechnen des PCC aller Keys über alle traces</li>
  304. </ol>
  305. <p><img data-src="img/simulation_corr.png" /></p>
  306. <p><span class="math inline">→</span> Das korrekte Keybyte ist: 0x68</p>
  307. </section>
  308. <section id="angriff---hardware" class="slide level1">
  309. <h1>Angriff - Hardware</h1>
  310. <ol type="1">
  311. <li>Implementierung von Speck auf CW</li>
  312. <li>Aufzeichnen von <span class="math inline"><em>n</em></span> Power Traces</li>
  313. <li>Leakage Test</li>
  314. <li>Berechnung des Software Modells</li>
  315. <li>Berechnen der Korrelationen zwischen Modell/Powertraces
  316. <ul>
  317. <li>Keybyte für Keybyte</li>
  318. <li>Rückrechnen des Rundenschlüssels</li>
  319. </ul></li>
  320. </ol>
  321. </section>
  322. <section id="t-test" class="slide level1">
  323. <h1>T-Test</h1>
  324. <ul>
  325. <li>Kann verwendet werden, um <em>Leakage</em> zu erkennen
  326. <ul>
  327. <li>Gibt das Berechnen einer Chiffre mehr Information zurück als geplant: Leakage</li>
  328. <li>Ausnutzbar z.B. durch die Power Traces</li>
  329. </ul></li>
  330. <li>Berechnet durch:</li>
  331. </ul>
  332. <p><img data-src="img/ttest_calc.png" /></p>
  333. <ul>
  334. <li>Vergleicht zwei unabhängige Stichproben miteinander</li>
  335. <li>Je unterschiedlicher die Mittelwerte <span class="math inline">→</span> desto mehr Leakage</li>
  336. </ul>
  337. </section>
  338. <section id="t-test-1" class="slide level1">
  339. <h1>T-Test</h1>
  340. <ul>
  341. <li>T-Test der aufgezeichneten Power-Traces:</li>
  342. </ul>
  343. <p><img data-src="img/t_test_original.png" /></p>
  344. <ul>
  345. <li>Erkennbar, dass Leakage vorhanden sein muss</li>
  346. </ul>
  347. </section>
  348. <section id="korrelationen-des-ersten-keybytes" class="slide level1">
  349. <h1>Korrelationen des ersten Keybytes</h1>
  350. <ul>
  351. <li>Korrelationen des ersten Keybytes</li>
  352. <li>Korrelation fällt höher aus als im Modell</li>
  353. <li>Deutliches Maximum der Korrelation bei 0x22 (Korrektes Keybyte)</li>
  354. </ul>
  355. <p><img data-src="img/correlation_first_keybyte.png" width="550" /></p>
  356. </section>
  357. <section id="problem-blocksize" class="slide level1">
  358. <h1>Problem: Blocksize</h1>
  359. <ul>
  360. <li>Bei <strong>Speck3264:</strong> Operationen nicht auf Byte, sondern auf 16-Bit Ebene</li>
  361. <li>Erste Idee: Modell und Korrelation auf <span class="math inline">2<sup>16</sup></span> Keys</li>
  362. <li><span class="math inline">→</span> Keyspace ist abdeckbar (65536 Keys)</li>
  363. <li><span class="math inline">→</span> Zu langsam</li>
  364. <li><span class="math inline">→</span> Nicht möglich für andere Modis von Speck (32 Bit Subkeys)</li>
  365. <li><strong>Lösung:</strong> Modell funktioniert auch auf allen Teilbytes per Shift:</li>
  366. </ul>
  367. <div class="sourceCode" id="cb4"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>rightkey <span class="op">=</span> <span class="bn">0x00</span></span>
  368. <span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> guess_key <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">256</span>):</span>
  369. <span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> leftkey <span class="op">=</span> model( (guess_key <span class="op">&lt;&lt;</span> <span class="dv">8</span>) <span class="op">+</span> righkey )</span>
  370. <span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
  371. <span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> guess_key <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">256</span>):</span>
  372. <span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> rightkey <span class="op">=</span> model( (leftkey <span class="op">&lt;&lt;</span> <span class="dv">8</span>) <span class="op">+</span> guess_key )</span></code></pre></div>
  373. <ul>
  374. <li>Auch umsetzbar auf Speck mit Blocksize &gt; 16 Bit</li>
  375. </ul>
  376. </section>
  377. <section id="problem-nth-keybytes" class="slide level1">
  378. <h1>Problem: <span class="math inline"><em>n</em><sup><em>t</em><em>h</em></sup></span> Keybytes</h1>
  379. <ul>
  380. <li>Modell kann nur für die ersten zwei Keybytes genutzt werden, da:</li>
  381. </ul>
  382. <div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i in <span class="fl">0.</span><span class="er">.</span><span class="op">&lt;</span><span class="dv">22</span></span>
  383. <span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> ER16<span class="op">(</span>Ct<span class="op">[</span><span class="dv">1</span><span class="op">],</span> Ct<span class="op">[</span><span class="dv">0</span><span class="op">],</span> rk<span class="op">[</span>i<span class="op">++])</span></span></code></pre></div>
  384. <ul>
  385. <li>Die bereits bekannten Rundenschlüssel müssen mit eingeschlossen werden</li>
  386. <li>Muss an der richtigen Stelle passieren (<span class="math inline">⊕</span>-Operation)</li>
  387. </ul>
  388. </section>
  389. <section id="problem-nth-keybytes-1" class="slide level1">
  390. <h1>Problem: <span class="math inline"><em>n</em><sup><em>t</em><em>h</em></sup></span> Keybytes</h1>
  391. <ul>
  392. <li>Anpassung des Modells:</li>
  393. </ul>
  394. <div class="sourceCode" id="cb6"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># -------------- for one key -----------------#</span></span>
  395. <span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> x <span class="op">=</span> ((x <span class="op">&lt;&lt;</span> (<span class="dv">16</span> <span class="op">-</span> ALPHA)) <span class="op">+</span> (x <span class="op">&gt;&gt;</span> ALPHA)) <span class="op">&amp;</span> mod_mask <span class="co"># x = ROR(x, 7)</span></span>
  396. <span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> x <span class="op">=</span> (x <span class="op">+</span> y) <span class="op">&amp;</span> mod_mask <span class="co"># x = ADD(x, y)</span></span>
  397. <span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a></span>
  398. <span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> x <span class="op">=</span> x <span class="op">^</span> knownkey[<span class="dv">0</span>]</span>
  399. <span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a></span>
  400. <span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># -------------- for second key -----------------#</span></span>
  401. <span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a></span>
  402. <span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a> y <span class="op">=</span> ((y <span class="op">&gt;&gt;</span> (<span class="dv">16</span> <span class="op">-</span> BETA)) <span class="op">+</span> (y <span class="op">&lt;&lt;</span> BETA)) <span class="op">&amp;</span> mod_mask <span class="co"># y = ROL(y, 2)</span></span>
  403. <span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a> y <span class="op">=</span> y <span class="op">^</span> x <span class="co"># y = XOR(y, x)</span></span>
  404. <span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a> x <span class="op">=</span> ((x <span class="op">&lt;&lt;</span> (<span class="dv">16</span> <span class="op">-</span> ALPHA)) <span class="op">+</span> (x <span class="op">&gt;&gt;</span> ALPHA)) <span class="op">&amp;</span> mod_mask <span class="co"># x = ROR(x, 7)</span></span>
  405. <span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a> x <span class="op">=</span> (x <span class="op">+</span> y) <span class="op">&amp;</span> mod_mask <span class="co"># x = ADD(x, y)</span></span>
  406. <span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a></span>
  407. <span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a> x <span class="op">=</span> x <span class="op">^</span> knownkey[<span class="dv">1</span>] <span class="co"># x = XOR(x, k)</span></span>
  408. <span id="cb6-15"><a href="#cb6-15" aria-hidden="true" tabindex="-1"></a></span>
  409. <span id="cb6-16"><a href="#cb6-16" aria-hidden="true" tabindex="-1"></a> <span class="co"># -------------- for third key -----------------#</span></span>
  410. <span id="cb6-17"><a href="#cb6-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># [...]</span></span></code></pre></div>
  411. </section>
  412. <section id="korrelationen-des-ersten-keybytes-1" class="slide level1">
  413. <h1>Korrelationen des ersten Keybytes</h1>
  414. <ul>
  415. <li>Graph zeigt die Korrelationen des ersten Keybytes bis 5000 traces</li>
  416. <li>Ab ~800 Traces hebt sich die Korrelation deutlich hervor</li>
  417. </ul>
  418. <p><img data-src="img/traces.png" width="550" /></p>
  419. </section>
  420. <section id="gegenmaßnahmen" class="slide level1">
  421. <h1>Gegenmaßnahmen</h1>
  422. </section>
  423. <section id="hiding" class="slide level1">
  424. <h1>Hiding</h1>
  425. <ul>
  426. <li>Verstecken des eigentlichen “Leakages” in Rauschen</li>
  427. <li><span class="math inline">→</span> Erhöhung des vorhandenen Rauschens während der Berechnung</li>
  428. <li>Mehrere Möglichkeiten
  429. <ul>
  430. <li>Mischen der Instruction-Order</li>
  431. <li><strong>Hinzufügen von “Dummy Instructionen”</strong></li>
  432. <li>Clock Jitter</li>
  433. </ul></li>
  434. </ul>
  435. </section>
  436. <section id="hiding---code" class="slide level1">
  437. <h1>Hiding - Code</h1>
  438. <ul>
  439. <li><strong>Ansatz:</strong> Korrelation kommt von <code>ER16()</code>
  440. <ul>
  441. <li>Add/XOR/Rotate</li>
  442. </ul></li>
  443. <li>Hinzufügen weitere AXR Operationen um noise zu erhöhen</li>
  444. <li>Ersetzen von jeder XOR Operation mit folgender Implementierung:</li>
  445. </ul>
  446. <div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="dt">uint16_t</span> XOR<span class="op">(</span><span class="dt">uint16_t</span> a<span class="op">,</span> <span class="dt">uint16_t</span> b<span class="op">,</span> <span class="dt">int</span> random<span class="op">)</span> <span class="op">{</span></span>
  447. <span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">uint8_t</span> tmp <span class="op">=</span> random <span class="op">^</span> <span class="bn">0x5F</span><span class="op">;</span></span>
  448. <span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> tmp <span class="op">^=</span> <span class="op">(</span>random <span class="op">^</span> a<span class="op">);</span></span>
  449. <span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> tmp <span class="op">^=</span> <span class="op">(</span>tmp <span class="op">^</span> b<span class="op">);</span></span>
  450. <span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> tmp <span class="op">&amp;=</span> <span class="op">(</span>tmp <span class="op">&amp;</span> a<span class="op">);</span></span>
  451. <span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> tmp <span class="op">&amp;=</span> <span class="op">(</span>tmp <span class="op">&amp;</span> b<span class="op">);</span></span>
  452. <span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> a <span class="op">^</span> b<span class="op">;</span></span>
  453. <span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
  454. <ul>
  455. <li><code>Random</code> wird bei jeder Verschlüsslung erneut generiert</li>
  456. </ul>
  457. </section>
  458. <section id="hiding---t-test" class="slide level1">
  459. <h1>Hiding - T-Test</h1>
  460. <ul>
  461. <li>Ergebnisse des T-Tests mit implementierter Hiding Maßnahmen:</li>
  462. </ul>
  463. <p><img data-src="img/t_test_hiding_random.png" /></p>
  464. <ul>
  465. <li>Bedarf weiterer Analysen, denn Unterschiede der beiden T-Tests sind nur minimal</li>
  466. <li>Laut T-Test <strong>keine</strong> Indikation dass Hiding funktioniert</li>
  467. </ul>
  468. </section>
  469. <section id="korrelationen-des-ersten-keybytes-2" class="slide level1">
  470. <h1>Korrelationen des ersten Keybytes</h1>
  471. <ul>
  472. <li>Besseres Ergebnis der Korrelationen bis 5000 Traces</li>
  473. <li>Korrelationen flachen ab ~800 drastisch ab</li>
  474. <li>Keine Korrelation sticht heraus</li>
  475. </ul>
  476. <p><img data-src="img/corr_traces_hiding_5k.png" width="550" /></p>
  477. <ul>
  478. <li>Es war nicht möglich den Angriff erneut durchzuführen</li>
  479. <li>Neue Korrelationen nach einigen Tests lediglich bei ~0.18 mit falschem Keybyte</li>
  480. <li><span class="math inline">→</span> Maßnahme ist erfolgreich</li>
  481. </ul>
  482. </section>
  483. <section id="hiding-potentieller-bypass" class="slide level1">
  484. <h1>Hiding (potentieller) Bypass</h1>
  485. <ul>
  486. <li>Korrelation sollte weiterhin möglich sein, wenn die Operationen in Betracht gezogen werden</li>
  487. <li>Schwierigkeit hängt am Zufallszahlengenerator</li>
  488. <li><strong>Problem:</strong> Sichere Zufallszahlen auf Embedded Chips sind nicht trivial</li>
  489. </ul>
  490. <p><span class="math inline">→</span> Bypass konnte <strong>nicht</strong> realisiert werden</p>
  491. </section>
  492. <section id="referenzen" class="slide level1">
  493. <h1>Referenzen</h1>
  494. <ul>
  495. <li><a href="Improved%20Differential%20Cryptanalysis%20of%20Round-Reduced%20Speck">Improved Differential Cryptanalysis of Round-Reduced Speck</a></li>
  496. <li><a href="Breaking%20Speck%20cryptosystem%20using%20correlation%20power%20analysis%20attack">Breaking Speck cryptosystem using correlation power analysis attack</a></li>
  497. <li><a href="%7BSpeck-R:%20An%20ultra%20light-weight%20cryptographic%20scheme%20for%20Internet%20of%20Things">Speck-R: An ultra light-weight cryptographic scheme for Internet of Things</a></li>
  498. </ul>
  499. </section>
  500. </div>
  501. </div>
  502. <script src="./reveal.js/dist/reveal.js"></script>
  503. <!-- reveal.js plugins -->
  504. <script src="./reveal.js/plugin/notes/notes.js"></script>
  505. <script src="./reveal.js/plugin/search/search.js"></script>
  506. <script src="./reveal.js/plugin/zoom/zoom.js"></script>
  507. <script>
  508. // Full list of configuration options available at:
  509. // https://revealjs.com/config/
  510. Reveal.initialize({
  511. // Display controls in the bottom right corner
  512. controls: true,
  513. // Help the user learn the controls by providing hints, for example by
  514. // bouncing the down arrow when they first encounter a vertical slide
  515. controlsTutorial: true,
  516. // Determines where controls appear, "edges" or "bottom-right"
  517. controlsLayout: 'bottom-right',
  518. // Visibility rule for backwards navigation arrows; "faded", "hidden"
  519. // or "visible"
  520. controlsBackArrows: 'faded',
  521. // Display a presentation progress bar
  522. progress: true,
  523. // Display the page number of the current slide
  524. slideNumber: true,
  525. // 'all', 'print', or 'speaker'
  526. showSlideNumber: 'all',
  527. // Add the current slide number to the URL hash so that reloading the
  528. // page/copying the URL will return you to the same slide
  529. hash: false,
  530. // Start with 1 for the hash rather than 0
  531. hashOneBasedIndex: false,
  532. // Flags if we should monitor the hash and change slides accordingly
  533. respondToHashChanges: true,
  534. // Push each slide change to the browser history
  535. history: false,
  536. // Enable keyboard shortcuts for navigation
  537. keyboard: true,
  538. // Enable the slide overview mode
  539. overview: true,
  540. // Disables the default reveal.js slide layout (scaling and centering)
  541. // so that you can use custom CSS layout
  542. disableLayout: false,
  543. // Vertical centering of slides
  544. center: true,
  545. // Enables touch navigation on devices with touch input
  546. touch: true,
  547. // Loop the presentation
  548. loop: false,
  549. // Change the presentation direction to be RTL
  550. rtl: false,
  551. // see https://revealjs.com/vertical-slides/#navigation-mode
  552. navigationMode: 'default',
  553. // Randomizes the order of slides each time the presentation loads
  554. shuffle: false,
  555. // Turns fragments on and off globally
  556. fragments: true,
  557. // Flags whether to include the current fragment in the URL,
  558. // so that reloading brings you to the same fragment position
  559. fragmentInURL: true,
  560. // Flags if the presentation is running in an embedded mode,
  561. // i.e. contained within a limited portion of the screen
  562. embedded: false,
  563. // Flags if we should show a help overlay when the questionmark
  564. // key is pressed
  565. help: true,
  566. // Flags if it should be possible to pause the presentation (blackout)
  567. pause: true,
  568. // Flags if speaker notes should be visible to all viewers
  569. showNotes: false,
  570. // Global override for autoplaying embedded media (null/true/false)
  571. autoPlayMedia: null,
  572. // Global override for preloading lazy-loaded iframes (null/true/false)
  573. preloadIframes: null,
  574. // Number of milliseconds between automatically proceeding to the
  575. // next slide, disabled when set to 0, this value can be overwritten
  576. // by using a data-autoslide attribute on your slides
  577. autoSlide: 0,
  578. // Stop auto-sliding after user input
  579. autoSlideStoppable: true,
  580. // Use this method for navigation when auto-sliding
  581. autoSlideMethod: null,
  582. // Specify the average time in seconds that you think you will spend
  583. // presenting each slide. This is used to show a pacing timer in the
  584. // speaker view
  585. defaultTiming: null,
  586. // Enable slide navigation via mouse wheel
  587. mouseWheel: false,
  588. // The display mode that will be used to show slides
  589. display: 'block',
  590. // Hide cursor if inactive
  591. hideInactiveCursor: true,
  592. // Time before the cursor is hidden (in ms)
  593. hideCursorTime: 5000,
  594. // Opens links in an iframe preview overlay
  595. previewLinks: false,
  596. // Transition style (none/fade/slide/convex/concave/zoom)
  597. transition: 'slide',
  598. // Transition speed (default/fast/slow)
  599. transitionSpeed: 'default',
  600. // Transition style for full page slide backgrounds
  601. // (none/fade/slide/convex/concave/zoom)
  602. backgroundTransition: 'fade',
  603. // Number of slides away from the current that are visible
  604. viewDistance: 3,
  605. // Number of slides away from the current that are visible on mobile
  606. // devices. It is advisable to set this to a lower number than
  607. // viewDistance in order to save resources.
  608. mobileViewDistance: 2,
  609. // reveal.js plugins
  610. plugins: [
  611. RevealNotes,
  612. RevealSearch,
  613. RevealZoom
  614. ]
  615. });
  616. </script>
  617. </body>
  618. </html>