Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EECE 5699: Hardware and Software Security

Lab 2 Fall 2023

Lab 2 - Correlation Power Analysis Attack

Due on Oct.  13 (F) 2023 Noon on GitHub

1    Overview

In this lab, you will implement a correlation power analysis (CPA) attack and recover a full round key used in an AES encryption process. You are provided with a set of power traces of the 128-bit AES core running on an FPGA board already acquired in the NUEESS lab (https://chest.coe.neu.edu/) of Northeastern University. You will first examine the power traces, and understand the implementation and the suitable power model. As the starting point, you are told which time point is the leakiest one. You will need to utilize this leakage point to perform a correlation power analysis and recover the full round key.

You can choose to use any programming languages and environments you are familiar with, such as Matlab, C, and Python.

2    Accept your Assignment on Github

Same as Lab 1, please click the following link to accept assignment: https://classroom.github.com/a/ 0FWNDnin

3    Data Set

Check data.zip under handout folder, and you will have a set of 7000 power traces for an unmasked AES running on an FPGA board (SAKURA-GII). Once you unzip the downloaded data, you will see the following files in .txt format (plain text):  ciphers, plaintexts, traces.

As you are attacking the last round, you will need to use ciphers.txt  and traces.txt files for this lab.  Each row of both files is for one encryption, which consists of one 16-byte ciphertext and one 3125-point power trace, respectively.

First, you will need to generate a plot of one power trace in the data set. You should see 11 dips in your plot. Q1:  Explain why there are 11 dips instead of 10 dips.

4    Correlation Power Analysis with Hamming Distance Power Model

For this part of the lab, you will need to use the Hamming Distance (HD) power model to recover all 16 AES key bytes. With the correct key byte value, the HD model yields the strongest correlation with power values at time point 2663 (the HD Leakage Point).

Organization of AES State:, The 128-bit AES encryption has ten rounds and eleven states, where each state is  16-byte and organized as in Table 1.   Its index is increasing vertically within columns  (column-major order).

0

4

8

12

1

5

9

13

2

6

10

14

3

7

11

15

Table 1: AES 16-Byte State

Hamming  distance  power model:  We attack the last round of AES and use the Hamming distance power model for each byte.  Assume the input state for the last round is S and the output state is the ciphertext C,  and the relationship between them is  cj   =  sbox[si] ⊕ kj   due  to  the  ShiftRow  operation,  i.e.,  si    = inv sbox[c j  ⊕ kj ]  ,  with the mapping between the input state index i and output state index j being as follows (derive the mapping and verify):

Input state i

Output state j

0

0

5

1

10

2

15

3

4

4

9

5

14

6

3

7

8

8

13

9

2

10

7

11

12

12

1

13

6

14

11

15

Table 2: Last-round input state index and output state index mapping

So the HD power model for each byte will be HD(si , ci ) = HD(inv sbox[c j  ⊕ kj ], ci ). For a selected key byte kj , for each key byte guess value, use this HD model to predict the power values and correlate them with the measured power values (at the leakage point).  The correct key byte value should be the one with the strongest correlation.

5    What You Need to Submit

Note you need to find the corresponding AES inverse SBox (inv  sbox) and use it in your attack code.  When finishing the attack, you need to submit the following two files onto GitHub:

1.  A PDF report file (less than 2 pages) containing:

(a)  A plot for one power trace.

(b)  A plot showing all key bytes recovery by CPA. The plot should have 16 subplots, each representing a key byte (refer to Slide 46 of Lecture 2) . You are also given two PNG files in the handout.zip, one successful key byte recovery and the other unsuccessful.

(c)  Report of the entire 16-byte AES last-round key, with each byte in hexdecimal.

(d)  Summary of your experience (including answers to questions). If your program does not find the key successfully, it is very important for you to provide some analysis here, so that the TA and I know your understanding level and efforts so as to evaluate for partial credit.

2.  Upload all your source files to GitHub.  You should edit the README.md file under submission that contains the necessary information to run your program. Please, do not submit the dataset provided to you!!

6    Extra Credit (20 points)

You can continue exploring the attack in more scenarios.

1.  Attack  Without  Knowing  the  Leakage  Point  -  10  extra  points:   You are given the leakage point when you perform the attack. In reality, an adversary would not know the leakage point. He can have some educated guess of the range of time points where the last round of the AES encryption happens, e.g., in the range of [2600, 2700].  CPA based on the HD power model has to be performed on all the time points in a range, as explained in class. You will obtain a 2-dimensional matrix of Pearson correlation coefficients (both time dimension and key-space dimension). The highest value in the matrix will give out both the correct key byte value and the leakiest point. Verify if the leaky point you find is indeed point 2663.

2.  Attack  Using  Hamming  Weight  (HW)  Power  Model  -  10  extra  points:   We have used the  HD power model for FPGA implementations. You can test whether there is power leakage under the HW model. Since you have already recovered the correct key value, you can choose one key byte, and use the key value to calculate the Hamming Weight of the last-round input under different plaintext.  Calculate the correlation between the HWs and the power values at each time point in the range [2400, 2500]. Pick the time point with the strongest correlation and test if you can launch an attack using the HW model at this point.