As of August 2020 the site you are on (wiki.newae.com) is deprecated, and content is now at rtfm.newae.com.

Difference between revisions of "Tutorial B5 Breaking AES (Straightforward)"

From ChipWhisperer Wiki
Jump to: navigation, search
(Capturing)
(Analyzing the Traces)
Line 106: Line 106:
 
<li>Open the Analyzer software</li>
 
<li>Open the Analyzer software</li>
 
<li>From the ''File --> Open Project'' option, navigate to the .cwp file you save previously. Open this file.</li>
 
<li>From the ''File --> Open Project'' option, navigate to the .cwp file you save previously. Open this file.</li>
<li><p>Select the ''Project --> Manage Traces'' option to open the dialog, enable the captured traces by adding a check-mark in the box. Close the dialog with `ESC`:</p>
+
<li>Switch to the ''Trace Output Plot'' tab on the right side.</li>
<p>[[File:tracemanage.png|image]]</p></li>
+
<li>Switch to the ''Results'' setting tab on the left side</li>
<li><p>If you wish to view the trace data, follow these steps:</p>
+
<li>Scroll down to the ''Trace Output Plot'' setting, highlighted below:
 
+
<p>
<ol style="list-style-type: decimal;">
+
[[File:v4_tracedraw.png|500px]]
<li>Switch to the ''Waveform Display'' tab</li>
+
</p></li>
<li>Switch to the ''General'' parameter setting tab</li>
+
<li>You can choose to plot a specific range of traces. For example type '''0-10'' in the '''Trace(s) to plot'' window.</li>
<li>You can choose to plot a specific range of traces</li>
+
<li>Hit the ''Redraw'' button when you change the trace plot range.</li>
<li>Hit the ''Redraw'' button when you change the trace plot range</li>
+
<li>You can right-click on the waveform to change options, or left-click and drag to zoom.</li>
<li>You can right-click on the waveform to change options, or left-click and drag to zoom</li>
+
<li>Use the toolbar to quickly reset the zoom back to original.</li>
<li>(oops there is no 6)</li>
+
<li>Try more advanced plotting options, like '''0(r),4-7(b)''' to plot trace 0 in red, and 4-6 in blue. See a full list of possible commands on the page [[Plotting_Widget]].</li>
<li>Use the toolbar to quickly reset the zoom back to original</li></ol>
+
</ol>
 
+
<p>[[File:traceplotting.png|image]]</p></li>
+
<li><p>You can view or change the attack options on the ''Attack'' parameter settings tab:</p>
+
<ol style="list-style-type: decimal;">
+
<li>The ''Hardware Model'' settings are correct for the software AES by default</li>
+
<li>The ''Point Setup'' makes the attack faster by looking over a more narrow range of points. Often you might have to characterize your device to determine the location of specific attack points of interest.</li>
+
<li>''Traces per Attack'' allows you to use only a subset of capture traces on each attack. Or if you have for example 1000 traces, you could average the results of attacking 50 traces over 200 attack runs.</li>
+
<li>''Reporting Interval'' is how often data is generated. A smaller interval generates more useful output data, but greatly increases computational complexity (e.g. slows down attack). If you only care about attacking the system, the reporting interval can be set to the number of traces. In which case the attack runs completely, and you get the results. For this tutorial you can set to a smaller number (such as 5).</li></ol>
+
  
 
<p>[[File:attacksettings.png|image]]</p></li>
 
<p>[[File:attacksettings.png|image]]</p></li>

Revision as of 15:26, 24 September 2017

This tutorial has been updated for ChipWhisperer 4.0.0 release. If you are using 3.x.x see the "V3" link in the sidebar.

B5: Breaking AES (Straightforward)
Target Architecture XMEGA
Hardware Crypto No
Software Release V3 / V4 / V5

This tutorial will take you through a complete attack on a software AES implementation. The specific implementation being attacked is a well-known AES implementation written in C, which is likely to be similar to other implementations used by proprietary systems.

Capturing

This tutorial runs on four different hardware targets. You only need to follow the steps for your given hardware.

Capturing with ChipWhisperer-Lite/Pro with default XMEGA Target (CW303)

WARNING: This video was recorded with API V3.x, some changes happened so please take note.

NOTE: You can see a Quick-Start Guide and Video for this target on the CW1173_ChipWhisperer-Lite page:

Cwlite demo video.png

Hardware Setup

  1. Connect the CW1173/CW1200 by USB cable to computer.

    image

  2. The software AES implementation that will run on the target is located in chipwhisperer\hardware\victims\firmware\simpleserial-aes. In a terminal window, navigate here and run the command make to build the firmware. As in previous tutorials, ensure that the firmware has been built for the correct board. Here, the output of make should end like
    AVR Memory Usage
    ----------------
    Device: atxmega128d3
    
    Program:    3078 bytes (2.2% Full)
    (.text + .data + .bootloader)
    
    Data:        352 bytes (4.3% Full)
    (.data + .bss + .noinit)
    
    
    Built for platform CW-Lite XMEGA
    
    -------- end --------
    

    Make sure that the platform is correct.

  3. Upload the firmware to the target chip. The process to do this is the same as the previous tutorials:
    • Open the ChipWhisperer Capture software.
    • Connect to the ChipWhisperer. (You can do this using a script or by filling out the generic settings and connecting to the board yourself.)
    • Open the XMEGA Programmer (**Tools > ChipWhisperer-Lite XMEGA Programmer**).
    • Find the hex file you compiled and program it onto the target.

Capturing the Traces

Cwsetup scriptselection.png

  1. Switch to the Python Console tab.
  2. The script selection window (2) lists available example scripts. Scroll down to "connect_cwlite_simpleserial.py" and click on it.
  3. You will see the script contents appear in the "Script Preview" window (3). You can either hit the "Run" button or double-click the filename of the script to execute it. Do either of those now.

The window should change to indicate the connect succeeded:

Cwsetup scriptselection cwliterun.png

  1. The console lists the exact script that is executed. Note you could have manually executed the script commands line-by-line in this console.
  2. The "Scope" and "Target" buttons will show as connected.
  3. The Status Bar will show a connection.

Note in previous software versions, this tutorial took you through manual setup. This can still be done (using the GUI), but instead now the API has been made more powerful, so the example configuration script will be used instead.

To do so, simply scroll down and select the "setup_cwlite_xmega_aes.py" file:

Cwsetup scriptselection xmegaconfig cwliterun.png

To complete the tutorial, follow these steps:

  1. Switch to the General Settings tab
  2. If you wish to change the number of traces, do so here. The default of 50 should be sufficient to break AES though!
  3. Hit the Capture Many button (M in a green triangle) to start the capture process.
  4. You will see each new trace plotted in the waveform display.
  5. You'll see the trace count in the status bar. Once it says Trace 50 done (assuming you requested 50 traces) the capture process is complete.
  6. Finally save this project using the File --> Save Project option, give it any name you want.
  7. Skip ahead to #Analyzing_the_Traces.

Capturing with ChipWhisperer-Lite and UFO Board

TODO

Analyzing the Traces

  1. Open the Analyzer software
  2. From the File --> Open Project option, navigate to the .cwp file you save previously. Open this file.
  3. Switch to the Trace Output Plot tab on the right side.
  4. Switch to the Results setting tab on the left side
  5. Scroll down to the Trace Output Plot setting, highlighted below:

    V4 tracedraw.png

  6. You can choose to plot a specific range of traces. For example type 0-10 in the Trace(s) to plot window.
  7. Hit the Redraw button when you change the trace plot range.
  8. You can right-click on the waveform to change options, or left-click and drag to zoom.
  9. Use the toolbar to quickly reset the zoom back to original.
  10. Try more advanced plotting options, like 0(r),4-7(b) to plot trace 0 in red, and 4-6 in blue. See a full list of possible commands on the page Plotting_Widget.

image

</li>
  • Finally run the attack by switching to the Results Table tab and then hitting the Attack button:

    image

  • If you adjusted the Reporting Interval to a smaller number such as 5, you'll see the progression of attack results as more traces are used. If not you should simply see the final results, which should have the correct key highlighted in red. In the following case the correct key was recovered:

    image

  • You can also switch to the Output vs Point Plot window to see where exactly the data was recovered:

    1. Switch to the Output vs Point Plot tab
    2. Turn on one of the bytes to see results.
    3. The known correct guess for the key is highlighted in red. The wrong guesses are plotted in green. You can see that the attacked operation appeared to occur around sample 40 for key 0. Remember you can click-drag to zoom in, then right-click and select View All to zoom back out.
    4. Turn on another byte to see results for it.
    5. This byte occured much later - sample 1240. By exploring where the maximum correlation was found for the correct key-guess of each byte, you can determine where exactly the attacked operation occured.

    image

  • </ol>

    Next Steps

    This has only briefly outlined how to perform a CPA attack. You can move onto more advanced tutorials, especially showing you how the actual attack works when performed manually.