NPCR and UACI Randomness Tests For Image Encryption: April 2011
NPCR and UACI Randomness Tests For Image Encryption: April 2011
net/publication/259190481
CITATIONS                                                                                                 READS
517                                                                                                       19,830
1 author:
            Yue Wu
            Raytheon BBN Technologies
            77 PUBLICATIONS 5,446 CITATIONS
SEE PROFILE
All content following this page was uploaded by Yue Wu on 22 May 2014.
                                                                               31
  Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
hypothesis tests; Section IV shows results of the proposed                      be discernible from a true random image. More specifically,
randomness tests of NPCR and UACI for a number of                               Definition 1. Ideally Encrypted Image
published image encryption methods; Section V concludes the                     An ideally encrypted image is a random field at size of
paper and discusses our future work                                               -by- , where for any fixed integer             and            ,
                                                                                the random variable of pixel value              identically and
              II. MATHEMATICAL DERIVATIONS OF                                   independently (i.i.d) follows a discrete uniform distribution on
             NPCR AND UACI RANDOMNESS TESTS                                     0 to ’s largest supported integer , i.e.             ,           ,
A. NPCR and UACI Definitions                                                                             .
   For our best knowledge, NPCR and UACI are first shown in
                                                                                   It is noticeable that the above definition is plausible in the
2004 [5, 18], both of which point to Yaobin Mao and Guanrong
                                                                                context of image encryption, where the aim of encryption is to
Chen. Since then NPCR and UACI become two widely used
                                                                                obtain random-like ciphertext images such that attackers cannot
security analyses in the image encryption community for
                                                                                figure out the internal relations between plaintext and
differential attacks.
                                                                                ciphertext. In fact, other security analyses [5-14], e.g.
   Suppose ciphertext images before and after one pixel change
                                                                                histogram analysis, entropy analysis and autocorrelation
in a plaintext image are   and , respectively; the pixel value
                                                                                analysis, are all designed to test whether or not a ciphertext
at grid       in    and    are denoted as         and        ;
                                                                                image is random-like.
and a bipolar array is defined in Eqn. (1). Then the NPCR
                                                                                   For any pixel at any location in an ideally encrypted image ,
and UACI can be mathematically defined by Eqns. (2) and (3),
                                                                                its value is equally likely to be an arbitrary intensity level in
respectively, where symbol denotes the total number pixels
                                                                                       , namely                                . In order to save
in the ciphertext, symbol denotes the largest supported pixel
                                                                                notations, the spatial index          can be expressed by an
value compatible with the ciphertext image format, and
                                                                                absolutely index as Eqn. (4) shows. As a result, we have
denotes the absolute value function.
                                                                                                 .
                                                                                                                                                      (4)
                                                                    (1)
                                                                    (2)
                                                                                C. NPCR Test
                                                                                  In this section, the expectation and the variance of NPCR for
                                                                    (3)         two ideally encrypted images are calculated first and then an
                                                                                 -level hypothesis test is derived based on these two statistics.
It is clear that NPCR concentrates on the absolute number of                    For simplicity,
pixels which changes value in differential attacks, while the
UACI focuses on the averaged difference between two paired                      Theorem I. For the th pixels ( [1,MN]) in two ideally
ciphertext images.                                                              encrypted images defined in Definition 1, define a random
   The range of NPCR is              . When                     , it            variable
implies that all pixels in     remain the same values as in .
When                   , it implies that all pixel values in     are
changed compared to those in . In other words, it is very                       Then this random variable follows a Bernoulli distribution
difficult to establish relationships between this pair of                       with the parameter                .
ciphertext image      and . However,                         rarely                 Proof. Using the assumption of independence and       ,
happens, because even two independently generated true                          it is easy to see,
random images fail to achieve this NPCR maximum with a high
possibility, especially when the image size is fairly large
compared to .
   The range of UACI is clearly             as well, but it is not
obvious that what a desired UACI for two ideally encrypted
images is. Fortunately, these results will be given in next
sections with the form of expectations and variances.
B. Ideally Encrypted Image                                                      Consequently,                                                         .
   Before start to derive the interested statistics about NPCR                  Therefore,                        .                                         ∎
and UACI for ideally encrypted images, the term of ‘ideally
encrypted image’ has to be clarified first. Although it may be                     Moreover, if the total number of pixels whose  is
considered differently in other literature, in this paper, we                   denoted as a random variable , then has the Binomial
consider an ideally encrypted image is some image that cannot                   distribution as Theorem II states.
                                                                           32
  Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
Theorem II. The random variable                  defined on                        values in  and     are both i.i.d, pixels in         is also i.i.d with
two ideally encrypted images follows a Binomial distribution                       some unknown distribution.
          , where               .                                                                                                                     (11)
Proof. Using the conclusion of Theorem I and i.i.d property                           Let                              , then this random variable
between pixels, it is clear that                                                   for the averaged changed intensity for one pixel location in two
                                                                                   ideally encrypted images follows a discrete distribution showed
                                                                                   in Theorem III.
(7)
(8)
                                                                    (9)
                                                                                   Similarly,                                                            .
                                                                                   Thus,                                            .                        ∎
As a result, the following statistical test can be used as a test of
NPCR for image encryption:                                                            Theorem III gives the probability density function (PDF) of
                                                                                   the random variable and the i.i.d distribution in the random
Definition 2. Randomness Test for NPCR                                             field as well. In addition, the mean and the variance of can
Suppose      and     are two test ciphertext images at the size                    also be obtained as Eqns. (12) and (13) show.
  -by- , the hypotheses with α-level significance for
           , then, are
                                                                                                                                                      (12)
                                                                              33
  Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
which is the sample size believed the CLT can be applied [19,
20].                                                                                           0.02                                                   0.02
Possibility
                                                                                                                                       Possibility
shown in Eqns.(15) and (16), respectively.                     ∎                               0.01                                                   0.01
                                                                                                 0                                                      0
                                                                                                      0    20   40     60   80   100                         99.55   99.6     99.65   99.7
                                                                   (16)                                          NPCR %                                              NPCR %
                                                                           34
Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
                       50.0000%    0.7813%     48.7150%    48.1825%     47.5858%     99.6094%    0.0975%     99.4491%    99.3826%     99.3082%
                       50.0000%    0.3906%     49.3575%    49.0913%     48.7929%     99.6094%    0.0487%     99.5292%    99.4960%     99.4588%
                       50.0000%    0.1953%     49.6787%    49.5456%     49.3964%     99.6094%    0.0244%     99.5693%    99.5527%     99.5341%
                       50.0000%    0.0977%     49.8394%    49.7728%     49.6982%     99.6094%    0.0122%     99.5893%    99.5810%     99.5717%
                       50.0000%    0.0488%     49.9197%    49.8864%     49.8491%     99.6094%    0.0061%     99.5994%    99.5952%     99.5906%
                                                                       Gray Image:
                                              NPCR %                                                         UACI %
                                                                         35
Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
                                                                         36
  Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
                                                                           37
   Cyber Journals: Multidisciplinary Journals in Science and Technology, Journal of Selected Areas in Telecommunications (JSAT), April Edition, 2011
too high UACI score.                                                                 On the other hand, judging two encryption methods by
   Considering these results in Table IV and Table V, ‘Lian                      comparing their test scores quantitatively is also questionable.
2005’ [13] and ‘Zhu 2010’ [14] are two best ones among the                       In other words, better than some poor method(s)/algorithm(s) is
test ten image encryption algorithms, because they passed the                    not sufficient to say a method is good. Because it is still unclear
both the NPCR and UACI randomness tests. Although ‘Zhu                           whether this method is able to generate ciphertext images as
2010’ has slightly higher NPCR and UACI scores than those of                     random-like as those ideally encrypted images, although its test
‘Lian 2005’, it does not mean that ‘Zhu 2010’ is more secure                     score is better than some other(s). Unless comparing test
than ‘Lian 2005’, because their test scores are not statistically                score(s) with theoretical values like those derived in this paper,
different. This conclusion also points out a common mistake in                   it is hard to know whether a method is good and how good it is.
the image encryption literature: some author claims his/her
method is better than some others’ by simply comparing some                                                      REFERENCES
test scores. For example, ‘Lian 2005’ [13] is used as a reference
algorithm for comparing the NPCR and UACI scores with ‘Zhu                       [1]    E. Biham and A. Shamir, "Differential Cryptanalysis of DES-like
                                                                                        Cryptosystems," in Proceedings of the 10th Annual International
2010’ in [14], where the author claims that ‘Zhu 2010’ is better                        Cryptology Conference on Advances in Cryptology: Springer-Verlag,
than ‘Lian 2005’ by simply comparing test scores. However,                              1991.
test results of ‘Zhu 2010’ and ‘Lian 2005’ in Tables IV and V                    [2]    E. Biham and A. Shamir, "Differential Cryptanalysis of the Full
show that they do not have significant difference. This implies                         16-Round DES," in Proceedings of the 12th Annual International
                                                                                        Cryptology Conference on Advances in Cryptology: Springer-Verlag,
that maybe both algorithms are able to generate random-like                             1993.
ciphertext image and thus the different test scores are purely                   [3]    "FIPS PUB 46: Data Encryption Standard," National Bureau of Standards,
caused by the stochastic process.                                                       1977.
                                                                                 [4]    H. Williams, A. Webster, and S. Tavares, "On the Design of S-Boxes," in
                                                                                        Advances in Cryptology — CRYPTO ’85 Proceedings. vol. 218: Springer
                            V. CONCLUSION                                               Berlin / Heidelberg, 1986, pp. 523-534.
                                                                                 [5]    G. Chen, Y. Mao, and C. Chui, "A symmetric image encryption scheme
   In this paper, we discussed the NPCR and UACI randomness                             based on 3D chaotic cat maps," Chaos, Solitons and Fractals, vol. 21, pp.
tests for image encryption. Unlike the conventional usage of                            749-761, 2004.
NPCR and UACI for calculating scores, we consider both                           [6]    S. Behnia, A. Akhshani, H. Mahmodi, and A. Akhavan, "A novel
                                                                                        algorithm for image encryption based on mixture of chaotic maps," Chaos,
scores as random variables under the ideally encrypted image                            Solitons and Fractals, vol. 35, pp. 408-419, 2008.
model and derive their expectations and variances. Meanwhile,                    [7]    L. Zhang, X. Liao, and X. Wang, "An image encryption approach based
hypothesis tests with an α-level of significance are designed for                       on chaotic maps," Chaos, Solitons & Fractals, vol. 24, pp. 759-765, 2005.
                                                                                 [8]    C. X. Zhu, Z. G. Chen, and W. W. Ouyang, "A new image encryption
NPCR and UACI tests respectively. With these two hypothesis                             algorithm based on general Chen's chaotic system," Journal of Central
tests, it is easy to accept or reject the null hypothesis that test                     South University (Science and Technology), 2006.
ciphertext images are random-like. Therefore, such tests                         [9]    C. K. Huang and H. H. Nien, "Multi chaotic systems based pixel shuffle
                                                                                        for image encryption," Optics Communications, vol. 282, pp. 2123-2127,
provide qualitatively results rather than quantitatively results                        2009.
for image encryption.                                                            [10]   X. Liao, S. Lai, and Q. Zhou, "A novel image encryption algorithm based
   Experimental results show the estimated expectations and                             on self-adaptive wave transmission," Signal Processing, vol. 90, pp.
variance of NPCR and UACI are very close to the theoretical                             2714-2722, 2010.
                                                                                 [11]   Q. Zhang, L. Guo, and X. Wei, "Image encryption using DNA addition
values, which justify the validity of theoretical values. Further,                      combining with chaotic maps," Mathematical and Computer Modelling,
the proposed NPCR and UACI randomness tests are also                                    vol. 52, pp. 2028-2035, 2010.
applied to various image encryption algorithms. Test results                     [12]   A. Kumar and M. K. Ghose, "Extended substitution-diffusion based
                                                                                        image cipher using chaotic standard map," Communications in Nonlinear
show that many of these tested algorithms are problematic or at                         Science and Numerical Simulation, vol. 16, pp. 372-382, 2011.
least not statistically random-like. Meanwhile, these results                    [13]   S. Lian, J. Sun, and Z. Wang, "A block cipher based on a suitable use of
also showed that the conventionally quantitative analysis                               the chaotic standard map," Chaos, Solitons & Fractals, vol. 26, pp.
                                                                                        117-129, 2005.
methodology for image encryption is questionable. Because                        [14]   Z.-l. Zhu, W. Zhang, K.-w. Wong, and H. Yu, "A chaos-based symmetric
these test scores, e.g. NPCR or UACI, are random variables                              image encryption scheme using a bit-level permutation," Information
dependent on parameters such as the image size and the format                           Sciences, vol. 181, pp. 1171-1186, 2010.
                                                                                 [15]   M. Yang, N. Bourbakis, and L. Shujun, "Data-image-video encryption,"
of the image rather than static values. Purely comparing two                            Potentials, IEEE, vol. 23, pp. 28-34, 2004.
NPCR/UACI scores for two algorithms without noting these                         [16]   "FIPS PUB140-1: Security Requirements for Cryptographic Modules."
parameters is not fair. For example, a NPCR score based on                              vol. 11: National Institute of Standards and Technology, 1994.
                                                                                 [17]   "FIPS PUB140-2: Security Requirements for Cryptographic Modules,"
gray images is 99.5710%, which is very close to the expectation                         National Institute of Standards and Technology, 2001.
99.6094% (see Table I), but when the test image size is                          [18]   Y. Mao, G. Chen, and S. Lian, "A novel fast image encryption scheme
512-by-512, this score is out of 99.9% confidence interval                              based on 3D chaotic Baker maps," Int. J. Bifurcation and Chaos in June,
(99.5717%, 100%] of the NPCR score. This conclusion means                               2003.
                                                                                 [19]   R. Peck, C. Olsen, and J. L. Devore, Introduction to Statistics and Data
that test ciphertext images do not follow the relations between                         Analysis: Cengage Learning, 2008.
two ideally encrypted images and thus it may be vulnerable to                    [20]   M. Sternstein, Statistics: Barron's Educational Series, 1996.
differential attacks. Moreover, the significance level tells that                [21]   R. J. Larsen and M. L. Marx, An introduction to mathematical statistics
                                                                                        and its applications: Pearson Prentice Hall, 2006.
the chance of making a wrong conclusion is one out of a
thousand.
                                                                            38
View publication stats