Keywords

1 Introduction

The demands for Image encryption is constantly increasing in recent years for the privacy protection issue. One of the naive approach is to use standard data encryption method such as AES or RSA. But, such conventional methods require long computing time and, what it makes worse, it produces a file that could not be handled by the standard JPEG decoder. Such a format-incompatibility inhibits the partial encryption of images and cannot support controllability of security level. Suppose a case that we want to hide only human faces or license plates in a picture and the hidden information might be retrieved later by someone authorized such as policemen or national prosecutors for criminal investigation. In this case, partial encryption for ROI (region of interest) should be very useful. Suppose another case that we want to hide details of image information while we want reveal the overall rough contents of pictures to the public for commercial reason or public purpose. This case motivates the encryption level controllability.

A number of researches have proposed to encrypt JPEG file preserving format compliance. These include techniques such as zig zag permutation which significantly increases the file size [1] and the use of permuted Huffman tables [2]. And DC bit plane scrambling as proposed in [3] also increases the file size. A length-preserving approaches are proposed in [4] by randomly toggling DCT (Discrete Cosine Transform) DC and/or AC coefficient signs. However, this approach is known to be vulnerable to the cryptographic attacks. Some works rely on standard encryption methods. In [5], selective encryption for JPEG images based on AES cipher is proposed. The encryption is performed in the Huffman coding stage of the JPEG using the AES encryption algorithm in the CFB mode. Unterweger and Uhl [6] proposed swapping code words of equal length between blocks for AC value histogram spreading. But, this has high computational complexity.

In this paper, we present a new JPEG format-compliant encryption method which provides a spectrum of security levels (against attacks) and encryption overheads (such as time and file size) by selective encryption options. In our method, we apply different combinations of encryption options to the various stages of standard JPEG. Some of our options preserve the file size while other options try to minimizes the file size overhead that provide high security level.

2 Proposed JPEG Encryption Approach

Our proposed algorithm consists of the five options as shown in Table 1, each of which contributes in different scope and encrypt information of different domain. Our main idea is that we can achieve desired security level of encryption and computing complexity by combining these five different encryption options.

Table 1 Five encryption options of our method

Figure 1 shows the standard JPEG encoding functional blocks together with the related image encryption options mentioned in Table 1. We also represent the random number generator which uses a single 1024 bit secret key. Random number generator produces a pseudo random sequences that are used as permutation maps for MCU Shuffle, DCT Block Shuffle, and AC Shuffle operation. Also, the random sequences are used as a mask for bitwise-XOR operation for AC and DC coefficient changes. The input picture frame is divided into MCUs and each MCU consists of DCT blocks.

Fig. 1
figure 1

The functional blocks for JPEG encoding and related encryption options

Each of the above encryption option is described as follows:

  1. 1.

    MCU Shuffle: Based on the random number sequence, the MCU shuffle map is constructed. The global-level information hiding effect is achieved through the MCU block shuffle.

  2. 2.

    DCT Block Shuffle: Each MCU consists of one or more DCT blocks. In the 4:2:0 subsampling, DCT block shuffle can be applied to only Y MCU. But, no shuffling is possible with Cb and Cr DCT block with the 4:2:0 subsampling.

  3. 3.

    AC Coefficient Shuffle: After DCT and quantization stages, one DC coefficient and 63 AC coefficients are obtained in each DCT block. Most of AC coefficients become zero by quantization. The encoded non-zero AC coefficients can be shuffled within each DCT block. We perform this encryption by VLC Huffman-coded symbol shuffling within DCT code block. This option is applied to both luminance (Y) and chrominance (Cb and Cr) DCTs.

  4. 4.

    AC Value Change: The VLC Huffman-coded symbol for AC values can be changed by bitwise-XOR operation with random bitmask. The random mask is obtained from a bit slice of the random number sequences generated by the PRNG (Pseudo Random Number Generator). The AC coefficients are encoded as a pair of ‘number of bits for code’ + ‘code value’, and the ‘code value’ can be replaced without breaking format compliance by any value while the length of ‘code value’ is preserved. This option is also applied to both Y and Cb/Cr.

  5. 5.

    DC Value Change: The VLC Huffman-coded symbol for DC values can be changed by any other value while the value range is in a legal range. Note that the DC value is encoded by DPCM (Differential Pulse Coded Modulation), in other word, DC of each DCT is encoded as the difference between DC value of current DCT block and that of previous DCT block. Thus, even though any bit pattern is syntactically legal, the choice of DC value should be done carefully not to exceed the proper range. This option is also applied to both Y and Cb/Cr.

DC values of JPEG format are encoded as the difference between current DCT block DC and previous DCT block DC. Therefore, ‘DC Value Change’ and ‘MCU Shuffle’ may result in the change of encrypted JPEG file size because the different DC code may have the different code length. The ‘DC Value change’ option changes DC value directly and the ‘MCU Shuffle’ option changes DC values by relative MCU location changes, accordingly, the neighboring DCT blocks are also influenced. The MCU shuffle method slightly increases file size (2.5 % on average) while DC value change method results in significant file size increase (10.6 % on average).

3 Experimental Results

We implemented the proposed JPEG encryption approach by modifying the existing JPEG encoder source code in C. Figure 2 shows encryption results with different combinations of encryption options.

Fig. 2
figure 2

An example of images with various encryption combinations (house image)

In Fig. 2, we only present eight combinations of encryption options among all the 31 possible combinations of five basic encryption options because most of the other combinations show the similar perceptual security level with one of the eight presented encryption results. Figure 2a is the original JPEG image and Fig. 2b–f are the results encrypted with one of the basic five encryption options. In Fig. 2b–d, g have relatively low security level, while Fig. 2e–f and Fig. 2h–i have relatively high security level. Note the ‘DC Value Change’ and ‘MCU Shuffle’ methods result in strong information hiding effects. However, ‘DC Value Change’ method alone leaks a silhouette of original image as shown in Fig. 2e. Figure 2d is the result by the method of existing work [6].

We illustrate the performance and cost for each encryption option as shown in Fig. 3. The size of circle area denotes the execution time ratio that is the overhead of each encryption operation.

Fig. 3
figure 3

File size increase, PSNR-drop, and execution time ratio of encryption methods

We conclude that the combination of ‘MCU shuffle’ and ‘AC value change’ is most efficient in terms of file size increase and perceptual security level. We compare our best method and the published existing work [6] which is the same approach as ‘AC shuffle’ and ‘DCT shuffle’. Figure 4 illustrates the encryption results by ours and [6].

Fig. 4
figure 4

Encryption performance comparison between ours and existing work [6]

In Table 2, we summarized the comparison results in terms of security level, file size increase, and the execution time quantitatively. Ours outperforms the existing works [6] except file size increase but which is not significant overhead.

Table 2 Comparison between ours and existing work

4 Conclusion

This paper aims to propose a robust JPEG encryption method that has JPEG-format compliance. We developed an encryption method that balances between security level and overheads. Our JPEG encryption method shuffles image information both in spatial domain and frequency domain resulting in the high security level. Our method is secure against any cryptographic attack as well as perceptual information cracking. In addition, ours is faster than conventional complex data encryption methods.