Tutorial A8 32bit AES

From ChipWhisperer Wiki
Revision as of 05:31, 18 July 2017 by Coflynn (Talk | contribs) (Hardware Setup)

Jump to: navigation, search

Most of our previous tutorials were running on 8-bit modes of operation. We can target typical implementation on ARM devices which actually looks a little different.

This tutorial is ONLY possible if you have an ARM target. For example the UFO Board with the STM32F3 target (or similar).

Background

A 32-bit machine can operate on 32-bit words, so it seems wasteful to use the same 8-bit operations. Indeed we can speed up the AES operation considerably by generating several tables (called T-Tables), as was described in the book The Design of Rijndael which was published by the authors of AES.

Building Firmware

You will have to build with the PLATFORM set to one of the ARM targets (such as CW308_STM32F0 for the STM32F0 victim, or CW308_STM32F3 for the STM32F3 victim). If you haven't setup the ARM build environment see the page CW308T-STM32F#Example_Projects. Assuming your build environment is OK, you can build it as follows:

  cd chipwhisperer\hardware\victims\firmware\simpleserial-aes
  make PLATFORM=CW308_STM32F3 CRYPTO_TARGET=MBEDTLS

If this works you should get something like the following:

  Creating Symbol Table: simpleserial-aes-CW308_STM32F3.sym
  arm-none-eabi-nm -n simpleserial-aes-CW308_STM32F3.elf > simpleserial-aes-CW308_
  STM32F3.sym
  Size after:
     text    data     bss     dec     hex filename
     8440    1076   10320   19836    4d7c simpleserial-aes-CW308_STM32F3.elf
     +--------------------------------------------------------
     + Built for platform CW308T: STM32F3 Target
     +--------------------------------------------------------

Hardware Setup

  1. Using a UFO board, connect your desired STM32Fx target:
  2. Before finishing the hardware setup, you should connect to the target device. To do this you can use one of the standard setup scripts. This will provide a clock & setup TX/RX lines as expected for the STM32F, which is required for the programmer to work.

Programming STM32F Device

The STM32Fx devices have a built-in bootloader, and the ChipWhisperer software as of 3.5.2 includes support for this bootloader.

Important notes before we begin:

  • You MUST setup a clock and the serial lines for the chip. This is easily done by selecting a start-up script such as the "AES SimpleSerial on XMEGA" startup script.
  • On the STM32F1, you MUST adjust the clock frequency to by 8MHz. The bootloader does not work with our usual 7.37 MHz clock frequency.

To access the bootloader you can perform these steps. They vary based on if you have a "Rev 02" board or a "Rev 03 or Later" board. The revision number is printed on the bottom side as part of the PCB part number (STM32F-03 is Rev -03 for example).

Rev -03 or Later

  1. Select the "Serial STM32F Programmer"
    Arm programmer.png
  2. Select the hex-file and press the "Program/Verify" button.
  3. The device should program, it may take a moment to fully program/verify on larger devices:
    Arm programmed.png

If you get verify errors, it's possible the shunt resistor is causing power to dip too low. This can be solved by mounting a jumper between the "SH-" and "SH+" pins at J16 (to the left of the SMA connector) on the UFO board. Retry programming with the jumper mounted.

Rev -02 Boards

The Rev -02 boards did not have all programming connections present. They require some additional steps:

  1. Select the "Serial STM32F Programmer"
    Arm programmer.png
  2. Mount a jumper between the H1 and PDIC pins (again this is ONLY for the -02 rev).
    STMF32F-02 programmer jumper.jpg
  3. Reset the ARM device either by pressing the reset button (newer UFO boards only), or by toggling power:
    Arm togglepower.png
  4. Select the hex-file and press the "Program/Verify" button.
  5. The device should program, it may take a moment to fully program/verify on larger devices:
    Arm programmed.png
  6. Remove the jumper between the H1/H2 pins.
  7. Reset the ARM device either by pressing the reset button (newer UFO boards only), or by toggling power:
    Arm togglepower.png

If you get verify errors, it's possible the shunt resistor is causing power to dip too low. This can be solved by mounting a jumper between the "SH-" and "SH+" pins at J16 (to the left of the SMA connector) on the UFO board. Retry programming with the jumper mounted.

Capturing Traces

The capture process is similar to previous setups. After running the setup script, adjust the following settings:

  1. Set the offset to by 0 samples:
    A8 offset.png
  2. Adjust the gain upward to get a good signal - note it will look VERY different from previous encryption examples:
    A8 traceexample.png
  3. Capture a larger (~500) number of traces.

Running Attack

The attach is ran in the same manner as previous AES attacks, we use the same leakage assumptions as we don't actually care about the T-Table implementation. The resulting output vs. point location will look a little "messier", as shown here:

A8 outputvspoint.png