*6.1.3 Correlation coefficient analysis*

The standard plain sample is characterized by a correlation close to 1. Although in a cipher sample the adjacent pixels should be uncorrelated [15]. Let *x* and *y* two gray

*Hardware Implementation of an Improved Hybrid Cryptosystem for Numerical Image Encryption… DOI: http://dx.doi.org/10.5772/intechopen.105207*


#### **Table 2.**

*E, PSNR, SSIM, and NC values of cipher samples.*


**Table 3.**

*Comparative study of PSNR and E values for Lena image.*

scale parameters of two adjacent pixels in the sample, and the correlation of the adjacent pixels is evaluated by the following Eqs. (3)–(6).

$$E(\mathbf{x}) = \frac{1}{N} \sum\_{i=1}^{N} \mathbf{x}\_i \tag{3}$$

$$D(\mathbf{x}) = \frac{1}{N} \sum\_{i=1}^{N} \left(\mathbf{x}\_i - E(\mathbf{x}\_i)\right)^2 \tag{4}$$

$$cov(\mathbf{x}, \mathbf{y}) = \frac{1}{N} \sum\_{i=1}^{N} (\mathbf{x}\_i - E(\mathbf{x})) \left(\mathbf{y}\_i - E(\mathbf{y})\right) \tag{5}$$

$$r\_{xy} = \frac{cov(\mathbf{x}, \mathbf{y})}{\sqrt{D(\mathbf{x})}\sqrt{D(\mathbf{y})}} \tag{6}$$

**Table 4** demonstrates that the cipher sample's correlation coefficients are close to 0. Therefore, we cannot extract the content of the plain sample from the cipher one. **Figure 8** illustrates the distributions of 2000 pairs of randomly selected adjacent pixels of the clear and ciphered Lena image.

Findings show that the correlation coefficient of the clear samples is close to 1, while the cipher images are close to zeros. Similarly, the distribution of adjacent pixels is inconsistent; i.e., there is no correlation between them. This proves that the cryptosystem eliminates the correlation of adjacent pixels in the clear sample, and it makes a ciphered sample with no correlation. A comparative evaluation with some existing


#### **Table 4.**

ρ *values of clear image and its correspondent cipher image.*

work for the correlation coefficient is tabulated in **Table 5**. The comparison proves that our system put forward gives the perfect results. Thus, the system can resist the statistical attacks.

#### **6.2 Key analysis**

To validate the robustness of the suggested algorithm, the key space, the key sensitivity, and the randomness analysis are tested in this section.

#### *6.2.1 Key space*

According to [18–20], the key space of a robust cryptosystem must be large to be protected from the brute-force hacker. In our algorithm, for an initial key Ki, there are 2128 dissimilar keys, which are very large. Therefore, the key brute-force attacks are computationally infeasible.

#### *6.2.2 Key sensitivity*

To assure a high level of protection, the cryptographic algorithm must be sensitive to the sample input and the initial secret key Ki. A simple alteration (one bit) in Ki, or in the sample, will cause a greatly significant modification in the output generated keys for encryption and output sample. The parameter Key sensitivity can be performed by employing the number of changing pixel rate (*NPCR*) and unified averaged changed intensity (*UACI*) randomness tests to test the force of the algorithm to defend against differential attacks [20], which are described as follows:

$$NPCR = \frac{1}{\mathcal{S}} \sum D(i, j) \times 100\% \tag{7}$$

*Hardware Implementation of an Improved Hybrid Cryptosystem for Numerical Image Encryption… DOI: http://dx.doi.org/10.5772/intechopen.105207*

**Figure 8.**

*Distribution of 2000 pairs of randomly chosen adjacent pixels for Lena image: (a)–(c): horizontal, vertical, and diagonal distribution of the original image; (d)–(f): horizontal, vertical, and diagonal distribution of the cipher image.*


#### **Table 5.**

*Comparative study of correlation coefficient for Lena image.*

$$UACI = \frac{1}{\mathcal{S}} \sum \frac{|d|}{\mathcal{G}} \times 100\% \tag{8}$$

where *S* is the size of the image, and *D*(*i, j*) is a logical value affected by the following cases:

$$D(i,j) = \begin{cases} \mathbf{0} \,\,\acute{y}\,\,I\_1(i,j) = I\_2(i,j) \\ \mathbf{1}\,\,\acute{y}\,\,I\_1(i,j) \neq I\_2(i,j) \end{cases} \tag{9}$$

*d* is the variance between two pixels on the sample with the same coordinates.

$$d = p\_1(i, j) - p\_2(i, j) \tag{10}$$

Thus, a sensitivity test applied to the initial key is evaluated by two initial keys, Ki1 and Ki2, where the key Ki2 is dissimilar by only one bit from the initial key Ki1 to cipher the same input. Then, we try deciphering the obtained samples with a wrong key. Here, the two keys, Ki1 and Ki2, are permuted in the decryption step; i.e., each image is decrypted by a wrong key, which is different by one bit from the correct key. This test is carried out with many Ki keys, which are randomly selected to properly evaluate the algorithm. Simulation results for the Lena image are shown in **Figure 9** and **Table 6**.

When analyzing results, we can conclude that our encryption system is very sensitive to small modifications in the entered sample. This proves the efficacity of the keccak hash function, which puts an image's initial key specific for encryption.

A comparative study is given in **Table 7** to evaluate the system compared to other related work and the results prove that the system is robust.

#### **6.3 Know plain text and chosen plain text attack**

This type of hacker is used to crack some of the cryptographic algorithms. Usually, an adversary employs black or white samples to extract the possible patterns in the algorithm. The white and dark samples are encrypted by the proposed method.

**Figure 9.**

*Key sensitivity test applied on initial key, (a) ciphered Lena by Ki1, (b) ciphered image by key Ki2, (c) variance between (a) and (b), (d) deciphered (a) by Ki2, (e) deciphered (b) by Ki1, and (f) variance between (d) and (e).*

*Hardware Implementation of an Improved Hybrid Cryptosystem for Numerical Image Encryption… DOI: http://dx.doi.org/10.5772/intechopen.105207*


#### **Table 6.**

NPCR *and* UACI *tests applied on the initial key.*


#### **Table 7.**

*Comparative evaluation of NPCR and UACI parameters for Lena image.*

**Figure 10.**

*(a) Black image, (b) white image, (c) ciphered black image, (d) ciphered white image.*

**Figure 10** gives the encrypted samples and no pattern is apparent. The value of the entropy for samples is selfsame as in other images and correlation coefficients are perfect. **Table 8** tabulates the correlation between adjacent pixels and the entropy values of both samples. Our proposed hybrid scheme is very resistant to attacks.
