Image_Encryption_Using_Chaos_and_Block_C
Image_Encryption_Using_Chaos_and_Block_C
1; January 2011
Abdolrasoul Mirghadri
Faculty and Research Center of Communication and Information Technology
IHU, Tehran, Iran
E-mail: [email protected]
Abstract
In this paper, a novel image encryption scheme is proposed based on combination of pixel shuffling and new
modified version of simplified AES. Chaotic baker’s map is used for shuffling and improving S-AES efficiency
through S-box design. Chaos is used to expand diffusion and confusion in the image. Due to sensitivity to initial
conditions, chaotic baker’s map has a good potential for designing dynamic permutation map and S-box. In order
to evaluate performance, the proposed algorithm was measured through a series of tests. These tests included
visual test and histogram analysis, randomness test, information entropy, encryption quality, correlation analysis,
differential analysis and sensitivity analysis. Experimental results show that the new cipher has satisfactory
security and is more efficient than AES which makes it a potential candidate for encryption of multimedia data.
Keywords: Image encryption, Shuffling, Simplified AES, Chaos, Baker’s map, S-box
1. Introduction
Visual information and imagery play an important role in almost all areas of our lives. Due to the substantial
increase in use of computers, there is an increasing tendency to security and image fidelity verification.
Transmitted images may have different applications, such as commercial, military and medical applications. So it
is necessary to encrypt image data before transmission over the network to preserve its security and prevent
unauthorized access. However, compared to text, much more processing power and bandwidth for processing is
required. In recent years a number of different image encryption schemes have been proposed in order to
overcome image encryption problems (Lv, Zhang, & Guo, 2009) (Akhshani et al., 2010) (Jolfaei & Mirghadri,
2010a). Due to desirable properties of non-linear dynamical systems such as pseudo-random behavior, sensitivity
to initial conditions and ergodicity, the chaos-based encryption has suggested a new and efficient way to deal
with the intractable problem of fast and highly secure image encryption.
In this research we have tried to find a simple, fast and secure algorithm for image encryption using the
characteristics of chaotic functions and the possibility of creating very long length keys. According to key’s large
space in the chaotic functions, this method is very robust. Finally, this algorithm is very sensitive to small
changes in key so even with the knowledge of the key approximate values; there is no possibility for the attacker
to break the cipher.
The rest of the paper is organized as follows: In Section 2, we describe the relation between chaos and
cryptography. In Section 3, we briefly introduce the methods used in this paper. The new algorithm is proposed
in section 4. In section 5, we analyze the security of the proposed image cipher and evaluate its performance
through various tests such as statistical analysis, differential analysis, key sensitivity analysis, etc and compare
the results. Finally, some conclusions are given in section 6.
2. Chaos and cryptography
Cryptography is the knowledge of protecting the privacy of information during communication under
antagonistic situations. Nowadays, cryptography plays an important role in the developing information
technologies and proliferating computer network communications. Current cryptographic methods are based on
number theoretic or algebraic concepts. Chaos is another paradigm, which seems promising. Chaos is one of the
possible behaviors associated with evolution of a nonlinear dynamic system and occurs for specific values of
system parameters. The chaotic behavior is a delicate behavior of a nonlinear system, which apparently looks
random. The discovery of this pseudo-random behavior happening as a result of deterministic systems turned out
to be quite revolutionary leading to many issues interconnecting stability theory, new geometrical features and
new signatures characterizing dynamical performances. The chaotic state can be observed by the existence in the
phase space of a chaotic attractor or fractal in which all the system trajectories evolve following a certain pattern
but are never the same. In a more analytical approach the chaotic state can be very well studied by the Lyapunov
exponents that globally characterize the behavior of dynamical systems (Kocarev et al., 2006). Chaos will be
observed only when there is at least one positive Lyapunov exponent and the total sum of all exponents is
negative, i.e. the dynamical system has a stable but random like state called chaotic state.
In the last two decades, Chaos theory has received a great deal of attention from the cryptographic community.
So, a remarkable number of chaotic systems, both physical and mathematical, were designed for realizing
encryption and decryption of messages in both hardware and software equipments (Patidar, Pareek & Sud, 2009)
(Etemadi Borujeni & Eshghi, 2009) (XiaoJun & MingGen, 2010).
Chaos based cryptography is still in its childhood and may not have exact parallelism to concepts and notions of
traditional cryptographic and cryptanalysis approaches. However, chaotic maps and cryptographic algorithms
have some similar properties: Pseudo-random behavior, sensitivity to initial conditions and parameters and
unstable orbits with long periods, depending upon the precision of the numerical implementation. Encryption
rounds of a cryptographic algorithm lead to diffusion and confusion properties. In a similar manner, iterations of
the chaotic map spread the initial region over the entire phase space.
3. Methods
We used baker’s map and S-AES algorithm to construct our new approach that are described as follows:
3.1 Baker's map
The baker’s map, invented by Eberhard Hopf in 1937, is an intuitively accessible, two-dimensional
chaos-generating discrete dynamical system (Fridrich, 1998) (Machado, Baptista & Grebogi, 2004). This is a
simple example of a map similar to a horseshoe, although it is a discontinuous map (Lichtenberg & Lieberman,
1992). Consider the map F for the half-open square [0,1) [0,1) onto itself where
( x) 2 x mod 1 0 (x ) 1,
1 1
2 ay 0 x
2
g ( a, x, y ) mod 1 0 g 1.
1
( ay 1) 1
x 1
2 2
2 0
Note that (0, 0) is the only fixed point of F, and it is unstable. The Jacobian matrix of F is J 1 for
0 2 a
almost all x, so det(J ) a . Therefore F is area preserving if and only if a 1 .
Consider first the case a 1 . Then the geometrical nature of the map is depicted in figure 1(a), where it is seen
that the map is equivalent to a horizontal stretching and vertical contraction, followed by a vertical cutting and
stacking. This resembles the preparation of dough, so F is often called the baker’s transformation (Lichtenberg &
Lieberman, 1992). When 0 a 1 , areas are contracted by F. We show F(S) in figure 1(b), where S is the unit
square.
The iterative relation of the baker’s map used in the proposed scheme is as follows (Otto & Denier, 2005):
x n 1 (x n y n ) |1 y n 1 (x n 2 y n ) |1.
Figure 2 demonstrates the pseudo-random number sequence generated by baker’s map for the initial points of x0
= 0.5 and y0 = 0.4 for 100 iterations.
5: D (it1) ← x n2 y n2
6: End For
7: For it1 = 1: NoIt do
8: M ← Max {D}
9: For it2 = 1: NoIt do
10: If D (it2) == M do
11: D (it2) ← -16 + it1
12: End If
13: End For
14: End For
15: S-box ← |D|
Table 1 shows a generated S-box using x = 0.2 and y = 0.3 as seed points of chaotic mapping. In this table, the
intermediary output of the inversion is not shown.
So, an equivalent replacement block for the S-box is built using two-dimensional chaotic baker’s map. The new
generated S-box is reversible and has random properties. According to the proposed scheme, each time that the
cryptographic algorithm runs, a new S-box is generated according to a seed point derived from an external secret
key. Hence, encrypting the same plain-images leads to different cipher-images. Using dynamic S-box increases
schemes resistance against differential and linear cryptanalysis and causes an increase in the system security.
Since the structure of the S-boxes is completely hidden from the cryptanalyst, these attacks have a more difficult
time exploiting that structure. Moreover, these S-boxes can be created on demand, reducing the need for large
data structures stored with the algorithm. The essential cryptographic characteristics and requirements for
obtaining good S-box have been checked and results showed the satisfactory level of them.
5. Security analysis
In this section we performed a series of test to justify the efficiency of the proposed image encryption scheme
and compared the results with AES. The evaluation consisted of theoretical derivations and practical
experimentation. A good encryption scheme should resist all kinds of known attacks, such as known plaintext
attack, ciphertext-only attack, statistical attack, differential attack and various brute-force attacks. We used the
following quantitative measures to evaluate the security of the proposed image encryption scheme (Jolfaei &
Mirghadri, 2010c).
5.1 Visual test and histogram analysis
The algorithm is implemented on a computer with processor Intel Pentium V, 2.00GHz Dual. Input test
plain-image is a 256-level gray scale image with the size of 128×128. In figure 6, (a) input image, (b) shuffled
image and (c) cipher-image is shown. Plain-image, shuffled image and cipher-image histograms are depicted in
figures 6(d), 6(e) and 6(f), respectively. The histogram of shuffled image is similar to the histogram of
plain-image. This means that the corresponding statistical information in shuffled image is as equal as the
plain-image. The encrypted image histogram, approximated by a uniform distribution, is quite different from
plain-image histogram. Uniformity caused by encryption algorithm is justified by the chi-square test (L’Ecuyer
& Simard, 2007) described as follows:
256
(v k 64) 2
2 64
,
k 1
where k is the number of gray levels (256), vk is the observed occurrence frequencies of each gray level (0–255),
and the expected occurrence frequency of each gray level is 64. Assuming a significant level of
0.05, 2 (255, 0.05) 293 , chi-square value for the final encrypted image of the proposed system is 216. This
implies that the null hypothesis is not rejected and the distribution of the encrypted histogram is uniform,
2test 2 (255, 0.05) .
Relatively uniform distribution in cipher-image histogram points out good quality of method. To prevent the
leakage of information to attackers, it is important to ensure that encrypted and original images do not have any
statistical similarities. The histogram analysis clarifies that, how the pixel values of image are distributed. Figure
7 shows histogram analysis on several images having different contents and sizes using proposed algorithm. The
histogram of original images contains large sharp rises followed by sharp declines as shown in figure 7(c). And
the histogram of the encrypted images as shown in figure 7(d) has uniform distribution which is significantly
different from original image and has no statistical similarity in appearance. Therefore, the proposed algorithm
does not provide any clue for statistical attack. Plain-images and cipher-images are shown in figures 7(a) and
7(b), respectively.
5.2 Randomness test
To ensure the security of a cryptosystem the cipher must have some properties such as good distribution, long
period, high complexity and efficiency. In particular, the outputs of a cryptosystem must be unpredictable in the
absence of knowledge of the inputs. Recently, the NIST designed a set of different statistical tests to test
randomness of binary sequences produced by either hardware or software based cryptographic random or
pseudorandom number generators. These tests focus on a variety of different types of non-randomness that could
exist in a sequence. The mathematical description of each test can be found at (Rukhin et al., 2010). So, we used
the NIST test suite in order to test the randomness of the surveyed algorithm. In all tests if the computed P-value
is < 0.01, then conclude that the sequence is non-random. Otherwise, conclude that the sequence is random.
Figure 8 depicts the NIST tests results and illustrates that the image sequences encrypted by the AES and the
proposed scheme have no defect and pass all the statistical tests with high P-values.
5.3 Information entropy
Information theory is the mathematical theory of data communication and storage founded in 1949 by Shannon
(Stinson, 1995). Modern information theory is concerned with error-correction, data compression, cryptography,
communications systems, and related topics. It is well known that the entropy H(s) of a message source s can be
calculated as:
2 N 1 1
H (s ) i 0 P (s i ) log 2
P (s i )
,
where P (s i ) represents the probability of symbol si and the entropy is expressed in bits. Let us suppose that the
source emits 28 symbols with equal probability, i.e., s {s1 , s 2 ,..., s 28 } . After evaluating equation (7), we
obtain its entropy H (s ) 8 , corresponding to a truly random source. Actually, given that a practical information
source seldom generates random messages, in general its entropy value is smaller than the ideal one. However,
when the messages are encrypted, their entropy should ideally be 8. If the output of such a cipher emits symbols
with entropy less than 8, there exists certain degree of predictability, which threatens its security. Let us consider
the ciphertext of the plain-image shown in figure 4(a). The number of occurrence of each gray level is recorded
and the probability of occurrence is computed. The entropy is as follows:
1
i 0 P (s i ) log2 P (s i ) 7.9902 8.
255
H (s )
The value obtained is very close to the theoretical value of 8. This means that information leakage in the
encryption process is negligible and the encryption system is secure upon the entropy attack.
5.4 Measurement of encryption quality
Image encryption quality measure is a figure of merit used for the evaluation of image encryption techniques.
With the application of encryption to an image a change takes place in pixels values as compared to those values
before encryption. Such change may be irregular. This means that the higher the change in pixels values, the
more effective will be the image encryption and hence the encryption quality. So the encryption quality may be
expressed in terms of the total changes in pixels values between the original image and the encrypted one. A
measure for encryption quality may be expressed as the deviation between the original and encrypted image
(Ahmed, Kalash & Farag Allah, 2006) (Jolfaei & Mirghadri, 2010d). The quality of image encryption may be
determined as follows:
Let P and C denote the original image and the encrypted image respectively, each of size H×W pixels with L
grey levels. P (x , y ),C (x , y ) {0,..., L 1} are the grey levels of the images P and C at position (x, y),
0 x H 1 , 0 y W 1 . We will define H L (P ) as the number of occurrence for each grey level L in
the original image (plain-image), and H L (C ) as the number of occurrence for each grey level L in the
encrypted image (cipher-image). The encryption quality represents the average number of changes to each grey
level L and it can be expressed mathematically as:
255
| H L (C ) H L (P ) |
Encryption Quality L 0 .
256
The encryption quality test was performed using the input image of size 128×128 shown in figure 4(a). The
encryption quality of the proposed scheme is 70.6250 while the encryption quality of AES is 69.5250.
5.5 Correlation coefficients analysis
In the image data each pixel is highly correlated with its adjacent pixels (Pisarchik & Zanin, 2008). An ideal
encryption algorithm should produce the cipher-images with no such correlation in the adjacent pixels.
Following equations are used to study the correlation between two adjacent pixels in horizontal, vertical and
diagonal orientations.
NPCR
i , j D (i , j ) 100%,
H W
where D (i , j ) is defined as
0, if C1 (i , j ) C 2 (i , j ),
D (i , j )
1, if C1 (i , j ) C 2 (i , j ).
Tests have been performed on the proposed scheme, about the one-pixel change influence on a 256 gray-scale
image of size 128×128. The MAE experiment result is shown in table 2. It is illustrated that there is a slight
fluctuation between MAE of row, column-row and diagonal-column-row permuted image. The MAE of shuffled
image is about 32 while the MAE for encrypted image is about 84. The MAE of encrypted image is 159 percent
more than MAE of shuffled image. The larger the MAE value, the better the encryption security. Also, the MAE
value of proposed scheme is about 1 percent higher than AES’s. The NPCR and UACI test results are shown in
table 3. Results obtained from NPCR show that the encryption scheme is not sensitive to small changes in the
input image. The UACI estimation result shows that the rate influence due to one pixel change is very low. The
results demonstrate that a swiftly change in the original image will result in a negligible change in the ciphered
image.
L’Ecuyer, P., & Simard, R. (2007). TestU01: A C Library for Empirical Testing of Random Number Generators.
ACM Transactions on Mathematical Software, 33(4), Article 22.
Li, S., Li, C., Chen, G., Bourbakis, N.G., & Lo, K.T. (2008). A General Quantitative Cryptanalysis of
Permutation-only Multimedia Ciphers against Plaintext Attacks. Signal Processing: Image Communication,
23(3), 212-223.
Lichtenberg, A.J., & Lieberman, M.A. (1992). Regular and Chaotic Dynamics. Springer, New York.
Lv, Z., Zhang, L., & Guo, J. (2009). A Symmetric Image Encryption Scheme Based on Composite Chaotic
Dispersed Dynamics System. In IEEE Proceedings of the Second International Symposium on Computer Science
and Computational Technology (ISCSCT ’09), China, 191-194.
Machado, R.F., Baptista, M.S., & Grebogi, C. (2004). Cryptography with Chaos at the Physical Level. Chaos,
Solitons and Fractals, 21(5), 1265-1269.
Mansoori, S.D., & Khaleghei Bizaki, H. (2007). On the vulnerability of Simplified AES Algorithm Against
Linear Cryptanalysis. International Journal of Computer Science and Network Security, 7(7), 257-263.
Musa, M., Schaefer, E., & Wedig, S. (2003). A Simplified AES Algorithm and its Linear and Differential
Cryptanalyses. Cryptologia, 27, 148-177.
Otto, S.R., & Denier, J.P. (2005). An Introduction to Programming and Numerical Methods in MATLAB.
Springer-Verlag, ISBN: 1852339195.
Patidar, V., Pareek, N.K., & Sud, K.K. (2009). A New Substitution–Diffusion Based Image Cipher Using Chaotic
Standard and Logistic Maps. Commun Nonlinear SciNumer Simulat, 14, 3056-3075.
Pisarchik, A.N., & Zanin, M. (2008). Image Encryption with Chaotically Coupled Chaotic Maps. Physica D,
237(20), 2638-2648.
Rukhin, A. et al. (2010b). A Statistical Test Suite for Random and Pseudorandom Number Generators for
Cryptographic Applications. NIST Special Publication 800-22, Revision 1a.
Shannon, C.E. (1949). Communication Theory of Secrecy Systems. Bell Syst Tech J, 28, 656-715.
Stinson, D.R. (1995). Cryptography: Theory and Practice. CRC Press LLC, ISBN: 0849385210.
XiaoJun, T., & MingGen, C. (2010). Feedback Image Encryption Algorithm with Compound Chaotic Stream
Cipher Based on Perturbation. SCIENCE CHINA Information Sciences, 53(1), 191-202.
Yang, M., Bourbakis, N., & Li, S. (2004). Data-Image-Video Encryption. IEEE Potentials, 23(3), 28-34.
Table 1. A generated S-box using baker’s map with x = 0.2 and y = 0.3 as seed points
Nibble S-box Nibble S-box
0 b 8 4
1 0 9 d
2 5 a 3
3 c b 9
4 7 c a
5 6 d f
6 8 e e
7 1 f 2
Table 3. NPCR and UACI value of AES and the proposed method
Method NPCR UACI
-3
AES <10 % <10-3%
Proposed scheme <10-3% <10-3%
(a) (b)
Figure 1. Baker’s map: (a) geometrical nature of the baker’s map, (b) area contraction by the map F
Figure 4. Permuting Tehran’s aerial image pixel location using baker’s map: (a) Tehran’s aerial image, (b)
chaotic row permutation, (c) chaotic column permutation, (d) chaotic diagonal permutation, (e) Tehran’s aerial
image histogram, (f) chaotic row permutation histogram, (g) chaotic column permutation histogram, (h) chaotic
diagonal permutation histogram
Image Size
256×256
Test 2
Image Size
512×512
Test 3
Image Size
1000×1000
Figure 7. Histogram analysis for three test images with different sizes: (a) plain-image, (b) cipher-image, (c)
plain-image histogram, (d) cipher-image histogram
(a) (b)
Figure 10. Key sensitivity test: Figures (a) and (b) show the encrypted image with its corresponding
histogram using proposed scheme with two different secret keys with slight differences