Design Lightweight Algorithm For Data Encryption in IoT (Rasool Salah Salman)
Design Lightweight Algorithm For Data Encryption in IoT (Rasool Salah Salman)
A Thesis
Submitted to the College of Education/ University of Al-
Mustansiriyah as a Partial Fulfillment of the Requirements for the
Degree of Master of Science in Computer Science
By
Rasool Salah Salman
Supervised By
Prof. Dr. Alaa Kadhim Farhan
and
Assist. Prof. Dr. Ali Shakir Mahmood
My dear parents…
Acknowledgments
First and foremost, I would like to thank and praise Allah, lord of the worlds, who
helped me to complete this thesis.
I would like to thank my respected supervisors Prof. Dr. Alaa Kadhim Farhan and
Assist. Prof. Dr. Ali Shakir Mahmood from the bottom of my heart, for their perfect
guidance and constant supervision throughout the project. They always guided me by
showing the right path to follow at every step to successfully complete this thesis. I am
greatly indebted to them for their encouragement and invaluable advice in this thesis.
I am also very thankful to the Head of the Department and all members of
Computer Science Department\ College of Education\ University of Al-Mustansiriyah
where I completed my thesis.
Also, I am tempted to individually thank all of my friends, but as the list might be
long and for fear I might omit someone, I will simply and genuinely say: Thank you all
for your love, care, and trust.
I am thankful to everyone who has supported me in order to complete this thesis.
Finally, I deeply thank my family: my dear, loving parents, my wife, my brothers,
and my sisters. Words cannot express the love and gratitude I have for them, for helping
me to reach this place.
I
entropy, correlation coefficient, histogram, unified average changing intensity
(UACI), and number of pixel change rates (NPCR). The NPCR and UACI for
the Lena image are at the accepted level at 99.6%, and 33.56%, respectively,
and the AC result is in the optimal range of 50.097%. While the histograms of
the different images were flat and uniform, the results of information entropy
and correlation on different images were close to 8 and 0, respectively. Also the
LWAES-128 succeeded in all NIST statistical tests. Therefore, according to
these results, the LWAES-128 offers more randomness.
II
List of Publications
III
List of Contents
Page
# Subject
No.
Abstract I
List of Publications III
List of Contents IV
List of Abbreviations VI
List of Figures VIII
List of Tables IX
List of Algorithms XI
CHAPTER ONE
General Introduction
1.1 Overview 1
1.2 Related works 2
1.2.1 Substitution Box (S-box) 2
1.2.2 Lightweight AES algorithm 4
1.3 The Problem Statement 6
1.4 Aim of Thesis 6
1.5 Outline of thesis 6
CHAPTER TWO
Theoretical Background
2.1 Introduction 8
2.2 Internet of Things 9
2.3 Internet of Things Architecture 10
2.3.1 Perception Layer 10
2.3.2 Network Layer 11
2.3.3 Application Layer 11
2.4 Security 11
2.4.1 Security Services 11
2.5 Internet of things Attacks 12
2.6 Lightweight Cryptography (LWC) 13
2.6.1 Lightweight Block ciphers 15
2.7 Advanced Encryption Standard (AES) 16
2.7.1 Initial Round 17
2.7.2 Round processes 17
IV
2.7.3 Key Expansion/ Schedule 22
2.8 Hash Algorithm (SHA3) 24
2.9 Chaos Theory-Based Cryptography 25
2.9.1 Logistic Map 26
2.9.2 Two-dimensional Logistic Map 28
2.10 Main Components of an IoT System 28
2.11 Features of an Excellent Cryptographic Algorithm 30
2.11.1 S-box Test Criteria 30
2.11.2 Image encryption metrics 32
2.11.3 Randomness NIST Tests 33
CHAPTER THREE
The proposed design of the Lightweight Encryption Algorithm
3.1 Introduction 35
3.2 The Proposed Encryption Algorithm (LWAES-128) 35
3.2.1 Key Generation of System 36
The Encryption Process utilizing LWAES-128
3.2.2 48
Algorithm
CHAPTER FOUR
Implementation the proposed System
4.1 Introduction 55
4.2 Implementation of the System 55
4.3 Requirements and Environment 57
4.4 Collection of Data from Sensors 59
4.5 Evaluation and Results 59
4.5.1 Substitution-Box Evaluation 60
4.5.2 Substitution-Box Evaluation Through Encrypting an
66
Image
4.5.3 Implementation of Encryption Process 69
4.5.4 Server Side 77
CHAPTER FIVE
Conclusions and Proposals for the Future Work
5.1 Introduction 79
5.2 Conclusions 79
5.3 Future Works 81
References 82
V
List of Abbreviations
Abbreviations Description
1-D One dimensional
2-D Two dimensional
AES Advanced Encryption Algorithm
AO Analog Out
AC Avalanche Criterion
BC Balanced Criterion
BIC Bit Independence Criteria
CIA Confidentiality , Integrity and Availability
CPU Central processing unit
CC Completeness Criterion
DES Data Encryption Standard
DP Dynamic Permutation
DoS Denial of Service
DO Digital Out
GF Galois Field
Inv-DP Inverse- Dynamic Permutation
I/O Input/output
InvS-box Inverse Substitution Box
IoT Internet of Thing
LP linear approximation Probability
LFSR linear feedback shift register
LWAES Lightweight Advanced Encryption Standard
LWAES-128 Lightweight Advanced Encryption Standard 128-bits
LWC Lightweight Cryptography
LANs Local area networks
MLAES Modified Lightweight Advanced Encryption Standard
M2M Machine to Machin
MS Millisecond
NIST National Institute of Standards and Technology
VI
NPCR Number of pixel change rate
PANs Personal area networks
RNG Random number generator
RNA Ribonucleic Acid
RCON Round Constant
RFID Radio frequency identification
RAM Random Access Memory
ROM Read Only Memory
RC5 Rivest Cipher 5
S-box Substitution Box
S-boxes Substitution Boxes
SPN Substitution Permutation Network
SHA3 Secure Hash Algorithm Version.3
SAC Strict Avalanche Criterion
UACI Unified average change intensity
WSN wireless sensor network
WANs Wide-area networks
XOFs Extendable Output Functions
XOR Exclusive – OR
List of Figures
Figure No. Title Pag
e
VII
No.
Chapter Two
Figure 2.1 IoT Applications 9
Figure 2.2 The three-layers IoT architecture 10
Figure 2.3 Trade-off between Security, Cost, and Performance 14
Figure 2.4 State Array 16
Figure 2.5 The AES overall structure 17
Figure 2.6 Generation S-box and InvS-box 18
Figure 2.7 AES ShiftRows process 20
Figure 2.8 AES MixColumn process 21
Figure 2.9 AES InvMixColumn matrix 21
Figure 2.10 AES AddRounKey Process 22
Figure 2.11 AES Key Expansions 23
Figure 2.12 SHA3 sponge construction 24
Figure 2.13 Variations of logistic map with time (i) 27
Figure 2.14 Behavior of the logistic map for = 4 27
Chapter Three
overall structure of the proposed LWAES-128 (a) the
Figure 3.1 37
encryption process and (b) the decryption process
Figure 3.2 Key Generation of System 38
Figure 3.3 Flow chart of construction the proposed S-box 41
Figure 3.4 Example of S-box construction 43
Figure 3.5 Examples of key construction for the initial round 47
Figure 3.6 S-box matrix with explanation to SubByte function 51
Figure 3.7 ShiftRows function 52
Figure 3.8 Example of DP function 53
Figure 3.9 Example of AddRoundKey function 54
Chapter Four
Figure 4.1 Proposed LWAES-128 algorithm implementation 56
Figure 4.2 Histograms of the tested images 68
Figure 4.3 LWAES-128 encrypting and decrypting time 71
Figure 4.4 Encryption Time comparison with related works 72
Figure 4.5 Decryption Time compared to the related works 73
Figure 4.6 Encryption Time on Raspberry Pi compared to the 74
VIII
related works
The power consumption of the proposed algorithm
Figure 4.7 77
and other related algorithms
Figure 4.8 Server outputs sensors data after decrypting 78
List of Tables
Page
Table No. Title
No.
Chapter Two
Table 2.1 AES S-box 19
Table 2.2 AES InvS-box 20
The optimal values of S-box criteria and statistical
Table 2.3 33
metrics.
Chapter Three
An instance of the suggested S-box employed for
Table 3.1 50
encryption
An instance of the Inverse S-box employed for
Table 3.2 50
decryption
Table 3.3 Example of DP table employed for encryption 52
Example of inverse DP table employed for
Table 3.4 52
decryption
Chapter Four
Table 4.1 Specifications for the DHT22 and Flame sensors 57
Table 4.2 Raspberry Pi 4model B specifications 58
An example of collecting sensors data every 5
Table 4.3 59
seconds
Comparison between the standard AES and
Table 4.4 60
LWAES-128 algorithms
Table 4.5 BC test on S-box when x0=0.05 and =3.7 61
Table 4.6 S-box values when x0=0.7 and =3.91
1 61
Table 4.7 BC test on S-box when x0 =0.7 and =3.91
0 1
62
Table 4.8 S-box values when x0= 0.05 and =3.7 62
IX
Table 4.9 Inverse S-box values when x0=0.05 and =3.7
1
63
Table 4.10 S-box values when x0=0.15 and =3.7 63
Table 4.11 Inverse S-box values when x0=0.15 and =3.7 64
Comparisons of the AC test of (A...Z) utilizing the
Table 4.12 proposed S-box when x0= 0.05 and = 3.7 with 64
some other related approaches
Example for AC computation of the proposed S-box
Table 4.13 65
(if x0=0.05 and =3.7) and other related S-boxes
Comparisons of the AC test of (A...Z) utilizing the
Table 4.14 suggested S-box when x0=0.7 and =3.91 with some 65
other related approaches
Example for AC computation of the proposed S-box
Table 4.15 66
(if x0=0.7 and =3.91) and related S-boxes
Table 4.16 Entropy results of the tested images 67
Table 4.17 Correlation coefficient of the tested images 67
Table 4.18 NPCR and UACI results of the tested images 69
Table 4.19 LWAES-128 encrypting and decrypting average time 70
Encryption Time and Throughput compared to the
Table 4.20 71
related works
Decryption Time and Throughput compared to the
Table 4.21 72
related works
Table 4.22 Encryption Time comparison with related work 73
Comparison of the LWAES-128 encryption time and
Table 4.23 74
throughput on the Raspberry Pi with related works
NIST tests on the cipher-text from the suggested
Table 4.24 74
LWAES-128
The status of the Raspberry device during executing
Table 4.25 76
encryption
The power consumption comparison of the proposed
Table 4.26 76
algorithm and other related algorithms
X
Table of Algorithms
Algorithm No. Title Page No.
Chapter Three
XI
Chapter One
General Introduction
Chapter One
General Introduction
1.1 Overview
Recently, the topic of the Internet of Things (IoT) has emerged as a result
of the rapid development in computer sciences and communications [1]. With
the IoT, billions of things (devices) in the physical world are connected to other
systems or devices over the network to the Internet [2]. Some technologies, like
radio frequency identification (RFIDs), wireless sensor networks (WSNs), or
combining these technologies, cloud service, machine-to-machine connectivity
(M2M), etc., can be used to make this connection [3]. IoT has many
applications, including health care, smart buildings, smart homes, smart
factories, and so on. IoT makes it possible for objects to recognize each other,
get intelligence, get information regarding themselves, and also get information
that other objects have collected [4].
In the IoT, data is collected by objects from the physical world and
transmitted over the Internet, making these data vulnerable to attacks and
hackers [5]. This sent data may be important and needs to be secured.
Cryptography algorithms are used to secure this data [6].
There are several cryptographic algorithms used to offer security solutions,
which are classified into symmetric and asymmetric kinds [7]. However,
conventional algorithms are unsuitable for use in an IoT environment due to
their high computational complexity, which is incompatible with the IoT's
limited resources such as power, CPU, and memory [8]. Therefore, lightweight
cryptography algorithms appeared as a solution for limited resource devices.
Lightweight cryptographic algorithms must offer the best tradeoff between
security, cost, and performance [9].
1
In this thesis, the design and implementation of a lightweight encryption
algorithm for securing IoT sensing data transmitted by the IoT devices are
proposed.
1.2 Related Works
The following studies have been chosen based on their relevance to the
subject matter of this thesis. As mentioned below, these studies are divided into
two categories: The first focuses on constructing a substitution box (S-box), and
the second on Lightweight AES algorithm.
1.2.1 Substitution Box (S-box)
The S-box is an essential part of the block ciphers due to the fact that it is
responsible of the confusion process between plain and cipher text. Therefore,
many researchers attempt to design a more secure S-box to replace the
conventional S-box in standard algorithms in order to increase the level of
security. The studies relevant to the S-box involve:
1- Dragan Lambi )2016) [10] presented a new approach for constructing S-
boxes that relies on a discrete chaotic map with permutations. The generated
S-boxes were subjected to a set of criteria like bijection, non-linearity, strict
avalanche, output bit independence, and input(I)/output(O) XOR
distribution, where the findings indicated that the constructed S-boxes have
strong cryptographic features. This approach didn't have any kind of
approximation effect because it didn't need to estimate continuous values.
This was because it used discrete chaotic maps that relied on the composition
of permutations.
2- C. Unal, et al. (2016) [11] They generated a strong S-box by using a new
random number generator (RNG). They generated it by using the new scaled
Zhongtang chaotic system with very complex and intriguing dynamic
properties. According to the results of the S-box criteria tested on the
2
generated S-box and compared to other works, the generated S-box was
strong, and the new RNG also passed all NIST tests.
3- L. Liyan, et al. (2018) [12] suggested a new approach to constructing S-box
based on a spatiotemporal nonlinear chaotic. First, they generated an initial
S-box. Then, they used a permutation process on the chaos sequences to
randomly rearrange the S-box's components. So this helped to enhance the
bit independence criteria (BIC) and linear approximation probability (LP) of
the constructed S-box. The results also showed that the constructed S-box
succeeded the statistical tests of NIST-800-22 and met the following criteria:
linear approximation, nonlinearity, output bit independence, bijective, I/O
XOR Distribution, and Strict Avalanche. So, their suggested method has
strong cryptographic properties.
4- L. Qing, et al. (2019) [13] proposed a new algorithm for generating Boxes
by using a novel hybrid chaotic system (tent and logistic). Which has
improved chaos efficiency and a higher chaos range than the tent and
logistics method, and which can improve the randomness of chaos sequences
as well as increase the key space of cryptographic algorithms. At first they
generated initial S-box by using a new linear map and then performed
permutation process on the generated initial S-box via utilizing the sequence
that generated from tent and logistic to enhances the encryption
characteristics of the constructed S-box. The test results showed that the
suggested S-box has much lower values of linear probability and differential
probability and acceptable nonlinearity values than other S-boxes, so it can
be used in block cipher algorithms.
5- F. Alaa, et al. (2020) [14] introduced a novel mechanism for generating
multi-S-boxes that relied on RNA processing. Each one of these S-boxes is
constructed from the previous S-box relying on the secret key where the
obtained S-boxes meet the invariability criterion, avalanche criterion, strict
avalanche criterion, balance criterion, and completeness criterion. The
3
suggested S-box achieved an accuracy of about 99%, so it can be applied in
several block cipher algorithms.
6- J. Zijing and D. Qun (2021) [15] proposed a mechanism for generating S-
boxes relying on the bent function and logistic chaotic system. First, they
used logistic chaos to generate bent functions. Then, they constructed the S-
boxes from the generated bent functions. The test results and performance
analysis of their constructed S-box showed that the following criteria:
nonlinearity, difference uniformity, strict avalanche, and independence were
satisfied, and the generated S-box has great cryptographic characteristics.
4
with a random number generator and the RCON operation was also
replaced with a Shift operation. The test results and performance analysis
of the LWAES algorithm showed that it passed the following statistical
tests: frequency, poker, run, and serial. Also, the process of encrypting
and decrypting took less time than with the original algorithm.
3- J. Rokan, et al. (2019) [18] proposed modifications to the AES algorithm
to become lightweight algorithm. This work done by using the five-
dimensional chaotic system (a hybrid of logistic and Lorenz). This
proposal employs the same functions as Standard AES except the mix
column function is replaced with a multi-XOR function, a shift-cycle
function, SHA3-256, five chaos keys, and two S-boxes. The modified
lightweight AES (MLAES) algorithm was implemented on the Raspberry
Pi Model B. The findings showed that MLAES reduced the execution
time and the CPU cycles compared to the standard AES.
4- F. Hazzaa, et al. (2021) [19] suggested a lightweight encryption
algorithm based on the AES algorithm. The suggested algorithm uses the
same operations as in AES but with development aimed to reduce
execution time and power consumption to achieve a lightweight
algorithm and also keep the level of security the same as in AES. In this
work, the SubByte and MixColumn operations were enhanced. The
SubByte operation using a multi-S-box resulted in increasing the security
of the algorithm, while the MixColumn operation using a single (4*4)
key matrix resulted in reducing the required operations in the
multiplication of two matrixes (state and key matrix), thus reducing the
execution time and power usage. Also, the suggested algorithm using
nine rounds resulted in decreased execution time and power consumption.
The evaluation results of the suggested algorithm showed that the
execution time and power usage were enhanced by about 33% compared
5
to standard AES, but the level of security remained the same as in AES
due to the increased complexity in SubByte operation.
6
Chapter Four clarifies Implementation the proposed.
Chapter Five introduces the conclusions and Proposals for the Future
Work.
7
Chapter Two
Theoretical Background
Chapter Two
Theoretical Background
2.1 Introduction
Today, data security is a critical component for the efficient
performance of every organization's diverse requirements [20]. One of
the important requirements of these networks is to provide a secure
connection for the transmission of data [21]. Cryptography algorithms are
used to protect transmitted data from unauthorized access. There are two
kinds of cryptographic algorithms are Symmetric and Asymmetric. The
symmetric type utilizes the same key for encrypting and decrypting
processes, while the asymmetric type utilizes public key and private key
[22]. The public key is employed for encrypting processes while the
private key is employed for decrypting processes. AES, DES, Blowfish,
and RC5 are some examples of symmetric cryptography algorithms [23].
IoT devices are often run by using limited resources, such as low
power, small memory size, and a limited CPU [25]. Due to the limited
resources of these devices, several traditional cryptographic techniques
cannot be used successfully. So, to secure data, a lightweight
8
cryptographic technique is needed [26]. Many cryptographic algorithms
have been developed to protect this transmitted data, one of which is
chaos-based cryptography.
9
various areas (smart grids, health, fitness, transportation, etc.). The data
that moves through these connected devices may be sensitive and very
important, so the people who make IoT devices and applications need to
employ security properties [30].
10
from the physical environment by using sensors and actuators. It also finds,
gathers, and processes the information before sending it to the network layer.
2.4 Security
Security implies protection of an automated systems to achieve the aim of
maintaining the integrity, availability, and confidentiality of the
information system resources (involving hardware, soft-ware, information, and
communications) [35].
These services are extended by adding two more services, accountability and
authenticity, which are needed to provide security completely. The two
additional security services are explained below:
1. Physical attacks are possible when the attacker is near to the network or the
system's devices. These attacks come in many forms, like Node Tampering
(physically altering a device or node), Malicious Code Injection, radio
frequency Interference on RFIDs (generating and sending noise signals
through radio frequency communications), Malicious Node Injection
(dropping a fake node between two valid nodes with the aim of controlling
data flow among them), Sleep Denial Attack (attacker feeds incorrect inputs
to devices, causing them to activate and use more power, causing them to
shut down), and any other attacks [41].
12
2. Network Attacks are executed by modifying the IoT network to do harm. It
can be simply executed without the need to be near the network. These
attacks come in many forms, like Traffic Analysis Attack, RFID Spoofing,
Wormhole Attack, Man in the Middle Attack (an attacker intercepts the
connection between two IoT devices to access sensitive information by
eavesdropping), Replay Attack (capturing a certified packet and re-sending
it to the target repeatedly, causing the network to be busy and may lead to a
DoS attack), and Denial of Service (DoS) attack (an attacker works on
slowing or crashing the server or the network resources) [41].
3. Software Attacks are performed by exploiting the advantages of connected
software or security gaps that exist in the internet of things system, like
Trojan, Worms, virus, jamming (which corrupt the system to modify or steal
information or even execute DoS), and malware attacks [42].
4. Data Attacks the main data attacks that are common in the internet of
things nowadays are Data Inconsistency, Unauthorized Access, and Data
Breach.
13
hackers or unauthorized access. So, a lot of researchers have concentrated on
developing LWC with the aim of consuming less time securing such devices.
Three factors are needed to execute the LWC: size, power usage, and speed
(throughput-delay). Power usage is essential with devices that run on limited
battery life. High throughput is also essential for devices that send huge
amounts of information like sensors or cameras, while low delay is essential for
14
systems that require control processes in real-time like car control systems, etc.
[9].
There are a large number of lightweight block cipher algorithms that have
been designed to offer security while optimizing the usage of resources. Some
15
examples of these algorithms are PRESENT, CLEFIA, KATAN, HEIGHT, and
many more [50].
16
There are four processes performed in each round of AES; they are
SubByte, ShiftRow, MixColumn, and AddRoundKey, except the last round,
which is without MixColumn process [51]. The general structure of the AES is
shown in figure (2.5).
17
2.7.1 Initial Round
AddRoundKey process – XOR operation between the state matrix and the
initial roundkey.
2.7.2 Round processes
Each round in AES performed the following process except the last round:
In the last round of AES, the same above processes are performed but
with the dispense MixColumn process.
1. SubBytes process
A nonlinear substitution is performed on each byte of the state to
replace it with another byte from the lookup-table (S-box) in this process.
It offers confusion between the original text and cipher-text [53]. Each of
the 256 values in the S-box is determined using the multiplicative inverse
in Galois Field GF (28), and then to using the affine transformation. The
generation of both S-box and its inverse (InvS-box) is shown in figure
(2.6).
18
Figure (2.6): Generation S-box and InvS-box [35]
Table 2.1 shows the AES S-box which is employed in the SubByte
process during the encryption process. Each byte of the state matrix is
substituted with another one from S-box as follows: The byte is split into two
parts. The first part is utilized to select the row, and the second part is utilized to
select the column. After that, the selected row and column of the S-box are
crossed to pick a unique byte. For instance, the hexadecimal value {80}
indicates row 8 and column 0 of the S-box that contains the value {CD}, i.e.,
the value {80} is changed to the value {CD} [35].
19
The invers SubByte process (InvSubByte) is used in the decryption
process. It uses the same function but with the inverse S-box (InvS-box)
[54]. Table 2.2 shows the InvS-box.
20
2. ShiftRows process
In the encryption, a transposition process is performed on the second,
third, and last rows of the state to shift the three rows cyclically by a
specific number of steps to the left-direction. In the decryption, the same
process is applied but in the reverse direction (InvShiftRows), i.e.,
shifting the second, third, and last rows of the state to the right-direction
[53]. Figure (2.7) shows the ShiftRows process.
3. MixColomun process
21
In the encryption, the MixColumn process performs the multiplication
function on every column in the resulting state with its correspondent in a
predefined matrix of polynomials generated for this phase by GF(28) [55].
Figure (2.8) explains this process.
4. AddRoundKey process
22
In encryption, the AddRoundKey performs the sum operation utilizing bit-
wise XOR between the round key and the obtained state as shown in figure
(2.10) [35]. Every round is assigned a unique round key, which is constructed
from the key schedule that will be explained in section (2.7.3).
In decryption, the same process is performed due to the XOR function
having the inverse feature. When the XOR function is performed between the
encrypted state and the key, the original data is obtained [56].
23
is performed to generate the first word of the new key, while a simple XOR is
performed to generate the last three words of the new key.
With the exception of the first word, every word of the new key is
generated through performing an XOR function between the word in the
position (Wi) of the preceding key and the word in the position (W i-1) of the new
key.
While the first is generated by applying the function g to the last word of
the prior key and then XORing the result with the first word of the prior key.
The function g has the following sub-functions:
24
The Rcon is a word in which the last 3 bytes are all is zero. Therefore, by
performing an XOR operation between the word and the Rcon, it affects
only on the first byte of the word. Every round has a different Rcon.
During the decryption process, the same subkeys are created but are
scheduled for the AddRound process in the opposite order [58].
25
2.9 Chaos Theory-Based Cryptography
It means using chaos theory with cryptographic algorithms. Chaotic
theory is a subfield of mathematics, and it is nonlinear, sensitive to starting
conditions and control parameters, and its behavior cannot be predicted. All
these features meet the requirements of confusion and diffusion properties
needed by cryptographic algorithms [61].
The lyapunov exponents are used for any chaotic system for checking the
sensitivity to initial conditions. A chaotic system will have a positive lyapunov
exponent, whereas stable points and cycles will have a negative lyapunov
exponent. Recently, there has been a growing interest in the use of chaotic
systems in the development of cryptographic algorithms. The excellent
dynamical features of chaotic systems lead to excellent encryption features of
cryptographic algorithms. The Chaotic systems have been employed in the
development of cryptosystems such as image encryption techniques, hash
functions, and pseudorandom number generators [65][66]. The security level is
evaluated by its ability to resist various types of attacks, such as plain text
attacks, statistical attacks, deferential attacks, brute-force attacks, and so on.
26
As noted in [67], there are two major ways to employ a chaotic system in a
cryptographic algorithm:
27
Where x represents the population at any given time i, and represents
the growth rate (control parameter). As shown in figure (2.13), the (x i+1) is a
value within 0 and 1 for all (i), whereas the (is a value within 0 and 4 [70].
Figure (2.14) clarifies the behavior of the logistic map for = 4.
Figure (2.14) explains the variations in logistic map behavior when the
value of the growth rate () is within the range (2.4, 4.0). The number of
intervals increases as the u gets closer to 4, and the system's behavior becomes
unexpected and seems random. When the control is greater than 3.6, the
logistic map has a positive lyapunov exponential. When is less than 3.6, the
lyapunov exponential is negative, which means the system is not chaotic [62].
28
Figure (2.14): Behavior of the logistic map for = 4 [70]
2
y i+1 =❑2 y i ( 1− y i ) +❑2 ( x i + x i y i ) (2.3)
Where x and y are initial states which belong to the interval (0, 1), while
the ❑1, ❑2, ❑1 , ¿2 are the control parameters. To make the system have chaotic
behavior, the value of parameter ❑1 should be greater than 2.75 and smaller than
3.4. The value of parameter ❑2 should be greater than 2.7 and smaller than 3.45.
The value of parameter ❑1 should be greater than 0.15 and smaller than 0.21.
The value of parameter ❑2 should be greater than 0.13 and smaller than 0.15
[50].
29
have a unique set of properties to design an effective internet of things system
[26]. Below is a detailed illustration of these components:
1- Sensors: The sensor represents the front-end device of the IoT. They are
called "things" and their major aim is to gather information from their
physical environment. Each sensor must have a unique identification and an
IP address to be easily recognized through a big network. Additionally, they
should be active in order to gather information in real time. These devices
can operate on their own (independent) or are designed to operate with the
assistance of humans. Sensors include temperature sensors, humidity
sensors, gas sensors, and so on. [71]. Each sensor works by converting the
signals of the physical parameters like (temperature, humidity, gas, etc.) to
digital or analog representations which are readable by the machines and
humans. [72].
2- Processors: Processors are considered the brains of any IoT system. Their
major function is to process the gathered sensing information in order to
obtain useful information from the massive amount of sensing information
gathered. Processors usually operate on a real-time foundation and can be
simply managed via applications. Processors are also responsible for
protecting the sensing information by executing the encryption and
decryption processes. Embedded hardware devices, microcontrollers, etc.,
can handle the data since they are embedded with processors [73]. In IoT
systems, Arduino and Raspberry Pi are two of the most commonly utilized
devices.
■ Arduino: is a simple-to-use microcontroller that connects to a
computer and is able to execute one application at a time. It is an
open-source platform, indicating that the hardware is inexpensive and
software development is free [74]. It can read analog or digital signals
from various sensors and convert them into outputs, like switching
30
LEDs on or off, controlling a motor, and many more actions
dependent on the system. There are different versions of Arduino; the
UNO version is the most commonly known [75].
■ Raspberry Pi: is a microcomputer that has an operating system. It is
able to execute many programs simultaneously. Raspbian, which is
based on the Debian distribution of Linux, is the recommended install
OS on the Raspberry because it is free and open-source, which keeps
the cost of the system low [76]. The Raspberry Pi is the key element
of the internet of things. There are different versions of Raspberry,
including pi zero, B, B+, and others [77].
3- Gateways: are utilized to transmit processed data to the appropriate
destination, which means the job of gateways is data routing. In other words,
the gateways allow data flow between the source (IoT devices) and the
target destination. A network connection is essential for every IoT system to
communicate. LANs, WANs, PANs, and others are instances of network
gateways [71].
4- Applications: are additional component of an Internet of Things system.
They are important for the correct use of gathered information. Applications
are managed by users and act as the delivery center for certain services.
Home automation, security systems, and others are examples of applications
[71].
31
The block ciphers utilize the S-boxes to provide the confusion property
through the encryption phase. In order to determine if the utilized S-box has
excellent features and the confusion is obtained, the S-box criteria must be
employed, like balanced, completeness, avalanche, strict avalanche, and
Invertability. These criteria are explained below.
No .chaned Bits∈CipherText
AC= (2.4)
Total No . Bits∈CipherText
32
cryptographic test, particularly for Substitution–permutation network block
ciphers, which indicates that every outcome bit must be dependent on whole
input bits. The strict avalanche test combines these tests (AC and CC). The SAC
simply indicates that when a single bit of the input is altered, the whole of the
output bits must be altered by 1/2 for whole input sequences. If the SAC test is
passed for any certain S-box, this indicates that S-box has excellent diffusion
[80].
5. Invertability
This criterion basically checks that every entry into the S-box results in a
unique output. This criterion is important for successful recovery (inverse
substitution), which substitutes the values using the inverse S-box [80]. Thus,
the S-box meets the invertability criterion if S-box (M1) = S-box (M2), where
M1 = M2. The S-box is invertability if it has the ability to recover the plaintext
data by using the inverse S-box [78].
1. Entropy
Entropy is the measure of the randomness of the image values. If the
entropy values are high, the image values are more random [81] [82]. The
optimal entropy value is near or equal to 8. Equation (2.5) is used to
calculate the entropy.
Entropy=∑ P ( x i ) log 2
i ( )
1
P ( xi )
(2.5)
33
2. Pixels Correlation Analysis
It is a statistical evaluation used to determine the relationship between the
pixels of the original image and the encrypted image. To fulfill this test, the
correlation coefficient must be close to 0 [83]. Equation (2.6) is used to
calculate the correlation coefficient.
Correlation=∑
( ( i−µi ) ( j−µj )
σi σ j ) (2.6)
3. Histogram analysis
NPCR= [ ∑ I ( i, j )
i,j
M ×H ] . 100 % (2.7) [86]
UACI =
1
M×H [ ∑ |C1 ( i, j )−C2 ( i, j )|
i,j
255 ] . 100 % (2.8) [89]
34
Where I (i, j) = 1 if C1 (i, j) ≠C2 (i, j), otherwise I (i, j) =0 and C1 and
C2 indicate the encrypted images of original image before and after
single-pixel alteration in the original image.
The following table 2.3 shows the optimal value of each above criteria and
statistical metrics:
Table 2.3: The optimal values of S-box criteria and statistical metrics.
# Test Condition of passing the test )Optimal value(
1 BC Equals numbers of ones and zeroes in output sequence
2 CC Every output bit must dependent on all input bits
3 AC 50 %
4 SAC satisfy AC and CC
5 Entropy Near or equals to 8
6 Correlation Near or equals to 0
7 Histogram uniform and flat
8 NPCR 99.5
9 UACI 33.3
35
not, where if the p-value = 0.01 or p-value > 0.01 means the sequence
satisfied the test [87].
36
Chapter Three
The proposed design of the
Lightweight Encryption Algorithm
Chapter Three
The proposed design of the Lightweight Encryption Algorithm
3.1 Introduction
This chapter illustrates the development of an encrypting algorithm that can
be employed to protect the IoT sensing data. Many alterations are made to the
design of the AES algorithm, such as changing the MixColumn process, which
consumes a lot of time, with a dynamic permutation process to be lightweight.
Despite these modifications, the key structure of AES (substitution permutation
network (SPN)) has been kept. Moreover, since the outputs of chaotic systems
have excellent features that are suitable for encryption systems, the construction of
the proposed encryption system relies on a combination of chaotic systems. One of
the alterations to the AES is constructing a strong S-box that is employed in the
SubByte process rather than the conventional AES S-box. This proposal is
designed in order to offer a high level of security and a fast implementation time in
the encrypting and decrypting process of sensing data. Furthermore, it is designed
to consume less memory and maintain the usage and temperature of the processor
(CPU) at normal levels to be suitable with any IoT device, which can be utilized in
different IoT applications, for instance, industrial factories, smart buildings, health
care, and so on, which needs to be secured to prevent attacks and unwanted access.
35
construction of the system, which refers to the method utilized to generate all the
needed encryption tools (S-box, dynamic permutation (DP) table, and rounds
keys). The tools have been generated depending on each other, utilizing a
combination of chaotic systems. (initial key) is another tool generated utilizing the
Shake-128 hashing algorithm. The second step is the encryption process utilizing
the designed LWAES-128, which relies on these generated tools. The encryption
and decryption operations utilizing the proposed LWAES-128 are shown in Figure
(3.1).
36
Master Key (n-bits)
Plaintext Block (4X4) Plaintext Block (4X4)
Shake-128 Initial Key
Initial Key
AddRoundKey 128-bits 128-bits AddRoundKey
(4X4) Inv-New S-box
-1
(4X4)
New S-box
Round 9
Inv-ShiftRows
ShiftRows
map
Round 1
Inv-DP
D logistic
DP
AddRoundKey Yi
Odd Keys Xi Odd Keys
(4X4) AddRoundKey
(4X4)
New S-box Inv-New S-box
Round 8
Sub-Keys Generation based on two- dimensional logistic map
ShiftRows Inv-ShiftRows
Round 2
DP Inv-DP
Round 7
New S-box Inv-ShiftRows
ShiftRows Inv-DP
Round 8
DP
Round 1
ShiftRows Inv-ShiftRows
Round 9
DP Inv-DP
Encryption Decryption
37
For initial rounds, the initial key is constructed from Shake-128, and two
sets of chaos keys are constructed, one set for odd rounds and second one set for
even rounds, resulting in every round in LWAES-128 having a different key and
also having a different permutation values (from DP table). All of these
modifications help to make the AES lightweight by reducing the time consumed in
the encryption and decryption process while maintaining a high level of security.
Master Key x0 y 0
x0 12 1 2
Concatenation
Fractions Xi Fractions Xi Fractions Yi
xi and yi
39
types of keys (odd round keys and even round keys) and generating
the table of DP values according to algorithm (3.4)
End
40
Figure (3.3): Flow chart of construction the proposed S-box
41
array= Null, string array S-box [16,16]
Step 3: While (i < 256)
Step 3.1: x [i + 1] = * x[i] * (1 - x[i])
Step 3.2: Converting x[i] to hex and extract only two digits (digits
7 and 8) and then store it in H
Step 3.3: If (S contents H) Then {i++ and go to step 3} // This step
is to avoid duplication of values
Step 3.4: else s[i]=H; i++ and go to step 3
Step 3.5: End if
Step 4: End While
Step 5: For i=0 to 15
Step 6: For j=0 to 15
Step 6.1: S-box [i, j] = S[index]
Step 6.2: index ++
Step 7: next j
Step 8: next i
End
Figure (3.4) shows an instance of the creation of S-box utilizing the chaotic
values resulted by the one-dimensional logistic equation when = 3.64103 & x0 =
0.0131.
42
Chaotic values Hex values S-box values
0.0131 0x1.ad42c3c9eecc0p-7 2c
0.047072655841700006 0x1.819e83ac07e78p-5 e8
0.16332503065144144 0x1.4e7d5a8a210d4p-3 d5
0.49754662211546025 0x1.fd7cdc98e27afp-2 cd
. . Extracting two .
. Converting to . .
. hex . digits (from 7 to .
. . 9) .
Algorithm 3.3 below shows the steps required to generate the inverse of the
S-box that is required in the decrypting phase to retrieve the plain-text.
The following is an example that explains how each value can be generated
in the inverse S-box: Suppose we have the value {ED} from row (6) and column
43
(0) of the S-box. First, dividing these values into two values, {E} and {D} and
converting each of these values into integers to become 14 and 13, which indicate
row 14 and column 13 in the inverse S-box. Then convert the numbers (6,0) of the
row and column of the {ED} value into hex and combine them to use as the value
of the inverse S-box. Therefore, the value of the S-box {ED} represents {60} in
row 14 and column 13 in the inverse S-box.
45
s an s1 arrays are has 32 values which are represent the first even
and odd round keys
Step 8: Repeat steps 5, 6, and 7 to construct all the four keys for even rounds
and all the five keys for odd rounds
Step 9: Apply the below steps to generate 16 different numbers for each row
in DP/ DP is integer array of size (9*16)
Step 9.1: Extract three digits at one time from d then convert it into integer
and store it in t// t is temporary
Step 9.2: Calculate (t mod 17) then store the result in t1//t1 is temporary
Step 9.3: If (t1>0) & (t1 not exist in the current row of DP) & (t1 not
equal to current address of DP) Then
Insert t1 into current row of DP
Else go to step 9.1 to extract another value
Step 10: Repeat steps 9 until DP has 9 rows with each row 16 different
numbers // 9 rows for 9 rounds
End
The algorithm 3.5 below represents the generation of the inverse array of DP
table that will be used in decryption process.
The standard AES algorithm restricts the user to entering a master key with a
size of 128 bits to be used for the initial round in the encryption/decryption
process. Therefore, the proposed LWAES-128 overcomes this restriction by using
the Shake-128 hashing algorithm to generate the 128 bits of the initial key. The
initial key is generated as follows: obtaining the master key from the user with any
size (variable size), then using it as input to the Shake-128 algorithm to produce
the initial key of size 128 bits (fixed size), which is completely different from the
obtained master key. Thus, the user is not restricted by the size of the key, and the
key has also become more complex. The examples in figure (3.5) below explain
how to generate the key for the initial round by using Shake-128 hashing
algorithm.
Input (variable
Hashing algorithm Digest (fixed size 128 bits)
size)
A a5ba3aeee1525b4ae5439e54cd711f14
a 85c8de88d28866bf0868090b3961162b
SHAK-128
ab12 d4149ef2094ed584311d64e107e6ec6e
abcdf 614fce17c050de859a3b5fe5f6ff3388
47
Algorithm 3.6 explains the encryption process utilizing LWAES-128. The
three types of keys are utilized in the encryption process: the first is generated by
utilizing the Shake-128 hashing algorithm for the initial round; the other two types
are generated by utilizing two-dimensional logistic map equations, the first for
even rounds and the second for odd rounds. The plaintext will be encrypted with
10 different keys; 1 key for the initial round, 4keys for even rounds, and 5keys for
odd rounds.
The first alteration to the AES is to improve the SubByte function by
utilizing the suggested S-box, which is constructed using a one-dimensional
logistic equation. The second step is to utilize the suggested DP table in the DP
function rather than the Mixcolumn function to reduce the time consumed in the
Mixcolumn function. The DP table utilized in this proposal is constructed utilizing
two-dimensional logistic map equations. The generated DP table has 9 rows. Each
row contains 16 positions, with a different order assigned to each round. All these
modifications aim to make the standard AES lightweight by reducing the time of
execution in encryption and decryption processes and keeping it robust to avoid
several attacks.
48
Step 3: For i=1 to 10// i indicate to round number i<10// i.e., nine rounds
Step 3.1: Apply SubByte function utilizing the S-box that constructed by
one-dimensional logistic map
Step 3.2: Apply ShiftRow function on produced state from step 3.1
Step 3.3: Apply DP function on produced state from step 3.2 utilizing
the DP table that constructed by two-dimensional logistic map
(utilizing the round number i to extracting the matched row
from DP table)
Step 3.4: IF i is odd Then
Apply the AddRoundKey function between the produced state
from step 3.3 and key[(i/2)+0.5)] from keys for odd round
Step 3.5: Else
apply the AddRoundKey function between the produced state
from step 3.3 and key[(i/2)] from keys for even round
Step 4: next i
Step5: Store encrypted block and repeat steps (2 and 3) to encrypt new block
until encrypted all data blocks
End
49
Table (3.1): An instance of the suggested S-box employed for encryption
Y
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 99 F9 D2 57 1C 70 A2 13 1A A7 BC 3D 58 71 69 EF
1 6A E3 F0 E4 37 21 16 F6 12 14 5E A5 20 EB AE 1B
2 06 74 CE 35 79 E8 1F 8C 8B B 7C 4A 92 17 2D B1
3 85 77 46 C0 5F 9C 68 EC E7 3C 3A 64 CC A0 E AC
4 AD D4 53 76 28 8E 15 67 FC 1D 9B CA 09 5A 29 04
5 7B 49 27 22 B6 41 39 03 9A 4D 38 A3 4B BB 42 BA
6 ED 18 FB C3 97 75 F7 D7 AA D5 AB E5 23 0D 93 B2
7 60 F8 EE EA B5 48 C1 78 26 E6 D6 56 2F 7E 52 25
X
8 CF 6E B7 A4 73 8F 88 02 65 83 DC A9 C4 5C 8A D9
9 FF 07 55 FE 63 2A 01 3E A8 7F 1E 05 A6 FD 7A B4
A 8D 6F AF 2C B3 31 6D 40 DB 0A 19 61 10 82 24 F2
B F1 00 4E DD 72 90 5D 11 C5 CB 51 9F D8 DA 86 08
C 94 30 96 6C 89 F3 B0 54 C8 3F D1 44 95 A1 66 BE
D 80 FA 6B 32 7D 62 3B E2 87 C9 D0 34 0F 50 47 5B
E 81 4F 36 DE 45 84 C2 E1 BF DF 98 91 9E 9D 0C C6
F E0 CD E9 33 BD F5 2E 2B 43 D3 4C F4 B9 59 C7 B8
5 DD BA 7E 42 C7 92 7B 03 0C FD 4D DF 8D B6 1A 34
6 70 AB D5 94 3B 88 CE 47 36 0E 10 D2 C3 A6 81 A1
7 05 0D B4 84 21 65 43 31 77 24 9E 50 2A D4 7D 99
8 D0 E0 AD 89 E5 30 BE D8 86 C4 8E 28 27 A0 45 85
9 B5 EB 2C 6E C0 CC C2 64 EA 00 58 4A 35 ED EC BB
A 3D CD 06 5B 83 1B 9C 09 98 8B 68 6A 3F 40 1E A2
B C6 2F 6F A4 9F 74 54 82 FF FC 5F 5D 0A F4 CF E8
50
C 33 76 E6 63 8C B8 EF FE C8 D9 4B B9 3C F1 22 80
D DA CA 02 F9 41 69 7A 67 BC 8F BD A8 8A B3 E3 E9
E F0 E7 D7 11 13 6B 79 38 25 F2 73 1D 37 60 72 0F
F 12 B0 AF C5 FB F5 17 66 71 1 D1 62 48 9D 93 90
Every byte in the state is changed with another one from the S-box as
follows: As shown in figure (3.6), the byte of state is split into two parts, with the
first part indicating the row of the S-box and the second part indicating the column
of the S-box. The row and column are then crossed to get the new byte from the S-
box and replace it with the current byte in the state.
5 ShiftRows function
The LWAES-128 uses the same ShiftRows function as in the original AES
without any change. This function offers a permutation process to the state. It
works as follows: keeping the first row of the state without any change while
51
shifting cyclically to the left the second, third, and fourth row by 1byte, 2bytes, and
3bytes, respectively, as shown in figure (3.7).
The third function in the LWAES-128 algorithm is the DP. It offers permutation
process to the state. The generated DP table in algorithm 3.4 is used in this
function. Tables (3.3) and (3.4) show2 the example on the DP table and its inverse.
The DP table contents 9 rows within each row 16 different numbers assigned for
each round.
Table (3.3): Example of DP table employed for encryption
Round 1 11 15 8 5 7 1 16 9 12 13 4 10 14 6 2 3
Round 2 14 13 15 1 12 7 10 2 4 8 9 3 5 16 6 11
Round 3 16 4 5 8 1 11 9 14 3 15 10 2 12 7 6 13
Round 4 15 16 10 13 12 4 9 5 2 14 1 3 8 7 6 11
Round 5 2 8 15 6 12 4 1 11 5 9 7 3 10 13 16 14
Round 6 9 14 1 11 15 16 2 13 5 4 10 3 7 12 8 6
Round 7 8 6 4 14 2 1 3 15 5 12 7 10 11 13 16 9
Round 8 6 1 8 15 10 11 3 2 12 7 14 4 16 13 5 9
Round 9 15 1 5 14 4 2 10 9 3 12 16 8 6 13 11 7
52
Round 4 11 9 12 6 8 15 14 13 7 3 16 5 4 10 1 2
Round 5 7 1 12 6 9 4 11 2 10 13 8 5 14 16 3 15
Round 6 3 7 12 10 9 16 13 15 1 11 4 14 8 2 5 6
Round 7 6 5 7 3 9 2 11 1 16 12 13 10 14 4 8 15
Round 8 2 8 7 12 15 1 10 3 16 5 6 9 14 11 4 13
Round 9 2 6 9 5 3 13 16 12 8 7 15 10 14 4 1 11
Figure (3.8) below shows an example of applying the DP function. The first
step is selecting the row's number according to the round's number. In this
example, the round's number is 1, which means selecting the first row from table
DP, then reading the first number in the selected row, which indicates the byte
position in the state, then moving this byte into position 1. Then reading the second
number from the current row to select the position of another byte from the state,
moving it into position 2, and so on.
The last function in the LWAES-128 is the AddRoundKey. In this function, the
XOR operation will be performed between the state (data block) and the 128 bits
53
of the round key. It is performed columnwise, i.e., each column in the state is
XORed with the corresponding column in the roundkey, as shown in figure (3.9)
below:
When this function is executed on the initial round, the key utilized is
derived from the key for the initial round that was generated by the Shake-128
hash algorithm. When the index of the round is even, the key utilized in this
function is derived from the keys of the even rounds, and lastly, when the index of
the round is odd, the key utilized is derived from the keys of the odd rounds.
54
Chapter Four
Implementation the proposed
System
Chapter Four
Implementation the proposed System
4.1 Introduction
After the proposed LWAES-128 encryption algorithm has been designed,
it is evaluated utilizing many statistical tests and implemented in a practical
environment utilizing the Raspberry Pi model 4 and sensors. The LWAES-128
is utilized to protect sensor data while sending it over the network. The
temperature sensor, humidity sensor, and flame sensor are employed to detect
the temperature, humidity, and whether or not there is a fire, and then transfer
this collected data to the server via a wireless network. This collected data has
an essential role in the server's actions, so using the LWAES-128 encrypting
algorithm provides secure this data against attackers.
This chapter illustrates, analyzes, and discusses the results of the
proposed LWAES-128 encryption algorithm. The WAES-128 is tested and
evaluated by utilizing various security tests. Lastly, LWAES-128 is utilized to
encrypt the data of sensors DHT22 and flame before it is sent to the server over
the network.
4.2 Implementation of the System
The proposed LWAES-128 encryption algorithm, as illustrated in the
previous chapter, was meant to protect the sensing data in an IoT network. As a
case study, a Raspberry Pi device and some sensors like temperature, humidity,
and flame are utilized to monitor the temperature, humidity, and whether or not
there is a fire in the place.
The temperature degree and humidity rate are determined by utilizing the
DHT22 sensor, while the flame sensor is utilized to determine the presence of a
fire or not. The sensors' data will be transmitted to the server over the network.
These sensors' data are essential for the server in making decisions, and
when hacked and modified by hackers, this will lead to decisions that cause
55
errors in the system. As a solution, the data from these sensors will be encrypted
by utilizing LWAES-128 algorithm installed in the Raspberry Pi device. This
IoT system can be utilized to measure humidity and temperature, for instance, in
factories, nuclear power plants, or smart homes.
As shown in figure (4.1), two types of sensors, Raspberry Pi 4model B and
server, are utilized in this proposal. In the first step, data from sensors connected
to the Raspberry Pi device is collected. This data is then encrypted using the
LWAES-128 algorithm that is installed on the Raspberry Pi device. Finally, the
encrypted data from the sensors is securely sent to the server side over a
wireless network.
On the server side, after receiving the encrypted sensor data from the
Raspberry Pi, the decryption process is performed by utilizing the LWAES-128
algorithm to obtain the original sensor data. In this proposal, the server utilized
is a laptop running Windows 10.
56
Figure (4.1): Proposed LWAES-128 algorithm implementation
4.3 Requirements and Environment
For implementation of the proposed LWAES-128 algorithm on IoT
devices, two requirements are needed: hardware and software requirements. The
hardware requirements that are utilized in this proposal are sensors (DHT22 and
Flame-fire), a Raspberry Pi 4model B, a computer, and wireless network, while
the software requirements that are utilized in this proposal are the Python
programming language version 3.10.6 for programming the proposed LWAES-
128 algorithm and the sensors, the Raspbian operating system for the raspberry-
pi, and the Windows 10 operating system for the computer. Table 4.1 shows the
Specifications of the utilized sensors.
temp: (± 0. 5°)
5
Average Sensing 2s 2s
period
57
percentage. It has a single-bus digital interface. By using the library
(Adafruit_Python_DHT), the Raspberry-pi collects the data from the DHT22
sensor.
The flame IR sensor is sensitive to the light that is generated by the
flame. It can detect light wavelengths within the range (from 720 nm to 1100
nm) in the spectrum of infrared. When the flame sensor detects a flame, the
digital output (DO) becomes (1), otherwise it becomes (0). The Raspberry Pi
can read the data from this sensor by determining the pin number (GPOI) that is
linked as the data-pin.
The data is collected from the sensors as numerical values via the
raspberry-pi module. Then the Raspberry Pi encrypts this collected data by
utilizing the LWAES-128 algorithm. Lastly, the Raspberry Pi sends this
encrypted data to the server side utilizing a wireless connection by socket (IP
address).
A Raspberry Pi is a microcomputer that has an operating system. It is able
to execute many programs simultaneously. The Raspberry Pi 4model B utilized
in this proposal is the latest product in the raspberry-pi family. Table 4.2 shows
the specifications of the utilized Raspberry Pi 4model B.
58
4.4 Collection of Data from Sensors
In this proposal, the Raspberry Pi is programmed to collect data from the
sensors every 5 seconds to monitor changes in the environment. An example of
collecting data from sensors every 5 seconds is shown in table 4.3.
Table 4.3: An example of collecting sensors data every 5 seconds
Time (sec) Temperature (C) Humidity (% RH) Fire
1 35° 44% 0
6 35° 45% 0
11 35° 41% 0
16 34° 60% 0
21 35° 46% 1
As observed in table 4.3, the first column (time) means that the collected
data at the initial time is listed in the first row, after 5 seconds it is listed in the
second row, and so on. At the initial time (1 sec), the data collected by
Raspberry Pi are: temperature = 35 C, humidity = 44%, and fire = 0 means no
fire detection, whereas the collected sensing data at the time in row 5 are:
temperature = 35 C, humidity = 46%, and fire = 1 means there is a fire detected.
Through this sensing data, it is noticed that there is an abnormal condition,
which is the presence of a fire in that place.
These collected data will be encrypted using the LWAES-128 algorithm
before being sent to the server. On the server side, the encrypted data is first
received and then passed to the LWAES-128 algorithm to be decrypted and
displayed on screen.
4.5 Evaluation and Results
59
it a lightweight encryption algorithm that can be employed to protect IoT
devices. The round’s functions in the LWAES-128 are Sub Bytes, Shift Rows,
Dynamic permutation (DP), and Add Round Key. Table 4.4 explains the
comparison between the standard AES and LWAES-128 algorithms.
Table 4.4: Comparison between the standard AES and LWAES-128 algorithms
Standard AES LWAES-128
Key length 128-bits 128-bits
Block length 128- bits 128- bits
Key space 2128 2128
No. keys 11 10
No. rounds 10 9
Sub Bytes, Shift Rows, Sub Bytes, Shift Rows,
Round’s function MixColumns, and Add Dynamic permutation (DP),
Round Key and Add Round Key
Structure SPN SPN
The balanced criterion test is also applied to the constructed S-box from x0 =
0.7 and = 3.91, as shown in table ( 4.6) below.
4
0 66 73 25 93 49 C8 62 10 6A 6C 86 5B 65 82 01 5E
1 67 C0 83 30 F1 EF F0 A2 60 B1 7D CC 39 85 05 7A
2 3B A0 34 8E 8A 45 E3 C2 20 3F 96 84 24 04 A4 31
3 21 2E 36 7C 40 EB B4 54 80 75 06 BC 4E 53 CD 2A
4 CE 1E C4 71 E0 FA 79 22 51 CF D5 0C 91 5F 0E 6F
5 B0 47 32 6E 81 2B 0F F5 23 50 42 C1 64 CA 2F 35
6 FE 02 DA 15 7E B8 F4 08 D4 18 68 D8 D2 2C 9B E4
7 E7 A8 1C 6B A9 8D 3D 6D 89 FC F3 CB 38 AF 16 7B
8 7F E5 03 59 BD C6 EE 0A 77 D3 4D B2 9F BB BF FD
9 44 D9 95 63 3A 74 D1 DF C7 72 AE 88 78 E9 F8 E6
A 4A ED C9 28 F2 4F F7 07 EC 14 9D 26 4C 90 FF 99
B 4B 57 0B 27 5C 29 B7 D6 58 97 BA 92 C5 E2 1B B9
C AB AA 1A FB 94 AC AD 12 3E B6 8C 76 E1 DB B5 B3
D 19 70 8F 8B 87 98 55 C3 3C 13 09 1F A1 DD 56 0D
E A3 46 F9 DC DE EA BE 52 A6 48 17 D0 43 41 9A A7
F 9E 5D 1D A5 D7 61 9C 00 33 69 11 37 5A 2D E8 F6
When testing the proposed S-box with the BC test, the result shows a
balance which is due to having an equal number of zeros and ones as seen in
table (4.7), which explains the BC test for two different strings utilizing the
suggested S-box compared with other S-boxes.
61
Table 4.7: BC test on S-box when x0 =0.7 and =3.91
0 1
Proposed S-box 32 0 32 0 32 32
It is due to every bit in the new S-box relying on the input values x 0 and of
the one-dimensional logistic map. If there are two different values of x 0
(different by only a single number after the decimal point), then the S-box
constructed from the first x0 differs from the S-box constructed from the second
x0. This characteristic is one of the important features of employing the chaotic
system, which indicates that a small alteration in the starting conditions results
in a large alteration in the output. For instance, the S-box constructed by x 0 =
0.05 and = 3.7 and the S-box constructed by x0 = 0.15 and =3.7 are different
from each other, thus the new S-box meets the CC test. The outcomes of these
two instances are listed in table (4.8), (4.9), (4.10), and (4.11).
s
62
A 8D 6F AF 2C B3 31 6D 40 DB 0A 19 61 10 82 24 F2
B F1 00 4E DD 72 90 5D 11 C5 CB 51 9F D8 DA 86 08
C 94 30 96 6C 89 F3 B0 54 C8 3F D1 44 95 A1 66 BE
D 80 FA 6B 32 7D 62 3B E2 87 C9 D0 34 0F 50 47 5B
E 81 4F 36 DE 45 84 C2 E1 BF DF 98 91 9E 9D 0C C6
F E0 CD E9 33 BD F5 2E 2B 43 D3 4C F4 B9 59 C7 B8
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 B1 96 87 57 4F 9B 20 91 BF 4C A9 29 EE 6D 3E DC
1 AC B7 18 07 19 46 16 2D 61 AA 08 1F 04 49 9A 26
2 1C 15 53 6C AE 7F 78 52 44 4E 95 F7 A3 2E F6 7C
3 C1 A5 D3 F3 DB 23 E2 14 5A 56 3A D6 39 0B 97 C9
4 A7 55 5E F8 CB E4 32 DE 75 51 2B 5C FA 59 B2 E1
5 DD BA 7E 42 C7 92 7B 03 0C FD 4D DF 8D B6 1A 34
6 70 AB D5 94 3B 88 CE 47 36 0E 10 D2 C3 A6 81 A1
7 05 0D B4 84 21 65 43 31 77 24 9E 50 2A D4 7D 99
8 D0 E0 AD 89 E5 30 BE D8 86 C4 8E 28 27 A0 45 85
9 B5 EB 2C 6E C0 CC C2 64 EA 00 58 4A 35 ED EC BB
A 3D CD 06 5B 83 1B 9C 09 98 8B 68 6A 3F 40 1E A2
B C6 2F 6F A4 9F 74 54 82 FF FC 5F 5D 0A F4 CF E8
C 33 76 E6 63 8C B8 EF FE C8 D9 4B B9 3C F1 22 80
D DA CA 02 F9 41 69 7A 67 BC 8F BD A8 8A B3 E3 E9
E F0 E7 D7 11 13 6B 79 38 25 F2 73 1D 37 60 72 0F
F 12 B0 AF C5 FB F5 17 66 71 01 D1 62 48 9D 93 90
63
C 78 9B C5 86 4D A6 52 BF 22 0D F6 F0 82 12 9D 01
D FA 72 C6 92 67 AC A3 E3 FE 08 7C 98 4B 74 3E EE
E 37 9E 94 5B 5A E9 7D A7 24 06 61 8D 27 11 5F F7
F 21 A9 5C 99 1C 97 8E 2B 3F AD 1A 70 D5 1D DF B9
Table 4.12: Comparisons of the AC test of (A...Z) utilizing the proposed S-box
when x0= 0.05 and = 3.7 with some other related approaches
Input Sum of AC Values of Each Input
Approach AC Average
data (26)
Ref [14] A…Z 13.250 0.5096
Ref [15] A…Z 13.625 0.5240
64
proposed A…Z 13.125 0.5048
Table 4.13 shows an example that explains how to compute the AC value
in the case of a single bit difference per entry utilizing the proposed S-box
(when x0=0.05 and =3.7) and compared approaches.
Table 4.13: Example for AC computation of the proposed S-box (if x0=0.05
and =3.7) and other related S-boxes
Hex- Binary Substitute in Binary
Approach Data AC
Code Input the S-box Output
Ref [14] B 42 01000010 A8 11001110 6/8 =
Alter 1 bit C 43 01000011 BB 00100000 0.75
Ref [15] B 42 01000010 A8 11111011 3 /8 =
Alter 1 bit C 43 01000011 BB 01111110 0.375
proposed B 42 01000010 A8 01010011 3 /8 =
Alter 1 bit C 43 01000011 BB 01110110 0.375
Table 4.15 shows an example that explains how to compute the AC value
in the case of a single bit difference per entry utilizing the proposed S-box
(when x0=0.7 and =3.91) and compared approaches.
65
Table 4.15: Example for AC computation of the proposed S-box (if x0=0.7 and
=3.91) and related S-boxes
Hex- Binary Substitute in Binary
Approach Data AC
Code Input the S-box Output
Ref [11] S 53 01010011 5F 01011111 5 /8 =
Alter 1 bit R 52 01010010 64 01100100 0.625
Ref [12] S 53 01010011 7C 01111100 3 /8 =
Alter 1 bit R 52 01010010 65 01100101 0.375
Ref [13] S 53 01010011 C7 11000111 6 /8 =
Alter 1 bit R 52 01010010 79 01111001 0.75
proposed S 53 01010011 6E 01101110 4 /8 =
Alter 1 bit R 52 01010010 32 01101110 0.5
66
1. Entropy analysis
It is used to determine the randomness value in an image. If the entropy
value is high, the image values are more random. The optimal entropy value is
near or equal to 8. Table 4.16 shows the results of the entropy metric on the
encrypted four images using proposed S-box. All the results are close to 8
meaning that all encrypted images have good degree of random value caused by
the proposed S-box thus the proposed S-box meet the entropy metric.
2. Correlation Coefficient
Some attackers exploit the relationship between the pixels of an image to
hack it, so the correlation coefficient helps to determine the degree of the
relationship between the pixels of an image. The optimal correlation coefficient
must be near or equal to 0. Table 4.17 shows the results of this metric on the
encrypted four images. All the results are close to 0, which means that the
proposed S-box is able to remove the relationship between the pixels and
prevent attackers from exploiting it.
67
Peppers 0.0030
3 Histogram analysis
A histogram displays the frequency of occurrence of pixel values in original
and encrypted images. The distribution of the encrypted image histogram must
be uniform and flat to remove the image's statistical features, which are
exploited by the attacker. Figure (4.2) displays the histogram of the original and
encrypted four images. All of the histograms of the encrypted images look flat
and uniform, which means that the proposed S-box is able to remove the
statistical features from images and stop attackers from using them.
Lena
Baboon
Woman
Peppers
Plaintext ¿(byte¿)
Throughput= (4.1) [88]
EncryptionTime ( millisecond )
69
128, traditional AES, and MLAES. Table (4.21) and figure (4.5) explain the
comparison of consumed decryption time utilizing the proposed LWAES-128
with related work.
After that, the LWAES-128 algorithm is implemented on the Raspberry
Pi to encrypt the data from sensors. The average time consumed for encrypting
the data and the throughput are measured to evaluate the performance of this
algorithm on a true IoT device, as explained in table (4.23) and figure (4.6). The
total time that was consumed by reading data from the sensor, encrypting it, and
sending it to the server side was also measured. The total time for these
operations reaches around 1.27 seconds.
Table (4.24) displays the NIST statistical tests results for the binary
sequences produced by the proposed LWAES-128 algorithm. It proves that the
LWAES-128 algorithm passed all 16 tests, with all of the testing results being
close to one. The NIST statistical tests are performed on the cipher-text.
Table 4.19 shows the average encryption and decryption time using the
LWAES-128 algorithm.
Table 4.19: LWAES-128 encrypting and decrypting average time
Text Size Encrypting Time Decrypting Time
(byte) (millisecond) (millisecond)
10 0.0687 0.0684
25 0.1266 0.1268
70 0.2862 0.2863
100 0.3961 0.3965
1000 3.3981 3.4011
2000 6.601 6.604
5000 16.552 16.554
10000 32.8837 32.8701
15000 51.0921 51.1002
25000 85.5727 85.5711
70
90 LWAES-128 algorithm
80
70
Time (milliseconds)
60
50
40
30
20
10
Text size (byte)
0
10 25 Encrypting
70 100time 1000 Decrypting
2000 5000 Time 10000 15000 25000
Table 4.20: Encryption Time and Throughput compared to the related works
180
Encryption Time
160
140
Time (milliseconds)
120
100
80
60
40
20
0
10 25 70 100 1000 2000 10000
72
180
Decryption Time
160
140
Time (milliseconds)
120
100
80
60
40
20
0
10 25 70 100 1000 2000 10000
73
throughput of 74.786 bytes per millisecond, whereas, the traditional AES
consumes 3.123 milliseconds and provides a throughput of 22.414 bytes per
millisecond, MLAES consumes 2.45 milliseconds and provides a throughput of
28.571 bytes per millisecond to encrypting the same text size.
3
2.5
2
1.5
1
0.5
0
10 25 70
Text size (byte)
Traditional AES MLAES [18] Proposed LWAES-128
Table 4.24: NIST tests on the cipher-text from the suggested LWAES-128
e
74
Discrete Fourier Transform (Spectral) Test 0.985357 Random
Non- Overlapping Template 0.159576 Random
Overlapping template 0.445460 Random
Maurer’s universals 0.669039 Random
Linear Complexity 0.909393 Random
Serial test 0.520191 Random
Approximate Entropy 0.148339 Random
Cumulative Sums (forward) 0.319992 Random
Cumulative Sums (backward) 0.186974 Random
Random Excursions 0.798896 Random
Random Excursion Variant 0.897953 Random
Through the LWAES-128 findings, it can be seen that despite all these
modifications to the traditional AES algorithm, it is still resistant to attacks. The
use of a combination of (1-D and 2-D chaotic logistic) in all of these
modifications gives a high level of security and speed when encrypting, making
it appropriate for IoT devices. Because different chaotic systems are used to
modify the standard AES, the proposed LWAES-128 algorithm also success in
all NIST tests when performed on 1000000-bits of cipher-text, as explained in
table 4.24 above.
The CPU status and memory usage of the Raspberry device are also
monitored while executing the LWAES-128 algorithm to encrypt the data
sensors and send it to the server, where table 4.25 shows that the LWAES-128
algorithm uses 0.34% or less than 1% of the memory size and 1.1% of the CPU
It also maintains the CPU temperature in a regular state.
The information explained in this table indicates the CPU and memory
usage of the Raspberry Pi as follows: the left column of this table represents the
total CPU load (for all programs operating on it), and the memory total size
compared to the total size utilized (for all open programs including Python and
others), while the right column of this table represents the amount of CPU and
memory usage during encryption by LWAES-128.
75
Table 4.25: The status of the Raspberry device during executing encryption
Raspberry status while the LWAES-128 CPU and Memory usage for
algorithm is running LWAES-128
CPU Memory (MB) CPU: 1.1%
Temp: 41° C Total: 7898 Memory: 27.3 MB (0.345 %)
Total load:10.9% Used: 261 i.e. less than 1%
Shared: 69
Buff/Cache:534
Table 4.26 and figure (4.7) shows the power consumption of the proposed
algorithm and other related algorithms when encrypting three different text sizes
(10, 25, and 70 bytes) on the raspberry pi device.
Table 4.26: The power consumption comparison of the proposed algorithm and
other related algorithms
76
Power Consumption
16
14
Power consumption (MJ)
12
10
8
6
4
2
0
10 25 70
Text size (byte)
Standard AES MLAES [22] Proposed LWAES-128
Figure (4.7): The power consumption of the proposed algorithm and other
related algorithms
77
Figure (4.8): Server outputs sensors data after decrypting
Every five seconds, the Raspberry Pi collects data from the sensor , s
encrypts it, and then transmits it to the server. If the connection between the
server and the Raspberry Pi is established, the server will directly receive this
encrypted data, decrypt it, and display it on the screen. The average time
consumed by the decryption process is just 0.898 milliseconds.
78
Chapter Five
Conclusions and Proposals for the
Future Work
Chapter Five
Conclusions and Proposals for the Future Work
5.1 Introduction
The current chapter presents conclusions about the findings obtained
from the implementation of the proposed LWAES-128 algorithm as well as
some proposals to be made for future work. Section (5.2) explains the
conclusion, and section (5.2) provides the proposals for future works.
5.2 Conclusions
Based on the findings that are explained in the preceding chapter of
running many statistical tests on the proposed LWAES-128 encryption
algorithm and calculating the time spent in the encrypting process employing
this algorithm, the proposed LWAES-128 can be employed as a lightweight
solution for protecting any IoT system.
79
3. The creation of the proposed S-box and its inverse takes just 15.6
milliseconds. It also meets the S-box criteria and achieves excellent results
compared to related works. The statistical metrics of the proposed S-box
when used to encrypt images also proved its strength against attacks.
5. The use of DP process leads to a high level of diffusion due to the use of
nine dynamic rows in the table of DP. Each row contains 16 positions, with a
different order assigned to each round, i.e., each round has a different row.
9. In addition to the initial key, two kinds of keys are also used in the LWAES-
128; one for the even rounds and one for the odd rounds. This will increase
80
the avalanche effect. These two types of keys are constructed by using the
two-dimensional logistic system.
81
References
82
References
[3] K.-L. Tsai, Y.-L. Huang, F.-Y. Leu, I. You, Y.-L. Huang, and C.-H. Tsai,
“AES-128 Based Secure Low Power Communication for LoRaWAN
IoT Environments,” IEEE Access, vol. 6, pp. 45325–45334, 2018, doi:
10.1109/ACCESS.2018.2852563.
[12] L. Liu, Y. Zhang, and X. Wang, “A Novel Method for Constructing the
S-Box Based on Spatiotemporal Chaotic Dynamics,” Appl. Sci., vol. 8,
no. 12, p. 2650, Dec. 2018, doi: 10.3390/app8122650.
[13] Lu, Zhu, and Wang, “A Novel S-Box Design Algorithm Based on a New
Compound Chaotic System,” Entropy, vol. 21, no. 10, p. 1004, Oct.
2019, doi: 10.3390/e21101004.
[25] A. Ahmad, “A New Security Method for the Internet of Things Based
on Ciphering and Deciphering Algorithms,” Kirkuk Univ. Journal-
Scientific Stud., vol. 13, no. 3, pp. 154–174, Sep. 2018, doi:
10.32894/kujss.2018.13.3.12.
[36] D. Puthal and R. Ranjan, “Big Data Stream Security Classification for
IoT Applications,” Encyclopedia of Big Data Technologies, no. January.
Springer, 2019, doi: https://doi.org/10.1007/978-3-319-63962-8_236-1.
[49] D. Sehrawat and N. S. Gill, “Lightweight Block Ciphers for IoT based
applications : A Review,” Int. J. Appl. Eng. Res., vol. 13, no. 5, pp.
2258–2270, 2018.
[61] H. Liu and X. Wang, “Cryptanalyze and design strong S-Box using 2D
chaotic map and apply to irreversible key expansion”, pp. 1–14, Nov.
2021, doi: doi.org/10.48550/arXiv.2111.05015.
تشـير نتــائج التحليــل إلى أن خوارزميــة LWAES-128المقترحــة تسـتهلك وقتًا أقــل في
التشفير وفك التشفير ،حيث يمكنهــا تشــفير حجم نص يبلــغ 25000بــايت في 85.57مللي ثانيــة
فقط عند تنفيـذها على كمـبيوترـ محمـول يعمـل بنظـام . Windows 10لـذلك ،فـإن خوارزميـة
LWAES- 128لديها سرعة أكبر مقارنة مع AESالقياســية واألعمــال األخــرى ذات الصــلة.
يلبي S-boxالمصمم متطلبات األمان لـ ، S-boxبما في ذلك معيار ) ، avalanche (ACو
،balancedو ، strictو ) ،completeness(CCو )(BC avalanche )(SAC
،correlationو ،informationو coefficient ، Invertabilityو entropy
، histogramو ، UACIو NPCR.حيث كانت قيم NPCRو UACIلصورة Lenaفي
المستوى المقبول عند ٪99.6و ٪33.56على التــوالي ،وتكــون نتيجــة ACفي النطــاق األمثــل
.٪50.097بينما كانت histogramللصور المختلفة مسطح وموحــدـ ،بلغت قيم الـ entropyو
correlation coefficientللصـــور المســـتخدمة قريبـــة من 8و 0على التـــوالي .كمـــا نجح
LWAES-128في جميع االختبـارات اإلحصـائية )NIST(.لـذلك ،وفقًا لهـذه النتـائج ،تـوفرـ
خوارزمية LWAES-128مزيدًا من العشوائية.
جمهورية العراق
وزارة التعليم العالي والبحث العلمي
الجامعة المستنصرية
كلية التربية
قسم علوم الحاسبات
من قبل
رسول صالح سلمان
بإشراف
أ.د .عالء كاظم فرحان
أ.م.د .علي شاكر محمود
2022م 1444هـ