Next Article in Journal
Relationship between Tissue Gliding of the Lateral Thigh and Gait Parameters after Trochanteric Fractures
Next Article in Special Issue
Multi-Swarm Algorithm for Extreme Learning Machine Optimization
Previous Article in Journal
Secured and Deterministic Closed-Loop IoT System Architecture for Sensor and Actuator Networks
Previous Article in Special Issue
Multi-End Physics-Informed Deep Learning for Seismic Response Estimation
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Novel Binary Hybrid PSO-EO Algorithm for Cryptanalysis of Internal State of RC4 Cipher

1
Department of Basic Engineering Science, Faculty of Engineering, Menoufia University, Shebin El-Kom 32511, Menoufia, Egypt
2
Department of Information Systems, Faculty of Computers and Information, Menoufia University, Shebin El-Kom 32511, Menoufia, Egypt
3
Department of Basic Engineering Science, Higher Institute of Engineering and Technology, Tanta 31739, Gharbia, Egypt
4
College of Applied Computer Science, King Saud University, Riyadh 11451, Saudi Arabia
5
Department of Computer Science, Yarmouk University, Irbid 21163, Jordan
6
Faculty of Sciences and Technology, University of Kairouan, Sidi Bouzid 4352, Tunisia
*
Authors to whom correspondence should be addressed.
Submission received: 17 April 2022 / Revised: 14 May 2022 / Accepted: 16 May 2022 / Published: 19 May 2022

Abstract

:
Cryptography protects privacy and confidentiality. So, it is necessary to guarantee that the ciphers used are secure and cryptanalysis-resistant. In this paper, a new state recovery attack against the RC4 stream cipher is revealed. A plaintext attack is used in which the attacker has both the plaintext and the ciphertext, so they can calculate the keystream and reveal the cipher’s internal state. To increase the quality of answers to practical and recent real-world global optimization difficulties, researchers are increasingly combining two or more variations. PSO and EO are combined in a hybrid PSOEO in an uncertain environment. We may also convert this method to its binary form to cryptanalyze the internal state of the RC4 cipher. When solving the cryptanalysis issue with HBPSOEO, we discover that it is more accurate and quicker than utilizing both PSO and EO independently. Experiments reveal that our proposed fitness function, in combination with HBPSOEO, requires checking 104 possible internal states; however, brute force attacks require checking 2128 states.

1. Introduction

Cryptology is the study of methods that ensure information secrecy. Cryptology has two branches: cryptography and cryptanalysis. Cryptography studies the design of cryptosystems, whereas cryptanalysis studies the cracking of crypts or cryptosystems for retrieving crucial information. Cryptanalysis is the science of deciphering ciphertext to obtain its plaintext without knowing the secret key employed. Any cryptosystem’s cryptanalysis can be stated as an optimization problem.
The work of cryptanalysis is difficult. A cryptanalyst can use a number of different methods to break a cipher, depending on the amount of information available to the attacker. The Known Plaintext Attack (KPA) is a type of attack where the attacker possesses plaintext and matching ciphertext samples [1].
The Ciphertext Only Attack (COA) is another form of attack where the cryptanalyst knows the ciphertext only. The KPA is easier to implement than the COA because the attacker has access to more information (both plaintext and ciphertext pairs), allowing the secret key to be extracted more readily.
The two main components of modern cryptography are symmetric-key cryptography and asymmetric-key cryptography. The first group is then subdivided into block and stream ciphers as shown in (Figure 1). The operational premise of a stream cipher is that for every bit of plain text, there is a corresponding bit of keystream; these two are combined with an XOR operation to obtain one bit of ciphertext. The fundamental issue is that each piece of plaintext is coded independently from the others. Stream ciphers come in a variety of shapes and sizes, and they are useful in real-world applications such as: CSS used in DVD encryption, A5/1 and A5/2 used in GSM encryption, EO used in Bluetooth and RC4 used in SSL and WEP applications [2].
Heuristics is a technique used in computer science, artificial intelligence, and mathematical optimization to solve a problem faster when traditional techniques are too slow, or to discover a rough answer when traditional approaches fail to provide a perfect solution. A metaheuristic is an iterative strategy that drives a subordinate heuristic by intelligently mixing several notions for exploring and utilizing the search space. These algorithms are inspired by natural events. Meta-heuristic optimization algorithms are gaining popularity in engineering applications because they: (i) rely on relatively simple concepts and are easy to implement; (ii) do not require gradient information; (iii) can bypass local optima; and (iv) can be used to a wide range of challenges in a variety of fields. Meta-heuristic algorithms inspired by nature mimic biological or physical occurrences to solve optimization issues. They have been classified into four categories (see Figure 2): evolution-based, physics-based, swarm-based and human-based algorithms. The laws of natural evolution motivate evolution-based approaches. Genetic Algorithms (GA) [3], which replicate Darwinian evolution, are the most prominent evolution-inspired approach. Evolution Strategy (ES) [4], Genetic Programming (GP) [5], and Biogeography-Based Optimizer (BBO) [6] are some other popular algorithms. Physics-based methods, such as Simulated Annealing (SA) [7], Gravitational Search Algorithm (GSA) [8] and Equilibrium optimizer (EO) [9], emulate the physical universe’s principles. Swarm-based strategies, which mirror the social behavior of groups of animals, make up the third category of nature-inspired methods. Particle Swarm Optimization [10], Ant Colony Optimization (ACO) [11], Grey Wolf Optimization (GWO) [12] are the most popular algorithms in this category. Other meta-heuristic methodologies inspired by human behavior in the literature are also available, such as Teaching Learning Based Optimization (TLBO) [13], Harmony Search (HS) [14] and Tabu (Taboo) Search (TS) [15].
The goal of all of these algorithms is to discover the best solution for quality and convergence as efficiently as possible. A nature-inspired algorithm should incorporate exploration and exploitation elements to guarantee that the global optimum is discovered. Exploration is defined as the capacity to search the universe at large. This capacity is linked to escaping local optima and avoiding stagnation in local optima. Exploitation, on the other hand, refers to the capacity to look for potential ideas locally and increase their quality. Good performance is the outcome of a good trade-off between these two attributes. It is tough to strike a balance between these two qualities because when one improves, the other deteriorates [16]. A hybrid technique is one method for establishing a good balance, in which two or more algorithms are combined to make each algorithm’s performance better; the resulting hybrid technique is referred to as a memetic method [17].
It is not a novel idea to use metaheuristic optimization to tackle cryptanalysis challenges. Since the early 1990s, there has been a lot of research carried out on this subject, although the scope has been limited to a small number of cryptography and optimization methods. We will discuss a novel technique in this study that combines PSO and EO algorithms to increase their performance, and we will apply this approach to the cryptanalysis problem. The remainder of this work is broken down into the sections below: Section 2 discusses the scope of work relating to the use of evolutionary approaches in the field of cryptanalysis. The mathematical models of PSO, EO and HPSO-EO are explained in Section 3. Section 4 introduces the stream ciphers and RC4 cipher. Section 5 and Section 6 introduce the fitness function and proposed algorithm “BHPSO-EO’’ for attacking the stream cipher (RC4), while Section 7 offers the results and discussion. Finally, in Section 8, the work’s conclusion is presented.

2. Related Work

Several prior studies have investigated RC4 cryptanalysis. In 1995, Roos [18] identified a link between the used key’s first three bytes and the RC4 keystream’s first byte. The RC4 creates a keystream that is biased in different methods to different sequences. In a correlation attack, Mantin and Shamir [19] demonstrated that the second output byte was skewed toward zero with a probability of 1/128, although it should be 1/256. When the original state’s third byte is 0 and the second byte is not equal to 2, the second output byte is always 0. Klein [20] published a cryptanalysis of the RC4 Cipher in 2008, which revealed more correlations between the output key sequence and the applied keys.
Metahuristic algorithms have already been used to attack stream ciphers; Bogdan and Călin [21] submitted a paper in 2011 using the Tabu Search Methodology to recreate the internal state of the RC4 stream cipher. In 2015, Iwona and Mariusz [22] applied the Genetic Algorithm to the cryptanalysis of the RC4 cipher. In this research, GA was applied to find the keystream for RC4 with different key lengths key lengths of 64, 80, and 128 bits. We found that in the three different experiments, the fitness did not reach one, which indicates that the key obtained by the algorithm is an approximate key and is not real; however, in our paper, we obtain a real key as we obtained a value of fitness of one, which means that all the bits of the keystream are true, indicating that the proposed algorithm is more accurate. In 2019, Maiya, Saibal and Muttoo applied Particle Swarm Optimization to solve the RC4 stream cipher. The authors used COA in cryptanalysis to find the initial value of the key and not the keystream, whereas this paper focuses on finding the keystream in RC4 using KPA; we also introduce a novel algorithm based on the hydride PSO and EO that enhances their performance.
Various researchers have used hybrid algorithms to handle a range of problems in the optimization field during the last few decades. In solving numerous complex problems, these hybrid algorithms have outperformed their equivalents [23]. In [24], GA was combined with PSO to achieve global optimization. The authors of this study used GA and PSO hybridization to generate people not just from crossover and mutation operators, but also from PSO’s global and local search operators. For global numerical optimization, GA has been combined with the Taguchi method [25]. In [26], the authors of this study used hybrid Ant Colony Optimization with Firefly Algorithm for unconstrained optimization problems. In [27], GWO was hybridized with CSA based on the dynamic fuzzy learning strategy to solve large scale optimization problems. Hybrid strategies did substantially better in these tests than other global or local search approaches.

3. Methods

3.1. Particle Swarm Optimization

The Particle Swarm Optimization approach (PSO) was invented in 1995 by James Kennedy and Russell C. Eberhart [28]. This algorithm used to solve nonlinear optimization problems. Simulations of social psychological expression in birds and fish inspired this method. In the classic PSO model, a swarm of particles is given a population of random alternative solutions. They are constantly looking for new solutions in the D-dimension problem space. The fitness of a particle is directly proportional to its position. At time t, particle jth has a velocity ( v i j t ) and a location ( x t ). The terms P best and G best are included in PSO’s equation. Over the course of each iteration, these mathematical equations are utilized to update position and velocity:
v i j t + 1 = w v i j t + c 1 R 1 ( P b e s t t x t ) + c 2 R 2 ( G b e s t t x t )
x t + 1 = x t + v t + 1 ,   ( i = 1 , 2 ,   n p ) a n d   ( j = 1 , 2 ,   n v ) .  
where
w = w m a x w m i n * i t e r a t i o n m a x i t e r a t i o n
where w is the inertia weight. P b e s t t : among all particles, this is the best location of all time G b e s t t : among all particles, this is the best global location. Figure 3 shows the flow chart for it.
w m a x = 0.4   ,   w m i n = 0.9   , v i j t ,   v i j t + 1 is the velocity of the jth member of the ith particle at iteration number (t) and (t + 1). Usually, R1 and R2 are random numbers between (0, 1), c 1 = c 2 = 2 .

3.2. Equilibrium Optimizer (EO)

The Equilibrium Optimizer (EO) [9] is a novel continuous optimization approach based on physical principles. Because of its excellent exploration and exploitation capabilities, the EO technique has the benefit of being able to modify the answer at random. Particles with EO concentrations are similar to the particles and locations used to represent search agents in Particle Swarm Optimization (PSO). The search agents alter their concentration at random with regard to the best-so-far solutions, namely equilibrium candidates, to eventually achieve the equilibrium state (optimal outcome). The following is a more in-depth description of EO’s central concept.

3.2.1. Inspiration

The EO algorithm takes its inspiration from the physical mass balance equation. The mass balancing equation provides a physical basis for the conservation of entering mass, departing mass, and generated mass in the control volume. A first-order ordinary differential equation represents a universal mass balancing equation, in which the change in mass over time equals the mass entering the system minus the mass departing the system plus internal generation. The mass balancing equation is represented by Equation (4).
v d c d t = Q   C e q Q C + G  
where v denotes the control volume, C denotes the concentration of particles in the control volume, v d c d t denotes the control volume’s mass change rate, Q denotes the flow rate of volumetric fluid into and out of the control volume, C e q denotes the the particle density within the control volume at an equilibrium state without generation, and G denotes the mass generation rate within the control volume. A steady equilibrium state occurs when v d c d t = 0 and   λ = Q v defined as turnover rate (the inverse of residence). Equation (4) can be rearranged to solve for d c d t as a function of Q v .
d c λ   C e q λ   C + G v = d t
Equation (6) shows the time-integration of Equation (5).
C 0 C d c λ   C e q λ   C + G v = t 0 t d t
The following is the end result:
C = C e q + ( C 0 C e q ) F + G λ v ( 1 F )
where F is the following formula:
F = e λ ( t t 0 )
The beginning start time and concentration are t 0 and   C 0 , respectively, and are dependent on the integration interval.
The general structure of the EO technique is given by Equation (7). As Equation (7) shows, three terms have an impact on the EO algorithm’s search and update pattern. In the next part, we will go through the algorithm and update its formula in detail.

3.2.2. Equilibrium Pool ( C e q )

The final convergence state of the method, which is meant to be the global optimum, is called the equilibrium state [9]. The equilibrium pool is generated using the EO algorithm, which contains candidate particles for equilibrium. Experiments identified five candidate particles for the equilibrium pool, four of which were determined as the best particles during the optimization phase, and the fifth is the mathematical mean of the four above particles. Four best particles aid in bettering the exploration, the average, on the other hand, contributes to the exploitation. The equilibrium pool’s vector is as follows:
C e q , p o o l = { C e q ( 1 ) ,   C e q ( 2 ) ,   C e q ( 3 ) ,   C e q ( 4 ) ,   C e q ( a v e )   }
It is important to note that each iteration’s particle update is carried out using the random selection approach; as a consequence, all possible solutions for each individual update at around the same time.

3.2.3. Exponential Term (F)

The exponential term (F) is crucial in balancing the EO algorithm’s exploration and exploitation. (F) is calculated according to Equation (8). The iterative function time (t) decreases as the number of iterations increases, and λ is a random vector between [0, 1].
t = ( 1 i t e r M a x i t e r ) ( a 2 i t e r M a x i t e r )
The current and maximum numbers of iterations are i t e r and M a x i t e r , respectively. In Equation (8), the value of t 0   is computed as follows:
t 0 = 1 λ ln ( a 1 s i g n ( r 0.5 )   [ e λ t 1 ] ) + t
The constants a 1 and a 2 regulate the exploration and exploitation capacities, respectively. A higher value of a 1 indicates that the exploration capability is better and the exploitation capability is lower. The greater value of a 2 indicates the lesser exploration ability, the stronger the exploitation ability. The exploration and exploitation direction is indicated by s i g n ( r 0.5 ) . Equation (8) becomes as shown in Equation (12) after replacing the values of t and t 0 as indicated in Equations (10) and (11).
F = a 1 s i g n ( r 0.5 )   [ e λ t 1 ]

3.2.4. Generation Rate (G)

The EO algorithm’s most important parameter is the generating rate, as it aids in providing a precise answer by enhancing exploitation. The generation rate is calculated as follows:
G = G 0   e k ( t t 0 )
G 0   is the starting value, while k is the decay constant ( k = λ ). As a result, the generation rate is finally expressed as follows:
G = G 0   F
where:
G 0 = G C P   ( C e q λ   C )
G C P = { 0.5   r 1                       r 2 G P 0                                     r 2 < G P              
The probability that the generating term contributes to the updating process is represented by GCP, which is known as the control parameter for the generation rate; the number of particles that use generation terms to update their state is determined by the probability of this contribution. Equation (16) yields GCP, where (GP = 0.5) is the probability of the generation, and its function is to strike a reasonable balance between exploration and exploitation. r 1 and r 2 are two random values in the range of [0, 1]. Finally, EO’s rule for updating is as follows:
C = C e q + ( C C e q ) F + G λ v ( 1 F )
The second term in the EO algorithm is in charge of performing a global search in the search space to identify an optimum location, while the third term aids in increasing the solution’s precision. It is also important to note that EO uses a particle’s memory conserving mechanism, which helps to boost the algorithm’s exploitation capabilities. The flow chart of the EO algorithm is depicted in Figure 4.

3.3. Proposed Algorithm (HPSO-EO)

A set of hybrid PSO-EO is a combination of separate PSO and EO. Hybrid algorithms are created so that the strengths of one algorithm compensate for the drawbacks of the other. As a result, the constant inertia weight, PSO, has the constraint of only covering a narrow search space for tackling higher-order or complex design problems. The EO algorithm, on the other hand, provides several benefits. Firstly, the use of exponential terms (F) allows EO to strike a balance between exploration and exploitation. Secondly, the exact solution is provided by employing the generation rate. Finally, using an average particle in the computation of an equilibrium pool aids in the discovery of unknown search areas during the initial iterations when the particles are far apart. Therefore, we introduce a new hybrid PSO-EO algorithm that combines the benefits of both.
The proposed algorithm corrects the PSO algorithm’s flaw and enhances the exploration phase, allowing it to test a large number of viable solutions. During this phase, the best particle’s position in the EO replaces the particle’s location attempting to discover the optimal solution to a complex nonlinear problem. The best EO algorithm solutions are regarded as one of the proposed algorithm’s solutions. So, the EO algorithm directs the PSO particles to the most effective solutions. In this algorithm the velocity equation and the position equation have been computed as shown:
v i j t + 1 = w v i j t + c 1 R 1 ( P b e s t t x t ) + c 2 R 2 ( G b e s t t x t ) + c 3 R 3 ( E O _ b e s t t x t ) .
x t + 1 = x t + v t + 1

4. Stream Ciphers (RC4)

A keystream, which is a bitstream, is produced by the majority of stream cipher algorithms. This keystream is then XOR-ed with plaintext, which is a message to be encrypted. The encrypted stream is referred to as “ciphertext”, Figure 5 describe the stream cipher diagram. The key is used as a seed (initial value) for the stream cipher algorithm; this value is not used directly. This method is intended to generate a keystream that is significantly longer than the key itself. The keystream length depends on the plaintext length, but the initial value (IV) is independent of the plaintext length, which might be the same or different. Another difference between the IV and the keystream is that the keystream must be kept secret to ensure the secrecy of the communication, whereas the IV can be made public. The ciphertext and keystream must be XOR-ed in order to decrypt the encrypted message [29]. RC4 is a variable key-size stream cipher that is commonly utilized in software implementation because of its efficiency. It is found in SSL/TLS (Secure Socket Layer/Transport Layer Security) standards, as well as WEP (Wired Equivalent Privacy) and email encryption software. Ron Rivest of RSA Security created RC4 in 1987. RC4 is made up of two parts: a key-scheduling algorithm (KSA) that takes the key K (typically 40–256 bits in size) as the input and a keystream generator (PRGA) that generates a pseudo-random output sequence.

4.1. The Key-Scheduling Algorithm

The RC4 stream cipher’s initial step is the KSA; the KSA generates the initial permutation S from {0, …, N − 1} given a (random) key of length l bytes. The length of the key is usually between 5 and 32 characters. The key length’s maximum value N is 256 bits. S is set to {0, …, N − 1} and then the key bytes are mixed in using Algorithm 1. The input of this algorithm is the initial value of the key usually between 40 bits and 256 bits and the output is the initial permutation S.
Algorithm 1 Key-scheduling
for  0 i N 1
   S [ i ] = i
end for
j = 0
for  0 i N 1
     j = ( j + S [ i ] + k e y [ i   m o d   k e y l e n g t h ] ) m o d   N
   s w a p   ( S [ i ] , S [ j ] )
end for

4.2. The Pseudo-Random Generation Algorithm

PRGA employs the permutation S created by KSA to generate a pseudo-random key sequence. S(i) and S(j) are added together, and then looking up their sum (mod N) in S, the output byte is calculated. In the encoding process, the calculated output byte is used as a key sequence (Algorithm 2).
Algorithm 2 The Pseudo-Random Generation
i = j = 0
Do Generation Out Key Sequence
   i = ( i + 1 )   m o d u l o   N
   j = ( j + S [ i ] ) m o d u l o   N
   s w a p   ( S [ i ]   a n d   S [ j ] )
   O u t B y t e = S [ ( S [ i ] + S [ j ] )   m o d u l o   N ]
while R e q u i r e d   K e y   S e q .   g e n e r a t e d

5. Fitness Function

There is one more major issue that has to be resolved. It is the fitness function f f i t that qualifies how good a solution is to compare solutions. In this article, we used a plaintext attack, so the plaintext and ciphertext are both accessible to the attacker. The attacker can calculate the keystream by using both plaintext and ciphertext. Both attacker and the cryptanalysis algorithm generate keystreams that are identical in length. After that, the keystreams are compared to one another. When the fitness value is equal to 1, it signifies that the examined bits streams and the stream created by the cryptanalysis method are 100% compatible. The fitness value ranges from 0 to (1) that indicates how many matching bits there are in the provided solution. The equations below demonstrate how to compute fitness.
K m = P n C n
f f i t = # ( K m K ´ m ) | K |
where the number of zeros in ( K m K ´ m ) are denoted by #, and specifies the X O R operation. K m is the keystream analyzed by the attacker, K ´ m is the keystream created by the cryptanalysis algorithm, | K | is the keystream length in bits,   P n is the known plaintext and C n is the known ciphertext.

6. Proposed Algorithm for Attacking RC4 Cipher Using Binary HPSOEO

The proposed algorithm is explained in addition to how HPSOEO can be used to discover the keystream utilized in RC4 cipher encryption and decryption. The issue is effectively finding the keystream. All of the approaches discussed in Section 3 were created to solve problems that required continuous optimization; in the case of cryptanalysis, the problem involved binary data. As a consequence, we may compute the position vector using Equation (19) and convert the continuous values to binary values using this formula:
x d ( t + 1 ) = { 1     ,     i f             r a n d s i g m o i d ( X ) 0     ,                         o t h e r w i s e              
where s i g m o i d   ( X ) is defined in Equation (23) and x d ( t + 1 ) is the binary update location at iteration t in dimension d.
s i g m o i d ( X ) = 1 1 + e ( X / 2 )
In this approach, each particle represents an (l-bit) binary key, where l is the key’s length that was used in the encryption (because the RC4 cipher is a varying key-size crypto algorithm) to set up a particle with n particles   [ 0 ,   1 ] . To evaluate each particle’s fitness, we use Equation (22). The particle with the greatest fitness occupies the best position. The velocity and particle position are updated using Equations (18) and (22). The updated particle’s location is used to compute the fitness. The technique is then continued until the appropriate number of iterations has been reached. Algorithm 3 depicts an algorithm for locating the keystream using BHPSOEO. Figure 6 shows the flow chart of BHPSOEO algorithm.
Algorithm 3 Keystream Using BHPSOEO
Initialization (initialization a     ,   G P   , w ,   v e l o c i t y , p o s i t i o n   a n d   c o n c e n t r a t i o n s ).
Randomly initialize particle’s positions of n particles and concentrations ∈ [0, 1].
Calculation the fitness values of search particles according to Equation (21).
Determine p B e s t   ,   G B e s t ,   C e q 1 , C e q 2 ,   C e q 3   and   C e q 4  
i t e r = 1  
While ( i t e r < M a x _ i t e r )
  For i = 1   t o   n o   o f   p a r t i c l e s
   Calculate the value of fitness for each particle according to Equation (21).
   Update p B e s t   ,   G B e s t ,   C e q 1 , C e q 2 ,   C e q 3   and   C e q 4
   Compute C a v e = ( C e q 1 + C e q 2 + C e q 3 + C e q 4 ) / 4 and C e q p o o l according to Equation (9)
  End For
 Computing memory saving memory i f   i t e r > 1 and compute t according to Equation (10)
  For i = 1   t o   n o   o f   p a r t i c l e s
   Choose one candidate at random from the equilibrium pool (vector).
   Compute F   according to Equation (12)
   Compute G C P according to Equation (16)
   Update concentrations according to Equation (17)
   Update the velocity according to Equation (18)
   Update the position vector according to Equation (22)
  End For
   i t e r = i t e r + 1
End while

7. Experimental Set Up and Result

The results of the experiments are displayed in Figure 7 and Figure 8. Figure 8 shows the comparison between the BPSO, BEO and BHPSOEO algorithms in the internal state of RC4 streams for 64-bit text length, and the initial value of the key is 40 bits in different population sizes. Figure 8 shows the comparison between these algorithms in the internal state of cryptanalysis of the RC4 stream for 128-bit text length, and the initial value of the key is 64 bits in different population sizes. From our results, we notice that firstly, the performance of BHPSOEO is better than the performance of other algorithms in different population sizes and different text length sizes. Secondly, when we increase the population size, the average fitness of all algorithms increases. Thirdly, when we increase the text length, the search space increases.
The BPSO, BEO and BHPSOEO algorithms for attacking the internal state of RC4 are implemented using the MATLAB program. Table 1 shows the numerical results for cryptanalysis RC4 cipher using HBPSOEO, BEO and BPSO when the text length is 64 bits. Table 2 shows the parameters are used in this exprement. These algorithms were executed 50 times with different population sizes. In the case of the text length of 64 bits, we used N = (10, 20, 30, 40, 50) and when the text length was 128, we used N = (50, 60, 70, 80, 90, 100).
From the results, we notice that the BHPSOEO algorithm gives us the best performance. It is the only algorithm that gives us the real key when the fitness is equal to 1; this means that all the bits in the tried key are correct. However, the other algorithms give us the maximum value of the fitness but do not reach one; this means that some of the bits in the tried key are not correct.
When the text length is 128 bits, Table 3 presents the numerical results for cryptanalysis of the RC4 encryption using HBPSOEO, BEO, and BPSO. Table 4 shows the parameters are used in this experiment. We can see from the results that the BHPSOEO algorithm performs the best. When the fitness equals 1, it is the only algorithm that offers us the real key, which signifies that all bits in the tested key are correct. However, the other algorithms offer us the maximum fitness value but do not attain one, implying that some bits in the tested key are incorrect.
The Root Mean Square Difference (RMSD) approach method was used to compare HBPSOEO vs. BEO and HBPSOEO vs. BPSO in Figure 9 and Figure 10. RMSD is a formula for calculating the difference between two sets of data x1 and x2 as shown in (23). The wider the gap between data sets, the higher the RMSD number.
R M S D = 1 N ( x 1 , i x 2 , i ) 2 N
The difference between BHPSOEO and BPSO is high and nearly constant for different sizes, as shown in the plots in Figure 9 and Figure 10, but the average difference between BEO and BHPSOEO is initially big and subsequently declines. This proves that BHPSOEO is more efficient for cryptanalysis than both BPSO and BEO.

8. Conclusions and Future Works

A novel hybrid evolutionary technique that combines Particle Swarm Optimization (PSO) and Equilibrium Optimizer (EO) is presented in this study to increase the performance of both PSO and EO. This algorithm can be converted to binary form and used to solve the problems of cryptanalysis. We all know that cryptanalysis is a difficult problem to solve and that it takes a long time. From the results of our research, we were able to solve the cryptanalysis problem in a short time compared to traditional methods.
We use this novel algorithm to recover the internal state of the RC4 cipher, and this can be improved; this algorithm gives a more accurate solution than other algorithms such as PSO and EO. Compared to traditional methods such as brute force attacks, to find the internal state of the key in the case of a text length of 64 bits, we need (264 keys) to find the real one, and in the case of a text length of 128 bits, we need (2128 keys) to find the real one; however, when we use the proposed algorithm in the case of a text length of 64 bits, we can obtain the key after checking 1000 keys only, and in the case of a text length 128 bits, we can obtain the real key after checking 5000 keys only. This proves that the proposed algorithm is very efficient in solving the cryptanalysis problem.
Finally, because the fitness function used in our experiment is independent of the cipher under attack, this technique can be easily adapted to other recent block or stream ciphers. As a result, we may utilize this method to attack AES. Using other swarm intelligence technologies to attack AES is also part of our future study.
The pros and cons of our methodology can be summarized in Table 5:

Author Contributions

Conceptualization, R.M.R.-A. and H.A.; methodology, R.M.R.-A.; software, S.S.A.E.; validation, R.M.R.-A., H.A. and S.S.A.E.; formal analysis, S.S.A.E.; resources, H.A.; data curation, H.D.; writing—original draft preparation, S.S.A.E.; writing—review and editing, W.S.E. and H.D.; visualization, S.S.A.E. and A.M.; supervision, W.S.E. and H.D.; project administration, E.A.M.; funding acquisition, E.A.M. and A.M. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the Deanship of Scientific Research at King Saud University, Saudi Arabia through the Research Group under Grant RG-1439-039.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Acknowledgments

The authors extend their appreciation to the Deanship of Scientific Research at King Saud University for funding this work through research group No. RG-1439-039.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Stinson, D.R. Cryptography: Theory and Practice; Chapman and Hall/CRC: Boca Raton, FL, USA, 2005. [Google Scholar]
  2. Jindal, P.; Singh, B. RC4 encryption—A literature survey. Procedia Comput. Sci. 2015, 46, 697–705. [Google Scholar] [CrossRef] [Green Version]
  3. Holland, J.H. Genetic Algorithms—Computer programs that ‘evolve’ in ways that resemble natural selection can solve complex problems even their creators do not fully understand. Sci. Am. 1992, 267, 66–72. [Google Scholar] [CrossRef]
  4. Rechenberg, I. Evolutionsstrategien. In Simulationsmethoden in der Medizin und Biologie; Springer: Berlin/Heidelberg, Germany, 1978; pp. 83–114. [Google Scholar]
  5. Koza, J.R. Evolution of subsumption using genetic programming. In Proceedings of the First European Conference on Artificial Life, Paris, France, 11–13 December 1991; MIT Press: Cambridge, MA, USA, 1992; pp. 110–119. [Google Scholar]
  6. Mohammed, S.; Simon, D.; Member, S. Biogeography-Based Optimization. IEEE Trans. Evol. Comput. 2008, 12, 702–713. [Google Scholar]
  7. Kirkpatrick, S.; Gelatt, C.D.; Vecchi, M.P. Optimization by simulated annealing. Science 1983, 220, 671–680. [Google Scholar] [CrossRef] [PubMed]
  8. Rashedi, E.; Nezamabadi-pour, H.; Saryazdi, S. GSA: A Gravitational Search Algorithm. Inf. Sci. 2009, 179, 2232–2248. [Google Scholar] [CrossRef]
  9. Faramarzi, A.; Heidarinejad, M.; Stephens, B.; Mirjalili, S. Equilibrium optimizer: A novel optimization algorithm. Knowl.-Based Syst. 2020, 191, 105190. [Google Scholar] [CrossRef]
  10. Okwu, M.O.; Tartibu, L.K. Particle Swarm Optimisation. Stud. Comput. Intell. 2021, 927, 5–13. [Google Scholar] [CrossRef]
  11. Mirjalili, S. Ant colony optimization. Stud. Comput. Intell. 2019, 780, 33–42. [Google Scholar] [CrossRef]
  12. Mirjalili, S.; Mirjalili, S.M.; Lewis, A. Grey Wolf Optimizer. Adv. Eng. Softw. 2014, 69, 46–61. [Google Scholar] [CrossRef] [Green Version]
  13. Rao, R.V.; Savsani, V.J.; Vakharia, D.P. Teaching–Learning-Based Optimization: An optimization method for continuous non-linear large scale problems. Inf. Sci. 2012, 183, 1–15. [Google Scholar] [CrossRef]
  14. Askarzadeh, A.; Rashedi, E. Harmony Search Algorithm: Basic Concepts and Engineering Applications; IGI Global: Hershey, PA, USA, 2017. [Google Scholar]
  15. Glover, F. Tabu Search—Part I. J. Comput. 2018, 1, 190–206. [Google Scholar]
  16. Yang, X.S. Swarm intelligence based algorithms: A critical analysis. Evol. Intell. 2014, 7, 17–28. [Google Scholar] [CrossRef] [Green Version]
  17. Mafarja, M.M.; Mirjalili, S. Hybrid Whale Optimization Algorithm with simulated annealing for feature selection. Neurocomputing 2017, 260, 302–312. [Google Scholar] [CrossRef]
  18. Roos, A. A Class of Weak Keys in the RC4 Stream Cipher. 1995. Available online: http://www.impic.org/papers/WeakKeys-report.pdf (accessed on 15 April 2022).
  19. Fluhrer, S.; Mantin, I.; Shamir, A. Weaknesses in the Key Scheduling Algorithm of RC4. In International Workshop on Selected Areas in Cryptography; Springer: Berlin/Heidelberg, Germany, 2001; Volume 2259, pp. 1–24. [Google Scholar]
  20. Klein, A. Attacks on the RC4 stream cipher. Des. Codes Cryptogr. 2008, 48, 269–286. [Google Scholar] [CrossRef] [Green Version]
  21. Crainicu, B.; Enachescu, C. A metaheuristic tabu search approach for internal state reconstruction of RC4 stream cipher. In Proceedings of the 2011 RoEduNet International Conference 10th Edition: Networking in Education and Research, Iasi, Romania, 23–25 June 2011; pp. 1–4. [Google Scholar]
  22. Polak, I.; Boryczka, M. Genetic algorithm in stream cipher cryptanalysis. In Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Springer: Cham, Switzerland, 2015; Volume 9330, pp. 149–158. [Google Scholar] [CrossRef]
  23. Talbi, E.-G. A Taxonomy of Hybrid Metaheuristics. J. Heuristics 2002, 8, 541–564. [Google Scholar] [CrossRef]
  24. Kao, Y.T.; Zahara, E. A hybrid genetic algorithm and particle swarm optimization for multimodal functions. Appl. Soft Comput. J. 2008, 8, 849–857. [Google Scholar] [CrossRef]
  25. Tsai, J.T.; Liu, T.K.; Chou, J.H. Hybrid Taguchi-genetic algorithm for global numerical optimization. IEEE Trans. Evol. Comput. 2004, 8, 365–377. [Google Scholar] [CrossRef]
  26. Rizk-Allah, R.M.; Zaki, E.M.; El-Sawy, A.A. Hybridizing ant colony optimization with firefly algorithm for unconstrained optimization problems. Appl. Math. Comput. 2013, 224, 473–483. [Google Scholar] [CrossRef]
  27. Rizk-Allah, R.M.; Slowik, A.; Hassanien, A.E. Hybridization of Grey Wolf Optimizer and Crow Search Algorithm Based on Dynamic Fuzzy Learning Strategy for Large-Scale Optimization. IEEE Access 2020, 8, 161593–161611. [Google Scholar] [CrossRef]
  28. Kennedy, J.; Eberhart, R. Particle swarm optimization Paper—Ignore From Refs. In Proceedings of the ICNN’95—International Conference on Neural Networks, Perth, WA, Australia, 27 November–1 December 1995; pp. 1942–1948. [Google Scholar]
  29. Rueppel, R.A. Stream ciphers. In Analysis and Design of Stream Ciphers; Springer: Berlin/Heidelberg, Germany, 1986; pp. 5–16. [Google Scholar]
Figure 1. Main classification of a modern cipher.
Figure 1. Main classification of a modern cipher.
Sensors 22 03844 g001
Figure 2. Classification of meta-heuristic algorithms.
Figure 2. Classification of meta-heuristic algorithms.
Sensors 22 03844 g002
Figure 3. Flow chart of PSO algorithm.
Figure 3. Flow chart of PSO algorithm.
Sensors 22 03844 g003
Figure 4. The flow chart of EO algorithm.
Figure 4. The flow chart of EO algorithm.
Sensors 22 03844 g004
Figure 5. Stream cipher diagram.
Figure 5. Stream cipher diagram.
Sensors 22 03844 g005
Figure 6. The flow chart of BHPSOEO algorithm.
Figure 6. The flow chart of BHPSOEO algorithm.
Sensors 22 03844 g006
Figure 7. Convergence curve of BHPSOEO, BPSO and BEO for cryptanalysis of RC4 cipher with TextLen = 64 bits for different population sizes.
Figure 7. Convergence curve of BHPSOEO, BPSO and BEO for cryptanalysis of RC4 cipher with TextLen = 64 bits for different population sizes.
Sensors 22 03844 g007
Figure 8. Convergence curve of BHPSOEO, BPSO and BEO for cryptanalysis of RC4 cipher with TextLen = 128 bits for different population sizes.
Figure 8. Convergence curve of BHPSOEO, BPSO and BEO for cryptanalysis of RC4 cipher with TextLen = 128 bits for different population sizes.
Sensors 22 03844 g008
Figure 9. RMSD in average fitness for BPSOEO versus BEO and BPSO in cryptanalysis of the RC4 cipher when text length is 64 bits.
Figure 9. RMSD in average fitness for BPSOEO versus BEO and BPSO in cryptanalysis of the RC4 cipher when text length is 64 bits.
Sensors 22 03844 g009
Figure 10. RMSD in average fitness for BPSOEO versus BEO and BPSO in the cryptanalysis of RC4 cipher when text length is 128 bits.
Figure 10. RMSD in average fitness for BPSOEO versus BEO and BPSO in the cryptanalysis of RC4 cipher when text length is 128 bits.
Sensors 22 03844 g010
Table 1. BHPSEO, BEO and BPSO numerical results for cryptanalysis of RC4 cipher for a 64-bit text length.
Table 1. BHPSEO, BEO and BPSO numerical results for cryptanalysis of RC4 cipher for a 64-bit text length.
N = 10N = 20N = 30N = 40N = 50
BHPSOEOBest fitness11111
Worst fitness0.828130.859380.906250.921880.92188
The average0.937190.973750.984690.990620.99094
Std0.038910.039110.021980.0175760.014837
Time33.57 s49.20341 s99.58 s100.37 s123.895 s
BEOBest fitness0.906250.953130.968750.984380.98438
Worst fitness0.781250.843750.859380.828130.90625
The average0.854690.902810.929060.94250.95281
Std0.037650.0279310.030640.0281360.025153
Time15.58 s30.80 s46.33 s65.17 s60.66 s
BPSOBest fitness0.796880.79690.81250.828130.84375
Worst fitness0.703130.718750.734380.734380.75
The average0.744060.76250.763130.775630.78625
Std0.0227390.018940.0185040.0218160.022419
Time12.30 s35.83 s50.61 s67.25 s86.99 s
Table 2. The BHPSOEO parameters to attack RC4 cipher with Textlen 64 bits.
Table 2. The BHPSOEO parameters to attack RC4 cipher with Textlen 64 bits.
ParameterDefinitionValue
c1Cognitive Acceleration Coefficient2.1
c2Social Acceleration Coefficient2.1
c3Coefficient vector2.1
WInertia Weight0.9 + rand()/2
NPopulation size(10–50)
DNo of variables64
K_LThe length of initial value of key40
TexLenThe length of ciphertext and plaintext64
TmaxMaximum number of iterations100
RThe number of times the algorithm is run50
Table 3. BHPSEO, BEO and BPSO numerical results for cryptanalysis of the RC4 cipher of a 128-bit text length.
Table 3. BHPSEO, BEO and BPSO numerical results for cryptanalysis of the RC4 cipher of a 128-bit text length.
N = 50N = 60N = 70N = 80N = 90N = 100
BHPSOEOBest fitness111111
Worst fitness0.882810.851560.898440.906250.906250.91406
The average0.952810.963440.967030.971880.974530.97188
Std0.0316450.0315850.0306580.0262220.0224220.025204
Time127.03 s105.28 s176.86 s201.98 s225.69 0 s246.83 s
BEOBest fitness0.953130.953130.968750.968750.976560.97656
Worst fitness0.851560.843750.8750.867190.882810.88281
The average0.908910.905940.902810.928280.930780.9375
Std0.0229060.0233560.0197990.0213920.0281360.020519
Time62.47 s98.28 s101.08 s113.19 s133.09 s160.85 s
BPSOBest fitness0.757810.750.750.757810.757810.75781
Worst fitness0.695310.703130.703130.703130.710940.71094
The average0.721090.722810.724530.729060.728280.72953
Std0.0141390.0120450.0116850.0139790.0111930.011148
Time85.93 s87.30 s90.41 s101.33 s110.85 s135.49 s
Table 4. The BHPSOEO parameters to attack the RC4 cipher with Textlen, 128 bits.
Table 4. The BHPSOEO parameters to attack the RC4 cipher with Textlen, 128 bits.
ParameterDefinitionValue
c1Cognitive Acceleration Coefficient2.1
c2Social Acceleration Coefficient2.1
c3Coefficient vector2.1
WInertia Weight0.9 + rand()/2
NPopulation size(50–100)
DNo of variables128
K_LThe length of initial value of key64
TexLenThe length of ciphertext and plaintext128
TmaxMaximum number of iterations100
RThe number of times the algorithm is run50
Table 5. The pros and cons of our methodology.
Table 5. The pros and cons of our methodology.
The proposed algorithm
(BHPSOEO)
The prosThe cons
  • The BHPSOEO algorithm gives us the best performance. It is the only algorithm that gives us the real key one when the fitness is equal to 1; this means that all bits in the tried key are correct.
  • By comparing the proposed algorithm with the brute force attack in cryptanalysis of RC4, we find that if the key length is 64 bits, the search space is reduced from 264 to 103, and in the case where the key length is 128 bits, the search space is reduced from 2128 to (5 × 103)
  • More accurate than using GA [22] to attack RC4.
From the view of the running time, the BHPSOEO algorithm computation time is greater than the PSO and EO after the same iterations.
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Rizk-Allah, R.M.; Abdulkader, H.; Elatif, S.S.A.; Elkilani, W.S.; Al Maghayreh, E.; Dhahri, H.; Mahmood, A. A Novel Binary Hybrid PSO-EO Algorithm for Cryptanalysis of Internal State of RC4 Cipher. Sensors 2022, 22, 3844. https://0-doi-org.brum.beds.ac.uk/10.3390/s22103844

AMA Style

Rizk-Allah RM, Abdulkader H, Elatif SSA, Elkilani WS, Al Maghayreh E, Dhahri H, Mahmood A. A Novel Binary Hybrid PSO-EO Algorithm for Cryptanalysis of Internal State of RC4 Cipher. Sensors. 2022; 22(10):3844. https://0-doi-org.brum.beds.ac.uk/10.3390/s22103844

Chicago/Turabian Style

Rizk-Allah, Rizk M., Hatem Abdulkader, Samah S. Abd Elatif, Wail S. Elkilani, Eslam Al Maghayreh, Habib Dhahri, and Awais Mahmood. 2022. "A Novel Binary Hybrid PSO-EO Algorithm for Cryptanalysis of Internal State of RC4 Cipher" Sensors 22, no. 10: 3844. https://0-doi-org.brum.beds.ac.uk/10.3390/s22103844

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop