Physical Unclonable Functions seminar repository for the course Advanced Information System Security and Blockchain 2023/24 at Engineering in Computer Science Master's degree Sapienza.
Python packages
pyserial
numpy
tqdm
The Arduino program, the custom serial monitor and the Python analysis script are contained in the arduino folder. Make sure that bytes_to_read
in serial_monitor.py
is at most the value in char bytes[]
and i <
in sram_puf.ino
. For instance
bytes_to_read = 4
and
char bytes[4] __attribute__((section(".noinit")));
void setup()
{
Serial.begin(115200);
for (int i = 0; i < 4; i++)
{
Serial.write((unsigned int)bytes[i]);
}
Serial.println();
}
void loop() {}
The number of bytes to read from the device depends on the device itself. The seminar involved a Keystudio Mega 2560 R3 board with 8KB of SRAM. Taking into account the bytes occupied by the program, the boot loader, etc., 8004 is the upperbound of bytes that can be retrieved.
To read data from the board, do the following steps:
- Set up the parameters, i.e. the number of bytes
- Compile and upload the program onto the board. You can do this by using, for instance, the Arduino IDE
- Identify the port where your device is connected to and hardcode it into the variable
SERIAL_PORT
inserial_monitor.py
(again, the Arduino IDE should point it out) - Start the monitor by running
python3 serial_monitor.py
- Connect the device via USB to your computer
- Wait for the string to be read (upon completion, the string will be printed on
stdout
) - Disconnect the device from your computer
- Wait some seconds to let the memory cells completely discharge
- Repeat from 5
- Once the amount of strings collected makes you happy, press
Ctrl-C
to exit the program
Once you collected some strings from the device, you may want to compute some metrics. Run
python3 analysis.py
The main code of the fuzzy extractor proposed by Canetti et al. is in canetti.py
. You can execute it by running
python3 canetti.py
Some parameters can be set to perform different experiments. In particular:
- n is the length of the string in bits
- k is the length of the key in bits
- eabs is the absolute error of the noisy source
- experiments is the number of runs performed to collect statistics
- random_w chooses whether retrieving them from a file (0) or generating them randomly (not 0). In the first case, make sure to collect data from your device before executing this script.
The cryptographic primitive which the fuzzy extractor is built upon, i.e. digital lockers, is implemented in digitallocker.py. Random generation of strings is in charge of patterns.py.
This is a Git Submodule that refers to this repository. It contains the code of the fuzzy extractor proposed by Liberati et al.
To compile run:
make
for an optimized compilationmake debug
to have more debug informationmake test
to include also speed metrics
After compilation, execute the code by running
make run
To clean up everything after execution, run:
make clean