Coder Social home page Coder Social logo

iot-aes-128's Introduction

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 Side Channel Attack. This code is just for simplicity and readability to explain how 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.

iot-aes-128's People

Contributors

ricoen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.