# Analysis of DES Plaintext Recovery Based on BP Neural Network

Authors: Sijie Fan; Yaqun Zhao
Journal: Security and Communication Networks
 (2019)

---

## Abstract

Backpropagation neural network algorithms are one of the most widely used algorithms in the current neural network algorithm. It uses the output error rate to estimate the error rate of the direct front layer of the output layer, so that we can get the error rate of each layer through the layer-by-layer backpropagation. The purpose of this paper is to simulate the decryption process of DES with backpropagation algorithm. By inputting a large number of plaintext and ciphertext pairs, a neural network simulator for the decryption of the target cipher is constructed, and the ciphertext given is decrypted. In this paper, how to modify the backpropagation neural network classifier and apply it to the process of building the regression analysis model is introduced in detail. The experimental results show that the final result of restoring plaintext of the neural network model built in this paper is ideal, and the fitting rate is higher than 90% compared with the true plaintext.


---

## Body

## 1. Introduction

The study of cryptography mainly includes two aspects, cryptographic design and cryptanalysis. There are independent and mutually unified relationships between them [1]. Block cipher is an important branch of symmetric cryptography. It uses the same key in encryption and decryption and plays a very important role in information and communication security. We hope to use existing cryptanalysis methods to design cryptanalysis methods that can resist all cryptanalysis methods. At the same time, we also hope to use the updated cryptanalysis methods to find some security flaws in cryptanalysis algorithms.Modern cryptosystems often use methods to expand the key space or increase the complexity of encryption and decryption, and use some mathematical problems as the theoretical basis, which greatly improves the requirement of computational power in cryptographic deciphering. Sometimes the cost of traditional cryptographic deciphering methods may exceed the value of cryptographic deciphering. Artificial neural network (ANN) is the same discipline as cryptography for studying information processing. Neural network algorithm has the characteristics of nonlinear massively parallel-distributed processing and has strong high-speed information processing and uncertainty information processing capability. Using neural networks to solve cryptographic problems will provide a new research idea for cryptography.In 2008, Bafghi et al. used a recurrent neural network to solve the problem of finding the least-weight multibranch path between two known nodes in the differential operation graph of block cipher. The main idea was to minimize the loss function of the neural network [2]. In 2010, Alallayah et al. considered the black box characteristics of neural networks, combined with system identification technology and adaptive system technology, simulated the neural model of the cryptanalysis target system and could guess the key from a given ciphertext [3]. In 2012, Alani et al. used a new cryptanalysis attack on DES (Data Encryption Standard) and 3DES (Triple Data Encryption Algorithm) cryptographic algorithms. The attack implemented was a known plaintext attack based on a neural network. In this attack, they trained a neural network to retrieve plaintext from ciphertext without retrieving the keys used in encryption. Compared with other attacks, this method reduced the number of known plaintexts required and reduced the time required to perform a full attack [4]. The above methods were less able to directly restore the plaintext sequence, and the experimental procedures of the related literature were mostly based on the simplified cryptographic encryption algorithm and had very high requirements on the computing power.In this paper, we choose DES algorithm as a case study of block cipher. We propose to use BP (backpropagation) neural network algorithm to simulate the mapping relationship between ciphertext and plaintext. The ciphertext obtained by DES encryption is converted into binary string, which is fed to our improved BP neural network as input after processing according to the preprocessing method defined in this paper. The difference between predicted output and true plaintext is compared for the purpose of cryptanalysis. Compared with previous work, the plaintext recovered by this experiment has a better fitting effect with true plaintext. According to the error rate defined in this paper, the experimental error rate can be controlled below 10%.The second section of this paper briefly introduces the development history and basic working principle of block cipher. The third section briefly introduces the principle of BP algorithm and the modification we have made to it, thus successfully building a regression model. The fourth section shows our experimental process and results.


## 2. Brief Introduction to Block Ciphers

Block cipher is one of the important systems in modern cryptography, which is an important part of many cryptosystems. Block cipher usually refers to a kind of cipher algorithm that can only deal with a piece of data of a certain length at a time. Here, the “piece” is called a block. The number of bits in a block is called the block length. Specifically, the principle of block cipher is to divide the plaintext message sequence into a groupm1,m2,…,mn,mn+1,mn+2,…,m2n,… encrypts it according to a set of fixed encryption algorithms under the control of the key K=k1,k2,…,km, and outputs a group of ciphertext c1,c2,…,cn,cn+1,cn+2,…,c2n,…. The model is shown in Figure 1.Figure 1
Block cipher workflow.Under the same key, the block cipher transforms the input plaintext group with lengthi equally, so it only needs to study the transformation rules for any group [5].A cryptosystem consists of five parts (plaintextP, ciphertext C, key K, encryption transformation E, and decryption transformation D). It satisfies the following conditions [6]:(1)
P=p1,p2,…,pn is a limited set of plaintext(2)
C=c1,c2,…,cn is a limited set of ciphertext(3)
K=k1,k2,…,km is a limited set of keys(4)
E=e1,e2,…,en is a limited set of encryption change rules(5)
D=d1,d2,…,dn is a limited set of decryption change rules(6)
∀k∈K,∃ek∈E,dk∈D,s.t,dkekp=p, ∀p∈P,ek:P⟶C,dk:C⟶PDES is a method of encrypting 64-bit plaintextm by 16 rounds of encryption processing with 56-bit key and obtaining 64-bit ciphertext. We choose DES as the block cipher for research because it can change the encryption key and network level faster, encrypting at a faster rate and reducing the impact of other factors. The specific description is as follows:(1)
Enter 64-bit plaintext and perform initial replacement IP(2)
Divide the plaintext into two parts, each part of 32 bits, which are represented byL0 and R0, respectively(3)
After adding the key, perform 16 rounds of operationf,f:0,132×0,148⟶0,132(4)
After 16 rounds, the left and right bit strings are exchanged and then connected for inverse replacement(5)
Output 64-bit ciphertext


## 3. Backpropagation Neural Network

Artificial neural network is a cross-disciplinary field of multidisciplinary research in brain science, neuropsychology and information science. It is a research hotspot in high-tech fields in recent years. Its research goal is to explore the mystery of human intelligence by studying the composition mechanism and thinking mode of the human brain and then to make the machine have human-like intelligence by simulating the structure and working methods of the human brain [7].BP (backpropagation) neural network usually refers to the multilayer forward neural network based on error rate backpropagation algorithm, and the error rate backpropagation algorithm is the most successful neural network learning algorithm to date. It uses the error rate after output to estimate the error rate of the direct predecessor layer of the output layer and then uses this error rate to estimate the error rate of the previous layer. After such a layer of backpropagation, the error rate estimates of all other layers are obtained [8]. The BP neural network topology includes an input layer, a hidden layer, and an output layer. The model is shown in the following Figure 2.Figure 2
Backpropagation neural network model.The BP neural network model is often used for classification. It has high self-learning, self-adaptive, and fault-tolerant ability. That is to say, BP neural network can simulate the mapping relationship between input and output through continuous learning, and this process is reflected in the dynamic adjustment of network weights and thresholds. After repeated training, the error rate is stable in an acceptable range. At this time, the corresponding network parameters can be finally determined to achieve local optimum. If the local nerve unit of BP neural network is damaged, it has little effect on the global training results [9].Based on the above work, we modify a classifier based on BP algorithm and realize the regression model of BP neural algorithm. A large number of plaintext pairs are fed into the model to get the difference between the output plaintext and the true plaintext. The modified model is as follows.


### 3.1. Forward Propagation

(1)
Input Layer
:
a
0
=
x
,
Layer
1
:
z
=
σ
w
1
x
+
b
1
,
Layer
2
:
y
=
σ
w
2
z
+
b
2
.


### 3.2. Backpropagation

(2)Loss function:L=12fx−y2,Layer2:y=k2,k2=σw2z+b2,Error=δ2=∂L∂k2=y−fx,∂L∂b2=∂L∂k2∂k2∂b2=δ2σ′z,∂L∂w2=∂L∂k2∂k2∂w2=δ2z⊙σ′z,Layer1:Error=δ1=∂L∂k1=∂L∂k2∂k2∂z∂z∂k1=y−fxw2⊙σ′z⊙σ′k1,where k1=w1x+b1 and ⊙ represents the multiplication of the corresponding position of the matrix.(3)∂L∂b1=∂L∂k1∂k2∂b1=δ1,∂L∂w1=∂L∂k1∂k1∂w1=δ1x.


## 3.1. Forward Propagation

(1)
Input Layer
:
a
0
=
x
,
Layer
1
:
z
=
σ
w
1
x
+
b
1
,
Layer
2
:
y
=
σ
w
2
z
+
b
2
.


## 3.2. Backpropagation

(2)Loss function:L=12fx−y2,Layer2:y=k2,k2=σw2z+b2,Error=δ2=∂L∂k2=y−fx,∂L∂b2=∂L∂k2∂k2∂b2=δ2σ′z,∂L∂w2=∂L∂k2∂k2∂w2=δ2z⊙σ′z,Layer1:Error=δ1=∂L∂k1=∂L∂k2∂k2∂z∂z∂k1=y−fxw2⊙σ′z⊙σ′k1,where k1=w1x+b1 and ⊙ represents the multiplication of the corresponding position of the matrix.(3)∂L∂b1=∂L∂k1∂k2∂b1=δ1,∂L∂w1=∂L∂k1∂k1∂w1=δ1x.


## 4. Experimental Process

We use DES blocks with variable plaintext and constant keys to convert variable plain text to binary text, which are stored in different document texts. Each document has a 3.2 million-bit binary number. We use it as plaintext, after DES (electronic codebook mode) encryption, the corresponding cipher is obtained. In the data collection phase, data from the California Institute of Technology Caltech-256 dataset are selected, and the data into 1001 files are stitched as plaintext, and the size of files are 512 KB, ten of them were selected as our experimental data [10]. The intercepted image of the plaintext file and the ciphertext file obtained by encrypting them are shown respectively in Figures 3 and 4.Figure 3
Plaintext sample.Figure 4
Ciphertext sample.Since the single plaintext document is too large and the computer computing power is limited, we do some of the same processing for each ciphertext text and compress the ciphertext structure. We take an 8-bit binary number from start to finish in turn to convert it to a decimal number, so that each ciphertext becomes a100000×1 matrix. Similarly, for each plaintext, we take a 8-bit binary number from start to finish in turn to convert it to a decimal number, so that each plaintext becomes a 100000×1 matrix. Then we input all the samples of the preprocessed ciphertext and the plaintext into the modified BP neural network and obtain the output. We compare this output with the expected plaintext to make the BP neural network a simulated decryption system. Convert each decimal digit of the output of the neural network into binary. If the number of digits is not enough, the high digits are filled with 0 and then all of them are connected to restore the plaintext effect.We define the mean squared error of the output matrix and the processed matrix representing the true plaintext as the evaluation criteria for the experimental effect. That is, the output matrix of the modified BP neural network isA′=aij′ , the processed plaintext text matrix is A=aij, and the evaluation criterion is(4)error=∑aij−aij′2n.The experimental process is as follows.


### 4.1. Input Plaintext

The known plaintext (binary text) is encrypted according to des (ecb mode) to obtain the corresponding ciphertext, and the known ciphertext is processed and converted into a format that can be fed into the neural network;


### 4.2. Neural Network Training

Modify the BP neural network model, change it from the classification model to the regression model, and constantly adjust the internal parameters of the neural network until the best training effect is achieved.


### 4.3. Output Result

The experimental error rate is stable at an acceptable level, and the improved model is used to achieve plaintext recovery.


## 4.1. Input Plaintext

The known plaintext (binary text) is encrypted according to des (ecb mode) to obtain the corresponding ciphertext, and the known ciphertext is processed and converted into a format that can be fed into the neural network;


## 4.2. Neural Network Training

Modify the BP neural network model, change it from the classification model to the regression model, and constantly adjust the internal parameters of the neural network until the best training effect is achieved.


## 4.3. Output Result

The experimental error rate is stable at an acceptable level, and the improved model is used to achieve plaintext recovery.


## 5. Results and Discussion

After repeated training, the parameters of BP neural network are constantly adjusted. We used the sigmoid activation function, and the number of trainings exceeds 1000. The error rate can be stabilized at about 10%. The experimental results are shown in the following Table1:Table 1
Experimental results.
Number of experiments
Error rate
1
0.3632983
2
0.3375012
3
0.2215154
⋅
⋅
⋅
⋅
⋅
⋅
998
0.1022956
999
0.1022163
1000
0.1021363The correlation between data is too large, which will inevitably lead to unreliable and unpredictable networks. Therefore, our input is encrypted by DES blocks of constant keys, but special attention should be paid to the number of trainings for controlling neural networks. Overtraining the network, the network may become over-fitting [11, 12], so it may not be possible to accurately predict the plaintext outside the training set, resulting in an excessive error rate.The modified BP neural network optimizes the weight in backpropagation by the steepest descent method, which converges straight down to the local minimum point in the weight space. However, in addition to trying several different weight initial values, there is no better suggestion than the difference in the output of the neural network [13]. Correct selection of the learning rate effectively controls the size of the step size used to modify each weight in the multidimensional weight space [14]. If the selected learning rate is too large, the local minimum may be continually overrun, causing oscillations and slowly converge to a lower error rate. If the learning rate is too low, the number of iterations required may be too large, resulting in a slow neural network performance [15].


## 6. Conclusion

In this experiment, we propose to apply the modified BP neural network algorithm to cryptanalysis and implement it. Here, we define mean-square error for analyzing output. Efficiency can be further improved by increasing the number of samples used to train the neural network and adjusting the weights and biases of the neurons in each layer.Although the DES algorithm is no longer used in new commercial and public applications, the reason why we choose the DES algorithm for cryptanalysis is that the design structure of the DES algorithm is also reflected in other cryptographic algorithms, such as the gost algorithm and the camella algorithm. In addition, many software still compatible with DES algorithm, because there is no real way to completely crack DES algorithm.In the future, a lot of work on weight selection and adaptation (training) of neural networks still needs to be completed, especially the possibility of hardware implementation is still an area worthy of further study. There may be different types of neural networks for cryptanalysis [16], resulting in unexpected results.



---

*Source: 9580862-2019-11-11.xml*