On the Image Encryption Algorithm Based on the Chaotic System, DNA Encoding, and Castle

Hundreds of image encryption algorithms have been developed for the security and integrity of images through the combination of DNA computing and chaotic maps. This combination of the two instruments is not sufficient enough to thwart the potential threats from the cryptanalysis community as the literature review suggests. To inject more robustness and security stuff, a novel image encryption scheme has been written in this research by fusing the chaotic system, DNA computing and Castle—a chess piece. As the plain image is input, its pixels are shifted to the scrambled image at the randomly chosen pixel addresses. This scrambling has been realized through the routine called Image Scrambler using Castle (ISUC). Castle randomly moves on the hypothetical large chessboard. Pixels taken from the plain image are shifted to the addresses of the scrambled image, where Castle lands in each iteration. After the plain image is scrambled, it is DNA encoded. Two mask images are also DNA encoded. Then to throw the diffusion effects in the cipher, DNA Addition and DNA XOR operations between the DNA encoded pixels data and the DNA encoded mask images have been conducted. Next, the pixels data are converted back into their decimal equivalents. Four dimensional chaotic system has been used to get the chaotic vectors. The hash codes given by the SHA-256 function have been used in the cipher to introduce the plaintext sensitivity in its design. We got an information entropy of 7.9974. Simulation carried out through the machine, and the thorough security analyses demonstrate the good security effects, defiance to the varied attacks from the cryptanalysis community, and the bright prospects for some real world application of the proposed image cipher.


I. INTRODUCTION
The science and art of cryptography is as old as the human civilization itself. As the societies grew, tribes of human beings started to be organized into different kingdoms. Naturally, all these developments led to the new ideas and phenomena like politics, superiority, power and battles etc. These advancements propelled people to communicate with each other secretly and with the selective recipients. Not only the science of cryptography got founded but at the same time continued to be evolved. The roots of cryptography are found The associate editor coordinating the review of this manuscript and approving it for publication was Lefei Zhang . in the ancient Roman and Egyptian civilizations. Hundreds of cryptosystems have been developed since then. Whatever the cryptosystem is, the basic idea stays the same, i.e., to communicate secretly in the presence of an eavesdropper.
In history, certain zeitgeists have always been characterizing the cultures all over the world. No doubt, today's is information and communication technologies. Images have assumed a central place in all of this. Be it academia, industry, research and science facilities, diplomatic and government settings, art, design, medicine, social life to name a few, these images have infiltrated in the entire cross sections of the societies. People from all over the world routinely store these images on different gadgets like hard disks, tablets, VOLUME 9, 2021 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ PDAs etc., or transmit them to their acquaintances through the public networks like Internet. Sometimes, these images happen to be extremely secret and confidential, a picture of some spy, blueprint of some new industrial product, for instance. So, to safeguard them from the ubiquitous hackers and antagonists, foolproof steps must be adopted. The current study is a step forward in this direction. One will find plethora of ciphers like AES, DES, RSA etc. in the literature. Unfortunately, they can't be applied over the images since their area of application was text data [1], [2]. Since the images have radically different characteristics like bulky volume, high redundancy and strong inter-pixel bonding etc., this is the reason that these ciphers can't be applied over them. So, an entirely different setting is required for the solution of this problem. Fortunately, the chaotic maps have proved very handy for the enterprise of image encryption. Many ciphers have been developed through the fusion of these maps with DNA computing. Some image ciphers used chaotic maps with other instruments and concepts like knight [3], king [4], 15-puzzle [5], fractals [6], Latin cubes [7], Nine palace [8], swapping operations [9], circular shift operations [10] etc.
The current study has tried to seek the harmonious complementarities existing among the three giants, i.e., chaos, DNA computing and chess piece Castle in order to develop a more secured cipher. We describe them one by one in the following. Chaos is a mathematical theory [11], which investigates the behavior of dynamical systems, being highly dependent to the system parameters and the initial conditions. It's an interdisciplinary enterprise, which states that given the apparent random behavior of the chaotic systems, there exist strictly deterministic patterns in the form of constant feedback loops, fractals and self-organization. This theory maintains that a very minute change in one of the parameters and states can bring a huge difference in the later states. It means there exists a sensitive dependence on the system parameters and the initial conditions. There is a very interesting metaphor, the butterfly effect, regarding chaos that goes like this, ''if a butterfly flaps its wing in Brazil, it can cause a hurricane in the Texas.'' This theory was given by Edward Lorenz [12]. Strictly complying with the idea of chaos theory, mathematicians have given a large number of chaotic maps/systems. These maps are basically the set of mathematical equations which provide the random numbers. These maps have proved very useful in developing a large number of image cryptosystems due to their excellent inbuilt properties as described earlier.
Recently, a 2D modular chaotification system has been developed in order to improve the chaos complexity [13]. In the reported work, the authors have contended that the existing chaotic maps may be plagued with defects like incomplete output distributions and discontinuous chaotic ranges. Such defects may disrupt the working of the potential chaos-based applications. Owing to the fact that the modular operation is a bounded transform, the map introduced in [13] may spawn the behaviors of chaoticity in a relatively wider parameters ranges whereas the existing maps do not demonstrate such behavior. In a yet another research work [14], a new 2D chaotic system has been developed called 2D-LSM. This new 2D chaotic system has wide and continuous chaotic range than many of the existing 2D chaotic maps. This map has been employed to devise an image cipher which exploits the properties of Latin square and color image in their entirety.
DNA stands for deoxyribonucleic acid. This is the germ plasm of all life styles [15]. DNA is basically a type of biological macromolecule and is comprised of nucleotides. These nucleotides contain a single base and there are four types of bases, i.e., A(Adenine), C(Cytosine), G(Guanine) and T(Thymine). A DNA is a double-stranded molecule occurring in nature. The two DNA strands complementing each other are held with each other to make a double-helix structure by hydrogen bonds between the complementary bases of A and T (or C and G). Watson and Crick, the two scientists, discovered this double-helix structure. Therefore, this structure is termed as Watson-Crick complementarity [16].
Chess is a game whom history has made synonymous with the ingenuity. This has become an epitome of ruse, collusion, plot, maneuvering, rigging, planning, strategy and other terms of such character. We believe that the chess has an immense potential for the enterprise of cryptography. Each player/piece of chess moves in its unique way. Knight, a chess piece, has already been used in the different image ciphers for image scrambling [3]. One of the drawbacks of using knight for scrambling is that it moves in two and half boxes of the chess, so, the scrambling effects will be localized in the given input plain image. To address this problem, we have conceived the idea of using Castle, another chess piece, for the project of scrambling. Castle moves in the entire chessboard in one go both horizontally and vertically. In this way, scrambling effects will spread all over the image leading to the greater security.
As described earlier, through the fusion of chaotic systems and DNA computing, many image encryption algorithms have been produced. We will describe here few of them. An RGB image encryption scheme was proposed by [5]. The authors of this scheme used chaotic tent map, the intertwining logistic map, DNA computing and the game of 15-puzzle in their proposed scheme. Scrambling was carried out by the 15-puzzle game and the diffusion effects were embedded through the DNA encoding. One more scheme for the image encryption using the Henon-sine map and DNA encoding was given by [17]. In the confusion process, the permutation-diffusion architecture was employed. Besides, the DNA encoding and XOR operation were used in the diffusion process. The substitution boxes were used in diffusion process to make DNA level encryption more complicated and hence more secured. The results showed that their scheme was secured enough to avert the varied attacks. An another algorithm for the images encryption based on fractional Fourier transformation, chaotic map and DNA was given by [18]. Lorenz map chaotic stream was utilized in the random phase masks generation. The plain image was transformed into DNA matrix, which was then joined with the random phase mask using the fractional Fourier transform.
The results showed that their proposed scheme could safeguard against different attacks. A multiple images encryption algorithm using the strands of DNA was written in [19]. The given images were merged into a single image and the single image was resized into a one dimensional array. The confusion process was performed using the indexes of the half array. These indexes were also used in the diffusion process to diffuse the pixels using DNA sequences. The results showed that their scheme was not only secured against different types of attacks but was also fast. The DNA encoding scheme was also used in another image encryption scheme proposed by [20]. In this scheme, the binary search tree (BST) was utilized. Based on the size of the given input image, a candidate BST was determined and was converted into the DNA sequences along with the plain image and XOR operation was performed between them to get the DNA based diffused image. Results showed that the scheme was robust against the different attacks. Besides, an image cipher based on DNA, 3D latin cubes and pixel-level dynamic filtering was given in [21]. The 5D hyperchaotic system was used for the random number sequences. The dynamic filtering was applied over each pixel value to get the diffusion effects over the image. Then the DNA encoding was implemented to further diffuse the image. Obtained image was converted into the 3D DNA level cubes. The latin cuber operation was performed over them and then it was converted back into the 2D cipher image. The results obtained were quite good. A yet another novel approach in image encryption was developed by [22]. The pixel level filtering and DNA level diffusion were used in this scheme using the hyperchaotic map. After the generation of random sequences, the dynamic filtering was applied over the pixels value to alter them. The bit level scrambling was then implemented to perform the permutation process. Next, the DNA level encoding was carried out to perform the diffusion process. The simulation results demonstrated that the scheme has the desirable security effects. Recently, a novel image encryption algorithm has been developed by using the keys derived from plaintext image and DNA [23]. The proposed scheme has employed the idea of chaotic visual selective encryption of the given image data. To guarantee an immunity against the potential threats, the initial values of the chaotic map have been made dependent over the plain image through SHA-512 hash function and the random DNA sequence. The proposed scheme used three 1D chaotic maps. Diffusion operation has been introduced in the plain image through the selection of blocks that have greater correlation. Further, an XOR operation has been carried out with the random matrix. Remaining two chaotic maps cracked the inherent inter-pixel tight correlation through the confusion operation. As the cipher image is sliced into the Least Significant Bit (LSBs) and the Most Significant Bits (MSBs), the host image underwent the lifting wavelet transformation. Simulation and security analysis indicated the robustness and real world application of the image cipher. Moreover, in [24] an image encryption scheme was developed using a novel permutation and DNA operations. For plaintext sensitivity, DNA hamming distances and SHA-256 hash codes have been employed to temper the initial conditions of the 4D chaotic map. A novel scrambling scheme was used through the instrument of improved balanced binary tree. Afterwards, dynamic block coding rules have been embedded in which distinct coding rules were used from the distinct image blocks. In order to realize the diffusion effects, a novel algorithm through inter-block and intra-block has been introduced which carried out the DNA operations on the key matrix and the intermediate encryption result. Experimental results indicated the robustness and immunity of the cipher against the varied attacks from the hackers' community. In a work [25], a new image encryption algorithm has been given through chaos, DNA strands and multi-objective particle swarm optimization (PSO). In order to reach the best cipher image, linear differential descent strategy and chaotic initial particle swarm optimization were employed to avoid in getting stuck the local optima. DNA mask image has been created using the logistic map and DNA encoding. Position of a particle was made to correspond to position of the plain image. Further, the iterative PSO algorithm was applied to the correlation coefficient and the information entropy. Performance analysis indicated that the entropy and correlation coefficient attained very good values. Moreover, the scheme had the ability to defy the typical attacks. Some researchers employed compression as well to their encryption algorithms like [26], [27] to raise the communication speed.
Many works have been cracked due to the different loopholes in the design principles of the image ciphers as literature suggests. Low plaintext sensitivity, for instance, is the cause of cryptanalysis by the known-plaintext and chosen-plaintext attacks upon them. As an example, scheme given in [28] was cracked by the chosen-plaintext attack [29]. Cause of this breakage was that the chaotic vectors produced were independent of the input plain image for encryption. To put this in other words, the scheme given in [28] had not the plaintext sensitivity. Hence, novel image encryption algorithms are needed with suitable plaintext sensitivity in their designs. In [30], some rationality and practicability problems have been figured out about the image cipher reported by the name of 2D logistic-adjusted-sine-map-based image encryption scheme [31]. This scheme was cryptanalyzed by the chosen plaintext attack described in [30]. The experimentations suggested that the plain images could be recovered without having any access to the secret key. Later on, some improvements were suggested to avoid such kinds of attacks in the future. In another cryptanalysis work [32], an image cipher consisting of chaotic system and DNA technology [33] was broken. This scheme was again cracked by the chosen plaintext attack over it. To improve the scheme, some remedial measures were suggested by the cryptanalysts. In a yet another cryptanalysis task [34], a scheme given in [35] has been successfully broken by the chosen plaintext attack. Few tests were conducted through the proposed attack algorithm and the moduli employed in the ICS-IE algorithm [35]. The simulations indicated that the proposed attack algorithm was VOLUME 9, 2021 correct in successfully recovering the plain images without having any know-how about the secret key. Lastly in this work [36], an image cipher based on the DNA level diffusion and the pixel level filtering was analyzed for the possible loopholes in [22]. Through the launch of plaintext attack, the scheme [22] was broken by the [36].
In this research study, after taking inspiration from the above discussion, we undertake to engineer a yet another image encryption algorithm which can be characterized by the following features.
• Castle -a chess piece will be used for the project of scrambling. Previously, chess pieces knight and king have used for scrambling. Although, the given images got scrambled through them but their drawback was that the effects remained localized. Whereas, the scrambling through Castle puts greater scrambling effects and hence render more security. The reason is that Castle can sweep the entire chessboard in one move.
• Four dimensional dynamical chaotic system has been used for the generation of the random data. This dynamic system has rich dynamical structures.
• Fuller potential of DNA encoding has been reaped. The DNA encoding rules have been dynamically applied over the pixels. These rules have been figured out from the pixels data instead of the random vectors given by the chaotic map. This act makes the cipher more defiant from the differential attacks.
• The plaintext sensitivity has been increased by making the starting address of the Castle to initiate its scrambling project from any of the pixel address on the chessboard. This act caused to create a richer plaintext sensitivity. Besides, as a byproduct, key space also got increased. Rest of the paper has been formatted as follows. Section II discusses the basic theories upon which the study rests, i.e., the theory of chaotic system, DNA computing and chess piece Castle. Section III describes the way, the random data has been spawned, and the algorithm for encryption. Section IV is for the simulation of the encryption scheme. Security analysis has been performed in the Section V. The paper has been wrapped up in the last Section VI along with the necessary remarks of conclusion.

II. BUILDING BLOCKS
This section is a brief discussion about the building blocks which our study has used.

A. FOUR DIMENSIONAL CHAOTIC MAP(FDCM)
The chaotic systems are the popular source for the generation of the random data. Lorenz and Rossler developed their 3D chaotic maps. Afterwards, Yong and Yun-Qing [37] came up with a better 4D chaotic dynamical system which can be described as followsẋ This map is dissipative, symmetrical and enjoys the rich dynamical structures. Figure 1 depicts topology and the chaotic behavior of attractors of this chaotic map for B. DNA COMPUTING As described earlier, four nucleotides, i.e., A(Adenine), C(Cytosine), G(Guanine) and T(Thymine) complement each other ( Figure 2). For instance, if '01' is connected to A then '10' will be connected to T. In the same way, if '11' is connected to C then '00' will be connected to G. There are a total of 4! or 24 kinds of encoding possibilities, in which 8 comply with the complementary rules of Watson-Crick (Table 1). In the realm of DNA technology and in particular DNA computing, research [38] reports some operations over the DNA strands. These operations include XOR, addition and subtraction binary operations. Table 2 shows these operations.
To use A, T, C and G in the proposed encryption algorithm, two conversion functions DNA−Conv and DEC −Conv have been defined which take 8-bit pixel value and convert it into its DNA sequence of length four and vice versa using the   Other operations like addition, subtraction and XOR are also used in the realm of DNA cryptography. These operations are like the popular operations which are carried out in the binary number system. As 8 kinds of encoding rules are there, similarly, there exist 8 kinds of addition, subtraction and XOR operations. All these three operations have been depicted in the Table 2 according to the rule 1. Normally, the symbols +, − and ⊕ for DNA addition, DNA subtraction and DNA XOR are used. These operations will be carried out between the two DNA sequences of length four based upon the eight rules.

C. CASTLE
Castle is a piece of chess -a classical, strategical and a board-based game which is usually played between the two persons [39]. Chessboard is an 8 × 8 grid shown in the Figure 3a. Both the rows and columns are labeled with the integers from 1 to 8. There are 32 pieces in the game in which each player has 16 pieces. The names of the pieces are King, Queen, Bishop, Knight, Castle (aka as Rook) and Pawn. Each piece plays in a distinct way from the most weak (Pawn) to the most powerful (Queen). There are different colored pieces for each player, normally in the black and white colors lying on the first two rows of the chessboard. The particular instance of the Figure 3a shows that the black colored pieces have been placed on the rows 7 and 8, whereas the white colored pieces are lying on the rows 1 and 2. Each square of the chessboard has a unique address. For example, the initial addresses of the Castle with the black colors are (1,8) and (8,8). Aim of game is to defeat the opponent. In this research, only Castle has been used for the project of scrambling/confusion of the pixels. Castle moves only horizontally and vertically for an arbitrary steps as depicted in the Figure 3b. To make it a good fit, two deviations have been made from the game's rules: first, the chessboard will have the same size as that of the input image, second, if Castle goes past the edge, it will appear from the opposite edge. Random numbers will govern the Castle for different movements in arbitrary directions.

III. PROPOSED IMAGE ENCRYPTION ALGORITHM
The proposed algorithm uses chaos theory, DNA computing and random movement of Castle in one setting to encrypt the given input image. It is to be noted that this scheme is for the gray scale image of the arbitrary size m × n. The algorithm is based on some stages ( Figure 4). In the first stage, a gray scale image is input. SHA-256 hash codes for this image are generated to realize the effects of plaintext sensitivity. This sensitivity assures to foil the chosen plaintext/ciphertext attacks on the cipher. Each different input image will cause to spawn unique random data since the hash codes generated modify the starting values of the map. Different initial values cause different random numbers. In the second stage, since the chaotic data generated is in the ''raw'' form, this data is normally customized corresponding to the peculiar logic of the algorithm. Specifically, key streams formed are direction, dist1, dist2, mask − one and mask − two. Of course, these five streams of random numbers will serve the different purposes of the cipher. In the third stage, scrambling has been performed. We assert that the main contribution of the current study is the usage of random movement of Castle for the project of image scrambling. Castle moves randomly on the vast chessboard of the size m × n for the number of pixels times, i.e., mn for given input image. The random variable direction decides whether the Castle has to move in the vertical direction or in the horizontal direction. If horizontal direction is decided, the random variable dist1 provides the distance with which the Castle has to move. In the same way, if the direction decided is of vertical, the random variable dist2 provides the distance with which the Castle has to move. The Castle moves in the range of (−(m − 1), (m − 1)) and (−(n − 1), (n − 1)) for the vertical and horizontal directions respectively. In case, the number given by the dist1 or dist2 is greater than the distance between the current position of the Castle on the chessboard and the edge, the Castle has been made to move cyclically and to make it appear from the opposite edge of the board. It is to be noted that the random streams dist1 or dist2 may also give a zero value. In this case, no movement of the Castle would take place.
A scrambled image with the size of given input gray scale image is formed, i.e., m × n. Reshape the input image to the size of 1 × mn. We have linked ingeniously the shifting of pixels from the input gray scale image to the scrambled image with the random movement of the Castle.
Here we will describe our procedure. We have three entities at our disposal, i.e, pixels of input image, scrambled empty image, random movement of the Castle. Starting from the given particular address at the chessboard, i.e., (startx, starty), the Castle will move to a particular address at the chessboard depending upon the value of variables direction, dist1 and dist2. The first pixel taken from the input image will be shifted to the same address on the scrambled image as the address on which the Castle is currently residing in its first iteration. In the second iteration, the Castle will move again to a particular address on the chessboard, in the same way, the second pixel will be shifted from the input image to the same address on the scrambled image as the address where the Castle has landed on the chessboard. This process will be repeated mn times. Sometimes, Castle lands to an address on the chessboard which has already been occupied by some pixel in the scrambled image, in that case, no shifting would be carried out. In the last, the remaining pixels from the input image would be shifted to the empty addresses of the scrambled image. The scrambled image, key streams mask − one and mask − two are encoded into the DNA strands in the fourth stage. It is to be noted that the rules of conversion have been taken directly from the pixels data instead of the key streams to make the cipher more secure and robust from the differential attacks. In the fifth stage, in order to throw the diffusion effects, DNA Addition and DNA XOR operations have been carried out between the DNA encoded pixel data and DNA encoded mask − two and mask − one respectively. In the sixth and last stage, this DNA encoded strands of the pixel data are translated to their decimal equivalents to obtain the final gray scale cipher image.

A. PROCEDURE FOR KEY STREAM GENERATION
To create the plaintext sensitivity, 256-bit hash code has been employed in the proposed encryption scheme. Generated hash code has been used to update the starting values of the chaotic map. For every plain image, a unique hash code K is generated. Afterwards, it is sliced into 8-bit blocks. In this way, we get 32 hexadecimal digits K = k 1 , k 2 , . . . , k 32 . The following steps explain the updates of the values.
Step 1: By the following equations, the variables of the chaotic map/system are being upgraded as (2)-(5), shown at the bottom of the page, where x 0 , y 0 , z 0 , w 0 are the initial values of the chaotic system before the addition of the plaintext sensitivity and x 0 , y 0 , z 0 , w 0 are the starting values of the chaotic map after adding plaintext sensitivity.
⊕, ∨ and ∧, respectively denote the logical XOR, OR and AND operations in the binary.
Step 2: The looping of the chaotic map (1) (mn + n 0 ) times rendered the four chaotic sequences , the variables m and n correspond to the size of input image. Further, value of n 0 is greater than 500. The first n 0 values of the map would be ignored to avoid the transient effects.
Step 3: Sequences x, y, z and w have been passed through the following equations (6) to obtain the sequences dist1, dist2, direction, mask − one and mask − two.
where x i , y i , z i and w i are the elements of x, y, z and w respectively. The remainder obtained when s is divided by t has been shown by mod(s, t). i = 1, 2, . . . , mn. Possible values of dist1 and dist2 are (−(n − 1), (n − 1)) inclusive, and (−(m − 1), (m − 1)) inclusive in a respective way. Figure 4 shows the encryption algorithm. Steps below explain the procedure.

B. ALGORITHM FOR IMAGE ENCRYPTION
Step 1: Gray image img is input in the system. Reshape it to the size 1 × mn and call it img1. Initialize the starting address  of the Castle, i.e., (startx, starty). Invoke the Algorithm 1 ISUC with the parameters img1, startx, starty, direcction, dist1, dist2, m, n to get the scrambled image img2. Algorithm 1 further calls Algorithm 2.

Algorithm 2 RemainingPixels
Input: img1, D, m, n Output: SI 1: k ← 0 2: for i ← 1 to m do 3: for j ← 1 to n do 4: if D(i, j) = −1 then 5: while img1(k + 1) = −1 do 6: k ← k + 1 7: end while 8: k ← k + 1 10: end if 11: end for 12: end for 13: SI ← D 8) Whatever value of (i, j) is selected, pixel from img(index) gets copied to the scrambled image D at (i, j) (line 40). It is to be noted that the if condition on line 39 checks whether the slot is empty. If it is, then the act of copying is carried out, otherwise, copying has not been carried out. It is to be further noted that the line at 41 assigns −1 to the img(index) so that a track can be kept for the pixels which have been copied. 9) Line 43 calls the Algorithm 2 to put the remaining pixels in the scrambled image D.  (i, j). The index k is updated on the line 9 for the next pixel.
Step 2: DNA-encode the pixels data img2 and the mask images mask − one and mask − two as follows.
Step 3: Do the DNA XOR and DNA Addition operations ( Table 2) between DNA image img3 and DNA key images mask − one1 and mask − two1 for the creation of effects of diffusion as follows: where i = 1, 2, 3, . . . , mn. img5 is the resultant image after creating the diffusion effects at DNA level.
Step 4: Lastly convert the DNA strands back into their decimal equivalents as (9), shown at the bottom of the page, where i = 1, 2, . . . , mn. img6 is the resultant cipher image.
Since the proposed image cipher has been fashioned along the lines of private key (symmetric key), therefore, its decryption version will be trivial. This version can be obtained by inversing the steps of the encryption procedure.

IV. SIMULATION RESULTS
To show the practical effectiveness and do-ability of the proposed image encryption, we will simulate it in this section. For this purpose, eight gray scale test images Lena, Baboon, Moon, Clock, Camera man, Airplane, Aerial, Chemical plant have been selected from the USC-SIPI Image Database. Each of these images have the size of 256 × 256. MATLAB 2016 version with 64-bit double-precision and standard of IEEE 754 [40] has been used to carry out the computer experiments of the proposed encryption/decryption algorithms.
To ignite the chaotic system for the generation of the streams of random numbers, these system parameters and initial values have been given to it:  Figures 5, 6 and 7 draw original plain images, encrypted images obtained after application of proposed cipher upon them and the decrypted images after applying the proposed decryption algorithm on the encrypted images. One can see that the proposed cipher has radically turned the test plain images into very unrecognizable format. Further, the plain images have been successfully retrieved after applying the decryption algorithm over the encrypted images. This vividly demonstrates the workability of the proposed algorithm.

V. PERFORMANCE AND SECURITY ANALYSES
Just visual inspection doesn't suffice the security requirements of any cipher as was done in the previous section.
118260 VOLUME 9, 2021   Researchers have developed a plethora of objective yardsticks to analyze the different security facets of any cipher. This section is for carrying out the performance and security analyses of the suggested image encryption using those yardsticks often called the validation metrics. Different metrics analyze the different aspects of the security of any cipher. These metrics normally include key space, key sensitivity, histogram and its variance, correlation coefficient, information entropy, differential attack, mean absolute error, peak signal-to-noise ratio, floating frequency, noise & data loss attacks, computational complexity and encryption throughput etc. Further, we have taken these studies [41]- [44] from the published works for the sake of comparison based on the different validation metrics.

A. KEY SPACE
Set of all possible secret keys of a cipher constitutes its key space. Sufficiently large key space serves as a great immunity to the potential brute-force attacks. Hackers try all the possible values of the secret key over the cipher until the concerned key is not found in this attack. To foil this attack, key space should be so much large that trying all the possible secret keys upon the cipher should not be feasible in the practical time. The researchers have evolved a consensus that 2 100 [44] is the minimum key space to counter the brute-force attack. So, to ensure security from this attack, key space of algorithms should be minimum of this value 2 100 . The secret key of the proposed cipher consists of the initial values x 0 , y 0 , z 0 , w 0 and the system parameters a, b, c, d, b 1 , b 2 , b 3 , b 4 of the chaotic map being used. If the computer precision of 10 −14 is assumed then key space comes out to be 10 14×12 = 10 168 . Apart from that, upon including the values of initial address of the Castle to start its journey on the chessboard i.e., (startx, starty) and DNA keys, i.e., DNAKey1, DNAKey2, DNAKey3 and DNAKey4 in the key space, it becomes 10 168 × 2 48 ≈ 2.81 × 10 182 , we are assuming here a 256 × 256 chessboard. Key space of 2.81 × 10 182 is far more greater than the minimum threshold of 2 100 . So the proposed cipher is immune from the threat of brute-force attack. Moreover, the Table 3 draws a comparison of the proposed cipher with some other published works. One can see that the proposed scheme beats these schemes [41], [44] regarding the key space.

B. FLOATING FREQUENCY
As the images are confused and diffused, the good ciphers are expected to render the encrypted images in such a way that the chaotic data has been distributed uniformly in all its sections (rows and columns). This is what the floating frequency instrument does [45]. Contrarily, if both rich and poor sections of encryption exist in the cipher images, they will be caught through this powerful security parameter. As far as the procedure of this parameter is concerned, windows of 256 elements (based on row and column) taken from the plain and cipher images are examined. During this examination, it is appraised that how many intensity values of the pixels are distinct with each other. Normally, two parameters VOLUME 9, 2021 (RFF) and (CFF) are employed. They stand for row floating frequency and the column floating frequency respectively. Following is the three step mechanism for the evaluation of this parameter. 1) Proceeding in a systematic fashion, windows of 256 pixels are taken from rows and columns of the given image. 2) Against each selected window, the RFF and CFF for the pixel intensities are determined. 3) Draw both RFF and CFF after finding their mean values. The CFF and RFF can be seen in the Figure 8 for the Lena's plain and cipher images. Specifically, in the Figure 8a, for the columns ranging from 1 to 256 of the plain image of Lena, the graph of floating frequency has been drawn. With the same pixels' intensity values, there are relatively more pixels. Hence, the values of CFF are low against all the selected windows. In contrast to that, relatively less pixels with the same intensity values exist in the Figure 8b. To put this in other words, there are more pixels with the different intensity values in each column. Such kind of phenomenon corresponds to the better ciphers. It further explains the high values of CFF. It is to be further noted that 128 and 162 respectively are the values of the means for the Lena's plain and encrypted images. In the percent form, this corresponds to 128 256 ×100% = 50% and 63% respectively. A greater percentage of CFF in the cipher image is indicative to the better security effects. In the same way, Figures 8c and 8d show the RFF for the Lena plain image and its encrypted version with the mean values of 107 and 161 respectively. 42% and 63% come out to be the their values in the percent form. Undoubtedly, more percentage of RFF in the encrypted versions of the plain images is better for the image ciphers.

C. KEY SENSITIVITY
The image ciphers furnished with the extreme key sensitivity are more secured. So this characteristic should not be ignored at all, while engineering any cryptographic product. This sensitivity is demonstrated using both the encryption and decryption algorithms of the cipher. In the encryption algorithm, a faint modification is introduced in the secret key. Encrypted image obtained ought to be totally distinct from the one which was obtained without introducing any change in the key. Same should hold true in the decryption algorithm, i.e., a very little change is made in the key and decryption algorithm is invoked. The original plain image should not be retrieved unless the 'verbatim' key is not employed.
The key sensitivity test for the proposed encryption algorithm has been performed by using the two slightly different keys for encrypting the single plain image. Suppose the initial key set is x 0 , y 0 , z 0 , w 0 , a, b, c, d, b 1 , b 2 , b 3 , b 4 and say this as K 0 . By using this key, the encryption algorithm has been applied on the plain image of Lena ( Figure 9a) and cipher image of Lena has been obtained and drawn in the Figure 9b. Now, a very minute tempering of 10 −14 is introduced in the variable x 0 of the secret key,  (d) Differential image between (e) and (f); (g) Decrypted image from (h) using correct key K 0 ; (i) Decrypted image from (j) using wrong key K 1 ; (k) Decrypted image from (l) using correct key K 1 ; (m) Decrypted image from (n) using wrong key K 0 .
i.e., x 0 = x 0 + 10 −14 . Other keys have been remained unchanged. In this way, a second set of keys has been obtained, i. e., x 0 , y 0 , z 0 , w 0 , a, b, c, d, b 1 , b 2 , b 3 and b 4 and call it as K 1 . Next, by using K 1 , the same Lena image of Figure 9a is encrypted and cipher image obtained is drawn in the Figure 9c. Besides, Figure 9d shows the differential image (obtained by pixel-to-pixel difference) between these two images. Apart from that, even tiny change of (10 −14 ) exists in keys, encrypted image in Figure 9b has 99.6384% differences from the one in Figure 9c regarding the pixel values.
For checking this sensitivity in a more sophisticated manner, rates of difference have been found between two cipher-images rendered by K 0 and K t (t = 1, 2, . . . 24). Keys K 0 and K t (t = 1, 2, . . . 24) are slightly different. Table 4 lists the results obtained. The Table 4 shows that the least difference rate between any two encrypted images is 99.5809% which is slightly greater than [46]. Average value of this metric calculates to be 99.62% which is better than [47], [48]. These metrics depict that the proposed image encryption is better than the others.
To check this sensitivity regarding second case, K 0 and K 1 are used for decrypting encrypted images of the Figures 9b  and 9c respectively. Resultant decrypted images are drawn in Figures 9e-9h. These figures vividly demonstrate the feature of the proposed image cipher that encrypted images can be recovered only by employing the correct keys. Even a very faint change in any variable of the key set causes to end with the entirely different image. Hence, we can assert that the important feature of key sensitivity runs through the very fabric of both the encryption and decryption machineries of the algorithm.

D. STATISTICAL ANALYSIS
In statistical analysis, normally, histogram and correlation analyses are covered.

1) ANALYSIS OF HISTOGRAM
An image is basically a peculiar combination of pixels with distinct intensity values. Histogram shows pixel values' distribution in a pictorial form. Histograms of normal images have a very curved and slanting bar which is replete with a lot of information about the image. The way, its bar goes up and down, is very attractive and fascinating to the cryptanalysis savvy. So the principal job of any image cipher is to restructure pixels' intensity values in a way that resultant histogram made through it contains a very uniform bar. This uniformity is a great immunity for the potential histogram attack. Histograms of Lena's plain and encrypted images have been drawn in the Figures 10a and 10b respectively. We can see that the histogram bar for the plain input image is going up and down, whereas the bar of cipher image is uniform. Uniform bars of the histogram act as a great barrier to the histogram attack over the ciphers. Set aside the visual results of the histograms regarding their bars, there exists an objective criterion for the quantification of the uniformity of a histogram, called variance. The relatively lesser values of this metric correspond to the higher uniformity of the histograms and vice versa [49], [50].
The mathematical formula for the calculation of variance is [51] var(P) = 1 n 2 where P is the 1D array of the values of histogram and P = {p 1 , p 2 , . . . , p 256 }. Here p i and p j refer to the frequency of pixels whose gray values are equal to i and j respectively. Variance values for the histograms of the cipher images of Lena, Baboon, Camera man, Airplane, Moon, Clock, Aerial, Chemical plant images can be seen in the Table 5. Variances in the first row of the table have been computed by initial key set K 0 , whereas, the ones in the remaining rows are obtained by modifying key which is K t (t = 1, 2, . . . 24) defined in the Section V-C. Table 5 shows that the average variance value for the selected images is 265.3581. Further, the variance for the Lena cipher image is 232.5076 which is better than [42].
Hence the proposed cipher is better.

2) CORRELATION ANALYSIS
Pixels of normal images are fashioned in such a way that a strong correlation exists between the neighboring pixels. Any two neighboring pixels residing in the horizontal, vertical or diagonal way are termed as adjacent/consecutive pixels. The prime focus of any image encryption algorithm is to dismantle this strong nexus between the consecutive pixels. Once these adjacent pixels are dismantled, the correlation among the adjacent pixels drops down steeply and the normal image becomes a noise-like image which can not be recognized. No correlation exists for an ideally randomized image.
To measure this metric, we have chosen arbitrarily 3,000 pairs of adjacent pixels. These pixels have been chosen for the plain and cipher images of Lena. Further, these pairs have been taken for the vertical, horizontal and diagonal directions. Mathematical formulation (correlation coefficient CC) for the computation of this metric is [49]: In the above equation, N is the total number of pixels whereas, x and y are the pixel intensity values of two adjacent pixels. Correlation distributions drawn in the horizontal, vertical and diagonal orientations have been depicted in the Figure 11. Further, this figure covers the plain and encrypted images of Lena.
Moreover, the values of correlation coefficients have been written in the Table 6. The values of this metric are close to 1 for the plain image whereas, they are close to 0 if the image is cipher. The Table 6 and Figure 11 jointly demonstrate that the relation between the plain image and cipher image has been reduced dramatically. To put this phenomenon in  the other words, the pixels of the plain image have undergone an across the board breakage. Table 7 has further drawn a comparison of this metric between the proposed algorithm and the ones published in the literature [41]- [44]. The majority of the results of the proposed algorithm are competitive.

E. INFORMATION ENTROPY ANALYSIS
Entropy connotes disorder, unpredictability, randomness and other words of such character. After the application of an image cipher over the plain image, its pixels are disarrayed significantly. To measure this disorder in the pixels of the image, naturally, we require such a formula which may guage    this disorder. Luckily, the formula given by Shannon [52], in 1949, does this job: The entropy value for the information source m has been denoted by H (m) in the above equation. Further, the probability of the symbol m i has been referred to by p(m i ). If some image with 256 gray values has been randomized to the idealistic proportions then the value of this metric calculates to be 8. The ciphers having value nearer to 8 bear greater security effects. Table 8 gives the entropy values for the various images. According to this table, the average measure of this metric for the images is very close to 8, the ideal value. Hence, the proposed algorithm is defiant to the entropy attack. Besides, this table also draws a comparison of this metric with some other algorithms in the published works. Proposed algorithm is superior than those in [41], [42], [44] for the Lena image regarding the validation metric of information entropy.

F. LOCAL SHANNON ENTROPY
A good image cipher is expected to distribute the pixels of the given image randomly to defy the varied attacks. The concept of local Shannon entropy (LSE) represents a relatively stricter expression of the randomness of the image pixels [53]. For the given image img, if k non-overlapping blocks S 1 , S 2 ,. . . ., S k with T B pixels are selected randomly, then the LSE is defined mathematically as where H (S i ) is the Shannon entropy of image block S i and can be defined as where L is the total number of pixel values and p(l) is the probability of l th value. According to the set of recommendations given in [53], the parameters (k, T B ) are set as (30,1936). Moreover, for the significance α = 0.05, the ideal value of LSE comes out to be 7.902469317 and an image is considered to pass the test if 7.901901305 ≤ LSE ≤ 7.903037329. Table 9 shows LSE values for the given encrypted images. Except one image, all the other images have passed the test of LSE. We can infer that the proposed image cipher has the capability to encrypt the plain images into their encrypted versions with requisite randomness for majority of the images.

G. PLAINTEXT SENSITIVITY ANALYSIS (DIFFERENTIAL ATTACK)
Hackers exploit every opportunity to have an access over the original plain images. One opportunity is to make a very minor corruption in the input image; encrypt the two images, i.e., one without the minor change and the other with a minor change, and find some meaningful relationing between the cipher and plain images. This explains the term ''Differential attack.'' To cope with this scenario, two security parameters, i.e., NPCR: Number of Pixels Change Rate and UACI : Unified Average Changing Intensity have been put forward by the researchers to observe the implications of modifying the intensity value of a single pixel in the plain image on the resultant cipher image. Their mathematical formulations are where M and N represent the width and height of the image respectively. D(i, j) can be defined by: (17) where C: cipher image with no change in the intensity value of the pixels and C : cipher image obtained after the modification of the single pixel value.  These values of the selected images have been written in Table 10. The average values of NPCR and UACI are 99.6061% and 33.5019% respectively which vividly prove that the suggested encryption scheme is sufficiently potent to withstand the differential attacks of NPCR and UACI . Besides, Table 11 compares our values of NPCR and UACI for the Lena image with some published works [41]- [44]. The proposed method has the better values of NPCR as compared to the ones given in [41]- [44]. Unfortunately, UACI values of the proposed scheme are not competitive.

H. PSNR ANALYSIS
PSNR stands for Peak signal-to-noise ratio. Notion behind the paradigm of image encryption is to cause an optimal difference between the two images. These images are input plain image and the output encrypted image. A validation metric called PSNR is normally employed to guage this difference. The mathematics corresponding to this concept is [5] Table depicts that the PSNR values are always infinite (∞) for the original and decrypted images. A fact that can be readily inferred from this phenomenon is MSE = 0. We will further infer that the proposed encryption scheme is lossless. Moreover, the proposed algorithm renders the better results of PSNR metric for the Lena image when compared with [54], [55].

I. MEAN ABSOLUTE ERROR (MAE)
This metric finds the difference/discrepancy in the plain input image and the encrypted output image. For the better security effects, its value should be large. Mathematically, this can be written as: In the equation for MAE, P corresponds to the plain image and C to the cipher image. c and d are the width and height of the image. Table 13 gives the results of this important metric. Besides, this table also compares our results with those of some other schemes [41], [42], [54], [56]. Our scheme performs better than the ones given in [41], [42] for the Lena image.

J. NOISE AND DATA CROP ATTACKS
Real world is very precarious and fuzzy. Things do not always proceed as they are expected. Sometimes, the encrypted images get contaminated due to some noise either during the  storage or during their transmission from one point to the other. Apart from that, some portion of an image may get lost, often called data crop attack. A nice encryption scheme has the inbuilt quality to bear the noise and data loss attacks. With different noise densities, Figures 12a to 12d depict the cipher images which have been adulterated by the noise of Pepper & Salt. These noise densities are respectively 0.1, 0.2, 0.3 and 0.4. Now to restore the original plain images, the decryption algorithm has been applied on these adulterated figures and the results obtained have been drawn in the Figures 12e to 12h. One can easily appreciate that a considerable original visual information is still intact.
Besides, using different data loss attacks, Figures 13a to 13c draw the encrypted images of Lena, Baboon and Camera man. Later on, these images were sent to the decryption machinery. Figures 13d to 13f plot the decrypted images so obtained. Again one can easily appreciate the original plain images. Hence we are justified in saying that the proposed image encryption and decryption schemes have the inbuilt ability to avert any threat of data loss and noise attacks.

K. ENCRYPTION TIME AND COMPLEXITY ANALYSIS
The proposed image cipher has been programmed under the Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz, RAM = 8.00 GB, System Type: 64-bit Operating System, x64-based processor. Moreover, Windows 10 and MATLAB R2016a are respectively the operating system and the programming language, which have been used in this study.  Certainly, the security is the topmost objective for any endeavor of cryptography. Encryption time, although less important than security, is also a very important consideration for the cryptographers. The ciphers having relatively less response time witness rosier prospects for their application in the industry. Normally the security and time are reciprocally interrelated. So, this is the job of the cryptographer to come up with a proper equilibrium between these two competing requirements while writing any cipher. In academia, two methods exist for the speed/performance analysis of the algorithms. These two methods are often called as empirical and theoretical methods. In the former method, the response time of the algorithm is directly figured out by using the timing devices like stopwatch. Table 14 shows the consumption of VOLUME 9, 2021 time by the cipher in encrypting the chosen images. The average time taken for all the images is 2.7236 seconds which is better than [43]. Besides, a relevant idea dubbed as encryption throughput (ET) is also discussed by researchers in this context. ET provides a sort of rate since it corresponds to the quantity of image being encrypted in the given time. The average value of ET for all the chosen images is 0.1941 which is better than 0.1707 [43].
Although empirical analysis is very simple, trivial and straightforward approach to measure the speed performance of the ciphers, but it is plagued with a number of loopholes. For instance, the time taken by the ciphers do not directly emanate from the body of algorithms, rather, it is 'polluted' due to the number of other extrinsic factors like particular input, underlying software and hardware, compiler etc. To transcend these particularities and limitations, a new setting is required which renders us a pure and innate performance of the algorithm under analysis. The latter or theoretical analysis provides us this setting. In it, Asymptotics [57] -a theory of mathematics, is usually employed. Here the computational complexity for the generation of the chaotic data and the image cipher will be analyzed. The time consuming operations for converting the raw data given by the chaotic map into the five key streams, i.e., dist1, dist2, direction, mask − one and mask − two take (5mn) in Step 3 of the Section III-A. The time consuming parts of the algorithm ISUC contributes (5mn) cost in Step 1 of the Section III-B. The cost for DNA encoding both the image and mask images is (3mn) in Step 2. Further, the operations of DNA XOR and DNA Addition cost (2mn) in Step 3. Lastly, the cost for converting the DNA encoded image to the decimal form is (mn) in Step 4. By adding all these costs, the total cost is (16mn), which is better than (24mn) [41] and (24mn) [42].

VI. CONCLUSION
The proposed image cipher has harnessed the potential of theory of chaos, DNA computing and chess piece Castle in one setting. Four dimensional chaotic map provided the streams of random numbers to perform the confusion and diffusion operations. The random movement of Castle on the hypothetical large chessboard scrambled the pixels of the given input gray scale image. To realize the diffusion effects, the scrambled image and the two streams of random numbers were converted into DNA strands followed by the DNA XOR and DNA Addition operations. These DNA level diffusion operations gave very promising results. SHA-256 hash codes have been introduced in the encryption algorithm in order to incorporate the plaintext sensitivity. Comprehensive security analyses and the computer simulation depict the robustness, impregnability and immunity to the diverse threats and the potential for some real world application of the encryption algorithm.
MUHAMMAD ATIF received the Ph.D. degree from Eindhoven University of Technology, The Netherlands, in 2011. He is currently an Associate Professor and the Head of the Computer Science and Information Technology Department, The University of Lahore. He is also working as an Assistant Director of the Office of Research, Innovation, and Commercialization (ORIC) and supervising various research and development projects. His research interests include the formal analysis of distributed algorithms and machine learning.
MUHAMMAD ADNAN KHAN received the B.S. and M.Phil. degrees from International Islamic University, Islamabad, Pakistan, by obtaining the Scholarship Award from the Punjab Information and Technology Board, Government of Punjab, Pakistan, and the Ph.D. degree from ISRA University, Pakistan, by obtaining the Scholarship Award from the Higher Education Commission, Islamabad, in 2016. He is currently working as an Assistant Professor with the Pattern Recognition and Machine Learning Laboratory, Department of Software, Gachon University, South Korea. Before joining Gachon University, he worked in various academic and industrial roles in Pakistan. He has been teaching graduate and undergraduate students in computer science and engineering for the past 12 years. He is also guiding five Ph.D. scholars and six M.Phil. scholars. He has published more than 190 research articles with Cumulative JCR-IF 290+ in international journals as well as reputed international conferences. His research interests include machine learning, MUD, image processing and medical diagnosis, and channel estimation in multi-carrier communication systems using soft computing.
MUHAMMAD HANIF received the B.S. degree in information technology from the University of Malakand, Pakistan, the M.S. degree in information technology from SEECS, NUST, Islamabad, Pakistan, and the Ph.D. degree in computer science from NCBA&E, Lahore, Pakistan. He is currently working as an Assistant Professor with the Department of Computer Science, Bahria University, Lahore Campus, Pakistan. He was with various academic institutions and has supervised numerous bachelor's and master's students for the past eight years. His research interests include images cryptography, computer graphics, networking, cloud computing, and the Internet of Things.
SAGHEER ABBAS received the Ph.D. degree from the School of Computer Science, NCBA&E, Lahore, Pakistan, in 2016. He is currently working as an Associate Professor with the School of Computer Science, NCBA&E. He has been teaching graduate and undergraduate students in computer science and engineering for the past eight years. He has published about 80 research articles with Cumulative JCR-IF 150+ in international journals as well as reputed international conferences. His research interests include cloud computing, the IoT, intelligent agents, image processing, and cognitive machines with various publications in international journals and conferences.
DILDAR HUSSAIN received the B.S. degree in computer science from Kohat University of Science and Technology, Pakistan, in 2010, and the Ph.D. degree in biomedical engineering from Kyung Hee University, South Korea, in 2019. From 2013 to 2019, he worked as a Research and Development Engineer with YOZMA BMTech Company Ltd., South Korea, where he developed diagnostic imaging equipment instruments, such as DXA, Chats X-rays, and Ultrasonic. He is currently working as a Postdoctoral Research Fellow with the School of Computational Science, Korea Institute for Advanced Study (KIAS), which is a subordinate institute of KAIST, South Korea. His research interests include bioinformatics, medical imaging, medical image analysis, computer vision, biomedical natural image processing, artificial intelligence, machine learning, deep learning, and mineral and nutritional study.