Framework for side-channel attacks through power consumption using the Correlation Power Analysis (CPA) attack method. This implementation includes attacks on AES-128 and ASCON-128. As a baseline were used scripts developed by Leo Weissbart and Łukasz Michał Chmielewski, provided by the CESCA Lab.
Download and unzip
cd /tmp
wget https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tgz
tar -xvf Python-3.13.5.tgz
cd Python-3.13.5
Install required libraries and compile Python
sudo apt install -y build-essential libssl-dev libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libreadline-dev libncurses5-dev zlib1g-dev tk-dev libgdbm-dev libdb5.3-dev libexpat1-dev
./configure --enable-optimizations
make -j$(nproc)
sudo make altinstall
Check if it is correctly installed
python3.13 --version
cd ~
git clone https://github.com/Qas1modo/CPA-Framework
cd CPA-Framework
mkdir venv
python3.13 -m venv ./venv
Activate venv (temporary)
source ./venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
python -m pip install numpy
python -m pip install numba
python -m pip install trsfile
python -m pip install tqdm
python -m pip install pandas
python -m pip install scipy
python -m pip install matplotlib
Temporary
export PYTHONPATH="~/CPA-Framework:$PYTHONPATH"
Permanent
echo 'export PYTHONPATH="~/CPA-Framework:$PYTHONPATH"' >> ~/.bashrc
Sometimes this does not work with '~', specify full path when it happens.
python -m pip install smartleia
git clone https://github.com/cw-leia/smartleia-target
cd smartleia-target
python3 -m pip install .
cd ..
rm -rf ./smartleia-target
python3 -m pip install picosdk
python3 -m pip install pycryptodome
All user configuration is located in the Configuration folder. Modify relevant files and their values to match your preferences.
- AES config to configure AES attack.
- Alignment config to configure directly started Alignment.
- ASCON config to configure ASCON attack.
- ASCON Trace Gen config to configure trace generator.
- Constants are used to store global constants, but they can be updated if necessary.
- Measurement Script Constants are used to store constants needed in measurement scripts, and can be updated if necessary.
- Measurement Script JavaCard config used to set up measurement script for JavaCard.
- Resampler config to configure directly started Resampler.
- TVLA config configures Test Vector Leakage Assessment(TVLA).
- Alignment ⇒ Perform alignment based on your config.
- Resampler ⇒ Resample traces based on your preferences.
- Trace Converter ⇒ Convert or cut trace sets based on your preferences inside the file.
- Trace Printer ⇒ Print metadata and sample snippets from a trace set based on your preferences inside the file.
- Trace Visualizer ⇒ Interactively visualise traces based on your preferences inside the file.
- TVLA ⇒ Run TVLA on TraceSet specified in this config.
- AES Attack ⇒ Run AES attack based on your preferences from config.
- ASCON Attack ⇒ Run ASCON attack based on your preferences from config.
- ASCON Trace Gen ⇒ Run Trace Generator to create traces for leakage detection testing based on your preferences from config.
- Measurement Script JavaCard ⇒ Measurement script used to capture power traces from JavaCard by Picoscope, configured from here.
If you want to use the framework for a new SCA attack, you can use Generics by inheritance.
- Generic Attacker ⇒ Has the necessary functionality to perform SCA attack (automatic alignment, ...).
- Generic Extractor ⇒ Helps you with running the attack on multiple targets and prints results.
- Generic Logger ⇒ Helps you with logging the attack performance.
- Generic Parallel Writer ⇒ Has the functionality to parallelly write/read TRS, NPY and NPZ files.
- Generic Trace Loader ⇒ Implement reading of TRS, NPY and NPZ files with their metadata.
- Generic Trace Writer ⇒ Implement reading/writing of TRS, NPY and NPZ files with their metadata.
- Generic Trace Creator ⇒ Used to create traces in TRS, NPY and NPZ file formats without input files.