Skip to content

Pure AES-128 implementation for IoT Module (Tested in Particle Photon)

License

Notifications You must be signed in to change notification settings

ricoen/IoT-AES-128

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 

Repository files navigation

IoT_AES-128

License: MIT

Plain AES-128 implementation (Rijndael Algorithm) for embedded system and IoT module (Tested in Particle Photon). References of this implementation (Many thanks to them):

Project Nayuki: https://www.nayuki.io/page/cryptographic-primitives-in-plain-python

Niyaz PK: http://www.hoozi.com/posts/advanced-encryption-standard-aes-implementation-in-cc-with-comments-part-2-decryption/

This implementation use sensor data from BME280 environmental sensor for plaintext. Added lines for send ciphertext via UDP and TCP/IP (Particle device only). Although it's resulted fair performance and good value of Avalanche Effect, but it can't be used for securing real IoT system because its vulnerabilities of using default mode (ECB mode) that can be analyzed with a Side Channel Attack. This code is just for simplicity and readability to explain how the AES algorithm is.

Important

USE FOR EDUCATIONAL PURPOSE ONLY.

For real IoT system use this cryptographic API or library instead

General: https://github.com/kokke/tiny-AES-c

Embedded system: https://tls.mbed.org/

ESP32: https://github.com/espressif/arduino-esp32/tree/master/tools/sdk/include/mbedtls

TCP/IP & UDP Lines

This lines is for TCP/IP and UDP function.

To define TCP/IP connection, you can change this line with your destination IP and port.

TCPClient client;

IPAddress tcpIP(192,168,43,113);
int tcpPort = 5050;

To define UDP connection, you can change this line.

UDP Udp;

IPAddress remoteIP(192,168,43,113);
int udpPort = 1337;

To send packet, you can use this line:

  1. For TCP/IP
if (client.connected())
  {
    client.write(enc);
  }
  1. For UDP
if (Udp.sendPacket(enc, sizeof(enc), remoteIP, udpPort) < 0)
  {
    Serial.printlnf("Error");
  }

Fore more line functions, you can explore in this reference:

Particle Docs. https://docs.particle.io/reference/device-os/firmware/photon/

Don't need to connect to UDP and TCP/IP?

View aes_upnocon.c file.

Test Results

1. AES Performance

This test purpose is to find throughput and Avalanche Effect of the algorithm implementation in the system. The test results was taken from 10 times encryption.

The time of encryption can be measured with the formula below:

For the throughput can be measured with this formula below:

Notes:
X-axis is encryption time (microseconds)
Y-Axis is troughput (bits/second)

2. Energy Consumption

This test purpose is to find how much energy used for one time encryption. The method used for this test is calculate Vshunt of the IoT modules such in the picture below.

The value of energy consumption is measured in 12 miliseconds time interval using oscilloscope. The results is the average of power and energy consumed for encryption in time interval.

The power needed for one cycle encryption process (12 miliseconds) can be measured with the formula below:

And the energy needed for one cycle encryption can be measured with the formula below:

Notes:
X-axis is conditition (encrypt/idle)
Y-Axis is Energy consumption (milliJoules)

References

Abdelgawad, A., 2014. Distributed data fusion algorithm for Wireless Sensor Network. Miami, IEEE.

Elminaam, D. S. A., Kader, H. M. A. & Hadhoud, M. M., 2010. Evaluating The Performance of Symmetric Encryption Algorithms. International Journal of Network Security, 10(3), pp. 213-219.

Donnay, V. J., 2013. Solar Panels, Energy and Area Under the Curve Teacher Guide, Bryn Mawr: Bryn Mawr College.

Moreno, C. & Fischmeister, S., 2017. Accurate Measurement of Small Execution Times – Getting Around Measurement Errors, Waterloo: University of Waterloo.

About

Pure AES-128 implementation for IoT Module (Tested in Particle Photon)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages