JPEG (Joint Photographic Experts Group) image encryption method and device and storage medium

Through adaptive feature key generation and multi-stage encryption, it solves the problems of overflow and selected plaintext attacks in JPEG image encryption, enhances the resistance to contour attacks, and achieves a balance between security and file size.

CN118573783APending Publication Date: 2024-08-30SOUTH CHINA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410420591.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-09
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing JPEG image encryption methods may cause overflow problems after encrypting DC coefficients and cannot effectively resist selected plaintext attacks. AC coefficient encryption increases file size and cannot completely resist contour attacks.

Method used

The adaptive feature key generation method is used to generate keys through image features F1, F2, and F3, and combined with the SHA-512 algorithm and ChaCha20 stream cipher encryption, iterative encryption and scrambling of DC coefficients, AC coefficients, and image blocks are performed respectively. , ensuring that a different key is used for each encryption stage.

Benefits of technology

It reduces the insecurity of selected plaintext attacks caused by leakage of image features and enhances resistance to contour attacks while maintaining the reasonableness of file size and encryption effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118573783A
    Figure CN118573783A
Patent Text Reader

Abstract

The invention discloses a JPEG (Joint Photographic Experts Group) image encryption method and device and a storage medium, and the method comprises the steps: carrying out the DCT (Discrete Cosine Transform) of a JPEG image, and obtaining image data; obtaining an initial seed key, obtaining a first key according to the initial seed key and the first image feature, obtaining a second key according to the first key and the second image feature, and obtaining a third key according to the second key and the third image feature; performing DC coefficient encryption on the image data by using a first key to obtain first encrypted data; performing block encryption on the first encrypted data by adopting a second key to obtain second encrypted data; and performing AC coefficient encryption on the second encrypted data by adopting a third key to obtain third encrypted data. According to the method, different self-adaptive feature keys are used in a mode of updating image features in each stage of image encryption, so that unsafety of selected plaintext attacks caused by leakage of necessary image features is reduced, and the method can be widely applied to the technical field of image encryption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image encryption technology, and in particular to a JPEG image encryption method, device and storage medium. Background Art

[0002] The existing JPEG image encryption method is generally implemented by processing the quantized DCT coefficients, that is, the DC coefficients and AC coefficients. These DC coefficient encryption methods can well achieve visual encryption of the image without causing too much increase in file size. However, most of them will cause the encrypted DC coefficient to overflow when the coefficient is decoded. This is because once the encoding value changes, it means that the difference between adjacent DC coefficients has changed, and some changes will cause the DC coefficient of the ciphertext image to exceed the representation range of the original DC coefficient. This process is difficult to predict. The existing technical solution achieves no overflow of the DC coefficient through conditional iterative group scrambling. Although the encryption of the DC coefficient has greatly changed the basic content of the image, if the AC coefficient is not modified, some contour information of the original image will still be leaked, so it is also necessary to encrypt the AC coefficient.

[0003] There are mainly the following ways to encrypt AC coefficients: 1) scrambling within AC coefficient blocks; 2) run-length scrambling; 3) additional bit encryption of AC coefficients; 4) AC coefficient prediction error coding. Compared with the shuffling of DC coefficients, the scrambling of AC coefficients is generally the main reason for the increase in file size. However, encryption achieved by simply modifying DCT coefficients cannot resist contour attacks. Therefore, some existing schemes will continue to scramble image blocks to ensure security under contour attacks. Image block scrambling is to treat each 8*8 coefficient block (corresponding to the 8*8 pixel block in the spatial domain) of the original image as a whole according to the JPEG coding characteristics, and shuffle these blocks, which destroys the statistical characteristics of each block of the original image, so that the encrypted image retains fewer original image features, which means that the ciphertext image has higher security. However, the existing encryption method can achieve security under contour attacks through specific scrambling methods, while simple scrambling cannot effectively resist chosen plaintext attacks. Summary of the invention

[0004] In order to solve at least one of the technical problems existing in the prior art to a certain extent, the present invention aims to provide a JPEG image encryption method, device and storage medium.

[0005] The technical solution adopted by the present invention is:

[0006] A JPEG image encryption method comprises the following steps:

[0007] Acquire a JPEG image, perform DCT transformation on the JPEG image, and obtain image data;

[0008] The frequency distribution statistics of the image are used as the first image feature F1, the least significant bit of the DC coefficient encoding of the original image is used as the second image feature F2, and the distribution histogram feature of the number of zero coefficients in the block is used as the third image feature F3;

[0009] Obtain an initial seed key kenc, obtain a first key kenc1 according to the initial seed key kenc and the first image feature F1, obtain a second key kenc2 according to the first key kenc1 and the second image feature F2, and obtain a third key kenc3 according to the second key kenc2 and the third image feature F3;

[0010] Using a first key kenc1 to perform DC coefficient encryption on the image data to obtain first encrypted data;

[0011] Using the second key kenc2 to block encrypt the first encrypted data to obtain second encrypted data;

[0012] The second encrypted data is AC-coefficient encrypted using the third key kenc3 to obtain third encrypted data.

[0013] Furthermore, the expression of the first image feature F1 is:

[0014] F1={(VLC1)2h1,…(VLC i )2h i ,…,(VLC N1 )2h N1}

[0015] In the formula, VLC i represents the i-th VLC code used by the image, N1 represents the total number of VLC codes; h i The binary representation of the usage frequency of the i-th VLC in the current JPEG image;

[0016] The expression of the second image feature F2 is:

[0017] F2={(b1)2,…(b j )2,…,(b N2 )2}

[0018] In the formula, (b j )2 represents the least significant bit of the DC coefficient of the j-th coefficient block; N2 represents the number of coefficient blocks;

[0019] The expression of the third image feature F3 is:

[0020] F3={h′1,…h′ k ,…,h′ N3 ,}

[0021] In the formula, h′ k represents the distribution frequency of non-zero AC coefficients in the kth block, and N3 represents the total number of coefficient blocks.

[0022] Furthermore, different adaptive feature keys are obtained by updating image features at each stage of image encryption:

[0023] For the image feature F, use the SHA-512 algorithm to perform hash mapping processing to obtain a 512-bit value, and then use this 512-bit value and the initial key K′ enc Perform an XOR operation to obtain the actual encryption key.

[0024] Furthermore, the DC coefficient encryption of the image data using the first key kenc1 to obtain the first encrypted data includes:

[0025] A1. Obtain DC differential value sequence DIV=(div1, div2,,…,div U ), U is the total number of differential values ​​div; the initial state (a is generated according to the first key kenc1 1 ,b 1 ,β 1 ), and generates a length of A random binary stream S, where T represents the number of iterations;

[0026] A2. Set the iteration parameter t=1;

[0027] A3. For the sequence DIV=(div1,div2,,…,div U ) Group according to the current number of iterations, each group contains 3t DIVs, and set the grouping parameter g = 1;

[0028] A4, read the gth group of div, process 3t(g-1)+1 to 3t·g DC coefficients, read the gth group of div in the binary bit stream S bits; if the bit is 1, the 3t(g-1)+1 to 3t(g-1)+t divs (the first t differential coefficients) and the 3t(g-1)+2t+1 to 3tg divs (the last t differential coefficients) of the group are pre-swapped; if the swapping of the two groups of coefficients will cause the DC coefficient to overflow, they are maintained as they are without swapping the coefficients, otherwise they are swapped; if the bit is 0, the first t differential coefficients and the middle t differential coefficients (3t(g-1)+i to 3t(g-1)+2t divs) are pre-swapped; if the swapping of the differential coefficients will cause the DC coefficient to overflow, they are maintained as they are without swapping, otherwise they are swapped;

[0029] A5. Let g = g + 1. If there is Then continue to step A4, otherwise go to step A6;

[0030] A6. Let t = t + 1. If t ≤ T is satisfied, continue to execute step A3. Otherwise, terminate the iteration.

[0031] A7. Perform stream encryption on the DC coefficient additional bits of each block whose block number is a multiple of 3×T, and output a scrambled sequence DIV′.

[0032] Further, the block encryption of the first encrypted data by using the second key kenc2 to obtain the second encrypted data includes:

[0033] Use B i Represents the set of all AC coefficients of the ith block of a JPEG image. All B i Form a set Sq b = {B1, B2, ..., B N};

[0034] According to the second key kenc2, a random array A={a1, a2,…, a N}, sort the random array A in ascending order to obtain a new array A′;

[0035] According to the new array A', the set Sq b Modify the block sequence in to obtain a new set Sq b ′, block encryption is completed.

[0036] Further, the AC coefficient encryption of the second encrypted data using the third key kenc3 to obtain the third encrypted data includes:

[0037] B1. Obtaining AC coefficient bit sequence S according to the second encrypted data RS =(RS1,RS2,…,RS N), the number of RS in each block Num=(num1,num2,…,num k ), initial state (a 3 ,b 3 ,β 3 ), standard quantization table T; according to the third key jenc3 and the initial state (a 3 ,b 3 ,β 3 ) Generate a random array Seq3 of length N, where N is the total number of run pairs;

[0038] B2. Set block parameter i=1;

[0039] B3, read the RS pair sequence of the i-th block of the image, that is, To RS pairs, let the number of RS pairs in the current block Calculate the number q of AC coefficients represented by these RS n , put the quantization table before q n The values ​​are evenly divided into g groups, and the normalization formula is used to normalize them to obtain the array S q =(q1,q1,…,q g );

[0040] B4, read the first To The value of the quantization table normalization value S q Add them one by one to get the new encrypted array S q1 =(sq1,sq2,…,sq g ), for S q1 Sort the internal values ​​in descending order according to their subscript values. Modify the arrangement order to obtain a new RS arrangement within the block;

[0041] B5, i = i + 1, if i ≤ k, continue to execute step B3, otherwise the iteration is completed and the scrambled sequence S' is output RS .

[0042] Further, the AC coefficient encryption of the second encrypted data using the third key kenc3 to obtain the third encrypted data includes:

[0043] The second encrypted data is parsed, and all the AC coefficient additional bit information is extracted in sequence to obtain the VLI coding sequence S VLI =(VLI1, VLI2, VLI3, ...);

[0044] Use the encryption key Kenc3 to encrypt S VLIEncrypt and get the final ciphertext binary stream S′ VLI .

[0045] Furthermore, the stream cipher encryption algorithm used is the ChaCha20 algorithm.

[0046] Furthermore, the JPEG image encryption method further comprises a decryption step:

[0047] Get the ciphertext image bit stream;

[0048] Obtain a first image feature F1, generate a first key kenc1, and perform DC coefficient decryption on the ciphertext image bit stream according to the first key kenc1 to obtain first decrypted data;

[0049] Acquire the second image feature F2, generate a second key kec2, and perform block sequence recovery on the first decrypted data according to the second key kec2 to obtain second decrypted data;

[0050] The third image feature F3 is obtained, and a third key kec3 is generated. The AC coefficient of the second decrypted data is restored according to the third key kec3 to obtain a JPEG plaintext bit stream.

[0051] Another technical solution adopted by the present invention is:

[0052] A JPEG image encryption device, comprising:

[0053] at least one processor;

[0054] at least one memory for storing at least one program;

[0055] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.

[0056] Another technical solution adopted by the present invention is:

[0057] A computer-readable storage medium stores a program executable by a processor, wherein the program executable by the processor is used to execute the method described above when executed by the processor.

[0058] The beneficial effect of the present invention is that the present invention provides a new adaptive feature key generation method, which uses different adaptive feature keys by updating image features at each stage of image encryption, thereby reducing the insecurity of chosen plaintext attacks caused by the leakage of necessary image features. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the embodiments of the present invention or the drawings of related technical solutions in the prior art are introduced below. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0060] Figure 1 It is a schematic diagram of the JPEG basic bit stream;

[0061] Figure 2 It is a schematic diagram of the storage of the paradigm Huffman table;

[0062] Figure 3 It is a schematic diagram of the scanning order within the AC coefficient block;

[0063] Figure 4 It is a framework diagram of a JPEG image encryption method provided by an embodiment of the present invention;

[0064] Figure 5 is a schematic diagram of iterative encryption of DC coefficient triples in an embodiment of the present invention;

[0065] Figure 6 is a schematic diagram of an example of block scrambling encryption in an embodiment of the present invention;

[0066] Figure 7 is a schematic diagram of a JPEG standard brightness quantization table in an embodiment of the present invention;

[0067] Figure 8 It is a flow chart of image decryption in an embodiment of the present invention. DETAILED DESCRIPTION

[0068] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

[0069] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0070] In the description of the present invention, the meaning of "several" is one or more, the meaning of "more" is two or more, and the meanings of "greater than", "less than", "exceed" and the like are understood as not including the number itself, and the meanings of "above", "below", "within" and the like are understood as including the number itself. If there is a description of the first and the second, it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In addition, "and / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects before and after are in an "or" relationship.

[0071] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.

[0072] Terminology explanation:

[0073] JPEG: An image standard.

[0074] DC coefficient: direct current coefficient.

[0075] AC coefficient: alternating current coefficient.

[0076] VLC: The AC coefficients in the JPEG image block are encoded in the form of Huffman coding + run-length coding. VLC is the Huffman coding part and represents the Huffman codeword.

[0077] (1)JPEG format standard

[0078] The compression process of the JPEG image concerned by the present invention mainly includes three stages: DCT transformation, data quantization and coefficient entropy coding. In order to ensure that the input parameter range of the coefficient transformation is reasonable, the DCT transformation first needs to divide the image into 8×8 blocks, and map the pixels originally in the [0,255] interval to the [-128,127] interval, and then convert the spatial domain image to the frequency domain according to the transformation formula, so that each 8×8 pixel block becomes an 8×8 DCT coefficient block, and the coefficient in the upper left corner of each coefficient block is the DC coefficient (direct current coefficient), and the remaining 63 coefficients in the block are called AC coefficients (alternating current coefficients). After the DCT transformation, the low-frequency energy in the spatial domain image block is concentrated in the upper left part of the image block, and the high-frequency energy is concentrated in the lower right part.

[0079] Since the values ​​after DCT transformation are mostly irrational numbers, accurate representation will take up too much space. Quantizing these data can re-represent the DCT coefficients by controlling the compression accuracy, thereby achieving further storage space compression. In order to have a better control over the accuracy of the image during the quantization process, the quality factor QF is used to adjust the quantization step size. Since the coefficient quantization and dequantization stages all obtain integer values, some coefficient precision will inevitably be lost, which also makes the quantization stage the main source of precision loss in image compression based on DCT transformation.

[0080] Entropy coding is the stage of coefficient compression after quantization. In this stage, more compact coding is implemented according to the characteristics of quantized DCT coefficients to achieve further lossless compression. The current mainstream entropy coding method is to encode according to image blocks, and then divide them into DC and AC coefficients to represent each image block. On this basis, the last step of compression is done by combining the coding method suitable for coefficient value compression with Huffman coding, and finally generating a JPEG bit stream. Figure 1 This is the basic structure of the JPEG image bit stream.

[0081] The basic structure of the JPEG image bitstream after entropy coding is as follows: Figure 1As shown. The JPEG bit stream starts with the image start marker (SOI) to mark the beginning of image encoding. The hexadecimal information of SOI is FFD8, followed by the image header information (JP), the entropy coded data part (ECS), and the image end marker (EOI). The hexadecimal code of EOI is FFD9. The entropy coded data segment stores the DCT coefficient information after the image is quantized. The storage of this segment of information is distributed in the arrangement of blocks, that is, the blocks are stored in the order of blocks. The block information encoding is defined by the block end marker (EOB). Each image block includes DC coefficient and AC coefficient (hereinafter collectively referred to as quantization coefficient) information. The work of the present invention also mainly operates in this part. The image header information segment includes some image versions and configuration information. After the basic identification information is the quantization table and Huffman table information used by the image, which is used to store the quantization table and Huffman table used for image compression and decompression. Figure 2 The figure shows the form of the Huffman table in a JPEG bitstream. The first 16 fields {L1, L2, ..., L16} represent the number of Huffman code words corresponding to the Huffman code with a code length of 1 to 16. The V representing the Huffman code words of each length can be read based on this number. i,j (represents the original value information before coefficient encoding), where i represents the encoding length and j represents the original codeword sequence of the current encoding length. RSVs refers to all V i,j The Huffman code table used by the coefficients can be generated by constructing a Huffman tree based on the paradigm.

[0082] In order to achieve greater compression, the JPEG standard first uses intermediate coding compression for the representation of quantized coefficients, and then further compresses them using Huffman coding to further reduce the file size. Due to the different distribution characteristics of the two DCT coefficients, different intermediate coding methods are used for further compression coding of the two coefficients. After quantization, the AC coefficient is generally very close to 0, while the DC coefficient value is still larger than the AC coefficient. Therefore, the DC coefficient generally chooses to use differential coding to reduce the coding cost, that is, the difference between the DC coefficient of the current block and the DC coefficient of the previous block is stored as the differential coding value (div). Since the DC coefficient of the first block does not exist in the previous block, the previous DC coefficient is preset to 0. In order to facilitate the representation of differential coding, the JPEG standard groups the DC coefficient differential values ​​(div) according to the length of the proportion they account for, as shown in Table 1, where size represents the bit size of the differential coding, div represents the DC coefficient differential coding value, VLI represents the actual coded bit stream, and the encoding rule of VLI is: if the differential value div is 0, no encoding is required; if div is a number greater than 0, it is directly converted to its own binary representation; if the value of div is less than 0, it is represented as the inverse of the binary representation of the absolute value of div.

[0083] Table 1

[0084]

[0085] After the above differential coding grouping, the group number identifier of the group needs to be Huffman coded so that each div of different size has a corresponding Huffman codeword. In this way, the coding can further control the file size while ensuring correct encoding and decoding, and finally form Figure 1 In the {DCH, DCA} format, DCH is the Huffman code of the size corresponding to the differential code div, and DCA represents the VLI bit information, that is, the actual div value information. Based on this, when the JPEG codec is encoding and decoding, it can read the corresponding Huffman codeword to know how many bits the subsequent additional code is, thus ensuring high compression and achieving lossless data preservation.

[0086] After quantization, the AC coefficients are generally small and tend to be zero. In the JPEG coding standard, the AC coefficient blocks are generally scanned in a zigzag arrangement, such as Figure 3 As shown. AC coefficients with high repetition rates (mostly 0) can eliminate data redundancy to a large extent through run-length coding. Run-length coding is a very simple lossless data compression algorithm that uses the number of consecutive appearances of the current data element to perform compression coding. In the JPEG standard, the storage format of the AC coefficient after run-length coding becomes (run / size, value), where run represents the number of consecutive 0 coefficients that appear before the non-zero AC coefficient, size represents the bit size occupied by the non-zero AC coefficient after 0, and value represents the value of the non-zero AC coefficient. After forming the coding format of (run / size, value), JPEG uses Huffman coding to allocate codewords to run / size pairs, which can further reduce the codeword length. The basic principle is consistent with the previous DC coefficient representation, and finally forms Figure 1 For example, if there is an AC coefficient with a run / size value of 0 / 3 and a coefficient value of 7, it can be encoded as {100, 111} according to the Huffman table of the JPEG standard, where '100' is the Huffman codeword corresponding to the run length of 0 / 3. During decoding, the run / size conversion can be completed according to the code table corresponding to VLC, and then the encoded data of VLI can be read.

[0087] (2) Chaotic sequence generation

[0088] The image encryption and decryption algorithm of the present invention uses a large number of random number sequences, which must ensure the chaos of the sequence, that is, have a large data range and complex data distribution characteristics. The embodiment of the present invention uses a 2D-LSCM (Two Dimension Logistics Sine Coupling Map) chaotic system in combination with the encryption key used to generate a random number sequence. Compared with other chaotic systems, the behavior of this chaotic system is more complex and the chaotic range is wider. The definition of 2D-LSCM is as follows.

[0089]

[0090] Where β is a chaotic system control parameter used to control the degree of chaos in the system. When the parameter β∈(0,1), the obtained random number sequence initially has chaotic behavior, especially when β∈(0,0.3)∪(0.67,1), the calculated sequence has hyperchaotic behavior. The image encryption involved in the present invention is divided into three main modules, so it is necessary to generate three groups of random sequences. The present invention generates three groups of initial states according to the encryption key: (a 1 ,b 1 ,β 1 ),(a 2 ,b 2 ,β 2 ),(a 3 ,b 3 ,β 3 ) are used to encrypt the differential DC coefficient, encrypt the AC coefficient block scrambling, and encrypt the AC coefficient. In addition, since the mantissa is 52 bits in the IEEE754 floating point representation, for the generation of parameter a and parameter b, the present invention first randomly selects 52 bits in the encryption key Kenc to generate a decimal in the range of (0,1). In order to ensure the hyperchaotic behavior of the chaotic system used for encryption, it is necessary to ensure that the parameter β is in the interval (0.67,1). According to the floating point standard, the first two bits of the floating point number need to be set to '1', so only 50 bits are selected in the encryption key, which ensures the availability of the chaotic system. The generation of the four sets of parameters is as follows:

[0091]

[0092]

[0093]

[0094] Among them, kenc1, kenc2, and kenc3 are the keys used by the three encryption and decryption modules of the present invention respectively. i Represents the i-th bit of the binary representation of the key kenc.

[0095] (3) New JPEG encryption scheme

[0096] The embodiment of the present invention proposes a new JPEG encryption scheme, which enhances the security under chosen plaintext attacks by optimizing the generation method of adaptive keys, analyzes some original defects of the DC coefficient encryption method and makes some corresponding improvements accordingly, and redesigns the DC coefficient encryption scheme on this basis. In addition, the encryption of the AC coefficient is made more adaptable to the content in combination with the characteristics of the JPEG image content distribution, achieving a better visual encryption effect.

[0097] 3.1 Adaptive Key Generation

[0098] The security of an encryption system does not depend on the confidentiality of the encryption system itself, but on the privacy key. Some current JPEG image encryption methods use a unified privacy key to encrypt images, which poses a great security risk. In order to better resist known plaintext attacks, some schemes attempt to combine image features to construct adaptive keys so that each encryption has a different key as much as possible. In order to ensure that the decryption key can be effectively reconstructed on the decryption side, these image features should be reconstructible on the decryption side. However, the use of directly reconstructible image features is susceptible to chosen plaintext attacks. Considering the security shortcomings of existing encryption algorithms, the present invention designs a new adaptive feature key generation method, which attempts to use different adaptive feature keys by updating image features at each stage of image encryption, thereby reducing the insecurity of chosen plaintext attacks caused by the leakage of necessary image features. And an initial key seed K′e is used based on the image feature F. nc To construct the actual key. For the image feature F, this part uses the SHA-512 algorithm to perform hash mapping processing to obtain a 512-bit value, and then compares this 512-bit value with the initial key K′ enc Perform XOR operation to get the actual encryption key K enc :

[0099]

[0100] in, represents the XOR operation, SHA3(·) represents the hash function, and F is the image feature used in the current stage.

[0101] In order to effectively resist the current mainstream chosen plaintext attack and contour attack, the JPEG encryption scheme proposed in this invention is divided into three modules: DC coefficient group iterative encryption, AC coefficient encryption and image block scrambling, and the processing order of these three stages is strictly restricted. After consideration, the encryption order selected by this invention is DC coefficient encryption, block scrambling, and AC coefficient encryption. In this way, different image features can be effectively used to construct encryption keys. Using image VLC uses frequency distribution statistics as the first image feature F1, as shown in formula (2), where VLC i Indicates the i-th VLC encoding used by the image, h i It represents the binary representation of the usage frequency of the i-th VLC in the current JPEG image, and N1 represents the number of all VLCs.

[0102] F1={(VLC1)2h1,…(VLC i )2h i ,…,(VLC N )2h N1} (2)

[0103] The least significant bit of the DC coefficient encoding of the original image is used as the second image feature F2, and the calculation method is shown in formula (3), where (b j )2 represents the least significant bit of the DC coefficient of the j-th coefficient block, and N2 represents the number of coefficient blocks.

[0104] F2={(b1)2,…(b j )2,…,(b N2 )twenty three)

[0105] The distribution histogram feature of the number of zero coefficients in the block is used as the third feature F3, as shown in formula (4), h′ k Represents the distribution frequency of non-zero AC coefficients of the kth block.

[0106] F3={h′1,…h′ k ,…,h′ N3 ,} (4)

[0107] 3.2 Image Encryption

[0108] The embodiment of the present invention combines the adaptive key generation method to construct the following Figure 4The image encryption framework shown in Figure 1. This encryption method uses different keys for three rounds of encryption. Even if a new image is constructed based on image features, the block scrambling sequence cannot be obtained based on the new image, because the image features we expose are used to encrypt the DC coefficient, and the encryption of the DC coefficient not only depends on the key, but also on whether the DC coefficient of the image itself overflows. In other words, it is impossible to construct a feature image based on image feature information, thereby achieving security under chosen plaintext attack + contour attack.

[0109] 3.2.1 DC coefficient encryption

[0110] The DC coefficient is the coefficient in the upper left corner of the 8×8 coefficient block of the JPEG image, and uses differential coding. If the differential coding value of the DC coefficient is directly modified or scrambled, the original correlation between adjacent DC coefficients will be greatly modified, achieving excellent encryption effect, but because of the modification of the differential value div, it may eventually cause the length of the encoded bit stream of the image DC coefficient to change, resulting in an increase in file size, and even causing the DC coefficient to overflow and cause the JPEG format to fail. Obviously, if the DC differential coefficient is scrambled and modified, the coefficient value can be modified well, but the actual DC coefficient overflow may cause incompatibility with the JPEG encoder. Therefore, the scrambled encryption of the DC coefficient only needs to consider the coefficient overflow that may be caused.

[0111] The present invention groups the DC coefficients first, and groups the adjacent DC coefficients with the same sign to perform iterative shuffling to ensure the security of encryption. In this way, the coefficient overflow of the shuffling process can be effectively avoided by setting a reasonable limit. In the encryption process, a chaotic map is used to generate a random bit sequence of fixed length. First, the random number initial state (a 1 ,b 1 ,β 1 ), and then generate the random number sequence Seq1 required for encryption based on this initial state, and determine the current bit of the binary bit stream S used for encryption by the parity of each number in the random number sequence Seq1. The specific method is that if the random number at the current position is an even number, bit 0 is generated, and if the current random number is an odd number, the bit at the same position of S is 1. Thus, a random binary bit stream S of the same length is obtained.

[0112] In some embodiments, the iterative scrambling of binary groups will further expand the scrambling range as the number of iterations increases. However, since the DC coefficient is stored in a differential coding manner, the processing of the coefficient is essentially the scrambling of the differential coefficient. Therefore, the sum of all coefficients in the group will not change. It can be concluded that the limitation of the scrambling method is that the last DC coefficient of the group will not change each time the group is iterated. Taking binary group iteration as an example, if it is known that the number of iterations is 16, the last iteration is a group of 32 DC differential coefficients (2×16=32), so the DC coefficient of each block number that can divide 32 does not change after encryption. Therefore, we use triple iterative scrambling of DC coefficients in the encryption method this time. This not only has the advantage of expanding the coefficient change ratio shown in Table 2, but also can reduce the number of DC coefficients that have not changed during the iteration process. Under the same number of iterations, the number of unchanged DC coefficients of the method of the present invention is significantly reduced. As shown in Figure 5 Taking the DC coefficient in as an example, the present invention uses a triplet to perform two iterations, and there are two DC coefficients (the 6th and 12th respectively) that have not changed. However, if a binary is used, there will be three DC coefficients (the 4th, 8th, and 12th respectively) that have not changed under the same number of iterations. In order to fundamentally solve this problem, this embodiment performs additional bit encryption on the unchanged DC coefficient based on this feature, which can further ensure the security of the encryption method in this chapter. At the same time, the triplet also has more diverse group-internal chaos methods. Compared with the binary, the DC coefficient is modified or not modified according to the key bit '1' or the key bit '0', and 1 / 2 of the DC coefficient and 0 of the DC coefficient are modified respectively. When the key bit is 1, the triplet is iterated within the group, and the head and tail ends are exchanged, which will modify 2 / 3 of the DC coefficient value. When the key bit is 0, the first two parts are exchanged, which will modify 1 / 3 of the DC coefficient, effectively expanding the encryption range. The specific comparison details are described in Table 2.

[0113] Table 2 Comparison of coefficient modification ratios of binary and triple groups

[0114]

[0115] As an optional implementation, the encryption algorithm is as follows:

[0116] Input: DC difference value sequence DIV = (div1, div2,,…,div U ), key kenc1, number of iterations T

[0117] Output: DIV′=(div′1,div′′,,…,div′ U )

[0118] Step 1: Use the original key kenc′ to generate the key kenc1 according to formula (1) and formula (2), and generate the initial state (a) according to kenc1 1 ,b 1 ,β 1 ), based on which the length is generated A random binary stream S, where T represents the total number of iterations;

[0119] step2: Set the iteration parameter t=1;

[0120] step3: for the sequence DIV=(div1,div2,,…,div U ) Group according to the current number of iterations, each group contains 3t DIVs, and set the grouping parameter g = 1;

[0121] Step 4: Read the gth group of div, process 3t(g-1)+1 to 3t·g DC coefficients, and read the gth group of div in the binary bit stream S. bit, if the bit is '1', the 3t(g-1)+1 to 3t(g-1)+t divs (the first t differential coefficients) and the 3t(g-1)+2t+1 to 3tg divs (the last t differential coefficients) of the group are pre-swapped. If the swapping of the two groups of coefficients will cause the DC coefficient to overflow, they are maintained as they are without swapping the coefficients, otherwise they are swapped. If the bit is 0, the first t differential coefficients and the middle t differential coefficients (3t(g-1)+i to 3t(g-1)+2t divs) are pre-swapped. If the swapping of the differential coefficients will cause the DC coefficient to overflow, they are maintained as they are without swapping, otherwise they are swapped.

[0122] Step 5: Let g = g + 1, if there is Then continue to execute step 4, otherwise execute step 6;

[0123] Step 6: Let t = t + 1. If t ≤ T is satisfied, continue to execute step 3, otherwise end the iteration;

[0124] Step 7: Perform stream encryption on the DC coefficient additional bits of each block whose block number is a multiple of 3×T, and output the scrambled sequence DIV′.

[0125] Figure 5The example below shows the process of iterative scrambling encryption of a triplet with DIV=(-1,8,3,-1,-2,4,0,3,2,-1,1,7) and iteration number I=2. First, we generate a random binary bit stream S='100110' by default. We group DIV for the first time. At this time, every three divs form a group. According to the binary stream S='1010' generated by the key, the coefficients of the first and third parts of the first and third groups are exchanged, and the first and second coefficients of the second and fourth groups are exchanged. After processing, the differential sequence becomes (3,8,-1,-2,-1,4,3,0,2,7,1,-1). Then we perform the second grouping, with every 6 divs as a group, and perform the same operation as before. According to the key '10', we generate DIV′=(-1,-4,-1,-2,3,8,3,0,2,7,1,-1), and then perform stream encryption on the 6th and 12th DC coefficients to generate the final DIV′.

[0126] 3.2.2 Block Encryption

[0127] Contour attacks are all based on some distribution information in the image block. For example, NCC uses the constant number of non-zero AC coefficients in each block to attack. Therefore, using block scrambling on the basis of the original encryption of JPEG images can effectively improve the encryption effect. The block scrambling here actually treats all AC coefficients of each block as a whole B for scrambling. This embodiment uses B i The AC coefficients of the ith block of the JPEG image are represented by the set of all AC coefficients. First, the AC coefficient block distribution feature F3 needs to be saved before encrypting the AC coefficient block. The block encryption key kenc2 is generated using the feature F2 and kenc1 according to formula (1) and formula (3). i Form a set Sq b = {B1, B2, ..., B N}, and then use the encryption key kenc2 to generate a random array A = {a1, a2, ..., a N}, sort the random array A in ascending order, and then rearrange the sequence of blocks according to the corresponding relationship to complete the scrambled encryption of the block. Figure 6 This is a schematic diagram of the steps of block encryption. First, we get Figure 6 The random number sequence shown in (a) Then rearrange the random number sequence in ascending order, such as Figure 6 As shown in (b), the new sequence is obtained In this way, the original block sequence can be modified according to the subscript of the ascending sequence of random numbers to Figure 6 The result in (d) This generates a new block sequence, completing the block encryption process.

[0128] 3.2.3 AC coefficient encryption

[0129] Due to the distribution of AC coefficient coding within the block, it cannot be widely scrambled and encrypted like DC coefficient coding. As mentioned earlier, the AC coefficient coding form is {VLC, VLI}. If it is not handled properly, the VLC part will become an unrecognizable code, which will lead to the serious consequence that the image cannot be restored. The modification of AC coefficients in this embodiment is approached from two aspects. First, the RS pair (run / size) of the AC coefficient is treated as a whole for operation. This part of the operation can achieve image content blurring while ensuring format compatibility. Secondly, we can also only modify the VLI, which can also achieve the modification of the specific value of the AC coefficient to a certain extent.

[0130] 1) Encryption of the overall AC coefficient based on RS

[0131] By analyzing the RS distribution of JPEG image coefficient blocks, we can draw the following conclusions: from the upper left corner to the lower right corner, the run length gradually increases, and the additional bit encoding size gradually decreases. This is related to the image quantization table. Figure 7 It is a standard quantization table for JPEG image brightness.

[0132] See also Figure 7 , the values ​​in the upper left corner of the quantization table are generally smaller, while the values ​​in the lower right corner are generally larger. According to the quantization formula, it can be deduced that compared with the DCT coefficients in the upper left corner, the coefficients in the lower right corner will be closer to 0 after quantization, that is, there will be more 0 and small value coefficients in the coefficient distribution in the lower right corner. This is reflected in the specific run-length coding (run / size), that is, the 0 run length run of the run-length coding in the front section will be smaller, and the space size occupied by the additional bits will be larger.

[0133] Previously, the intra-block scrambling of run-length pairs was ordinary scrambling. If the characteristics of the image content can be taken into account when scrambling, a better content encryption effect can be achieved under the same scrambling logic. In the specific AC run-length pair encryption scheme, this embodiment first groups the quantization table according to the number of run-length pairs in the block. For example, if block B1 has 5 AC coefficient pairs, then we divide the values ​​of the quantization table parts of the corresponding lengths of these AC coefficients into five groups, normalize the quantization table values ​​of these 5 groups, and then use them as the weight of the key stream of the original AC coefficient block scrambling to enhance the intra-block encryption effect of the AC coefficient.

[0134] As an optional implementation, the following encryption algorithm is used for AC coefficient intra-block encryption:

[0135] Input: AC coefficient bit sequence S RS =(RS1,RS2,…,RS N ), the number of RS in each block Num=(num1,num2,…,num k ), initial state (a 3 ,b 3 ,β 3 ), standard quantization table T

[0136] Output: AC coefficient encrypted sequence S′

[0137] Step 1: Use the key kenc2 to generate the key kenc3 according to formula (1) and formula (4), and generate the initial state (a) according to kenc3 3 ,b 3 ,β 3 ) Generate a random array Seq3 of length N, where N is the total number of run pairs;

[0138] step2: Set block parameter i=1;

[0139] Step 3: Read the RS pair sequence of the i-th block of the image, that is, To RS pairs, let the number of RS pairs in the current block Calculate the number q of AC coefficients represented by these RS n , put the quantization table before q n The values ​​are evenly divided into g groups, and the normalization formula is used to normalize them to obtain the array S q =(q1,q1,…,q g );

[0140] step4: Read the first To The value of the quantization table normalized value S obtained above q Add them one by one to get the new encrypted array S q1 =(sq1,sq2,…,sq g ), for S q1 Sort the internal values ​​in descending order according to their subscript values. Modify the arrangement order to obtain a new RS arrangement within the block;

[0141] Step 5: i = i + 1, if i ≤ k, continue to execute step 3, otherwise the iteration is completed and the output scrambled sequence S′ is RS .

[0142] 2) AC coefficient encryption based on VLI coded value

[0143] Modifying the VLI coding part of the AC coefficient coding will not cause incompatibility with the JPEG format. This part performs stream cipher encryption on the additional bit VLI of the AC coefficient to achieve further encryption of the AC coefficient. First, parse the JPEG binary bit stream, extract all the additional bit information of the AC coefficient of the JPEG image in sequence, and obtain a VLI coding sequence S of the AC coefficient. VLI =(VLI1, VLI2, VLI3, ...), since the length of each VLI has been specified in the Huffman codeword VLC, the encryption process is VLI The modification will not cause format compatibility issues, and the conventional encryption method can be used directly for S VLI The encryption of S is safe and effective whether it is stream cipher encryption or bit stream XOR. VLI Encrypt and get the final ciphertext binary stream S′ VLI , as shown in formula (5), where ChaCha20 is a stream cipher encryption algorithm:

[0144] S′ VLI =ChaCha20(S VLI ,Kenc3) (5)

[0145] Through the encryption of the above three modules, the entire process of image encryption is completed.

[0146] 3.3 Image Decryption

[0147] After the steps described in Section 3.2, the bitstream-based encryption of the JPEG image is completed. In order to correctly extract the image features of each decryption step to generate the decryption key, the decryption order and encryption order must be strictly corresponding. Otherwise, it is difficult to generate the correct image features F at each stage, because only after completing the decryption of the previous part can the image features used for decryption in this stage be correctly extracted. The specific operation method of each decryption part is similar to the encryption operation in Section 3.2 above. The process is as follows: Figure 8 shown.

[0148] As an optional implementation, the decryption algorithm is as follows:

[0149] Input: ciphertext image bit stream P′, number of iterations I, standard quantization table T

[0150] Output: Plaintext image bit stream P

[0151] Step 1: Parse the bit stream P′ and read the DC coefficient bit stream S from it dc and AC coefficient bit stream S ac ;

[0152] Step 2: First, decrypt the DC coefficient and parse the bit stream S dc , obtain the DC coefficient difference sequence DIV′=(div′1,div′2,,…,div′ U );

[0153] Step 3: Use the original key kenc′ and the image feature F1 to generate the key kenc1 according to formula (1) and formula (2), and generate the initial state (a) according to kenc1 1 ,b 1 ,β 1 ), based on which the length is generated A random binary stream S;

[0154] step4: Set DC iteration parameter t=1;

[0155] Step 5: For the sequence DIV′=(div′1,div′2,,…,div′ U ) to group, with 3t divs in each group, and set the grouping parameter g=1;

[0156] Step 6: Read the gth group of div, process 3t(g-1)+1 to 3t·g DC coefficients, and read the gth group of div in the binary bit stream S. bits, if the key bit is '1', the first t divs (3t(g-1)+1 to 3t(g-1)+t divs) and the last t divs (3t(g-1)+2t+1 to 3gt divs) of the group are pre-swapped. If the swapping will cause the DC coefficient to overflow, then do not swap and keep it as it is, otherwise do the swap; if the key bit is '0', the first t divs and the middle t divs (3t(g-1)+t to 3t(g-1)+2t divs) are pre-swapped. Similarly, if the swapping will cause the DC coefficient to overflow, then do not swap and keep it as it is, otherwise do swap;

[0157] Step 7: Let g = g + 1, if Then continue to execute step6, otherwise execute step8;

[0158] Step 8: Let t = t + 1. If t ≤ T is satisfied, then continue to execute step 5. Otherwise, the DC coefficient decryption is completed. Then, the additional bits of the DC coefficient with a block number that is a multiple of 3*T are decrypted using a stream cipher, and the DC coefficient differential sequence DIV is saved.

[0159] Step 9: Perform block sequence recovery, read the least significant bit of each DC coefficient in the sequence DIV to generate the sequence DC lowAs the image feature F2, the key kenc1 is used to generate the decryption key kenc2 according to formula (1) and formula (3), and then the initial state (a) is generated according to kenc2. 2 ,b 2 ,β 2 ), and generate a random array S1 of length Nb, where Nb is the number of image coefficient blocks;

[0160] Step 10: Group the AC coefficients of each block into a set Sq′ b ={B′1,B′2,…,B′ Nb}, then use the encryption key kenc2 to generate a random array A = {a1, a2, ..., a Nb}, sort the random array A in ascending order, and then rearrange the block sequence according to the corresponding relationship, and the block sequence recovery is completed to obtain the original block sequence Sq b = {B1, B2, ..., B Nb};

[0161] Step 11: Decrypt AC coefficients and parse the original block sequence Sq b , read the number of zero AC coefficients in each block, use the key kenc2, generate the decryption key kenc3 according to formula (1) and formula (4), and generate the initial state (a) according to kenc3 3 ,b 3 ,β 3 ), and generate a random array S1 of length N, where N is the total number of run pairs, and read the image RS pair sequence S′ RS =(RS′1,RS′2,…,RS′ N )

[0162] step12: Set the block number parameter i=1;

[0163] Step 13: Read the RS pair set of the i-th block of the image, that is, To RS pairs, let the number of RS pairs in the current block Calculate the number q of AC coefficients represented by these RS pairs n , put the quantization table before q n The coefficients are evenly divided into g groups, and the normalization formula is used to normalize them to obtain the array S q =(q1,q1,…,q g ), read the first To The value of the quantization table normalized value S obtained above q Add them one by one to get the new encrypted array S q1 =(sq1,sqg ,…,sq g ), for S q1 Sort the internal values ​​in descending order according to their subscript values. Modify the order of arrangement;

[0164] Step 14: i = i + 1, if i ≤ Nb, continue to execute step 13, otherwise the iteration is completed and the scrambled sequence S is saved RS ;

[0165] Step 15: Extract all VLI′ in sequence to obtain the VLI′ bit stream sequence S′ VLI =(VLI′1, VLI′2, VLI′3, …). Then use the key Kenc3 and the ChaCha20 stream cipher algorithm to encrypt the bit stream S′ VLI The decrypted VLI sequence S is obtained VLI ;

[0166] step16: According to the DIV obtained earlier, Sq b , S RS and S VLI , and recombining them to get the original plaintext image bit stream P.

[0167] In summary, the present invention provides a format-compatible JPEG encryption scheme, which is secure against chosen-plaintext attacks. First, the scheme uses a stage-adaptive key to enhance security under chosen-plaintext attacks, and achieves more secure encryption through inaccessible image features. Secondly, the scheme uses a more effective triple iterative scrambling + additional bit encryption for the processing of DC coefficients, which ensures the range security of the coefficients and the ease of processing while achieving better encryption effects. For AC coefficients, the present invention proposes an intra-block encryption scheme based on image content, which can achieve better visual encryption effects under the same steps. At the same time, in order to ensure security under contour attacks, the present invention also uses block encryption to further enhance the encryption effect of JPEG images.

[0168] This embodiment also provides a JPEG image encryption device, including:

[0169] at least one processor;

[0170] at least one memory for storing at least one program;

[0171] When the at least one program is executed by the at least one processor, the at least one processor implements Figure 4 The method shown.

[0172] A JPEG image encryption device of this embodiment can execute a JPEG image encryption method provided by the method embodiment of the present invention, can execute any combination of implementation steps of the method embodiment, and has the corresponding functions and beneficial effects of the method.

[0173] The present application also discloses a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device can read the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes Figure 4 The method shown.

[0174] This embodiment also provides a storage medium, which stores instructions or programs that can execute a JPEG image encryption method provided by the method embodiment of the present invention. When the instructions or programs are run, any combination of implementation steps of the method embodiment can be executed, and the corresponding functions and beneficial effects of the method can be obtained.

[0175] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.

[0176] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features described may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions, and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.

[0177] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0178] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.

[0179] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0180] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0181] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0182] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.

[0183] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A JPEG image encryption method, characterized in that: The following steps are involved: Acquire a JPEG image, perform DCT transformation on the JPEG image, and obtain image data; The frequency distribution statistics of the image are used as the first image feature F1, the least significant bit of the DC coefficient encoding of the original image is used as the second image feature F2, and the distribution histogram feature of the number of zero coefficients in the block is used as the third image feature F3; Obtain an initial seed key kenc, obtain a first key kenc1 according to the initial seed key kenc and the first image feature F1, obtain a second key kenc2 according to the first key kenc1 and the second image feature F2, and obtain a third key kenc3 according to the second key kenc2 and the third image feature F3; Using a first key kenc1 to perform DC coefficient encryption on the image data to obtain first encrypted data; Using the second key kenc2 to block encrypt the first encrypted data to obtain second encrypted data; The second encrypted data is AC-coefficient encrypted using the third key kenc3 to obtain third encrypted data.

2. A JPEG image encryption method according to claim 1, characterized in that: The expression of the first image feature F1 is: <h2 style=";text-align:left;direction:ltr">F1 = {(VLC1)2h1,…(VLC<h2 style=";text-align:left;direction:ltr"> i <h2 style=";text-align:left;direction:ltr"> )2h<h2 style=";text-align:left;direction:ltr"> i <h2 style=";text-align:left;direction:ltr"> ,…,(VLC<h2 style=";text-align:left;direction:ltr"> N1 <h2 style=";text-align:left;direction:ltr"> )2h<h2 style=";text-align:left;direction:ltr"> N1 <h2 style=";text-align:left;direction:ltr">} In the formula, VLC i represents the encoding of the i-th VLC used by the image, N1 represents the total number of VLCs, and h i The binary representation of the usage frequency of the i-th VLC in the current JPEG image; The expression of the second image feature F2 is: F2={(b1)2,…(b j )2,…,(b N2 )2} In the formula, (b j )2 represents the least significant bit of the DC coefficient of the j-th coefficient block; N2 represents the number of coefficient blocks; The expression of the third image feature F3 is: F3={h′1,…h′ k ,…,h′ N3 ,} In the formula, h′ k represents the distribution frequency of non-zero AC coefficients in the kth block, and N3 represents the total number of coefficient blocks.

3. A JPEG image encryption method according to claim 1, characterized in that: At each stage of image encryption, different adaptive feature keys are obtained by updating image features: For the image feature F, use the SHA-512 algorithm to perform hash mapping processing to obtain a 512-bit value, and then use this 512-bit value and the initial key K′ enc Perform an XOR operation to obtain the actual encryption key.

4. A JPEG image encryption method according to claim 1, characterized in that: The first key K is used enc1 Performing DC coefficient encryption on the image data to obtain first encrypted data includes: A1. Obtain DC differential value sequence DIV=(div1, div2,,…,div U ), U is the number of differential values ​​div; the initial state (a is generated according to the first key kenc1 1 ,b 1 ,β 1 ), and generates a length of A random binary stream S, where T represents the number of iterations; A2. Set the iteration parameter t=1; A3. For the sequence DIV=(div1,div2,,…,div U ) Group according to the current number of iterations, each group contains 3t DIVs, and set the grouping parameter g = 1; A4, read the gth group of div, process 3t(g-1)+1 to 3t·g DC coefficients, read the gth group of div in the binary bit stream S bits; if the bit is 1, pre-swap the 3t(g-1)+1 to 3t(g-1)+t divs and the 3t(g-1)+2t+1 to 3tg divs of the group; if the swap of the two groups of coefficients will cause the DC coefficient to overflow, keep them as they are and do not swap the coefficients, otherwise swap them; if the bit is 0, pre-swap the first t differential coefficients and the middle t differential coefficients, if the swap of the differential coefficients will cause the DC coefficient to overflow, keep them as they are and do not swap them, otherwise swap them; A5. Let g = g + 1. If there is Then continue to step A4, otherwise go to step A6; A6. Let t = t + 1. If t ≤ T is satisfied, continue to execute step A3. Otherwise, terminate the iteration. A7. Perform stream encryption on the DC coefficient additional bits of each block whose block number is a multiple of 3×T, and output a scrambled sequence DIV′.

5. A JPEG image encryption method according to claim 1, characterized in that: The block encryption of the first encrypted data by using the second key kenc2 to obtain the second encrypted data includes: Use B i Represents the set of all AC coefficients of the ith block of a JPEG image. All B i Form a set Sq b = {B1, B2, ..., B N }; According to the second key kenc2, a random array A={a1, a2,…, a N }, sort the random array A in ascending order to obtain a new array A′; According to the new array A', the set Sq b Modify the block sequence in to obtain a new set Sq b ′, block encryption is completed.

6. A JPEG image encryption method according to claim 1, characterized in that: The method of using the third key kenc3 to perform AC coefficient encryption on the second encrypted data to obtain third encrypted data includes: B1. Obtaining AC coefficient bit sequence S according to the second encrypted data RS =(RS1,RS2,…,RS N ), the number of RS in each block Num=(num1,num2,…,num k ), initial state (a 3 ,b 3 ,β 3 ), standard quantization table T; according to the third key kenc3 and the initial state (a 3 ,b 3 ,β 3 ) Generate a random array Seq3 of length N, where N is the total number of run pairs; B2. Set block parameter i=1; B3, read the RS pair sequence of the i-th block of the image, that is, To RS pairs, let the number of RS pairs in the current block Calculate the number q of AC coefficients represented by these RS n , put the quantization table before q n The values ​​are evenly divided into g groups, and the normalization formula is used to normalize them to obtain the array S q =(q1,q1,…,q g ); B4, read the first To The value of the quantization table normalization value S q Add them one by one to get the new encrypted array S q1 =(sq1,sq2,…,sq g ), for S q1 Sort the internal values ​​in descending order according to their subscript values. Modify the arrangement order to obtain a new RS arrangement within the block; B5, i = i + 1, if i ≤ k, continue to execute step B3, otherwise the iteration is completed and the scrambled sequence S' is output RS .

7. A JPEG image encryption method according to claim 1, characterized in that: The third key K is used enc3 Performing AC coefficient encryption on the second encrypted data to obtain third encrypted data includes: The second encrypted data is parsed, and all the AC coefficient additional bit information is extracted in sequence to obtain the VLI coding sequence S VLI =(VLI1, VLI2, VLI3, ...); Use the encryption key Kenc3 to encrypt S VLI Encrypt and get the final ciphertext binary stream S′ VLI .

8. A JPEG image encryption method according to claim 1, characterized in that: The JPEG image encryption method also includes a decryption step: Get the ciphertext image bit stream; Obtain a first image feature F1, generate a first key kenc1, and perform DC coefficient decryption on the ciphertext image bit stream according to the first key kenc1 to obtain first decrypted data; Acquire the second image feature F2, generate a second key kec2, and perform block sequence recovery on the first decrypted data according to the second key kec2 to obtain second decrypted data; The third image feature F3 is obtained, and a third key kec3 is generated. The AC coefficient of the second decrypted data is restored according to the third key kec3 to obtain a JPEG plaintext bit stream.

9. A JPEG image encryption device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 8.

10. A computer-readable storage medium storing a program executable by a processor, characterized in that: The processor-executable program is used to perform the method according to any one of claims 1 to 8 when executed by the processor.