JPEG Image Encryption With Improved Format Compatibility and File Size Preservation
Image encryption techniques can be used to ensure the security and privacy of valuable images. The related works in this field have focused more on raster images than on compressed images. Many existing JPEG image encryption schemes are not quite well compatible with the JPEG standard, or the file size of an encrypted JPEG image is apparently increased. In this paper, a novel bitstream-based JPEG image encryption method is presented. First, the groups of successive DC codes that encode the quantized DC coefficient differences with the same sign are permuted within each group. Second, the left half and the right half of a group, whose size will increase with the number of iterations, of consecutive DC codes may be swapped with each other, depending on whether an overflow of quantized DC coefficients occurs during decoding. Third, all AC codes are classified into 63 categories according to their zero-run lengths, then the AC codes within each category are, respectively, scrambled. Finally, all MCUs, except for DC codes, are randomly shuffled as a whole. Moreover, an image-content-related encryption key is employed to provide further security. The experimental results show that the file size of an encrypted JPEG image is almost the same as that of the corresponding plaintext image except for slight variations because of byte alignment. In addition, the quantized DC coefficients decoded from an encrypted JPEG image will not fall outside the valid range. Improved format compatibility is provided compared with other related methods. Moreover, it is unnecessary to perform entropy encoding again because all of the encryption operations are performed directly on the JPEG bitstream. The proposed method proves to be secure against brute-force attacks, differential cryptanalysis, known plaintext attacks, and outline attacks. Our proposed method can also be applied to color JPEG images.