Hybrid Cryptographic End-to-End Encryption Method For Protecting IoT Devices Against MitM Attacks
Hybrid Cryptographic End-to-End Encryption Method For Protecting IoT Devices Against MitM Attacks
Innov’COM Laboratory, SUPCOM, University of Carthage, Route de Raoued 3.5 Km, Ariana, Tunis, Tunisia
Submitted May 5, 2024 / Accepted September 16, 2024 / Online first October 31, 2024
Abstract. End-to-End Encryption (E2EE) plays an es- data exchange in IoT applications [3]. An IoT device trans-
sential role in safeguarding user privacy and protecting mits a message payload to a subscriber through an MQTT
sensitive data across various communication platforms, in- broker on port 1883. The device, acting as an MQTT client,
cluding messaging applications, email services, and Inter- establishes a TCP connection with the broker on port 1883.
net of Things (IoT) devices. This paper presents a Hybrid Once connected, the device publish to a specific topic of inter-
Cryptography-Based E2EE method implemented on a Soft- est, with topics acting as channels for message transmission.
ware Defined Networking (SDN) infrastructure, to strengthen The device sends a publish message to the broker, specifying
bidirectional data security between hosts and IoT devices the topic and desired Quality of Service (QoS) level. The
via the non-secure Message Queuing Telemetry Transport broker then forwards the message payload to all subscribers
(MQTT) port. By addressing the threat of Man-in-the-Middle interested in that topic.
(MitM) attacks, the proposed system ensures that only autho-
rized users can decrypt transmitted messages. This paper In the context of an SDN-IoT environment [4], where the
thoroughly analyzes the implementation and advantages of control plane [5] is distinct from the data plane [6], and com-
our Hybrid Cryptography-Based E2EE method by comparing munication involves network devices orchestrated by a cen-
RSA and ECC encryption techniques. ECC-256 is favored for tralized controller, the process of subscribing and publishing
key generation, owing to its high efficiency and speed, mea- in MQTT remains largely unchanged. The SDN controller
sured at 0.4009 ms. Additionally, through a comparison of plays a central role in managing the network infrastructure
RSA, AES, and ChaCha20 algorithms, AES-256 emerges as and facilitating communication between MQTT clients and
the optimal encryption choice, demonstrating the fastest en- the broker. By leveraging SDN capabilities such as central-
cryption and decryption times for publishing 0.2758 ms and ized control and programmability, organizations can achieve
0.1781 ms, respectively and for subscribing, with encryp- more efficient and dynamic management of MQTT commu-
tion at 0.2542 ms and decryption at 0.1577 ms. Along with nication in their IoT deployments. Nevertheless, this commu-
its minimal packet size and low resource consumption, our nication may pose cybersecurity threats, such as an MitM at-
proposed Hybrid Cryptography-Based E2EE method, imple- tack [7] and [8], due to the vulnerability of port 1883 MQTT.
mented on SDN infrastructure, validate it’s effectiveness in When MQTT traffic is transmitted over port 1883 without
securing digital communications within SDN environments encryption, an attacker positioned between the client and the
compared to existing solutions. broker can intercept and manipulate the communication, as
shown in Fig. 1. This allows the attacker to eavesdrop on
the messages exchanged between the client and the broker,
modify the content of the messages, or even impersonate
Keywords either party, thereby compromising the confidentiality and
integrity [9] of the communication. To mitigate this vul-
Software-Defined Networking (SDN), cyber security, nerability, it’s recommended to use encryption [10] method
Man-in-the-Middle (MitM), end-to-end encryption, In- to secure MQTT communication and prevent MitM attacks.
ternet of Things (IoT) Therefore, securing the MQTT port is crucial to mitigate such
threats. E2EE [11] is an effective method that ensures trans-
mitted information remains confidential and secure. When
a device publishes data, it encrypts the information using the
1. Introduction public key of the intended recipient(s). Subscribing devices
In the context of IoT devices [1], MQTT [2] facilitates receive the encrypted data and use their private keys to de-
efficient and reliable communication between IoT devices crypt and access the original information. The encryption
and other systems via a central broker, enabling real-time and decryption processes occur exclusively at the endpoints,
DOI: 10.13164/re.2024.0583
584 N. KARMOUS, M. HIZEM, Y. BEN DHIAB, ET AL., HYBRID CRYPTOGRAPHIC END-TO-END ENCRYPTION METHOD . . .
3. System Model
Our system model comprises a smart home ecosystem,
consisting of IoT devices equipped with DHT11 sensors and
smart lights. Additionally, It includes an MQTT broker,
specifically the Mosquitto server [19], which was installed
on a Raspberry Pi 4 running the Raspbian OS. The purpose
of this system model is to encrypt the MQTT payload mes-
sages sent by the publisher via 1883’ port to the broker before
being decrypted by IoT devices or SDN host server.
4.1 Hardware and Software Tools Algorithm Key size [octets] Key generation time [ms]
RSA 2048 1.73303
This project utilizes specific hardware and software RSA 4096 3.1699
tools. The hardware includes a virtual machine run- ECC 128 0.2150
ning Ubuntu 22.04 with the following specifications: In- ECC 192 0.3262
tel Core i5-1235U processor (4.40 GHz Turbo max, 12 MB ECC 256 0.4009
cache, 10 cores), 16 GB DDR4 RAM, and 256 GB SSD stor- Tab. 1. Key generation time comparison for RSA and ECC al-
age. The software tools used are Mininet, a free and open- gorithms in SDN infrastructure
source tool for creating virtual networks and running net-
working applications at high speeds; Ryu Controller, an open-
source SDN controller that manages network devices via the
OpenFlow protocol for dynamic control and centralized man-
agement; Mosquitto, an open-source message broker imple-
menting the MQTT protocol for publishing and subscribing
to messages in IoT applications; Ettercap, a tool for perform-
ing man-in-the-middle attacks, which allows traffic intercep-
tion and analysis; and Wireshark, an open-source network
protocol analyzer for capturing and inspecting data packets
in real-time.
Encryption time for 10B Decryption time for 10B Encryption time for 30B Decryption time for 30B
Algorithm
[ms] [ms] [ms] [ms]
RSA-2048 0.9372 0.3839 0.9666 0.4412
RSA-4096 1.597 0.5546 1.772 0.6560
AES-128 0.1504 0.05927 0.1826 0.07110
AES-192 0.2138 0.1062 0.2391 0.1369
AES-256 0.2542 0.1577 0.2758 0.1781
ChaCha20-128 0.3091 0.2118 0.3200 0.2366
ChaCha20-192 0.3598 0.2575 0.3697 0.2782
ChaCha20-256 0.4116 0.3013 0.4595 0.3479
Tab. 2. Comparison of encryption and decryption times for 10-byte and 30-byte MQTT payload messages using RSA, AES, and ChaCha20
algorithms in SDN infrastructure.
Algorithm 1. Encrypting at sender’s side (IoT device). • Key Verification and Sharing: Upon receiving the
public key, the IoT device verifies its integrity using
1:<Input: published_data, public_key_receiver> a Message Authentication Code (MAC) provided by
2:<Output: encrypted_message> the SDN controller.
3.pm <–published_data
4. shared_secret <–perform_ECDH(public_key_receiver, pri-
vate_key_sender)
• Key Derivation: After successful verification, the IoT
5. derived_key <–HKDF(shared_secret, key_length=256) device uses the ECC public key to derive a shared se-
6. c_text <–encrypt_AES256(pm, derived_key) cret key. This shared secret is then employed to generate
7. encrypted_message <– ciphertext an AES-256 key for encrypting data.
return (encrypted_message)
• Data Encryption and Transmission: The encrypted
Algorithm 2. Decrypting at receiver’s side (host).
data is sent to the host. The host uses its private ECC
key to derive the same AES-256 key and subsequently
1:<Input: encrypted_message, public_key_sender>
decrypts the received data.
2:<Output: received_data>
3. ciphertext <– encrypted_message This approach ensures secure key distribution and data
4. shared_secret <– perform_ECDH(public_key_sender, pri- encryption, leveraging ECC for key management and AES-
vate_key_receiver ) 256 for data encryption within the SDN framework.
5. derived_key <–HKDF(shared_secret, key_length=256)
6. pmr <–decrypt_AES256(ciphertext, derived_key )
7. received_data <–pmr 5.1 Steps of our Methodology
return (received_data)
Figure 7 illustrates the methodology of our Hybrid
Cryptography-Based E2EE method within the SDN inter-
Algorithm 2 on the receiver’s side, upon receiving the face, establishing a secure connection between the IoT device
encrypted message and the IoT device’s public key, the host and the host. The detailed steps are outlined below.
device extracts the ciphertext. It then performs an ECDH
operation using the IoT device’s public key and its own pri- • Generate Keys
vate key to generate a shared secret. This shared secret is ECC involves creating key pairs consisting of a private
processed with a HKDF to derive a 256-bit encryption key. key and a corresponding public key. Here’s a detailed
The host device uses this derived key to decrypt the cipher- explanation of the key generation process for both par-
text with AES-256, revealing the original plaintext message, ties (IoT device and host device) using a 256-bit elliptic
which is then stored in received_data and returned. This curve:
ensures secure communication between the IoT device and
the host device by combining ECDH for secure key exchange Key Generation For IoT Device (Sender): Generate
and AES-256 for strong encryption. a private key 𝐼pr which is a randomly selected integer.
For a 256-bit elliptic curve, this integer should be in
Our Hybrid Cryptography-Based E2EE method ensures the range [1, 𝑛 − 1], where 𝑛 is the order of the elliptic
data confidentiality and secure transmission between the IoT curve. Calculate the public key 𝐼pu as:
device and the host.
𝐼pu = 𝐼pr ∗ 𝐺 (1)
Key Generation For Host Device (Receiver): Generate • Derive the Same Symmetric Key
a private key ℎpr which is a randomly selected integer.
For a 256-bit elliptic curve, this integer should be in The same step as in Sec. 5.1.3 is applied here to derive
the range [1, 𝑛 − 1], where 𝑛 is the order of the elliptic the symmetric key from the shared secret.
curve. Calculate the public key ℎpu as:
• Decrypt the Data with the Symmetric Key
ℎpu = ℎpr ∗ 𝐺. (2)
The host subscriber uses the derived symmetric key to
decrypt the encrypted data. We used the AES-256 al-
• Generate a Shared Secret gorithm for this step. The host subscriber now has the
decrypted data, which was originally encrypted by the
The IoT device wants to send an encrypted MQTT mes- IoT device.
sage to the host’s subscribers. It obtains the host sub-
scriber’s public key. To generate a shared secret key,
we used the ECDH key exchange protocol, where both
parties (IoT device and host) use their own private key 6. Deployment in SDN
and the other party’s public key. This shared secret
In Fig. 8, we integrate our Hybrid Cryptography-Based
is typically a point on the elliptic curve multiplication
E2EE method into an SDN network with 1 Ryu controller,
written as:
1 switch, and 4 hosts. Among the hosts, h1 represents an IoT
device sensor for temperature and humidity, publishing data
𝑆 = 𝐼pr ∗ ℎpu (3) every 1 second. h2 is the subscriber host, and h3 represents
an MitM attacker. Using Ettercap to launch MitM attacks
where 𝑆 is the shared secret point, 𝐼pr is the IoT device’s allows interception of data exchanged between an IoT device
private key, and ℎpu is the host’s public key. and h2. Figure 9 shows the initial Mininet setup with 4 hosts,
1 switch, and 1 controller.
• Derive a Symmetric Key from the Shared Secret
Next, the IoT device derives a symmetric key from the
shared secret. The symmetric key has a length of 32
bytes (256 bits), using HKDF with SHA-256 [31] as the
hash function.
• Generate the Shared Secret (On Host Side) Fig. 8. Our SDN topology utilized.
7. Discussion
This section presents a comparative study of three re-
lated works that are closely related to my enhanced E2EE
method.
P. Sushma in [14] used the MQTT protocol in an IoT
application and implemented Armstrong number encryption
to maintain the confidentiality of data over port 1883. From
the work, it can be inferred that decryption is faster than the
encryption process, taking 0.33 ms and 0.34 ms, respectively.
A. J. Hintaw and S. Manickam in [15] proposed a new
security solution called RSS for adoption on IoT devices.
This solution augments the existing MQTT protocol with en-
Fig. 12. Wireshark capture file of plaintext traffic collected by
an MitM attacker. hanced security features using two separate cryptosystems:
enhanced D-AES and KP-ABE. These cryptosystems dis-
tribute the publisher’s secret key to the subscriber and provide
confidentiality of the MQTT payload, broadcast encryption,
6.1 Before Applying Our Hybrid fine-grained access control, and collision resistance. The pro-
Cryptography-Based E2EE Method posed scheme increases the average total processing time by
only 2.16 and 3.21 ms for encryption and decryption, respec-
Figure 10 depicts the start of a simple Ryu controller.
tively, compared to related works, where encryption takes
As shown in Fig. 11, we launched an MitM attack using the
188 ms and decryption 232 ms.
Ettercap tool by h3 to collect data exchanged between h1, the
IoT device publisher, and h2, the host subscriber. As shown H. Li-Wen in [16] proposed a multi-level dynamic en-
in Fig. 12, the attacker h3 could easily collect the data ex- cryption algorithm for an Internet of Vehicles (IoV) sys-
changed between h1 and h2, which includes the temperature tem using MQTT. This algorithm encrypts and decrypts the
and humidity values sent by h1 to h2 using wireshark tools. MQTT messages, taking 1143 ms for encryption and 1309 ms
RADIOENGINEERING, VOL. 33, NO. 4, DECEMBER 2024 591
for decryption. The algorithm improves the overall efficiency based mechanisms into our encryption protocol to uniquely
of the system and realizes high efficiency and energy saving. identify and validate each data transmission session. These
enhancements aim to prevent malicious actors from reusing
Our proposed Hybrid Cryptography-Based E2EE
intercepted ciphertexts to impersonate legitimate data.
method secures MQTT payload data on port 1883 for pub-
lishing and subscribing. The selected key generation algo-
rithm, ECC-256, requires 0.184 ms for key generation. The
encryption of MQTT payload data is oriented to AES-256, References
with an encryption time of 0.2542 ms and a decryption time
of 0.1577 ms for subscribing, while the encryption time is [1] MENEGHELLO, F., CALORE, A., ZUCCHETTO, D., et al. IoT:
0.2758 ms and the decryption time is 0.1781 ms for pub- Internet of threats? A survey of practical security vulnerabilities in
real IoT devices. IEEE Internet of Things Journal, 2019, vol. 6, no. 5,
lishing. Our proposed Hybrid Cryptography-Based E2EE p. 8182–8201. DOI: 10.1109/JIOT.2019.2935189
method is adaptable to SDN environments, has minimal CPU
[2] SONI, D., MAKWANA, A. A survey on MQTT: A protocol of Inter-
usage and memory consumption, and outperforms other re- net of Things (IoT). In Proceedings of the International Conference
lated works. on Telecommunication, Power Analysis and Computing Techniques
(ICTPACT). Chennai (India), 2017, p. 1–20.
Table 3 presents a comparative study of our work with
related works. The comparison is based on the framework, [3] BEN DHIAB, Y., OULD-ELHASSEN AOUEILEYINE, M., AB-
DELKADER, M., et al. Edge-based human activity recognition:
method, key generation time, and average encryption and de- A novel approach using spectral analysis and deep learning. In Pro-
cryption time. This comparative study shows that our hybrid ceedings of the International Wireless Communications and Mobile
E2EE method performs better than the other works and is Computing (IWCMC). Ayia Napa (Cyprus), 2024, p. 1734–1739.
flexible and adaptive with SDN networks. DOI: 10.1109/IWCMC61514.2024.10592539
However, a current limitation is that the same encrypted [10] THAMBIRAJA, E., RAMESH, G., UMARANI, R. A survey on var-
ious most common encryption techniques. International Journal of
data is transmitted consistently over extended periods. To Advanced Research in Computer Science and Software Engineering,
address this, future work will involve regenerating keys on 2012, vol. 2, no. 7, p. 226–233.
an hourly basis and updating data transmission intervals to ei-
[11] HALE, B., KOMLO, C. On end-to-end encryption. Cryptol-
ther every minute or every five minutes. Additionally, we are ogy ePrint Archive, 2022, p. 1–20. [Online] Available at:
considering incorporating timestamp or sequence number- https://eprint.iacr.org/2022/449
592 N. KARMOUS, M. HIZEM, Y. BEN DHIAB, ET AL., HYBRID CRYPTOGRAPHIC END-TO-END ENCRYPTION METHOD . . .
[12] DIXIT, P., GUPTA, K., TRIVEDI, M. C., et al. Traditional and [28] KIM, K., CHOI, S., KWON, H., et al. PAGE-practical AES-GCM
hybrid encryption techniques: A survey. Networking Communica- encryption for low-end microcontrollers. Applied Sciences, 2020,
tion and Data Knowledge Engineering, 2018, vol. 4, p. 31–46. vol. 10, no. 9, p. 1–14. DOI: 10.3390/app10093131
DOI: 10.1007/978-981-10-4600-1_22
[29] HAAKEGAARD, R., LANG, J. The Elliptic Curve Diffie-
[13] SUSHMA, P., GOPAL, V. V. H. Armstrong number encryption
Hellman (ECDH). [Online] Cited 2023-08-18. Available at:
standard for smart devices - An IoT based encryption algorithm.
https://koclab.cs.ucsb.edu/teaching/ecc/project/2015Projects
Dogo Rangsang Research Journal, 2022, vol. 12, no. 12, p. 36–42.
/Haakegaard+Lang.pdf
ISSN: 2347-7180
[14] SUSHMA, P. Smart devices security with Armstrong number en- [30] KRAWCZYK, H. Cryptographic extraction and key derivation:
cryption standard algorithm using MQTT protocol-An IoT applica- The HKDF scheme. In Proceedings of the Annual Cryptology
tion. International Journal of Intelligent Systems and Applications in Conference (CRYPTO). Berlin (Germany), 2011, p. 631–648.
Engineering, 2024, vol. 12, no. 10, p. 45–51. ISSN: 2147-6799 DOI: 10.1007/978-3-642-14623-7_34
[16] LI-WEN, H., YANG, K., FU, L., et al. Dynamic encryption method for
MQTT communication. Journal of Physics: Conference Series, 2024,
vol. 2717, no. 1, p. 1–8. DOI: 10.1088/1742-6596/2717/1/012011
About the Authors . . .
[17] KHAN, M. R., UPRETI, K., ALAM, M. I., et al. Analysis of elliptic
curve cryptography & RSA. Journal of ICT Standardization, 2023, Nader KARMOUS is pursuing a Ph.D. at Innov’COM,
vol. 11, no. 4, p. 355–378. DOI: 10.13052/jicts2245-800X.1142 SUP’COM University, specializing in cybersecurity for IoT
[18] ROUTIS, G., DAGAS, P., ROUSSAKI, I. Enhancing privacy in the
devices using AI. He earned his Master’s degree in Computer
internet of vehicles via hyperelliptic curve cryptography. Electronics, Science from the University of Carthage in 2016.
2024, vol. 13, no. 4, p. 1–29. DOI: 10.3390/electronics13040730
Moez HIZEM is an Assistant Professor and a researcher at
[19] LIGHT, R. A. Mosquitto: Server and client implementation of the Innov’COM, SUP’COM, focused on AI, wireless systems,
MQTT protocol. Journal of Open Source Software, 2017, vol. 2,
no. 13, p. 1–2. DOI: 10.21105/joss.00265
and cognitive radio. He received his M.S. in Electronics in
2004, an M.Sc. in Telecommunications in 2006, and a Ph.D.
[20] GALLA, L. K., KOGANTI, V. S., NUTHALAPATI, N. Imple- in Telecommunications from ENIT in 2011. He is currently
mentation of RSA. In Proceedings of the International Conference
on Control, Instrumentation, Communication and Computational
pursuing an H.D.R. degree.
Technologies (ICCICCT). Kumaracoil (India), 2016, p. 730–733. Yassmine BEN DHIAB is a Ph.D. candidate at the In-
DOI: 10.1109/ICCICCT.2016.7987922
nov’COM Laboratory at SUP’COM, University of Carthage,
[21] NIMBHORKAR, S. U., MALIK, L. G. A survey on elliptic curve where she focuses on edge AI for optimizing IoT perfor-
cryptography (ECC). International Journal of Advanced Studies in
mance. She obtained her engineering degree in Microelec-
Computers, Science and Engineering, 2012, vol. 1, no. 1, p. 1–5.
tronics from ISIMM, University of Monastir, in 2019.
[22] GARG, S., RANA, M. K. A review on RSA encryption algorithm.
International Journal of Engineering and Computer Science, 2016, Mohamed OULD-ELHASSEN AOUEILEYINE is an As-
vol. 5, no. 7, p. 17148–17151. DOI: 10.18535/ijecs/v5i7.07 sistant Professor at the University of Carthage, with expertise
[23] ABDULLAH, A. M. Advanced encryption standard (AES) algorithm in IoT, TinyML, and eHealth. He has a strong background in
to encrypt and decrypt data. Cryptography and Network Security, electrical engineering and is active in professional organiza-
2017, vol. 16, no. 1, p. 1–12. tions and research in smart systems, security, and nanosatel-
[24] THARA, K. S. T., VALLALA, P. G. A survey of encryption al- lites.
gorithms in IoT. In Proceedings of the 17th SC@RUG 2019-2020.
Groningen (Netherlands), 2020, p. 9–14. ISBN: 978-94-034-2766-9
Ridha BOUALLEGUE is a Full Professor at ENIT and has
been teaching since 1990. He is currently the General Direc-
[25] VAHDATI, Z., YASIN, S., GHASEMPOUR, A., et al. Comparison of tor of SUP’COM and has founded several research labs and
ECC and RSA algorithms in IoT devices. Journal of Theoretical and
Applied Information Technology, 2019, vol. 97, no. 16, p. 4293–4301.
conferences. He earned his doctorate in 1998 and his H.D.R.
ISSN: 1992-8645 in 2003, focusing on telecommunications, digital communi-
cations, and next-generation wireless networks.
[26] SUAREZ-ALBELA, M., FERNANDEZ-CARAMES, T. M.,
FRAGA-LAMAS, P., et al. A practical performance comparison of Neji YOUSSEF is a Full Professor at SUPCOM, Tunisia.
ECC and RSA for resource-constrained IoT devices. In Proceedings
He received his B.E. in Telecommunications in 1983, the
of the Global Internet of Things Summit (GIoTS). Bilbao (Spain),
2018, p. 1–6. DOI: 10.1109/GIOTS.2018.8534575 D.E.A. in Electrical Engineering in 1986, and his M.E. and
Ph.D. in Communication Engineering from The University of
[27] YU, H., KIM, Y. New RSA encryption mechanism using one-
time encryption keys and unpredictable bio-signal for wireless com-
Electro-Communications, Tokyo, in 1991 and 1994, respec-
munication devices. Electronics, 2020, vol. 9, no. 2, p. 1–10. tively. His research interests include noise theory, wireless
DOI: 10.3390/electronics9020246 communications, and multipath fading channels.