# Study About the Performance of Ascon in Arduino Devices
## 5 Performance Analysis of the Ascon Implementation
### Selected Arduino Devices  
Four different types of Arduino devices were used in this performance comparison: Arduino DUE, Arduino Mega2560, Arduino Nano Every, and Arduino Nano ESP32 (Arduino S.r.l., Somerville, MA, USA, [[https://www.arduino.cc/en/software/](https://www.arduino.cc/en/software/)]([https://www.arduino.cc/en/software/](https://www.arduino.cc/en/software/)), accessed on 18 February 2025). Each Arduino device has the following characteristics:  
* Arduino DUE (Arduino S.r.l., Somerville, MA, USA) is based on a powerful 32-bit SAM3X8E ARM Cortex-M3 ARM microcontroller, with 96 KB of SRAM memory (divided into two banks, one of 64 KB and the other one of 32 KB), and with a 512 KB flash memory for the user application, and a clock speed of 84 MHz.
* Arduino Mega2560 (Arduino S.r.l., Somerville, MA, USA) (less powerful than the previous one) is a board based on the 8-bit AVR CPU core ATmega2560 microcontroller, 256 KB flash memory, of which 8 KB are used by the bootloader, and a clock speed of 16 MHz.
* Arduino Nano Every (Arduino S.r.l., Somerville, MA, USA) is based on an 8-bit AVR CPU core ATmega4809 microcontroller with hardware multiplier, 48 KB flash memory, and a higher clock speed of 20 MHz.  
* Arduino Nano ESP32 (Arduino S.r.l, Somerville, MA, USA) has the u-Blox NORA-W106-10B processor, which is based on SP32-S3 RISC-V microcontroller of dual core Xtensa LX7. Note that we have used only one core. It can reach speeds of up to 240 MHz. Its memory has 512 KB SRAM, 384 KB ROM, 8 MB PSRAM, and 16 MB flash.  
The mentioned Arduino devices were selected because they are the most used and sold devices. In addition, this selection of devices will allow us to compare two 8-bit and two 32-bit devices with each other and also make a comparison between the 8-bit and 32-bit devices.  
All Arduino devices used in this study were programmed in the Arduino IDE (Integrated Development Environment), version 2.3.2 (Arduino S.r.l, Somerville, MA, USA, [[https://www.arduino.cc/en/software/](https://www.arduino.cc/en/software/)]([https://www.arduino.cc/en/software/](https://www.arduino.cc/en/software/)) (accessed on 18 February 2025), which was installed on a 64-bit PC with 32 GB of RAM and Windows 11 Pro operating system. In order to be tested, the software runs directly on each Arduino device and once the time, cycles, etc. have been calculated within each device, the output data are sent through its serial port and read in the IDE environment on the PC.  
In addition, in order to interfere as little as possible with the reference implementations that other users can prefer to use, we have tried to modify the reference versions of the Ascon family as little as possible when implementing them in the different devices. In this way, we modified the generation of random keys and random data for Ascon, for which we have used the rand() function implemented by the Arduinos. In this case, Ascon needs to generate several data: message, key, nonce, etc. The function used is presented as Algorithm 7.
```
void RandGen(){ for (i = 0; i < C RYPTO_NPUBBYTES; i++) n[i] = rand()%0 xFF; for (i = 0; i < CRYPTO_KEYBYTES;i++) k[i]=rand()%0 xFF; for (i = 0; i < 16; i++) { a[i] = r and()%0 xFF; m[i] = r and()%0 xFF; }
```
**Algorithm 7** Random data generation for Ascon