*Article* **On the Security of a Latin-Bit Cube-Based Image Chaotic Encryption Algorithm**

#### **Zeqing Zhang \* and Simin Yu**

School of Automation, Guangdong University of Technology, Guangzhou 510006, China; siminyu@163.com **\*** Correspondence: 2111704029@mail2.gdut.edu.cn

Received: 15 August 2019; Accepted: 9 September 2019; Published: 12 September 2019

**Abstract:** In this paper, the security analysis of an image chaotic encryption algorithm based on Latin cubes and bit cubes is given. The proposed algorithm adopts a first-scrambling-diffusionsecond-scrambling three-stage encryption scheme. First, a finite field is constructed using chaotic sequences. Then, the Latin cubes are generated from finite field operation and used for image chaotic encryption. In addition, according to the statistical characteristics of the diffusion image in the diffusion stage, the algorithm also uses different Latin cube combinations to scramble the diffusion image for the second time. However, the generation of Latin cubes in this algorithm is independent of plain image, while, in the diffusion stage, when any one bit in the plain image changes, the corresponding number of bits in the cipher image follows the change with obvious regularity. Thus, the equivalent secret keys can be obtained by chosen plaintext attack. Theoretical analysis and experimental results indicate that only a maximum of 2.5 <sup>×</sup> <sup>√</sup><sup>3</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* <sup>+</sup> 6 plain images are needed to crack the cipher image with *w* × *h* resolution. The size of equivalent keys deciphered by the method proposed in this paper are much smaller than other general methods of cryptanalysis for similar encryption schemes.

**Keywords:** image chaotic encryption; cryptography; Latin cube; bit cube; chosen plaintext attack

#### **1. Introduction**

Image chaotic encryption algorithms have attracted some special attention in the field of information security [1–7]. In recent years, many image chaotic encryption schemes combined chaos theories with other technologies, such as one-time keys [8], bit-level permutation [9], DNA operations [10–13], parallel computing system [14], matrix semi-tensor product theory [15], cellular automata [16,17], neural network [18,19], Latin square or Latin cube [20–22], and so on, have been proposed. However, the security issues of image chaotic encryption algorithms have also attracted much attention. As a basic requirement of security, the ciphertext image of the image chaotic encryption algorithm must have good uniformity. In addition, the algorithm must have a large enough key space to resist brute force attacks. For instance, in order to show the security of the image chaotic encryption algorithm in the statistical sense, the key space analysis, statistical analysis, and differential analysis of the chaos encryption algorithm proposed in [23] and its corresponding extended algorithm are given in Sections 4 and 5 of [23], respectively. However, the high uniformity of ciphertext does not mean that the encryption algorithm has high security performance. For example, in [24], the security analysis of an image chaotic encryption algorithm proposed in [16] is given, and it is found that the generation of key stream is related to the sum of pixel values of plain images. Under the premise of satisfying the sum of pixel values of a plain image unchanged, only two pixel values of cipher image are changed corresponding to the variation of two pixel values of a plain image, which is vulnerable to differential attack. Therefore, the equivalent secret keys can be obtained by selecting 512 plain images. In [25], the cryptanalysis of a DNA encoding-based image scrambling and diffusion encryption

algorithm proposed in [10] is reported to find that the scrambling algorithm is also independent of plain image, so that it can be deciphered by chosen plaintext attack. In addition, by choosing some specific plain images, the original image chaotic encryption algorithm can be simplified into scrambling-only encryption algorithm, which has been proven to be insecure [26,27]. In [28], the security analysis of an image encryption algorithm based on a compound chaotic system proposed in [29] is given, and it is pointed out that there are a large number of equivalent secret keys in the image chaotic encryption algorithm. In [30], an 8D self-synchronous and feedback-based chaotic stream cipher using the lower 8 bits of one state variable for encryption is proposed. However, in [31], most of the secret keys are successfully acquired by means of a divide and conquer attack, known plaintext attack, and a chosen ciphertext attack, respectively. In [32], the security analysis of a Latin square based image chaotic encryption algorithm proposed in [22] is given to find the security vulnerabilities both in the diffusion stage and in the scrambling stage through chosen text attack. In [33], the chosen plaintext attack is adopted for the safety performance assessment of a 1D combinatorial chaotic encryption algorithm proposed in [34]. In addition, in [35], the chosen plaintext attack is also utilized for analyzing the security of a bit cube-based image chaotic encryption algorithm proposed in [36]. In addition, some chaotic cipher designers have also discovered the importance of cryptanalysis. For example, in Section 3 of [37], the resistance to the four classic attack methods is analyzed in detail. The analysis shows that the proposed encryption algorithm has resistance to the chosen plaintext attack because it is sensitive to the initial parameters.

In 2019, an image chaotic encryption algorithm based on orthogonal Latin cubes and bit cubes is given in [20]. First, a chaotic sequence is generated by logistic mapping, and it is further arranged in ascending order to obtain its corresponding chaotic index sequence. Next, a finite field is constructed by the chaotic index sequence, and three orthogonal Latin cubes are also generated. Then, the generated three orthogonal Latin cubes are used for the first-scrambling-diffusion- second-scrambling three-stage encryption. Although the designer claims that the algorithm has passed various statistical tests, the analysis results in this paper demonstrate that the algorithm has at least two security vulnerabilities as follows:


Based on the above-mentioned security vulnerabilities, this paper adopts both chosen plaintext attack and differential attack for analyzing the safety performance for the image chaotic encryption algorithm proposed in [20]. First, a full zero plain image and multiple non-full zero plain images are selected, and the differential operation is performed between the cipher image corresponding to this full zero plain image and the cipher image corresponding to those non-full zero plain images. On the premise that the sum of bit 1 in each differential operation is even, the chaotic index sequence *lx* can be deciphered. Next, based on the obtained *lx*, and on the condition that there exists an intersection in the solutions of unary quadratic equation on finite field *GF*(*q*), the secret keys *α*, *β*, *γ* can be further deciphered.

The rest of the paper is organized as follows: Section 2 briefly introduces the image chaotic encryption algorithm. Section 3 presents the security analysis. Section 4 gives the steps for deciphering image chaotic encryption algorithm. Section 5 demonstrates the numerical simulation experiments. Section 6 gives some improvement suggestions for the image chaotic encryption algorithm. Finally, Section 7 concludes the paper.

#### **2. Description of an Image Chaotic Encryption Algorithm**

#### *2.1. A Brief View of an Image Chaotic Encryption Algorithm*

In [20], the image chaotic encryption algorithm consists of secret keys selection, Latin cube generation, scrambling encryption, and diffusion encryption, as shown in Figure 1, where *key*0, *μ*0,

*α*, *β*, *γ* are the secret keys, *xn* (*n* = 0, 1, 2, ···) is a chaotic sequence generated by Logistic mapping, *lx* is a chaotic index sequence, *L*1, *L*2, *L*<sup>3</sup> are three Latin cubes, *P* is a 2D plain gray image, *M* is a bit cube representation of *P*, *S*<sup>1</sup> is a first-scrambling image of *M*, *D* is a diffusion image of *S*1, *S*<sup>2</sup> is a second-scrambling image of *D*, *E* is a 2D cipher gray image of *S*2, and *B* is generated by *L*1. When the size of the image is *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>*, the length of *xn* and *lx* is *<sup>q</sup>* <sup>=</sup> <sup>√</sup><sup>3</sup> <sup>8</sup> <sup>×</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>*, the side length of Latin cubes and bit cubes is *<sup>q</sup>* <sup>=</sup> <sup>√</sup><sup>3</sup> <sup>8</sup> <sup>×</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>*, and the secret keys *<sup>α</sup>*, *<sup>β</sup>*, *<sup>γ</sup>* ∈ {0, 1, 2, ··· , *<sup>q</sup>* <sup>−</sup> <sup>1</sup>}. Note that an appropriate image size *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* should be selected to ensure that *<sup>q</sup>* <sup>=</sup> <sup>√</sup><sup>3</sup> <sup>8</sup> <sup>×</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* <sup>=</sup> <sup>2</sup> <sup>×</sup> <sup>√</sup><sup>3</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* is an even number. In Figure 1, *L*1, *L*2, *L*<sup>3</sup> ∈ {0, 1, 2, ··· , *q* − 1} are Latin cubes, *M*, *S*1, *D*, *S*2, *B* ∈ {0, 1} are bit cubes, *P* is a 2D plain gray image, *E* is a 2D cipher gray image, *pk*, *pt*, *s*1, *b*, *d*, *ek* ∈ {0, 1} are 1D bit sequences corresponding to *P*, *S*1, *B*, *D*, *E*, and *t* = *T*(*k*) is a position scrambling rule corresponding to the first-scrambling stage.

**Figure 1.** Block diagram of an image chaotic encryption algorithm.

#### *2.2. Logistic Map*

According to Figure 1, the chaotic sequence is generated through logistic mapping, given by

$$
\mu \mathbf{x}\_{n+1} = \mu \mathbf{x}\_n (1 - \mathbf{x}\_n),
\tag{1}
$$

where *n* = 0, 1, 2, ··· , *xn* ∈ (0, 1), 0 ≤ *μ* ≤ 4. When *μ* > 3.573815, Equation (1) is chaotic.

#### *2.3. Generation of Latin Cubes*

Let the side length of *<sup>L</sup>*1, *<sup>L</sup>*2, *<sup>L</sup>*<sup>3</sup> be *<sup>q</sup>* <sup>=</sup> <sup>√</sup><sup>3</sup> <sup>8</sup> <sup>×</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>*, where *<sup>q</sup>* is an even number. For a given (*l*1, *l*2, *l*3), one gets *L*1(*l*1, *l*2, *l*3) = *ψ*1, *L*2(*l*1, *l*2, *l*3) = *ψ*2, *L*3(*l*1, *l*2, *l*3) = *ψ*3, 0 ≤ *ψ*1, *ψ*2, *ψ*<sup>3</sup> ≤ *q* − 1. If (*l*1, *l*2, *l*3) = (*l* 1, *l* 2, *l* <sup>3</sup>), (*ψ*1, *ψ*2, *ψ*3) = (*ψ* <sup>1</sup>, *ψ* <sup>2</sup>, *ψ* <sup>3</sup>), then *L*1, *L*2, *L*<sup>3</sup> are orthogonal to each other [38]. When *q* = 3, one gets three orthogonal Latin cubes, as shown in Figure 2a, and the corresponding triple tuple is shown in Figure 2b, respectively.

**Figure 2.** Three orthogonal Latin cubes and the corresponding triple tuple when *q* = 3. (**a**) three orthogonal Latin cubes; (**b**) the corresponding triple tuple.

The algorithm for generating Latin cubes proposed in [20] is implemented by replacing the ordered set {0, 1, 2, ..., *q*} in the generation method proposed in [38] with the chaotic index sequence *lx*. The detailed steps for generating three orthogonal Latin cubes by means of a finite field are in Algorithm 1.

**Algorithm 1** Steps for Generation of Latin Cubes.

**Input:** Secret keys *key*0, *<sup>μ</sup>*0, *<sup>α</sup>*, *<sup>β</sup>*, *<sup>γ</sup>*; Side length *<sup>q</sup>* <sup>=</sup> <sup>√</sup><sup>3</sup> <sup>8</sup> <sup>×</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>*;

**Output:** Three orthogonal Latin cubes *L*1, *L*<sup>2</sup> and *L*3; 1: Generate the chaotic sequence *<sup>x</sup>* = {*x*0, *<sup>x</sup>*1,..., *xq*−1} by using Logistic mapping.

2: Obtain the corresponding chaotic index sequence *lx* = {*c*0, *<sup>c</sup>*1, ··· , *ci*, ··· , *cq*−1} by arranging *<sup>x</sup>* = {*x*0, *<sup>x</sup>*1, ... , *xq*−1} in ascending order, where 0 ≤ *ci*, *<sup>i</sup>* ≤ *<sup>q</sup>* − 1, satisfying *lx*[*i*] = *ci*. Note that the chaotic index sequence *lx* can only be determined after the sequence value *ci* and the sequence number *i* are simultaneously obtained. When the sequence value *ci* is obtained, but the sequence number *i* is uncertain, the general form of the chaotic index sequence *lx* is in the form of

$$\mathbf{l}\mathbf{x} = \{\mathbf{c}\_{l\_0}, \mathbf{c}\_{l\_1}, \dots, \mathbf{c}\_{l\_0}, \dots, \mathbf{c}\_{l\_{q-1}}\},\tag{2}$$

where 0 ≤ *cik ik* ≤ *<sup>q</sup>* − 1, *<sup>i</sup>*<sup>0</sup> = *<sup>i</sup>*<sup>1</sup> = ··· = *ik* = ··· = *iq*−1, *lx*[*ik*] = *cik* . In the following, *<sup>ξ</sup>* or *<sup>ξ</sup>* denotes the sequence value and *i<sup>ξ</sup>* or *i <sup>ξ</sup>* denotes the sequence number in Equation (2), respectively.

3: Construct a finite field by using chaotic index sequence *lx*, and then one gets the orthogonal Latin cubes on the finite field, given by

$$\begin{cases} \begin{aligned} \, \, \_1L\_1 \left(l\_1, l\_2, l\_3\right) &= \alpha^2 \times c\_{l\_1} + \alpha \times c\_{l\_2} + c\_{l\_3}, \\\, \, \_2\left(l\_1, l\_2, l\_3\right) &= \beta^2 \times c\_{l\_1} + \beta \times c\_{l\_2} + c\_{l\_3}, \\\, \, \_3\left(l\_1, l\_2, l\_3\right) &= \gamma^2 \times c\_{l\_1} + \gamma \times c\_{l\_2} + c\_{l\_3}. \end{aligned} \tag{3}$$

where "+" denotes addition operation on the finite field, "×" denotes multiplication operation on the finite field, *α*, *β*, *γ* ∈ *lx*, *cl*<sup>1</sup> , *cl*<sup>2</sup> , *cl*<sup>3</sup> are sequence values of *lx*.

4: **return** *L*1, *L*2, *L*3.

#### *2.4. Steps for Image Chaotic Encryption*

According to Figure 1, and taking a plain gray image with 512 × 512 resolution as an example, one has *<sup>q</sup>* <sup>=</sup> <sup>√</sup><sup>3</sup> <sup>512</sup> <sup>×</sup> <sup>512</sup> <sup>×</sup> <sup>8</sup> <sup>=</sup> 128. The steps for image chaotic encryption are in Algorithm 2.


**Input:** Secret keys *key*0, *μ*0, *α*, *β*, *γ*; Plaintext image *P*;

**Output:** Ciphertxet image *E*;


first-scrambling image *S*<sup>1</sup> in the form of bit cube, such that

$$S\_1\left(l\_1, l\_2, l\_3\right) = M\left(L\_1\left(l\_1, l\_2, l\_3\right), L\_2\left(l\_1, l\_2, l\_3\right), L\_3\left(l\_1, l\_2, l\_3\right)\right). \tag{4}$$

4: Obtain the diffusion bit cube *B* (*l*1, *l*2, *l*3) by using Latin cube *L*1, given by

$$B\left(l\_{1}, l\_{2}, l\_{3}\right) = \begin{cases} \ 0, & \text{if } L\_{1}\left(l\_{1}, l\_{2}, l\_{3}\right) \ge 64, \\\ 1, & \text{if } L\_{1}\left(l\_{1}, l\_{2}, l\_{3}\right) < 64. \end{cases} \tag{5}$$

Then, get the diffusion 1D bit sequence *b*[*t*] corresponding to diffusion bit cube *B*(*l*1, *l*2, *l*3) as

$$b[t] = B\left(\left\lfloor t/128^2\right\rfloor, \left\lfloor t/128\right\rfloor \% 128, \ t\% 128\right),\tag{6}$$

where *<sup>t</sup>* ∈ {0, 1, 2, ··· , *<sup>q</sup>*<sup>3</sup> <sup>−</sup> <sup>1</sup>}, · is a round down operation, and "%" is a modulo operation. 5: Convert *S*1(*l*1, *l*2, *l*3) into the 1D bit sequence *s*1[*t*] as

$$\mathbf{s}\_{1}[t] = \mathbf{S}\_{1}\left( \left\lfloor t/128^{2} \right\rfloor, \left\lfloor t/128 \right\rfloor \% 128, \ t\% 128 \right). \tag{7}$$

Then, get the 1D bit sequence *d*[*t*] by using *s*1[*t*] and *b*[*t*] as

$$d[t] = s\_1[t] \oplus d[t-1] \oplus b[t],\tag{8}$$

where 0 <sup>≤</sup> *<sup>t</sup>* <sup>≤</sup> <sup>128</sup><sup>3</sup> <sup>−</sup> 1, *<sup>d</sup>*[−1] = 0, "⊕" denotes bitwise exclusive or operation.

6: Calculate *G*(*d*) = <sup>∑</sup>*q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *d*[*i*] , and convert the 1D bit sequence *d*[*t*] into the bit cube *D*(*l*1, *l*2, *l*3). Then, get the bit cube *S*<sup>2</sup> (*l*1, *l*2, *l*3) by utilizing *D*(*l*1, *l*2, *l*3), such that

$$S\_2\left(l\_1, l\_2, l\_3\right) = \begin{cases} D\left(L\_2\left(l\_1, l\_2, l\_3\right), L\_3\left(l\_1, l\_2, l\_3\right), L\_1\left(l\_1, l\_2, l\_3\right)\right), & \text{(G/d)}\% 2 = 0\text{)},\\ D\left(L\_3\left(l\_1, l\_2, l\_3\right), L\_1\left(l\_1, l\_2, l\_3\right), L\_2\left(l\_1, l\_2, l\_3\right)\right), & \text{(G/d)}\% 2 = 1\text{)}, \end{cases} \tag{9}$$

where *G*(*d*)%2 ∈ {0, 1} denotes the modular 2 operation on *G*(*d*). 7: Convert the bit cube *S*2(*l*1, *l*2, *l*3) into the 2D cipher gray image *E* with 512 × 512 resolution.

8: **return** *E*.

An example of encrypting a gray image with 2 × 4 resolution using the original encryption algorithm is shown in Figure 3. Figure 3a shows the three Latin cubes and the corresponding bit cubes *L* used for encryption. Figure 3b shows the encryption process. The numbers in the cells of *P* and *E* represent pixel values, and the bit values are represented in the cells of *S*1, *B*, and *S*2. The red cells in *M* indicate that they are bit representations of the red cell corresponding to *P*, i.e., the binary representation of 166 is (10100110)2.

**Figure 3.** An example of encrypting a gray image with 2 × 4 resolution. (**a**) three orthogonal Latin cubes and the corresponding bit cubes *L* used for encryption; (**b**) the encryption process.

#### **3. Security Analysis**

According to Figure 1, it is found that the generation of three orthogonal Latin cubes *L*1, *L*2, *L*<sup>3</sup> is not related to the plain image. When the secret keys are given, the three orthogonal Latin cubes *L*1, *L*2, *L*<sup>3</sup> remain unchanged for different input plain images, which are provided a prerequisite for chosen plaintext attack. Therefore, one can decipher the equivalent secret keys *lx*, *α*, *β*, *γ* corresponding to the original secret keys *key*0, *μ*0, *α*, *β*, *γ*.

#### *3.1. Analysis of Chaotic Index Sequence lx*

#### 3.1.1. Relation between the First-Scrambling Image *S*<sup>1</sup> and the Plain Image *M*

**Proposition 1.** *Suppose that M is the bit cube representation of P; S*<sup>1</sup> *is the first-scrambling image of M. The relationship between M and S*<sup>1</sup> *satisfies S*1(*i*0, *i*0, *i<sup>ξ</sup>* ) = *M*(*ξ*, *ξ*, *ξ*)*, where lx*[*i*0] = 0*, lx*[*i<sup>ξ</sup>* ] = *ξ, i*0, *ξ* ∈ {0*,* 1*,* 2*,* ··· *, q* − 1}*, i*<sup>0</sup> *denotes the sequence number corresponding to the sequence value 0, and i<sup>ξ</sup> denotes the sequence number corresponding to the sequence value ξ.*

**Proof.** Let *l*<sup>1</sup> = *l*<sup>2</sup> = *i*0, *l*<sup>3</sup> = *i<sup>ξ</sup>* , and substitute them into Equation (4), then, one gets

$$S\_1(i\_0, i\_0, i\_{\tilde{\xi}}) = M(L\_1(i\_0, i\_0, i\_{\tilde{\xi}}), L\_2(i\_0, i\_0, i\_{\tilde{\xi}}), L\_3(i\_0, i\_{0\prime}, i\_{\tilde{\xi}})). \tag{10}$$

In addition, let *l*<sup>1</sup> = *l*<sup>2</sup> = *i*0, *l*<sup>3</sup> = *i<sup>ξ</sup>* , and substitute them into Equation (3), then, one gets

$$\begin{cases} L\_1(i\_0, i\_0, i\_\xi) = a^2 \times c\_{i\_0} + a \times c\_{i\_0} + c\_{i\_\xi \prime} \\ L\_2(i\_0, i\_0, i\_\xi) = \beta^2 \times c\_{i\_0} + \beta \times c\_{i\_0} + c\_{i\_\xi \prime} \\ L\_3(i\_0, i\_0, i\_\xi) = \gamma^2 \times c\_{i\_0} + \gamma \times c\_{i\_0} + c\_{i\_\xi} \end{cases} \tag{11}$$

Since *lx*[*i*0] = 0, *lx*[*i<sup>ξ</sup>* ] = *ξ*, one has *lx*[*i*0] = *ci*<sup>0</sup> = 0, *lx*[*i<sup>ξ</sup>* ] = *ci<sup>ξ</sup>* = *ξ*. In addition, substituting *ci*<sup>0</sup> = 0 and *ci<sup>ξ</sup>* = *ξ* into Equation (11), one gets

$$L\_1(i\_{0\prime}i\_{0\prime}i\_{\tilde{\xi}}) = L\_2(i\_{0\prime}i\_{0\prime}i\_{\tilde{\xi}}) = L\_3(i\_{0\prime}i\_{0\prime}i\_{\tilde{\xi}}) = \tilde{\xi}.\tag{12}$$

In addition, substituting Equation (12) into Equation (10), it follows that *S*1(*i*0, *i*0, *i<sup>ξ</sup>* ) = *M*(*ξ*, *ξ*, *ξ*) holds. The proof is finished.

#### 3.1.2. The First Case for Analysis of Chaotic Index Sequence *lx*

Suppose that the 1D bit sequence corresponding to plain image *P*<sup>0</sup> is {*p*0[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> = {0} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , the cipher image corresponding to plain image *P*<sup>0</sup> is *E*0, the 1D bit sequence corresponding to cipher image *E*<sup>0</sup> is {*e*0[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , and the 1D bit sequence corresponding to plain image *Pk* is {*pk*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , where *pk*[*i*] is given by

$$p\_k[i] = \begin{cases} 1, & \text{if } i = k, \\ 0, & \text{if } i \neq k. \end{cases} \tag{13}$$

In addition, suppose that the cipher image corresponding to plain image *Pk* is *Ek*, the 1D bit sequence corresponding to cipher image *Ek* is {*ek*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , the 1D bit sequence corresponding to plain image *Pk*1*k*<sup>2</sup> = *Pk*<sup>1</sup> ⊕ *Pk*<sup>2</sup> is *pk*1*k*<sup>2</sup> [*i*] *q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> = *pk*<sup>1</sup> [*i*] ⊕ *pk*<sup>2</sup> [*i*] *q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , the cipher image corresponding to plain image *Pk*1*k*<sup>2</sup> is *Ek*1*k*<sup>2</sup> , the 1D bit sequence corresponding to cipher image *Ek*1*k*<sup>2</sup> is {*ek*1*k*<sup>2</sup> [*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , the 1D bit sequence corresponding to plain image *Pk*1*k*2*k*<sup>3</sup> = *Pk*<sup>1</sup> ⊕ *Pk*<sup>2</sup> ⊕ *Pk*<sup>3</sup> is *pk*1*k*2*k*<sup>3</sup> [*i*] *q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> = *pk*<sup>1</sup> [*i*] ⊕ *pk*<sup>2</sup> [*i*] ⊕ *pk*<sup>3</sup> [*i*] *q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , the cipher image corresponding to *Pk*1*k*2*k*<sup>3</sup> is *Ek*1*k*2*k*<sup>3</sup> , and the 1D bit sequence corresponding to *Ek*1*k*2*k*<sup>3</sup> is {*ek*1*k*2*k*<sup>3</sup> [*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> .

*Entropy* **2019**, *21*, 888

**Proposition 2.** *Suppose that the cipher image corresponding to plain image Pk is Ek, the 1D bit sequence corresponding to cipher image Ek is* {*ek*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *, the cipher image corresponding to plain image P*<sup>0</sup> *is E*0*, and the 1D bit sequence corresponding to cipher image E*<sup>0</sup> *is* {*e*0[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *. A differential operation is performed in the form of* <sup>∑</sup>*q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> (*e*0[*i*] <sup>⊕</sup> *ek*[*i*]) <sup>=</sup> *<sup>q</sup>*<sup>3</sup> <sup>−</sup> *mk*,0*, in which ek*[*il*] = *<sup>e</sup>*0[*il*] *(l* <sup>=</sup> 1, 2, ··· , *mk*,0; *il* ∈ {0, 1, 2, ··· , *<sup>q</sup>*<sup>3</sup> <sup>−</sup> <sup>1</sup>})*, <sup>q</sup>*3*is an even number. If* (*q*<sup>3</sup> <sup>−</sup> *mk*,0)%2 <sup>=</sup> *<sup>q</sup>*3%2 <sup>−</sup> *mk*,0%2 <sup>=</sup> *mk*,0%2 <sup>=</sup> <sup>0</sup>*, then <sup>T</sup>*(*k*) = *mk*,0 *holds, where T*(*k*) *denotes the position scrambling rule in the first-scrambling stage, k denotes the position of the k-th bit before the first-scrambling of plain image, and T*(*k*) *denotes the position of k-th bit after the first-scrambling of plain image.*

**Proof.** According to Equation (6), the relationship between the coordinates (*l*1, *l*2, *l*3) of bit cube *B*(*l*1, *l*2, *l*3) and the position *t* of 1D bit sequence *b*[*t*] corresponding to *B*(*l*1, *l*2, *l*3) is given by

$$\begin{cases} l\_1 = \lfloor t/q^2 \rfloor = \left\lfloor t/128^2 \right\rfloor, \\ l\_2 = \lfloor t/q \rfloor \text{ @=} \lfloor t/128 \rfloor \text{ @128}, \\ l\_3 = t^{\diamond} \!\!/ \!q = t^{\diamond} \!\!/ \!128}. \end{cases} \tag{14}$$

On the other hand, the relationship between the coordinates (*ξ*, *ξ*, *ξ*) of bit cube *M*(*ξ*, *ξ*, *ξ*) and the position *k* of 1D bit sequence *pk*[*i*] in Equation (13) is given by

$$k = \mathfrak{J}(q^2 + q + 1). \tag{15}$$

Thus, the relationship between the position of t-th bit after the first-scrambling of plain image and the position of k-th bit before the first-scrambling of plain image is given by

$$t = T(k) = T(\not\zeta(q^2 + q + 1)).\tag{16}$$

(1) Consider the first-scrambling stage. In the first-scrambling stage, only change the bit position, but the bit value should remain unchanged. Suppose that the input 1D bit sequence corresponding to plain image *Pk* is *pk*, after the first-scrambling of plain image, the corresponding output 1D bit sequence is *pt*. According to Equation (16), the relationship between position *t* and *k* satisfies *t* = *T*(*k*). In particular, if the input 1D bit sequence corresponding to plain image *P*<sup>0</sup> is *p*<sup>0</sup> = {*p*0[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> = {0} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , after the first-scrambling of plain image, the corresponding output 1D bit sequence is *pt* = {*pt*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , then one has *pt* = *p*<sup>0</sup> = {0} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> . (2) Consider the diffusion stage. Take the output 1D bit encryption sequence {*po*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> in the first-scrambling stage as the input 1D bit sequence in the diffusion stage. According to Equation (8), diffuse {*po*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> by using the diffusion 1D bit sequence {*b*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> , obtain the corresponding output {*do*[*i*]}1283−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> in the diffusion stage. By substituting *s*1[*i*] = *po*[*i*] = 0 into Equation (8), one has

$$\begin{cases} d\_o[0] = p\_o[0] \oplus d\_o[-1] \oplus b[0] = 0 \oplus 0 \oplus b[0] = b[0], \\ d\_o[1] = p\_o[1] \oplus d\_o[0] \oplus b[1] = 0 \oplus d\_o[0] \oplus b[1] = b[0] \oplus b[1], \\ d\_o[2] = p\_o[2] \oplus d\_o[1] \oplus b[2] = 0 \oplus d\_o[1] \oplus b[2] = b[0] \oplus b[1] \oplus b[2], \\ \dots \\ d\_o[i] = b[0] \oplus b[1] \oplus b[2] \cdot \dots \oplus b[i] \end{cases} \tag{17}$$

where *<sup>i</sup>* <sup>=</sup> 0, 1, 2, ··· , *<sup>q</sup>*<sup>3</sup> <sup>−</sup> 1, *<sup>d</sup>*0[−1] = 0. Similarly, take the output 1D bit encryption sequence {*pt*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> in the first-scrambling stage as the input 1D bit sequence in the diffusion stage. According to Equation (8), diffuse {*pt*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> by using the diffusion 1D bit sequence {*b*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> and obtain the corresponding output {*dt*[*i*]}1283−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> in the diffusion stage. By substituting *s*1[*i*] = *pt*[*i*] into Equation (8), and also by utilizing Equation (17), one has

$$\begin{cases} d\_l[0] = p\_l[0] \oplus d\_l[-1] \oplus b[0] = 0 \oplus 0 \oplus b[0] = d\_o[0], \\ d\_l[1] = p\_l[1] \oplus d\_l[0] \oplus b[1] = 0 \oplus d\_o[0] \oplus b[1] = 0 \oplus b[0] \oplus b[1] = d\_o[1], \\ \dots \\ d\_l[t] = p\_l[t] \oplus d\_l[t-1] \oplus b[t] = 1 \oplus d\_o[t-1] \oplus b[t] = 1 \oplus d\_o[t] = \overline{d\_o[t]}, \\ d\_l[t+1] = p\_l[t+1] \oplus d\_l[t] \oplus b[t+1] = 0 \oplus d\_l[t] \oplus b[t+1] = \overline{d\_o[t]} \oplus b[t+1] = \overline{d\_o[t+1]}, \\ \dots \\ d\_l[t] = p\_l[t] \oplus d\_l[t-1] \oplus b[t] = 1 \oplus d\_o[t-1] \oplus b[t] = \overline{d\_o[t]}, \end{cases} \tag{18}$$

where *dt*[−1] = 0. According to Equation (18), one has

$$\begin{cases} d\_t[i] = d\_o[i] & (0 \le i < t), \\ d\_t[i] = \overline{d\_o[i]} & (t \le i \le (q^3 - 1)), \end{cases} \tag{19}$$

where *do*[*i*] denotes the bitwise NOT of *do*[*i*]. (3) Consider the second-scrambling stage. Take the output 1D bit encryption sequences {*do*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> and {*dt*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> in the diffusion stage as the input 1D bit sequences in the second-scrambling stage, calculate *<sup>G</sup>*(*d*0) = <sup>∑</sup>*q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *d*0[*i*] , *<sup>G</sup>*(*dt*) = <sup>∑</sup>*q*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *dt*[*i*] , respectively. If *t*%2 = 0 in Equation (19) holds, then it follows that

$$G(d\_l)^
\diamondsuit 2 = G(d\_0)^
\diamondsuit 2.\tag{20}$$

According to Equation (9) with Equation (20), it is noted that the same scrambling rule for {*do*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> and {*dt*[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> is used in the second-scrambling stage. By comparing the first equation *dt*[*i*] = *do*[*i*] (0 <sup>≤</sup> *<sup>i</sup>* <sup>&</sup>lt; *<sup>t</sup>*) of Equation (19) with *ek*[*il*] = *<sup>e</sup>*0[*il*] (*<sup>l</sup>* <sup>=</sup> 1, 2, ··· , *mk*,0; *il* ∈ {0, 1, 2, ··· , *<sup>q</sup>*<sup>3</sup> <sup>−</sup> <sup>1</sup>}), it follows that *t* = *mk*,0. Then, according to Equation (16), *T*(*k*) = *mk*,0 holds. The proof is finished.

Based on Proposition 1, one has *S*1(*i*0, *i*0, *i<sup>ξ</sup>* ) = *M*(*ξ*, *ξ*, *ξ*), where *ξ* ∈ {0, 1, 2, ··· , *q* − 1} is the sequence value of chaotic index sequence *lx*, *i<sup>ξ</sup>* is the sequence number of *lx*. However, even though *ξ* is given, since *S*1(*i*0, *i*0, *i<sup>ξ</sup>* ) is the first-scrambling result of bit cube *M*(*ξ*, *ξ*, *ξ*), but the scrambling rule *T*(·) is unknown beforehand, the sequence numbers *i*<sup>0</sup> and *i<sup>ξ</sup>* cannot be directly available. Thus, Proposition 2 is needed to obtain the specific numbers *i*<sup>0</sup> and *i<sup>ξ</sup>* .

Based on Proposition 2, suppose that the input plain image *M*(*l*1, *l*2, *l*3) is given by

$$M(l\_1, l\_2, l\_3) = \begin{cases} 1, & \text{if } l\_1 = l\_2 = l\_3 = \emptyset, \\ 0, & \text{otherwise,} \end{cases} \tag{21}$$

where *<sup>ξ</sup>* ∈ {0, 1, ··· , *<sup>q</sup>* <sup>−</sup> <sup>1</sup>}. Based on Equation (15) with Equation (21), one has *<sup>k</sup>* <sup>=</sup> *<sup>ξ</sup>* · (*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>). Next, one obtains *mk*,0 by a chosen plaintext attack. If *mk*,0%2 = 0 holds, then the same scrambling rule is used for *d*<sup>0</sup> and *dt* in the second-scrambling stage, such that *T*(*k*) = *mk*,0 = *t*. Finally, according to Equation (14), it follows that

$$\begin{cases} \quad i\_0 = \left\lfloor t/q^2 \right\rfloor = \left\lfloor T(\mathfrak{J} \cdot (q^2 + q + 1))/q^2 \right\rfloor = \left\lfloor T(k)/q^2 \right\rfloor = \left\lfloor m\_{k,0}/q^2 \right\rfloor, \\\quad i\_{\mathfrak{J}} = t\%q = T(\mathfrak{J} \cdot (q^2 + q + 1))\%q = T(k)\%q = m\_{k,0}\%q. \end{cases} \tag{22}$$

An example of Proposition 2 is as in Figure 4. Figure 4a shows the ciphertext corresponding to the grayscale image lena. Figure 4b shows the corresponding ciphertext image after changing the bit at the bit-cube coordinates (6, 6, 6) of lena. Figure 4c is a bitwise exclusive or result between Figure 4a,b. Figure 4d is a bit statistical histogram of Figure 4c.

**Figure 4.** An example of Proposition 2. (**a**) the ciphertext corresponding to the grayscale image lena; (**b**) the corresponding ciphertext image after changing the bit at the bit-cube coordinates (6, 6, 6) of lena; (**c**) the bitwise exclusive or result between Figure 4a,b; (**d**) the bit statistical histogram of Figure 4c.

The difference between the two plaintexts is only 1 bit. It can be found from Figure 4d that the number of identical bits between their corresponding ciphertexts is 1,733,762, which is an even number. Substituting *mk*,0 = 1, 733, 762, *ξ* = 6, and *q* = 128 into Equation (22) yields *i*<sup>0</sup> = 105 and *i*<sup>6</sup> = 2.

3.1.3. The Second Case for Analysis of Chaotic Index Sequence *lx*

If *mk*,0%2 = 0, the above-mentioned method is no longer available, which needs to be further consideration.

**Corollary 1.** *Supposing that the cipher image corresponding to plain image Pk*1*k*<sup>2</sup> = *Pk*<sup>1</sup> ⊕ *Pk*<sup>2</sup> (*k*<sup>1</sup> = *k*2) *is Ek*1*k*<sup>2</sup> *, the 1D bit sequence corresponding to Ek*1*k*<sup>2</sup> *is* {*ek*1*k*<sup>2</sup> [*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *, the cipher image corresponding to plain image P*<sup>0</sup> *is E*0*, the 1D bit sequence corresponding to E*<sup>0</sup> *is*{*e*0[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *. A differential operation is performed in the form* *of* <sup>∑</sup>*q*3−<sup>1</sup> *i*=0 *e*0[*i*] ⊕ *ek*1*k*<sup>2</sup> [*i*] <sup>=</sup> *mk*1*k*2,0*, in which ek*[*il*] <sup>=</sup> *<sup>e</sup>*0[*il*] *(l* <sup>=</sup> 1, 2, ··· , *mk*1*<sup>k</sup>*2,0; *il* ∈ {0, 1, 2, ··· , *<sup>q</sup>*<sup>3</sup> <sup>−</sup> 1})*. If mk*1*<sup>k</sup>*2,0%2 = 0*, then* |*T*(*k*1) − *T*(*k*2)| = *mk*1*k*2,0 *holds. In addition, if* |*T*(*k*1) − *T*(*k*2)| %2 = 0*, then mk*1*k*2,0 = |*T*(*k*1) − *T*(*k*2)| *also holds.*

**Corollary 2.** *Suppose that the cipher image corresponding to plain image Pk*1*k*2*k*<sup>3</sup> = *Pk*<sup>1</sup> ⊕ *Pk*<sup>2</sup> ⊕ *Pk*<sup>3</sup> (*k*<sup>1</sup> = *k*<sup>2</sup> = *k*3) *is Ek*1*k*2*k*<sup>3</sup> *, the 1D bit sequence corresponding to Ek*1*k*2*k*<sup>3</sup> *is* {*ek*1*k*2*k*<sup>3</sup> [*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *, the cipher image corresponding to plain image P*<sup>0</sup> *is E*0*, the 1D bit sequence corresponding to E*<sup>0</sup> *is* {*e*0[*i*]} *<sup>q</sup>*3−<sup>1</sup> *<sup>i</sup>*=<sup>0</sup> *. A differential operation is performed in the form of* <sup>∑</sup>*q*3−<sup>1</sup> *i*=0 *e*0[*i*] ⊕ *ek*1*k*2*k*<sup>3</sup> [*i*] <sup>=</sup> *<sup>q</sup>*<sup>3</sup> <sup>−</sup> *mk*1*k*2*k*3,0*, in which ek*1*k*2*k*<sup>3</sup> [*il*] = *<sup>e</sup>*0[*il*] *(l* <sup>=</sup> 1, 2, ··· , *mk*1*k*2*<sup>k</sup>*3,0; *il* ∈ {0, 1, 2, ··· , *<sup>q</sup>*<sup>3</sup> <sup>−</sup> <sup>1</sup>})*, <sup>q</sup>*<sup>3</sup> *is an even number. If* (*q*<sup>3</sup> <sup>−</sup> *mk*1*k*2*k*3,0)%2 <sup>=</sup> *<sup>q</sup>*3%2 <sup>−</sup> *mk*1*k*2*<sup>k</sup>*3,0%2 <sup>=</sup> *mk*1*k*2*<sup>k</sup>*3,0%2 <sup>=</sup> <sup>0</sup>*, then <sup>T</sup>*(*k*1) + *<sup>T</sup>*(*k*2) <sup>−</sup> *<sup>T</sup>*(*k*3) = *mk*1*k*2*k*3,0 *holds, where T*(*k*1) < *T*(*k*3) < *T*(*k*2) *or T*(*k*1) > *T*(*k*3) > *T*(*k*2)*. In addition, if* [*T*(*k*1) + *T*(*k*2) − *T*(*k*3)] %2 = 0*, then mk*1*k*2*k*3,0 = *T*(*k*1) + *T*(*k*2) − *T*(*k*3) *also holds.*

Suppose that the set of all sequence values corresponding to the chaotic index sequence *lx* is Ω = {*ξi*<sup>1</sup> , *ξi*<sup>2</sup> , ··· , *ξiq*/2 , *ξ i* 1 , *ξ i* 2 , ··· , *ξ i q*/2 }. Let Ψ = {*ξi*<sup>1</sup> , *ξi*<sup>2</sup> , ··· , *ξiq*/2 } be the set of sequence value *ξ* corresponding to sequence number *i<sup>ξ</sup>* , where *i<sup>ξ</sup>* is obtained by using Equation (22). The relationship among *<sup>ξ</sup>*, *<sup>k</sup>*, *<sup>t</sup>* is *<sup>k</sup>* <sup>=</sup> *<sup>ξ</sup>*(*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>) and *<sup>t</sup>* <sup>=</sup> *<sup>T</sup>*(*k*) = *<sup>T</sup>*(*<sup>ξ</sup>* · (*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>)). For <sup>∀</sup>*<sup>ξ</sup>* <sup>∈</sup> <sup>Ψ</sup>, *mk*,0%2 <sup>=</sup> 0 and *t* = *mk*,0 hold. Similarly, let Ψ = {*ξ i* 1 , *ξ i* 2 , ··· , *ξ i q*/2 } be the set of sequence value *ξ* corresponding to sequence number *i <sup>ξ</sup>* . The relationship among *ξ* , *k* , *t* is *<sup>k</sup>* <sup>=</sup> *<sup>ξ</sup>* · (*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>) and *<sup>t</sup>* = *T*(*k* ) = *<sup>T</sup>*(*ξ* · (*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>)). For <sup>∀</sup>*ξ* <sup>∈</sup> <sup>Ψ</sup> , *mk*,0%2 = 0 and *t* = *mk*,0 do not hold.

When *<sup>ξ</sup>* <sup>∈</sup> <sup>Ψ</sup>, one has *<sup>k</sup>* <sup>=</sup> *<sup>ξ</sup>*(*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>) and *mk*,0%2 <sup>=</sup> 0, based on the Proposition 2, *<sup>t</sup>* <sup>=</sup> *mk*,0 holds. According to Equation (22), the sequence number *i<sup>ξ</sup>* corresponding to sequence value *ξ* is given by *i<sup>ξ</sup>* = *t*%*q*. However, when *ξ* ∈ Ψ , one has *k* = *ξ* (*q*<sup>2</sup> <sup>+</sup> *<sup>q</sup>* <sup>+</sup> <sup>1</sup>) and *mk*,0%2 <sup>=</sup> 0, the Proposition 2 is not available, *t* = *mk*,0 does not hold. Therefore, the sequence number *i <sup>ξ</sup>* corresponding to sequence value *ξ* ∈ Ψ cannot be determined by using Equation (22).

To further solve the above-mentioned problem, by selecting *k* <sup>1</sup>, *k* <sup>2</sup> (*k* <sup>1</sup> = *k* <sup>2</sup>), one can obtain *mk* 1,0 corresponding to *k* <sup>1</sup>, and *mk* <sup>2</sup>,0 corresponding to *<sup>k</sup>* <sup>2</sup> by using chosen plaintext attack, which satisfies *mk* 1,0%2 <sup>=</sup> 1 and *mk* 2,0%2 = 1. Under this circumstance, although *<sup>T</sup>*(*k* <sup>1</sup>) and *T*(*k* <sup>2</sup>) are unknown, but according to the Proposition 2, ∀*k* corresponding to *T*(*k*)%2 = 0 can be found, so that the remained ∀*k* satisfies *T*(*k* <sup>1</sup>)%2 = 1 and *T*(*k* <sup>2</sup>)%2 = 1, |*T*(*k* <sup>1</sup>) − *T*(*k* <sup>2</sup>)|%2 = 0. According to the Corollary 1, it follows that

$$m\_{k\_1'k\_2',0} = |T(k\_1') - T(k\_2')| = |t\_1' - t\_2'|. \tag{23}$$

According to the chosen plaintext attack, *mk* 1*k* <sup>2</sup>,0 in Equation (23) can be obtained from the given *ξ* <sup>1</sup>, *ξ* <sup>2</sup> ∈ Ψ , where *ξ* <sup>1</sup> corresponding to *t* <sup>1</sup> satisfies *t* <sup>1</sup> = *T*(*ξ* <sup>1</sup>(*q*<sup>2</sup> + *<sup>q</sup>* + <sup>1</sup>)), and *<sup>ξ</sup>* <sup>2</sup> corresponding to *t* 2 satisfies *t* <sup>2</sup> = *T*(*ξ* <sup>2</sup>(*q*<sup>2</sup> + *<sup>q</sup>* + <sup>1</sup>)), respectively.

For the same *k* <sup>1</sup>, *k* <sup>2</sup>, by selecting a suitable *<sup>k</sup>* such that *<sup>k</sup>* = *<sup>ξ</sup>*(*q*<sup>2</sup> + *<sup>q</sup>* + 1), *mk*,0%2 = 0, one gets *T*(*k* <sup>1</sup>) + *T*(*k* <sup>2</sup>) − *T*(*k*) %2 = 0. Then, according to the Corollary 2, it follows that

$$m\_{k\_1'k\_2'k,0} = T(k\_1') + T(k\_2') - T(k) = t\_1' + t\_2' - t\_\prime \tag{24}$$

where *T*(*k* <sup>1</sup>) < *T*(*k*) < *T*(*k* <sup>2</sup>) or *T*(*k* <sup>1</sup>) > *T*(*k*) > *T*(*k* <sup>2</sup>), *t* <sup>1</sup> < *t* < *t* <sup>2</sup> or *t* <sup>1</sup> > *t* > *t* 2.

According to the chosen plaintext attack, *mk* 1*k* <sup>2</sup>*k*,0 in Equation (24) can be obtained from the given *ξ* <sup>1</sup>, *ξ* <sup>2</sup> ∈ Ψ and *ξ* ∈ Ψ, where *ξ* <sup>1</sup> corresponding to *t* <sup>1</sup> satisfies *t* <sup>1</sup> = *T*(*ξ* <sup>1</sup>(*q*<sup>2</sup> + *<sup>q</sup>* + <sup>1</sup>)), *<sup>ξ</sup>* <sup>2</sup> corresponding to *t* <sup>2</sup> satisfies *t* <sup>2</sup> = *T*(*ξ* <sup>2</sup>(*q*<sup>2</sup> + *<sup>q</sup>* + 1)), *<sup>ξ</sup>* corresponding to *<sup>t</sup>* satisfies *<sup>t</sup>* = *<sup>T</sup>*(*ξ*(*q*<sup>2</sup> + *<sup>q</sup>* + 1)) = *mk*,0, in which *mk*,0 is known by a chosen plaintext attack as well.

Note that one can also select *t i* , *t <sup>i</sup>*+1, *t* (*i* = 2, 3, ··· ,(*q*/2 − 1)) in the same way, which is omitted here due to the limited length of the article.

According to Equations (23) and (24), four cases are given as follows:

*Entropy* **2019**, *21*, 888

(1) If *t* <sup>1</sup> < *t* < *t* <sup>2</sup>, then one has

$$\begin{cases} t\_2' = (m\_{k\_1'k\_2',0} + m\_{k\_1'k\_2'k,0} + t)/2 = A\_1, \\ t\_1' = (-m\_{k\_1'k\_2',0} + m\_{k\_1'k\_2'k,0} + t)/2 = B\_1. \end{cases} \tag{25}$$

(2) If *t* <sup>1</sup> > *t* > *t* <sup>2</sup>, then one has

$$\begin{cases} t\_1' = (m\_{k\_1'k\_2',0} + m\_{k\_1'k\_2'k,0} + t)/2 = A\_1, \\ t\_2' = (-m\_{k\_1'k\_2',0} + m\_{k\_1'k\_2'k,0} + t)/2 = B\_1. \end{cases} \tag{26}$$

(3) If *t* <sup>2</sup> < *t* < *t* <sup>3</sup>, then one has

$$\begin{cases} \mathbf{f}\_3' = (m\_{k\_2'k\_3',0} + m\_{k\_2'k\_3'k,0} + \mathbf{t})/2 = A\_2, \\ \mathbf{f}\_2' = (-m\_{k\_2'k\_3',0} + m\_{k\_2'k\_3'k,0} + \mathbf{t})/2 = B\_2. \end{cases} \tag{27}$$

(4) If *t* <sup>2</sup> > *t* > *t* <sup>3</sup>, then one has

$$\begin{cases} t\_2' = (m\_{k\_2'k\_3',0} + m\_{k\_2'k\_3'k,0} + t)/2 = A\_2, \\ t\_3' = (-m\_{k\_2'k\_3',0} + m\_{k\_2'k\_3'k,0} + t)/2 = B\_2. \end{cases} \tag{28}$$

Based on Equations (25)–(28), it follows that

$$\begin{cases} \{t\_1', t\_2'\} = \{A\_1, B\_1\}, \\ \{t\_2', t\_3'\} = \{A\_2, B\_2\}. \end{cases} \tag{29}$$

Then, according to Equation (29), it follows that

$$\begin{cases} t\_2' = \{A\_1, B\_1\} \bigcap \{A\_{2'}, B\_2\}, \\ t\_1' = \{A\_1, B\_1\} - \{t\_2'\}, \\ t\_3' = \{A\_2, B\_2\} - \{t\_2'\}. \end{cases} \tag{30}$$

Similarly, for *t <sup>i</sup>*−1, *<sup>t</sup> i* , *t* and *t i* , *t <sup>i</sup>*+1, *t*, one has

$$\begin{cases} t'\_i = \{A\_{i-1}, B\_{i-1}\} \bigcap \{A\_{i\prime} B\_i\}, \\ t'\_{i-1} = \{A\_{i-1\prime} B\_{i-1}\} - \{t'\_i\}, \\ t'\_{i+1} = \{A\_{i\prime} B\_i\} - \{t'\_i\}, \end{cases} \tag{31}$$

where *i* = 2, 3, ··· ,(*q*/2 − 1).

For any given *ξ <sup>l</sup>* ∈ Ψ and *ξ* ∈ Ψ, according to Equation (31), first, one can get the corresponding *t l* . Then, the sequence number *i ξ l* corresponding to the sequence value *ξ <sup>l</sup>* can be further obtained by using *t l* , such that

$$\begin{cases} \mathbf{i}\_{\xi\_l'}' = \mathbf{i}\_l'^\vee \boldsymbol{\omega} q\_\prime \\ \ln[\mathbf{i}\_{\xi\_l'}'] = \tilde{\mathbf{g}}\_{l'}' \end{cases} \tag{32}$$

where *l* ∈ {1, 2, ··· , *q*/2}.

Finally, according to the Equations (22) and (32), one can determine all the sequence values *ξ* ∈ Ψ, *ξ <sup>l</sup>* ∈ Ψ and all the corresponding sequence numbers *i<sup>ξ</sup>* , *i <sup>ξ</sup>* in Equation (2), so that the chaotic index sequence *lx* can be completely deciphered.

#### *3.2. Analysis of Secret Keys α, β, γ*

**Proposition 3.** *Under the condition that the chaotic index sequence lx is obtained, for any* (*l*1, *l*2, *l*3) = *(l* 1, *l* 2, *l* <sup>3</sup>*), where li*, *l <sup>i</sup>* ∈ {0, 1, 2, ··· , *q* − 1} *(i* = 1, 2, 3)*, if L*1(*l*1, *l*2, *l*3) = *L*2(*l*1, *l*2, *l*3) = 0 *and L*2(*l* 1, *l* 2, *l* <sup>3</sup>) = *L*3(*l* 1, *l* 2, *l* <sup>3</sup>) = 0*, then the secret keys α*, *β*, *γ can be uniquely determined.*

**Proof.** According to Equation (3), if *L*1(*l*1, *l*2, *l*3) = *L*2(*l*1, *l*2, *l*3) = 0 and *L*2(*l* 1, *l* 2, *l* <sup>3</sup>) = *L*3(*l* 1, *l* 2, *l* <sup>3</sup>) = 0 for any (*l*1, *l*2, *l*3) = (*l* 1, *l* 2, *l* <sup>3</sup>), then it follows that

$$\begin{cases} L\_1(l\_1, l\_2, l\_3) = L\_2(l\_1, l\_2, l\_3) = c\_{l\_1} \times \chi\_1^2 + c\_{l\_2} \times \chi\_1 + c\_{l\_3} \neq 0, \\ L\_2(l\_1', l\_2', l\_3') = L\_3(l\_1', l\_2', l\_3') = c\_{l\_1'} \times \chi\_2^2 + c\_{l\_2'} \times \chi\_2 + c\_{l\_3'} \neq 0, \end{cases} \tag{33}$$

where *cl*<sup>1</sup> , *cl*<sup>2</sup> , *cl*<sup>3</sup> are sequence values of chaotic index sequence *lx*, *χ*<sup>1</sup> ∈ {*α*, *β*}, *χ*<sup>2</sup> ∈ {*β*, *γ*}.

According to the first equation of Equation (33), one gets two solutions *χ*(1) <sup>1</sup> , *<sup>χ</sup>*(2) <sup>1</sup> for *χ*1. Similarly, according to the second equation of Equation (33), one gets two solutions *χ*(1) <sup>2</sup> , *<sup>χ</sup>*(2) <sup>2</sup> for *χ*2. Thus, there exists an intersection for the first equation and the second equation of Equation (33), given by *<sup>β</sup>* <sup>=</sup> {*χ*(1) <sup>1</sup> , *<sup>χ</sup>*(2) <sup>1</sup> } {*χ*(1) <sup>2</sup> , *<sup>χ</sup>*(2) <sup>2</sup> }. Based on the deciphered secret key *β*, the remaining two secret keys *<sup>α</sup>* <sup>=</sup> {*χ*(1) <sup>1</sup> , *<sup>χ</sup>*(2) <sup>1</sup> }−{*β*} and *<sup>γ</sup>* <sup>=</sup> {*χ*(1) <sup>2</sup> , *<sup>χ</sup>*(2) <sup>2</sup> }−{*β*} can further be deciphered as well.

If *L*1(*l*1, *l*2, *l*3) = *L*2(*l*1, *l*2, *l*3) = 0 and *L*2(*l* 1, *l* 2, *l* <sup>3</sup>) = *L*3(*l* 1, *l* 2, *l* <sup>3</sup>) = 0, then, an intersection for the first equation and the second equation of Equation (33) does not exist, so the secret keys *α*, *β*, *γ* cannot be obtained [39]. The proof is finished.

#### *3.3. Flowchart of Security Analysis*

The flowchart of security analysis is shown in Figure 5.

**Figure 5.** Flowchart of security analysis.

#### **4. Steps for Deciphering the Image Chaotic Encryption Algorithm**

The steps for deciphering image chaotic encryption algorithm are as Algorithm 3.

#### **Algorithm 3** Steps for Deciphering Image Chaotic Encryption Algorithm.

#### **Output:** The equivalent secret keys *lx*, *α*, *β*, *γ*;


Theoretical analysis and experimental results indicate that only a maximum of 2.5 <sup>×</sup> <sup>√</sup><sup>3</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* plain images are needed to decipher the chaotic index sequence *lx*, and only a maximum of six plain images are needed to decipher secret keys *<sup>α</sup>*, *<sup>β</sup>*, *<sup>γ</sup>*. Therefore, only a maximum of 2.5 <sup>×</sup> <sup>√</sup><sup>3</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* <sup>+</sup> 6 is needed to crack the cipher image with *w* × *h* resolution.

#### **5. Numerical Simulation Experiments**

In the numerical simulation experiments, the secret keys are set as *key*<sup>0</sup> = 0.34, *μ*<sup>0</sup> = 3.9, *α* = 20, *β* = 37, *γ* = 46, the image is with 512 × 512 resolution. According to the steps for deciphering the image chaotic encryption algorithm given in Section 4, the deciphering algorithm of the origin cipher is implemented by the C program language. Simulations are operated under a laptop computer with Intel Core i7-8550U CPU (Santa Clara, CA, USA) 1.80 GHz, 8 GB RAM, the operating system is Microsoft Windows 10 (Redmond, WA, USA). Using the original algorithm to encrypt and use the algorithm proposed in this paper to crack an image with size of 512 × 512 takes about 0.115 s and 10.702 s, respectively. Since the encryption process of the algorithm is independent of plaintext and ciphertext, the equivalent key obtained by deciphering any ciphertext image can be used to decipher all ciphertext images of the same resolution. Taking the standard 2D plain gray image Lena, Cameraman, Livingroom as three examples, the plain images, the cipher images, and the deciphered images are shown in Figure 6, respectively.

**Figure 6.** Plain images ((**a**–**c**) row), cipher images ((**d**–**f**) row), and deciphered images ((**g**–**i**) row) of Lena ((**a**–**g**) column), cameraman ((**b**–**h**) column), and living room ((**c**–**i**) column).

Although the previous analysis is for grayscale images, the original encryption algorithm can be easily extended to encrypt color images by encrypting each of the three channels of the color image as a separate grayscale image. In this case, the attack method proposed in this paper is still valid. Take a real-life image with 1024 × 2048 resolution as an example. Encrypting this image using the original encryption algorithm, it takes about 0.53 s to encrypt the three color channels with the same key, and it takes about 107.36 s to decipher the corresponding ciphertext using the attack method proposed in this paper. Encrypting three color channels with three different sets of keys takes about 1.42 s, and it takes about 318.45 s to decipher the corresponding ciphertext. The results are shown in Figure 7.

**Figure 7.** The result of the deciphering of the real-life image. (**a**) the original image; (**b**) encrypting the three color channels with the same key; (**c**) the deciphered image corresponding to (**b**); (**d**) encrypting the three color channels with three different sets of keys; (**e**) the deciphered image corresponding to (**d**).

#### **6. Suggestions for Improvement**

According to the analysis in Section 3, the original algorithm is insecure and cannot resist the choice of plaintext attack, and the complexity of the attack method is relatively low. To deal with its security defects, the corresponding suggestions for improvement to enhance the security are as follows:

(1) Enhance the sensitivity of the encryption algorithm to plaintext and ciphertext. According to the analysis in Section 3, the original algorithm has a universal equivalent key *lx*, *α*, *β*, *γ*. The original algorithm is not sensitive to both plaintext and ciphertext. The root cause of this defect is that the generation of Latin cubes is independent of plaintext image. This vulnerability can be solved by introducing some statistical properties of plaintext, such as the sum of all pixel values, into the generation phase of the Latin cubes.

(2) The mechanism used in the diffusion phase is too simple to achieve the avalanche effect of cryptography, which makes the encryption algorithm vulnerable to differential attacks. To fulfill this demand, increasing the number of encryption rounds or exploiting some complex diffusion mechanisms are worthy options.

#### **7. Conclusions**

This paper investigates the security of a Latin-bit cube-based image chaotic encryption algorithm. The algorithm adopts a first-scrambling-diffusion-second-scrambling three-stage encryption scheme. Although the designer claims that the algorithm has passed various statistical tests, the security analysis results in this paper demonstrate that the algorithm has some security vulnerabilities. In particular, the generation of Latin cubes is independent of plain image, and the change in the number of bits in the cipher image follows the change of any one bit in the plain image with obvious regularity. Thus, the equivalent secret keys *lx*, *α*, *β*, *γ* can be cracked by a chosen plaintext attack and differential attack. Only a maximum of 2.5 <sup>×</sup> <sup>√</sup><sup>3</sup> *<sup>w</sup>* <sup>×</sup> *<sup>h</sup>* <sup>+</sup> 6 plain images are needed to decipher the equivalent secret keys. Theoretical analysis and numerical simulation experiment results verify the effectiveness of the analytical method.

**Author Contributions:** Methodology, Z.Z.; Project administration, S.Y.; Software, Z.Z.; Supervision, S.Y.; Validation, S.Y.

**Funding:** This research was funded by the National Key Research and Development Program of China (No. 2016YFB0800401) and the National Natural Science Foundation of China (No. 61532020, 61671161).

**Conflicts of Interest:** The authors declare no conflict and interest.

#### **References**


c 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
