For decryption, the above stages are performed in reverse after generating the same 15 keys plus the initial key, and the last key is used first and applied to the pixels in the backwards direction. The XOR operation with the current key is performed directly with the encrypted pixels in the red and green vectors before performing decoding using the DNA matrix. Finally, the matrix is used for rearrangement.
4.2. Initial Permutation of Merged Bit String
In this section, we explain the basic steps for performing the initial permutation of the input RGB image using the key. To make things simple and clear, we go step by step in the first round, where the proposed approach accepts an RGB image and a
-bit secret key. Let the secret key =
. The first eight steps of our algorithm are related to random permutations of the pixels’ bits. These steps are repeated
times, 1 at the beginning of each round. At each round, the round key is used, which is generated according to the logistic function defined in Equation (1) as described in
Section 4.1. The first step is to extract the three color channels from the RGB image, which are the red channel
, the green channel
and the blue channel
, as shown in
Figure 1. These channels are considered three matrices, and each one has the same number of rows and columns. Each matrix of these matrices is converted into its corresponding vector.
Let the three channels be defined as follows:
In this sense, the red channel vector equals .
The green channel vector equals .
The blue channel vector equals .
The second step is to convert the 16-character key into its binary 128-bit equivalent. In our case, we choose the key
, so the bit representation is as follows:
Next, the first
bits are extracted from the key and assigned to
. The second
bits are extracted and assigned to
, and the third
bits are extracted and assigned to
. Then, all these bits are converted into their decimal values. In our case:
Next, we use these values to determine the amount of circular left shifts that we should perform on the red vector, green vector and blue vector. Different kinds of shifts (right or left) may be performed to increase the amount of randomness. However, you should remember the order in which different kinds of shifts have been made to be able to decrypt the cipher image. The rotation is performed by the obtained decimal values. When applying to previous vectors corresponding to matrices, it seems as though the shifts are being repeated too much, but regarding an actual image of size , for example, the vector is , which is larger than the maximum possible number of shifts, which is . When applying the previous step to the three vectors, the red vector is shifted left by , the green vector is shifted left by and the blue vector is shifted left by . The results are a random arrangement of pixels on the three independent vectors.
The red channel vector is .
The green channel vector is .
The blue channel vector is .
The last step is to construct a random matrix of
, which contains numbers from 0 to 23 as follows:
Taking the first bits from the key, bits from to determine the number of left shifts to the rows, and bits from to determine the number of up shifts to the columns. The operation is conducted as follows:
Bits determine the number of left shifts to the first row.
Bits determine the number of left shifts to the second row.
Bits determine the number of left shifts to the third row.
Bits determine the number of left shifts to the fourth row.
Bits determine the number of left shifts to the fifth row.
Bits determines number of left shifts to the sixth row.
Bits determine the number of up shifts to the first column.
Bits determine the number of up shifts to the second column.
Bits determine the number of up shifts to the third column.
Bits determine the number of up shifts to the fourth column.
After determining the number of rolls at each row and column, the rolling is performed according to the following procedure:
The first row is rolled left by , and then the first column is rolled up by .
The second row is rolled left by , and then the second column is rolled up by .
The third row is rolled left by .
The fourth row is rolled left by .
The fifth row is rolled left by , and then the third column is rolled up by .
The sixth row is rolled left by , and then the fourth column is rolled up by .
In our example the first bits of the key are , so we perform the following:
The first row is rolled left by , and then the first column is rolled up by .
The second row is rolled left by , and then the second column is rolled up by .
The third row is rolled left by .
The fourth row is rolled left by .
The fifth row is rolled left by , and then the third column is rolled up by .
The sixth row is rolled left by , and then the fourth column is rolled up by , which is equal to rolling up by 0.
After applying these shifts, the final map is:
The final map matrix is converted into a vector that represents the permutation of
bits merged from the red, green and blue channels of the current pixel. The map vector is as follows:
This means that bit number 16 is the first bit, bit number 21 is the second bit, etc. For example, the pixel at the second row and second column in the original matrices for red, green and blue is
. Remember that we should work on already rotated vectors, but this is only for the illustration of the permutation process. Each value is converted into binary, and the 3-bit strings are merged together as follows:
We then permute the bits according to the
vector, and the permuted bit string is equal to
Then, we convert each 8 bit to its corresponding decimal value as follows:
Figure 2 shows the scrambled image after the first permutation in the first round. The following are the values obtained when applying a 24-bit string permutation on the original matrices to show the amount of randomness and difference obtained.
Old Red channel
| Transposed Red channel
|
Old Green channel
| Transposed Green channel
|
Old Blue channel
| Transposed Blue channel
|
4.3. Nonlinear Rotational DNA S-Boxes
The initial Playfair cipher constructs a
matrix which contains all alphabetic letters, with the exception of a letter
or
. A secret keyword is chosen, and then a
matrix is constructed by arranging the letters of the keyword without repetition from left to right and top to bottom, followed by the rest of letters in the alphabet [
28]. The message to be encrypted is divided into diagrams or groups of two letters. When the two letters in the group are similar, another character is used as a separator and is placed between them. If the number of characters in the message is odd, a padding letter is added at the end. Substitution occurs according to the three rules listed below:
If the two letters are on the same row, they are replaced with the two letters to the right. When one of the letters is at the end of the row, it is replaced by the first letter in the row.
If the two letters are on the same column, they are replaced by the two letters below them. If one of the letters is at the end of the column, it is replaced by the first letter in the column.
If the two letters are not on the same row or the same column, a rectangle shape is made with letters, and the letters on the opposite corners are used to replace them.
In our proposed technique, we first construct an initial Playfair matrix of all possible combinations of four DNA nucleotides, starting from AAAA to TTTT. This constructs a
DNA matrix, where each entry is four DNA nucleotides, as shown in
Figure 3. Rows are numbered from 0 to 15, and columns are numbered from 0 to 15.
Next, we use the round key to randomly permutate the entries of the matrix defined in
Figure 3. The original key consists of 128-bit, and we divide it into two parts. Each part consists of
bits. The first part is organized into 16 groups. Each group consists of 4-bits, and each group is a decimal value from
to
. This decimal value is used to rotate one of the rows in the original Playfair matrix to the left. Similarly, the second part, which is 64-bit, is organized into 16 groups. Each group consists of 4-bits, and each group is a decimal value from
to
. This decimal value is used to rotate up one of the columns in the Playfair matrix. The rows are shifted left first, then the columns are shifted up. Other variants of this proposed algorithm include shifting one row to the left followed by shifting one column up. However, remember the order on which shifts are performed to be able to restore the Playfair matrix. After applying these shifts using our initial key, the produced Playfair matrix is as is shown in
Figure 4.
After producing the nonlinear random DNA Playfair matrix through key-based rotating operations, we use this matrix to encrypt the red and green channels. The operation is performed by taking one pixel from the red channel and the corresponding pixel in the green channel. Let the two values be and . Each value of these pixels is eight bits, i.e., corresponds to in binary, and corresponds to in binary. Now, we make the substitution using Playfair but with a novel idea that increases the randomness and nonlinearity of the proposed algorithm. The idea is that, instead of using static coding for converting binary strings to DNA nucleotides, we make the coding random and nonlinear based on the position that is determined by the row corresponding to the first four bits and the column corresponding to the second four bits of the 8-bit word that is being searched for in the DNA Playfair matrix. Therefore, each one of these bit strings is divided into two four-bit groups; one is used to determine the row, and the other is used to determine its column in the final DNA Playfair matrix.
The first value, 01111100, is divided into 0111 and 1100, which means that it is located at row 0111 (row number 7) and column 1100 (the column number 12). Note that we are starting from row 0. In the Playfair matrix, it corresponds to TGTG. The second value 01001110 is divided into 0100 and 1110, which means it is located at row 0100 (the row number 4) and column 1110 (the column number 14). In generated Playfair matrix, it corresponds to AGAC. After finding the two four-base DNA words, TGTG and AGAC, we apply rule three of Playfair because they are not in the same row or column, and the two values are replaced by ATGA and GGTT, which are equal to 01111110 and 01001100. We also use the 4-bit row number followed by the 4-bit column number of each word of the substituted words. The encoding is performed by replacing the four DNA nucleotide code with the corresponding 8 bits. The first 4 bits are the row number, and the second 4 bits are the column number.
We go through the red vector and the green vector to perform the same operation with one constraint after encrypting eight bits from the red and green channels. The current key has the XOR performed on it with the sixteen encrypted pixels’ values (eight encrypted pixels in the red vector followed by eight encrypted pixels in the green vector), and the new Playfair matrix is generated again. The operation is described in
Section 4.4, and it is necessary to defeat differential attacks and to make the whole obtained cipher values different if only one bit is changed in the plain image. The
DNA Playfair matrix after the first XOR with 16 encrypted pixels in the red and green channels is shown in
Figure 5.