Implementing Lightweight Cryptography in Smart Home Ecosystem

How I implemented Ascon v1.2 (a form of lightweight cryptography) in a smart home ecosystem

This project explores the implementation of Ascon v1.2, a lightweight cryptographic algorithm, in IoT devices, particularly in smart home ecosystems. Ascon v1.2 offers robust security and energy efficiency, crucial for devices with limited resources. The research demonstrated Ascon v1.2's effectiveness in securing sensitive data in smart homes, highlighting its balance of security, reliability, and efficiency. The project underscores the potential of Ascon v1.2 to enhance IoT security, promoting energy-efficient solutions and contributing to the growth of the smart home industry.

What is Lightweight Cryptography?

Lightweight cryptography involves efficient cryptographic algorithms tailored for devices with limited resources, like IoT sensors and smart cards. Designed for minimal energy consumption and small code size, these algorithms ensure secure data encryption and authentication while optimizing performance on low-power processors. They play a vital role in safeguarding sensitive information in resource-constrained environments.

This snapshot shows the Ascon v1.2 Python script used in a smart home ecosystem to encrypt data between the router and smart hub, simplifying encryption. It displays data in encrypted and decrypted forms, ensuring security without complicating device connectivity. You can gain access to this code via my GitHub repositories, 'GitHub - Ridwan-Jeylani/Ascon-v1.2-in-Smart-Homes' .

import os

from ascon import encrypt, decrypt #this section shows the 128 bit key and 128 bit nonce

key = os.urandom(16) # this is the 128-bit key

nonce = os.urandom(16) # this is the 128-bit

nonce def encrypt_data(plaintext, associated_data):#this section encrypts the plaintext and the associated data with Ascon v1,2

ciphertext = encrypt(key, nonce, associated_data, plaintext, variant="Ascon-128")

return ciphertext

def decrypt_data(ciphertext, associated_data): #this section decrypts the ciphertext data and the associated data with Ascon v1.2

plaintext = decrypt(key, nonce, associated_data, ciphertext, variant="Ascon-128")

return plaintext

#Alexa smart speaker data Alexa_smart_speaker_data = "Alexa, can you play my favorite song: 'Stop Breathing' by Playboi Carti"

associated_data_smart_speaker = b"Alexa Smart Speaker"

#Nest smart thermometer data

Nest_smart_thermometer_data = "The Temperature is set at: 24°C, Humidity: 55%"

associated_data_Nest_thermometer = b"Nest Smart Thermometer"

#Philips hue smart lights data

Philips_Hue_smart_lights_data = "Dim Living room lights to 60%"

associated_data_Philips_Hue_lights = b"Philip Hue Smart Lights"

#Panamalar smart garge door alarm system data

Panamalar_smart_garage_door_alarm_data = "The garage door closed"

associated_data_garage_door_alarm = b"smart garage door alarm"

# Encrypt and decrypt data for each device

encrypted_speaker = encrypt_data(Alexa_smart_speaker_data.encode("utf-8"), associated_data_smart_speaker)

decrypted_speaker = decrypt_data(encrypted_speaker, associated_data_smart_speaker)

encrypted_thermometer = encrypt_data(Nest_smart_thermometer_data.encode("utf-8"), associated_data_Nest_thermometer)

decrypted_thermometer = decrypt_data(encrypted_thermometer, associated_data_Nest_thermometer)

encrypted_lights = encrypt_data(Philips_Hue_smart_lights_data.encode("utf-8"), associated_data_Philips_Hue_lights)

decrypted_lights = decrypt_data(encrypted_lights, associated_data_Philips_Hue_lights)

encrypted_garage_door_alarm = encrypt_data(Panamalar_smart_garage_door_alarm_data.encode("utf-8"), associated_data_garage_door_alarm)

decrypted_garage_door_alarm = decrypt_data(encrypted_garage_door_alarm, associated_data_garage_door_alarm)

print(f"Alexa Smart Speaker - Encrypted data: {encrypted_speaker.hex()}")

print(f"Nest Smart Thermometer - Encrypted data: {encrypted_thermometer.hex()}")

print(f"Philips hue smart lights - Encrypted data: {encrypted_lights.hex()}")

print(f"Panamalar smart garge door alarm system - Encrypted data: {encrypted_garage_door_alarm.hex()}")

print(f"Alexa Smart Speaker - Decrypted data: {decrypted_speaker.decode('utf-8')}")

print(f"Nest Smart Thermometer - Decrypted data: {decrypted_thermometer.decode('utf-8')}")

print(f"Philips hue smart lights - Decrypted data: {decrypted_lights.decode('utf-8')}")

print(f"Panamalar smart garge door alarm system - Decrypted data: {decrypted_garage_door_alarm.decode('utf-8')}")