Lab 2 - Power Analysis Attacks

2026-01-12  |  Hackster , Labs , Power Analysis , Side Channel , Cryptography

Introduction

Power analysis attacks are a type of side-channel attack that exploit variations in the power consumption of a device to extract sensitive information, such as cryptographic keys. These attacks are particularly effective against embedded systems and hardware implementations of cryptographic algorithms.

In this lab, you will learn about power analysis attacks and how they can be used to compromise the security of a cryptographic implementation of AES-128.

Goals:

  1. Understand the basics of power analysis attacks on cryptographic hardware
  2. Understand the target AES implementation and how to interact with it using the provided hardware and software tools
  3. Design a suitable strategy for performing a correlation power analysis attack on the AES implementation by choosing a target clock cycle which would help you to identify the key
  4. Perform a complete correlation power analysis attack on the AES implementation to recover the key

Getting Started

  1. Do a git pull to get the latest version of the lab materials.
  2. Open up the examples/power_aes_no_io/ project
  3. Load the example bitstream onto the fpga with make run_fpga, this contains a bitstream with a known AES key (0x00112233445566778899aabbccddeeff). You won’t be able to observe very much - just dim colors on the ICE and RGB LEDs. This is expected, as:
  4. This bitstream contains a simple AES-128 implementation which is connected to a 128-bit linear feedback shift register (LFSR) which is used to generate the plaintext input to the AES. Each operating cycle, the LFSR shifts and generates a new plaintext input to the AES, which then performs a complete encryption. The only output of the AES is provided via an LED.
  5. The file top.v contains the top-level finite state machine which controls the operation of the AES and LFSR. Open it up and see how the LFSR and AES are being triggered, and how a few of the ouputs from the AES are being fed to the LEDs. Also see how the ICE_LED is being controlled.
  6. This implementation is vulnerable to a power analysis attack, as the power consumption of the device will vary based on the operations being performed and the data being processed. By measuring the power consumption of the device during encryption, you can potentially extract information about the key being used.
  7. Using your two provided SMA-BNC cables, connect the two SMA connectors on your Hackster to two channels of your oscilloscope. Now, configure the oscilloscope to use the ICE_TRIG signal as a trigger, and display the power consumption of the device on the other channel. You should be able to make a clear, repeating capture which shows the different clock cycles of the AES encryption process.
  8. Now, you need to design a strategy for performing a correlation power analysis attack on this AES implementation. This will involve choosing a target clock cycle during the AES encryption process which you think will be most informative for recovering the key. You will then need to write a program in Python which will analyse the power traces you capture from the board and perform the correlation power analysis attack to recover the key.
  9. In each “run” of the cryptographic hardware, the top-level module does the following:
  1. By resetting the core, we can reconstruct the value of the LFSR at each of the encryption cycles, and therefore the plaintext input to the AES at each cycle. Then, because we know the key is fixed in each encryption, by correlating the power consumption data with the known plaintext and key values, we can identify which key is being used.
  2. The LFSR is also implemented in top.v. It is a 128-bit LFSR with taps at bits 127, 109, 85, and 0. At reset it is initialised to 128'hACE1ACE159C359C3B386B386670D670C. Each cycle, the LFSR shifts left by one bit, and the new LSB is calculated as the XOR of the bits at the tap positions. You can use this information to reconstruct the plaintext input to the AES at each cycle.
  1. This pattern of operations is what makes it possible for us to perform the CPA attack straightforwardly.
  2. To automatically collect the power traces for the core, run make run_fpga_power. This resets the board and captures 5000*1024 power values from the Hackster’s internal ADC, which are then saved to a file called power_data.txt. These are collected based on the trigger signal, so they are aligned with the AES encryption cycles. You can use this data to perform your correlation power analysis attack.
  3. Open up this file and take a look.
  1. When you are ready to proceed, you should download from Moodle the Lab2_Bitstreams.zip and find the (your zID)_lab2_spi_aes.bin and (your zID)_lab2_power_aes_no_io.bin corresponding to you.

    • You can run these bitstreams by:

      • Power bitstream (regular operation for oscilloscope capture):
      $ ZID=(your ZID) make run_fpga
      
      • Power bitstream (capture power using onboard ADC):
      $ ZID=(your ZID) make run_fpga_power
      
  2. These are variants of the AES implementation you have been working with, but with a unique key.

  3. To begin with, use the oscilloscope to capture the power trace of your implementation while it is running. You should see a similar pattern to what you saw with the example bitstream, but with different values. Once you have the oscilloscope set up, take a screenshot and save it to a USB drive. You will hand this in as part of you deliverables.

  4. Your goal is to now perform the CPA attack on your implementation.

  5. Once you think you are done, you can check your answer by using the lab2_spi_aes.bin bitstream, which contains the same AES implementation (with your same cryptographic key) but with an SPI interface rather than the LFSR. You can encrypt some values and see if the key you recovered from the CPA gives you the ciphertexts you would expect!

Deliverables and Weightings:

This lab is worth 10% of your final grade for this course.

Resources

You will likely find the pseudo-code for the attack in the lecture slides for Week 4 helpful - see Slide 79.

Grading Rubric

Correlation Power Attack (10%)