Side Channel Analysis, Expectation-Maximization, Correlation Power Analysis, CPA, DPA
This repository contains the code for the demonstration of Unprofiled Expectation Maximization Distinguisher for Side Channel Analysis. For more detail about the theory you can checkout the article .
This is a joint work with
- Julien Béguinot (Télécom Paris, Institut Polytechnique de Paris)
- Wei Cheng (Secure-IC S.A.S, Télécom Paris, Institut Polytechnique de Paris)
- Sylvain Guilley (Secure-IC S.A.S, Télécom Paris, Institut Polytechnique de Paris)
- Olivier Rioul (Télécom Paris, Institut Polytechnique de Paris).
The repository is organized as follows:
- An Interactive Python Notebook DEMO.ipynb demonstrate how to use the Distinguishers.
- Figs contains figures about the performance of the distinguishers in various conditions.
- Code DPAV4 contains code to test the distinguishers on the DPAv4.2 Contest hosted at Télécom Paris.
- CodeSim contains code to evaluate the distinguisher by numerical simulations.
- DATA contains the Point of Interest already extracted from the 16 folders of the DPA Contest. There is also scripts that shows how to do it. The data to re-extract these PoIs is not present in the repository as theyr are verry heavy. Please use the DPAv4.2 Contest if you want to download them.
We briefly recall how the different distinguishers presented works. For more detail refer to the article. The notations used are
- t for plaintext
- q for index of a trace
- y for a trace
- x for a sensitive variable of the model
- m for a mask
- k for the secret key
- S for the Substitution Box
- w_H for the Hamming Weight
A state-of-the-art unsupervised attack on bivariate leakage with first-order masking is the second-order correlation power analysis with centered product combination on leakage of different shares . This is simply a classical CPA is applied to the centered product of the different samples. For a given key hypothesis k , we write
where
The distinguisher is then
where
For the maximum likelihood with templates, we assume that the parameters a^* and b^* are known. Hence the maximum likelihood distinguisher can be directly computed from the traces. This is unrealistic as these parameters are unknown in practice. Indeed, their knowledge requires a profiling on a identical device where the masks are also known; our attack scenario makes no such assumption. Its expression simplifies to
$$ \hat{k} = \arg \max_{k} \mathbb{P}(\mathbf{Y}=\mathbf{y}|k,a^{},b^{}). $$
We briefly recall how the U-EM distinguisher works. For more details please refer to the article.
The EM algorithm is made up of two main steps: The expectation step (E-Step) and the maximization step (M-Step).
One iteratively
- takes the expectation over the masks given the last value of the parameters that have been computed
- maximizes the expression in the parameters to update them.
- The algorithm stops when a given convergence criterion is achieved.
We initialize the value of a_0 and b_0 arbitrarly, and at each iteration p build (a_p) and (b_p) recursively using the formula
We show in the article that it reduces to
where \alpha denotes the Bayes posterior probabily that the mask is used for a given trace.
Let
The empirical autocorrelation matrix is
and the empirical intercorrelation is
The M-Step is given by the following rule:
When a convergence threshold is reached then the U-EM distinguihser ranks the key by deacreasing goodness of fit with the model. That is we compute the expression of the template attack but with the computed coeficient.
We can validate that the raw traces from the DPAv4.2 Contest actually leak information about the sensitive variables. This is done by computing the Pearson correlation coefficient in between the raw traces and the sensitive variables with Hamming Weight Leakage. We observe that the output of the SBox leaks aroud the time $ \approx 27 \times 10^4 $ and the masks leaks at different times e.g. $ \approx 30 \times 10^4$.
For the PoI extraction we repectively used for the 16 folders:
T0 = [ 270581,270581,270581,270581, 270580,270581,270580,270580, 270581,270580,270581,270581, 270581,270580,270580,270580 ]
T1 = [ 307824,307822,307825,307821, 307821,307823,307824,307823, 307824,307823,307824,307823, 307823,307824,307823,307823 ]
This browser does not support PDFs. Please download the PDF to view it: Download PDF.
This browser does not support PDFs. Please download the PDF to view it: Download PDF.
We have validated the performances of the Distinguishers numerically and on the real traces from DPA Contests.