# Design, Implementation, and Analysis of a Block Cipher Based on a Secure Chaotic Generator
## 3 Experiments Results and Security Analysis
### Correlation Analysis
#### 3.3.3 Cryptanalytic Analysis  
In the following part, we perform some habitual cryptanalytic analyses such as the key sensitivity and the plaintext sensitivity test.  
**Key Sensitivity**  
A secure encryption/decryption system should be very sensitive to the secret key, i.e., even a one-bit change in the secret key should produce a completely different encrypted image. The testing scenario of the key sensitivity was as follows: first, a plain-image \(I\) was encrypted using a secret key \(K_{1}\) to obtain \(C_{1}\), then the same plain-image \(I\) was encrypted using a secret key \(K_{2}\) different from \(K_{1}\) by just a one bit LSB to obtain \(C_{2}\). Three parameters, namely the number of pixels change rate (NPCR), the unified average changing intensity (UACI) [51], and the Hamming distance (see Equation (27)) were used to evaluate the key sensitivity and were defined as follows:  
\[NPCR=\frac{1}{R\times C\times P}\sum_{i=1}^{R}\sum_{j=1}^{C}\sum_{p=1}^{P}D(i,j,p)\times 100\% \tag{34}\]  
\[D(i,j,p)=\left\{\begin{array}{ll}0&if\ C_{1}(i,j,p)=C_{2}(i,j,p)\\ \\ 1&if\ C_{1}(i,j,p)\
eq C_{2}(i,j,p)\end{array}\right. \tag{35}\]  
\[UACI=\frac{1}{R\times C\times P\times 255}\sum_{i=1}^{R}\sum_{j=1}^{C}\sum_{p=1} ^{P}|C_{1}-C_{2}|\times 100\% \tag{36}\]  
In the above relation, \(i,j\), and \(p\) were, respectively, the row, column, and plane indexes of the image. \(R\), \(C\), and \(P\) were its length, width, and plane sizes.  
This test was repeated over 100 different secret keys.  
Table 10 presents the average results obtained for the NPCR, UACI, and HD.  
The resulting values obtained were near the optimal values of NPCR, UACI, and HD which were 99.6094%, 33.4635%, and 50%, respectively. Therefore, the proposed scheme was very sensitive to small changes in the secret key.  
**Plaintext sensitivity test**  
To resist known and chosen plaintext attacks, which are related to the differential attack, the cryptosystem must be sensitive to a single bit change in the plaintext. The plaintext sensitivity attack test case is almost identical to the key sensitivity attack. Indeed, after  
\begin{table}
\begin{tabular}{l c c c c} \hline \hline \multirow{2}{*}{**Image**} & \multirow{2}{*}{**Size**} & \multicolumn{3}{c}{**Key Sensitivity Test**} \\ \cline{3-5}  & & **NPCR (\%)** & **UACI (\%)** & **HD (\%)** \\ \hline Airplane & \(512\times 512\times 3\) & 99.6065 & 33.4666 & 50.0052 \\ Black & \(256\times 256\times 1\) & 99.6099 & 33.4323 & 50.0094 \\ Bridge & \(512\times 512\times 1\) & 99.6098 & 33.5052 & 50.0019 \\ Cameraman & \(256\times 256\times 1\) & 99.5992 & 33.4234 & 49.9844 \\ Flowers & \(256\times 256\times 3\) & 99.6040 & 33.4772 & 49.9941 \\ Goldhill & \(512\times 512\times 3\) & 99.6069 & 33.4464 & 49.9942 \\ Kiel & \(512\times 512\times 1\) & 99.6042 & 33.4650 & 49.9976 \\ Lena & \(512\times 512\times 3\) & 99.6088 & 33.4664 & 49.9907 \\ Sailboat & \(512\times 512\times 3\) & 99.6077 & 33.4680 & 50.0090 \\ White & \(256\times 256\times 1\) & 99.6231 & 33.5524 & 50.0000 \\ \hline \hline \end{tabular}
\end{table}
Table 10: Average NPCR, UACI, and HD key sensitivity tests.  
having encrypted a plain image, we chose 21-pixel positions [26] and we changed, in turn, their LSB bit, then we encrypted them and calculate the 21 HDs.  
In Figure 18, we show for each position the HDs of the 10 test images (red dots) as well as their average values (green line). As we can see, for each position, the average HD was close to the optimal value of 50%. Furthermore, the maximum value of the HD was equal to 50.1602% and the minimum value was equal to 49.8039% which was close to the optimal value.  
Moreover, in Table 11, we give the average NPCR, UACI, and HD on 21 positions for each image. According to these results, the average values of the obtained NPCR, UACI, and HD were almost equal to their optimal value. These values proved that the proposed chaos-based cryptosystem was highly sensitive to small changes in the plaintext.