A multi-image batch encryption method based on counter mode
By introducing counter mode and multi-threading technology in image encryption, a batch encryption method that can encrypt four images at the same time and update the wheel keys is designed, which solves the problem of difficulty in taking into account both efficiency and intensity in massive image encryption, and achieves high efficiency and Secure image encryption.
Patent Information
- Application Number
- CN202410992167.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-07-23
AI Technical Summary
In massive image encryption scenarios, the prior art is difficult to take into account both encryption efficiency and encryption strength, and simple reuse of single image encryption algorithms will increase the risk of encryption time and key reuse.
A batch encryption method is designed using multi-threading technology based on counter mode, which can encrypt four images at the same time and update the wheel key after each batch of four images is processed to ensure the encryption strength.
The encryption efficiency is improved, and the encryption efficiency and encryption strength in massive image encryption scenarios can be taken into account without increasing the burden of key transmission.
Smart Images

Figure CN118612356B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image encryption, and in particular relates to a multi-image batch encryption method based on a counter mode. Background Art
[0002] Digital images play an important role in information interaction, so the protection of image information has received increasing attention. Digital images are different from text information. There is a high correlation between adjacent pixels, so the traditional data encryption algorithm used to encrypt text is not suitable for encrypted images. Chaotic systems have the characteristics of being highly sensitive to the initial key, ergodic, and unpredictable, and have been widely used in the field of image encryption. At present, in addition to optimizing and improving the chaotic system itself in order to produce a chaotic system with better randomness and stronger anti-degradation ability, using chaotic sequences to build more robust and reliable encryption methods has also become a focus of researchers.
[0003] Scrambling and diffusion are commonly used structures in image encryption algorithms based on chaotic systems. They have been proven to be able to effectively solve the problem of high intrinsic correlation of images. A series of improved optimization schemes can well achieve high-intensity encryption of images. In the scrambling stage, the positions of pixels are randomly scrambled by the pseudo-random sequence generated by the chaotic system, thereby effectively destroying and reducing the strong correlation between adjacent pixels of the original plaintext image. From the perspective of the scrambling object, it can be divided into pixel-level scrambling and bit-level scrambling. From the perspective of the scrambling method, it can be divided into magic square transformation, random rearrangement, Zigzag scanning, etc. In the diffusion stage, the pseudo-random sequence generated by the chaotic system is further used to operate on the pixel values, so as to fully hide the original statistical characteristics of the plaintext image and complicate the association between the plaintext image and the ciphertext image as much as possible. From the perspective of the diffusion steps, it usually takes more than two to three rounds of encryption based on the ciphertext group linking mode to achieve a good diffusion effect. From the perspective of the diffusion method, combining compressed sensing, time-frequency conversion, genetic coding and other technologies can also achieve better encryption effects.
[0004] The application potential of chaotic systems in the field of image encryption, especially in the field of single-image encryption, has been widely reported. However, in practice, especially in the scenario of massive image encryption, the problems are often more complicated. Simply reusing a single-image encryption algorithm will face some problems in encryption efficiency and even encryption strength. On the one hand, if the serial mode is used to encrypt images one by one, the encryption strength can be guaranteed, but the time used for image encryption will be significantly increased, thus affecting the efficiency of communication. On the other hand, if the parallel mode is used to encrypt multiple images synchronously, the encryption efficiency can be guaranteed, but the same key stream will be used to encrypt each image, which will undoubtedly significantly increase the risk of the image being cracked. To ensure the security of the parallel mode, a common practice is to use "oneFigure 1 The method of "encryption" is to use a "secret" method, that is, each plaintext image has its own unique session key, so that the key stream generated by the chaotic system is not repeated, which increases the difficulty of decryption for the decoder. However, this will bring an obvious problem, how to establish a secure transmission channel to efficiently transmit a large number of session keys. At present, there is no such technology to meet such a demand. Another common practice is to splice multiple images into a large image, and then use a single-image encryption algorithm to encrypt it. The idea is to cleverly transform the multi-image encryption task into a single-image encryption task. This is practical for multi-image encryption scenarios where the number of images to be encrypted is not large, but it is obvious that in multi-image encryption scenarios where the number of images to be encrypted is extremely large, there will still be the problem of not being able to balance encryption efficiency and encryption strength. At the same time, completing image splicing and segmentation will also increase the extra time cost to a certain extent. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a multi-image batch encryption method based on a counter mode, aiming to design a practical multi-image encryption method by using multi-threading technology and counter mode. One of its main purposes is to introduce multi-threading technology to design a new batch encryption framework, which can simultaneously apply a single image encryption method to the encryption of four images without the need for additional operations such as splicing the images, thereby effectively improving the encryption efficiency; secondly, the counter mode is introduced to achieve round key updates after each batch of four images are encrypted, based on the acquisition of session keys related to all plaintext images, thereby effectively ensuring the encryption strength. Therefore, the scheme can well balance the encryption efficiency and encryption strength in the scenario of mass image encryption, and will not increase the burden of key transmission, thus having high practicality.
[0006] To solve the above technical problems, an embodiment of the present invention provides a multi-image batch encryption method based on a counter mode, comprising the following steps:
[0007] S1. Session keys using multiple plaintext images SK and round key R , respectively extract the initial state of the diffusion chaotic system x 1(1), y 1(1), Initial state of diffusive chaotic system 2 x 2(1), y 2(1) Initial state of the initial vector chaotic system x 3(1), the initial state of the chaotic system x 4(1);
[0008] S2. Read four plaintext images from multiple plaintext images P 1. P 2. P 3.P 4. Calculate P 1. P 2. P 3. P Maximum width of 4 W max and maximum height H max ;
[0009] S3. Using the initial state of the diffusion chaos system x 1(1), y 1(1), Initial state of diffusion chaotic system 2 x 2(1), y 2(1) After pre-iteration, the diffusion sequence is obtained S 1. S 2. S 3. S 4. After filling, converting and transposing, the corresponding diffusion key matrix is generated DK 1, DK 2, DK 3. DK 4;
[0010] S4. Using the initial state of the chaotic system using the initial vector x 3(1) After pre-iteration, the initial vector chaotic sequence is obtained S 5. Fill the four empty sequences to get the initial vector key IV 1 , IV 2 , IV 3 , IV 4;
[0011] S5. Using the initial state of the chaotic system x 4(1) After pre-iteration, the scrambled chaotic sequence is obtained S 6, and fill the four empty sequences to obtain the key stream for column scrambling CSK 1, CSK 2, CSK 3. CSK 4;
[0012] S6. Using the chaotic system W max In state x 4( W max ) After pre-iteration, the scrambled chaotic sequence is obtained S 7, and fill the four empty sequences to obtain the key stream for row scrambling RSK 1, RSK 2, RSK 3. RSK 4;
[0013] S7, open four threads, P 1, DK 1, IV 1, CSK 1, RSK 1Input thread one, P 2, DK 2, IV 2, CSK 2, RSK 2Input thread 2, P 3. DK 3. IV 3. CSK 3. RSK 1Input thread three, P 4. DK 4. IV 4. CSK 4. RSK 4Input thread 4, where thread 1, thread 2, thread 3 and thread 4 are respectively P 1. P 2. P 3. P 4 Run a single image encryption algorithm, the diffusion key matrix, initial vector key and key stream for scrambling on four threads, and adaptively crop according to the size of the image on the thread to obtain the ciphertext image C 1, C 2, C 3. C 4;
[0014] S8. Order R = R +1, updated round key R , repeat step S2 to step S7 until the encryption of the multiple plaintext images to be encrypted is completed.
[0015] In step S1, the diffusion chaos system 1 and the diffusion chaos system 2 use two two-dimensional hyperchaotic systems to generate a pseudo-random sequence for the diffusion process, and the formula is as follows:
[0016] ,
[0017] ,
[0018] The initial vector chaos system and the scrambling chaos system use two one-dimensional chaotic systems to generate a pseudo-random sequence for the scrambling process and an initialization vector for starting encryption, respectively, and the formula is as follows:
[0019] ,
[0020] .
[0021] Wherein, step S1 comprises the following steps:
[0022] S1.1, call the secure hash function SHA-256, the number of N The calculation is performed on multiple plaintext images. A 256-bit true random number is introduced during the calculation process to obtain the session key for this encryption. SK ;
[0023] S1.2. Order SK = SK +1, continue to call SHA-256 for calculation to obtain the 256-bit round key R ;
[0024] S1.3, using the following formula from the round key R The initial state of the diffusion chaotic system is extracted from x 1(1), y 1(1), Initial state of diffusive chaotic system 2 x 2(1), y 2(1) Initial state of the initial vector chaotic system x 3(1), the initial state of the chaotic system x 4(1);
[0025] ,
[0026] Among them, ⊕ is a bit-level XOR operation.
[0027] Wherein, step S3 comprises the following steps:
[0028] S3.1. Initialize four empty sequences S 1. S 2. S 3. S 4. The initial state x 1(1), y 1(1) and x 2(1), y 2(1) After inputting diffuse chaotic system 1 and diffuse chaotic system 2 respectively, they were pre-iterated 100 times and continued to run according to the following formula: W max * H max For four empty sequences S 1. S 2. S 3. S 4 is filled to obtain a diffusion chaotic sequence S 1. S 2. S 3. S 4:
[0029] ;
[0030] S3.2. S 1. S 2. S 3. S All elements in 4 are converted to integers between 0 and 255. The formula is as follows:
[0031] ;
[0032] S3.3, initialize four empty sequences and use the diffusion chaotic sequence S 1. S 2. S 3. S 4 Fill the four empty sequences according to the following formula to obtain the diffusion key matrix DK 1, DK 2, DK 3. DK 4:
[0033] ;
[0034] S3.4. Diffusion key matrix DK 1, DK 2, DK 3. DK 4 for cutting, the formula is as follows:
[0035] ;
[0036] S3.5, the pruned diffusion key matrix DK 1, DK 2, DK 3. DK 4 Transpose to size W 1* H 1, W 2* H 2, W 3* H 3. W 4* H 4 four diffusion key matrices.
[0037] Wherein, step S4 comprises the following steps:
[0038] S4.1. Initialize an empty sequence. x 3(1) After the initial vector chaos system is pre-iterated 100 times, it continues to run according to the following formula: W max Fill it up again to get the initial vector sequence S 5:
[0039] S 5={ S 5. x 3( i )},
[0040] in, i =1, 2, …, W max-1 , W max ;
[0041] S4.2. Initial vector sequence S All elements of 5 are converted to integers between 0 and 255. The formula is as follows:
[0042] ;
[0043] S4.3. Initialize four empty sequences and use the initial vector sequence S 5 Fill the empty sequence to get the initial vector key IV 1 , IV 2 , IV 3 , IV 4. The formula is as follows:
[0044] .
[0045] Wherein, step S5 comprises the following steps:
[0046] S5.1. Initialize an empty sequence. x 4(1) After 100 pre-iterations of the chaotic system with input scrambling, it continues to run according to the following formula: W max times, we get the scrambled chaotic sequence S 6:
[0047] S 6={ S 6. x 4( i )},
[0048] in, i =1, 2, …, W max-1 , W max ;
[0049] S5.2, initialize four empty sequences, use scrambled chaotic sequences S 6Fill the empty sequence to get the scrambling key CSK 1, CSK 2, CSK 3. CSK 4. The formula is as follows:
[0050] ;
[0051] S5.3, scramble the key CSK 1, CSK 2, CSK 3. CSK The elements in 4 are converted to integers to obtain the key stream for column scrambling CSK 1, CSK 2, CSK 3. CSK 4. The formula is as follows:
[0052] .
[0053] Wherein, step S6 comprises the following steps:
[0054] S6.1. Initialize an empty sequence. x 4( W max ) After 100 pre-iterations of the chaotic system, the system continues to run according to the following formula: H max times, we get the scrambled chaotic sequence S 7:
[0055] S 7={ S 7, x 4( i )},
[0056] in, i =1, 2, …, H max-1 , H max ;
[0057] S6.2, initialize four empty sequences, and use scrambled chaotic sequences S 7 Fill the empty sequence to get the scrambling key RSK 1, RSK 2, RSK 3. RSK 4. The formula is as follows:
[0058] ;
[0059] S6.3, scramble the key RSK 1, RSK 2, RSK 3. RSK The elements in 4 are converted to integers to obtain the key stream for row scrambling RSK 1, RSK 2, RSK 3. RSK 4.
[0060] Among them, in step S7, thread 1, thread 2, thread 3 and thread 4 all use the single image encryption algorithm to respectively P 1. P 2. P 3. P 4. Encryption. The specific steps of encrypting a plaintext image include:
[0061] S7.1, initialization width is W 1, height is H Empty matrix of 1 TC 1. Order TC 1(0, :)= IV 1 to start encryption at this stage, according to the following formula P 1. Scramble the image horizontally and diffuse it vertically to generate an intermediate ciphertext image. TC 1:
[0062] ;
[0063] S7.2. Order TC 1(:,0)= TC 1(:, W 1) To start encryption at this stage, perform vertical scrambling of the image according to the following formula, and simultaneously complete horizontal diffusion of the image to update the intermediate ciphertext image TC 1:
[0064] ;
[0065] S7.3, Order TC 1(0,:)= TC 1( H 1,:) to start encryption at this stage, scramble the image horizontally again according to the following formula, and simultaneously complete the diffusion of the image vertically to update the intermediate ciphertext image TC 1:
[0066] ;
[0067] S7.4. Order TC 1(:,0)= TC 1(:, W 1) To start encryption at this stage, scramble the image vertically again according to the following formula, and simultaneously complete the diffusion of the image horizontally to update the intermediate ciphertext image TC 1:
[0068] ;
[0069] S7.5. Output the updated intermediate ciphertext image in step 7.4 TC 1. Get the final ciphertext image C 1; At the same time, P 2. P 3. P 4. Steps S7.1 to S7.4 are synchronously executed in thread 2, thread 3 and thread 4 to perform encryption. The encryption process is executed in parallel under multiple threads, and the final ciphertext image is output. C 2, C 3. C 4.
[0070] The beneficial effects of the above technical solution of the present invention are as follows:
[0071] In order to obtain fast encryption speed, the present invention utilizes multi-threading technology and a safe and fast single-image encryption algorithm to encrypt four images at the same time, and there is no need to perform additional operations such as splicing the images, thereby effectively improving the encryption efficiency; secondly, in order to expand to large-scale images without increasing the difficulty of key management, a counter mode is introduced, and on the basis of obtaining session keys related to all plaintext images, round key updates are implemented after each batch processing of four images are encrypted, thereby effectively ensuring the encryption strength. Therefore, the scheme can well balance the encryption efficiency and encryption strength in the massive image encryption scenario, and will not increase the burden of key transmission, and has high practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 Schematic diagram of the process of the multi-image batch encryption method based on the counter mode provided by the embodiment of the present invention Figure 1 ;
[0073] Figure 2 Schematic diagram of the process of the multi-image batch encryption method based on the counter mode provided by the embodiment of the present invention Figure 2 ;
[0074] Figure 3 A schematic diagram of a process of multi-threaded synchronous encryption in a multi-image batch encryption method based on a counter mode provided by an embodiment of the present invention;
[0075] Figure 4 A plaintext image provided by an embodiment of the present invention, a ciphertext image obtained by using images of different sizes under a multi-image batch encryption method based on a counter mode, and a decrypted image;
[0076] Figure 5 A plaintext image provided by an embodiment of the present invention, a ciphertext image obtained by using images of different sizes under a multi-image batch encryption method based on a counter mode, and a decrypted image 2;
[0077] Figure 6The histogram of the plaintext image and the ciphertext image obtained by the multi-image batch encryption method based on the counter mode provided by the embodiment of the present invention Figure 1 ;
[0078] Figure 7 The histogram of the plaintext image provided by the embodiment of the present invention and the ciphertext image obtained by the multi-image batch encryption method based on the counter mode Figure 2 ;
[0079] Figure 8 A comparison diagram of the correlation of adjacent pixels in the horizontal, vertical and diagonal directions of a plaintext image and a ciphertext image obtained by a multi-image batch encryption method based on a counter mode provided in an embodiment of the present invention (based on a Peppers image). DETAILED DESCRIPTION
[0080] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0081] like Figure 1-3 As shown, an embodiment of the present invention provides a multi-image batch encryption method based on a counter mode, comprising the following steps:
[0082] S1. Session keys using multiple plaintext images SK and round key R , respectively extract the initial state of the diffusion chaotic system x 1(1), y 1(1), Initial state of diffusive chaotic system 2 x 2(1), y 2(1) Initial state of the initial vector chaotic system x 3(1), the initial state of the chaotic system x 4(1), including the following sub-steps:
[0083] S1.1, the diffusion chaos system 1 and the diffusion chaos system 2 use two two-dimensional hyperchaotic systems to generate a pseudo-random sequence for the diffusion process, and the formula is as follows:
[0084] ,
[0085] ,
[0086] The initial vector chaos system and the scrambling chaos system use two one-dimensional chaotic systems to generate a pseudo-random sequence for the scrambling process and an initialization vector for starting encryption, respectively, and the formula is as follows:
[0087] ,
[0088] ;
[0089] S1.2, call the secure hash function SHA-256, the number of N The calculation is performed on multiple plaintext images. A 256-bit true random number is introduced during the calculation process to obtain the session key for this encryption. SK ;
[0090] S1.3. Order SK = SK +1, continue to call SHA-256 for calculation to obtain the 256-bit round key R ;
[0091] S1.4, use the following formula to obtain the round key R The initial state of the diffusion chaotic system is extracted from x 1(1), y 1(1), Initial state of diffusive chaotic system 2 x 2(1), y 2(1) Initial state of the initial vector chaotic system x 3(1), the initial state of the chaotic system x 4(1);
[0092] ,
[0093] Among them, ⊕ is a bit-level XOR operation.
[0094] S2. Read four plaintext images from multiple plaintext images P 1. P 2. P 3. P 4, and get their widths respectively W 1, W 2, W 3. W 4 and height H 1, H 2, H 3. H 4. Calculate P 1. P 2. P 3. P Maximum width of 4 W max and maximum height H max , that is, W max =max{ W 1, W 2, W 3. W 4}, Hmax =max{ H 1, H 2, H 3. H 4};
[0095] S3. Using the initial state of the diffusion chaos system x 1(1), y 1(1), Initial state of diffusion chaotic system 2 x 2(1), y 2(1) After pre-iteration, the diffusion sequence is obtained S 1. S 2. S 3. S 4, and the corresponding size after padding, conversion and transposition is H max × W max The diffusion key matrix DK 1, DK 2, DK 3. DK 4, including the following sub-steps:
[0096] S3.1. Initialize four empty sequences S 1. S 2. S 3. S 4. The initial state x 1(1), y 1(1) and x 2(1), y 2(1) After inputting diffuse chaotic system 1 and diffuse chaotic system 2 respectively, they were pre-iterated 100 times and continued to run according to the following formula: W max * H max For four empty sequences S 1. S 2. S 3. S 4 is filled to obtain a diffusion chaotic sequence S 1. S 2. S 3. S 4:
[0097] ;
[0098] S3.2. S 1. S 2. S 3. S All elements in 4 are converted to integers between 0 and 255. The formula is as follows:
[0099] ;
[0100] S3.3, initialize four empty sequences and use the diffusion chaotic sequence S 1. S 2. S 3. S 4 Fill the four empty sequences according to the following formula to obtain the diffusion key matrix DK 1, DK 2, DK 3. DK 4:
[0101] ;
[0102] S3.4. Diffusion key matrix DK 1, DK 2, DK 3. DK 4 for cutting, the formula is as follows:
[0103] ;
[0104] S3.5, the pruned diffusion key matrix DK 1, DK 2, DK 3. DK 4 Transpose to size W 1* H 1, W 2* H 2, W 3* H 3. W 4* H 4 four diffusion key matrices.
[0105] S4. Using the initial state of the chaotic system using the initial vector x 3(1) After pre-iteration, the initial vector chaotic sequence is obtained S 5, and fill the four empty sequences to obtain a length of W max Initialization Vector Key IV 1 , IV 2 , IV 3 , IV 4, including the following sub-steps:
[0106] S4.1. Initialize an empty sequence. x 3(1) After the initial vector chaos system is pre-iterated 100 times, it continues to run according to the following formula: W max Fill it up again to get the initial vector sequence S 5:
[0107] S 5={ S 5. x 3( i )},
[0108] in, i =1, 2, …, W max-1 , W max ;
[0109] S4.2. Initial vector sequence S All elements of 5 are converted to integers between 0 and 255. The formula is as follows:
[0110] ;
[0111] S4.3. Initialize four empty sequences and use the initial vector sequence S 5 Fill the empty sequence to get the initial vector key IV 1 , IV 2 , IV 3 , IV 4. The formula is as follows:
[0112] .
[0113] S5. Using the initial state of the chaotic system x 4(1) After pre-iteration, the scrambled chaotic sequence is obtained S 6, and fill the four empty sequences to obtain a length of W max The key stream used to scramble the columns CSK 1, CSK 2, CSK 3. CSK 4, including the following sub-steps:
[0114] S5.1. Initialize an empty sequence. x 4(1) After 100 pre-iterations of the chaotic system with input scrambling, it continues to run according to the following formula: W max times, we get the scrambled chaotic sequence S 6:
[0115] S 6={ S 6. x 4( i )},
[0116] in, i =1, 2, …, W max-1 , Wmax ;
[0117] S5.2, initialize four empty sequences, use scrambled chaotic sequences S 6Fill the empty sequence to get the scrambling key CSK 1, CSK 2, CSK 3. CSK 4. The formula is as follows:
[0118] ;
[0119] S5.3, scramble the key CSK 1, CSK 2, CSK 3. CSK The elements in 4 are converted to integers to obtain the key stream for column scrambling CSK 1, CSK 2, CSK 3. CSK 4. The formula is as follows:
[0120] .
[0121] S6. Using the chaotic system W max In state x 4( W max ) After pre-iteration, the scrambled chaotic sequence is obtained S 7, and fill the four empty sequences to get a length of H max The key stream for row scrambling RSK 1, RSK 2, RSK 3. RSK 4, including the following sub-steps:
[0122] S6.1. Initialize an empty sequence. x 4( W max ) After 100 pre-iterations of the chaotic system, the system continues to run according to the following formula: H max times, we get the scrambled chaotic sequence S 7:
[0123] S 7={ S 7, x 4( i )},
[0124] in, i =1, 2, …, H max-1 ,H max ;
[0125] S6.2, initialize four empty sequences, and use scrambled chaotic sequences S 7 Fill the empty sequence to get the scrambling key RSK 1, RSK 2, RSK 3. RSK 4. The formula is as follows:
[0126] ;
[0127] S6.3, scramble the key RSK 1, RSK 2, RSK 3. RSK The elements in 4 are converted to integers to obtain the key stream for row scrambling RSK 1, RSK 2, RSK 3. RSK 4.
[0128] S7, open four threads, P 1, DK 1, IV 1, CSK 1, RSK 1Input thread one, P 2, DK 2, IV 2, CSK 2, RSK 2Input thread 2, P 3. DK 3. IV 3. CSK 3. RSK 1Input thread three, P 4. DK 4. IV 4. CSK 4. RSK 4 Input thread 4 (such as Figure 3 As shown), thread one, thread two, thread three and thread four are respectively P 1. P 2. P 3. P 4 Run a single image encryption algorithm to get the ciphertext image C 1, C 2, C 3. C 4. In addition, the diffusion key matrix, initial vector key and key stream for scrambling on the four threads are adaptively cropped according to the size of the image on the thread. PTaking 1 as an example, the specific steps are as follows:
[0129] S7.1, initialization width is W 1, height is H Empty matrix of 1 TC 1. Order TC 1(0, :)= IV 1 to start encryption at this stage, according to the following formula P 1. Scramble the image horizontally and diffuse it vertically to generate an intermediate ciphertext image. TC 1:
[0130] ;
[0131] S7.2. Order TC 1(:,0)= TC 1(:, W 1) To start encryption at this stage, perform vertical scrambling of the image according to the following formula, and simultaneously complete horizontal diffusion of the image to update the intermediate ciphertext image TC 1:
[0132] ;
[0133] S7.3, Order TC 1(0,:)= TC 1( H 1,:) to start encryption at this stage, scramble the image horizontally again according to the following formula, and simultaneously complete the diffusion of the image vertically to update the intermediate ciphertext image TC 1:
[0134] ;
[0135] S7.4. Order TC 1(:,0)= TC 1(:, W 1) To start encryption at this stage, scramble the image vertically again according to the following formula, and simultaneously complete the diffusion of the image horizontally to update the intermediate ciphertext image TC 1:
[0136] ;
[0137] S7.5. Output the updated intermediate ciphertext image in step 7.4 TC 1. Get the final ciphertext image C 1. At the same time, P 2. P 3. P4. Steps S7.1 to S7.4 are synchronously executed in thread 2, thread 3 and thread 4 to perform encryption. The encryption process is executed in parallel under multiple threads, and the final ciphertext image is output. C 2, C 3. C 4. So far, multi-threaded synchronous encryption of four plaintext images has been achieved.
[0138] S8. Order R = R +1, and then continue to call SHA-256 for calculation to update the 256-bit round key R , repeat step S2 to step S7 until the encryption of the multiple plaintext images to be encrypted is completed.
[0139] In order to verify the security and efficiency of the multi-image batch encryption method based on the counter mode provided by the present invention, simulation experiments and performance analysis are carried out below to further illustrate the beneficial effects of the present invention.
[0140] (1) Simulation experiment
[0141] Experimental simulation platform:
[0142] CPU:Intel(R)Core(TM)i5-4590H,3.30GHZ;
[0143] Memory: 4096MB;
[0144] Operating system: Windows10; Coding tool: Matlab2018a.
[0145] In this experiment, we selected 256×256 Cameraman image, 321×481 Boatman image, 481×321 Train image, 500×362 Flowers image, 512×768 Kodim04 image, 512×512 Peppers image, 768×512 Kodim01 image and 1024×1024 Airplane image as plaintext images. The encryption and decryption effects are shown in the figure below. Figure 4 , Figure 5 As shown in the figure, it can be seen that the plaintext image and the ciphertext image are very different, and the ciphertext image can no longer be seen as the original image.
[0146] (2) Histogram analysis
[0147] Figure 6 , Figure 7Given the histograms of the plaintext image and the corresponding ciphertext image, it can be clearly seen that the histogram of the ciphertext image is very uniform and significantly different from the histogram of the plaintext image. Compared with the plaintext image, there is no direct correlation at all, which makes it very difficult for attackers to analyze the ciphertext image through statistical attacks, and can completely prevent various effective statistical algorithm attacks.
[0148] (3) Correlation between adjacent pixels
[0149] Correlation of adjacent pixels Peppers image is selected as the plaintext image, and the test results of correlation of adjacent pixels are as follows Figure 8 shown. Figure 8 In the figure: (a), (b), (c) are the horizontal, vertical, and diagonal adjacent pixel correlation diagrams of the plaintext image Peppers, and (d), (e), (f) are the horizontal, vertical, and diagonal adjacent pixel correlation diagrams of the ciphertext image. Figure 8 It can be seen that the adjacent pixels of the plaintext image in the horizontal, vertical and diagonal directions are mostly concentrated, while the pixels of the ciphertext image are evenly distributed. The correlation of the plaintext image is much greater than that of the ciphertext, and the correlation of the ciphertext is close to 0, which also shows that the encryption algorithm can destroy the strong correlation between adjacent pixels of the plaintext image.
[0150] (4) Encryption time test
[0151] The encryption time test results are shown in Table 1 below.
[0152] Table 1. Encryption time test results.
[0153] Image size (number) Encryption time (seconds) 256×256 (4 pictures) 0.0533 512×512 (4 pictures) 0.1495 321×481 (25 images) + 500×362 (25 images) 768×512 (25 images) 1024×1024 (25 images) 2.1046 Time complexity (2+2)
[0154] As can be seen from the table above, due to the use of a new parallel solution with a linear time complexity of O(2W+2H) to perform secure single-image encryption and decryption operations, it only takes 2.1 seconds to complete the encryption even when processing hundreds of images of different sizes, meeting the efficiency requirements of large-scale image encryption.
[0155] The present invention proposes a multi-image batch encryption method based on counter mode. In order to obtain fast encryption speed, a novel scheme is adopted, which is constructed by using multi-threading technology and a secure and fast single-image encryption algorithm, so that four plaintext images can be encrypted simultaneously. In addition, in order to expand this scheme to large-scale images without increasing the difficulty of key management, a counter mode is introduced, so that the round key for encrypting every four images can be obtained from the plaintext-related and unpredictable session key. The present invention also proposes a secure and fast adaptive multi-channel pseudo-random number generator based on a 2D hyperchaotic system, which reduces the time consumption of generating key streams when meeting the requirements of parallel encryption of pictures of different sizes.
[0156] The above security tests show that the proposed algorithm has excellent performance in terms of security, and its password image correlation coefficient is close to 0 and the entropy is greater than 7.99. The NPCR and UACI test results show that the algorithm produces a password image similar to the ideal password and effectively resists attacks such as statistical, differential, exhaustive and even selective plaintext attacks. Since a new parallel scheme with a linear time complexity of O(2W+2H) is used to perform secure single-image encryption and decryption operations, it only takes 2.1 seconds to complete encryption even when processing hundreds of images of different sizes. Therefore, the present invention successfully meets the efficiency and security needs of large-scale image encryption.
[0157] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A multi-image batch encryption method based on counter mode, characterized in that: The following steps are involved: S1. Session keys using multiple plaintext images SK and round key R , respectively extract the initial state of the diffusion chaotic system x 1(1), y 1(1), Initial state of diffusive chaotic system 2 x 2(1), y 2(1) Initial state of the initial vector chaotic system x 3(1), the initial state of the chaotic system x 4(1); S2. Read four plaintext images from multiple plaintext images P 1. P 2. P 3. P 4. Calculate P 1. P 2. P 3. P Maximum width of 4 W max and maximum height H max ; S3. Using the initial state of the diffusion chaos system x 1(1), y 1(1), Initial state of diffusion chaotic system 2 x 2(1), y 2(1) After pre-iteration, the diffusion sequence is obtained S 1. S 2. S 3. S 4. After filling, converting and transposing, the corresponding diffusion key matrix is generated DK 1, DK 2, DK 3. DK 4; S4. Using the initial state of the chaotic system using the initial vector x 3(1) After pre-iteration, the initial vector chaotic sequence is obtained S 5. Fill the four empty sequences to get the initial vector key IV 1 , IV 2 , IV 3 , IV 4; S5. Using the initial state of the chaotic system x 4(1) After pre-iteration, the scrambled chaotic sequence is obtained S 6, and fill the four empty sequences to obtain the key stream for column scrambling CSK 1, CSK 2, CSK 3. CSK 4; S6. Using the chaotic system W max Status x 4( W max ) After pre-iteration, the scrambled chaotic sequence is obtained S 7, and fill the four empty sequences to obtain the key stream for row scrambling RSK 1, RSK 2, RSK 3. RSK 4; S7, open four threads, P 1, DK 1, IV 1, CSK 1, RSK 1Input thread one, P 2, DK 2, IV 2, CSK 2, RSK 2Input thread 2, P 3. DK 3. IV 3. CSK 3. RSK 1Input thread three, P 4. DK 4. IV 4. CSK 4. RSK 4Input thread 4, where thread 1, thread 2, thread 3 and thread 4 are respectively P 1. P 2. P 3. P 4 Run a single image encryption algorithm, the diffusion key matrix, initial vector key and key stream for scrambling on four threads, and adaptively crop according to the size of the image on the thread to obtain the ciphertext image C 1, C 2, C 3. C 4; S8. Order R = R +1, updated round key R , repeat step S2 to step S7 until the encryption of the multiple plaintext images to be encrypted is completed.
2. The counter mode-based multi-image batch encryption method according to claim 1, characterized in that: In step S1, the diffusion chaos system 1 and the diffusion chaos system 2 are combined by two two-dimensional hyperchaotic systems to generate a pseudo-random sequence for the diffusion process; The initial vector chaos system and the scrambling chaos system use two one-dimensional chaotic systems to respectively generate a pseudo-random sequence for the scrambling process and an initialization vector for starting encryption.
3. The multi-image batch encryption method based on counter mode according to claim 1, characterized in that: Step S1 includes the following steps: S1.1, call the secure hash function SHA-256, the number of N The calculation is performed on multiple plaintext images. A 256-bit true random number is introduced during the calculation process to obtain the session key for this encryption. SK ; S1.
2. Order SK = SK +1, continue to call SHA-256 for calculation to obtain the 256-bit round key R ; S1.3, using the following formula from the round key R The initial state of the diffusion chaotic system is extracted from x 1(1), y 1(1), Initial state of diffusive chaotic system 2 x 2(1), y 2(1) Initial state of the initial vector chaotic system x 3(1), the initial state of the chaotic system x 4(1); , Among them, ⊕ is a bit-level XOR operation.
4. The counter mode-based multi-image batch encryption method according to claim 1, characterized in that: Step S3 includes the following steps: S3.
1. Initialize four empty sequences S 1. S 2. S 3. S 4. The initial state x 1(1), y 1(1) and x 2(1), y 2(1) After inputting the diffusion chaos system 1 and diffusion chaos system 2 respectively, they were pre-iterated 100 times and continued to run according to the following formula: W max * H max For four empty sequences S 1. S 2. S 3. S 4 is filled to obtain a diffusion chaotic sequence S 1. S 2. S 3. S 4: ; S3.
2. S 1. S 2. S 3. S All elements in 4 are converted to integers between 0 and 255. The formula is as follows: ; S3.3, initialize four empty sequences and use the diffusion chaotic sequence S 1. S 2. S 3. S 4 Fill the four empty sequences according to the following formula to obtain the diffusion key matrix DK 1, DK 2, DK 3. DK 4: ; S3.
4. Diffusion key matrix DK 1, DK 2, DK 3. DK 4 for cutting, the formula is as follows: ; S3.5, the pruned diffusion key matrix DK 1, DK 2, DK 3. DK 4 Transpose to size W 1* H 1, W 2* H 2, W 3* H 3. W 4* H 4 four diffusion key matrices.
5. The counter mode-based multi-image batch encryption method according to claim 1, characterized in that: Step S4 includes the following steps: S4.
1. Initialize an empty sequence. x 3(1) After the initial vector chaos system is pre-iterated 100 times, it continues to run according to the following formula: W max Fill it up again to get the initial vector sequence S 5: S 5={ S 5, x 3( i )}, in, i =1, 2, …, W max-1 , W max ; S4.
2. Initial vector sequence S All elements of 5 are converted to integers between 0 and 255. The formula is as follows: ; S4.
3. Initialize four empty sequences and use the initial vector sequence S 5 Fill the empty sequence to get the initial vector key IV 1 , IV 2 , IV 3 , IV 4. The formula is as follows: 。 6. The multi-image batch encryption method based on counter mode according to claim 1, characterized in that: Step S5 includes the following steps: S5.
1. Initialize an empty sequence. x 4(1) After 100 pre-iterations of the chaotic system, the system continues to run according to the following formula: W max times, we get the scrambled chaotic sequence S 6: S 6={ S 6, x 4( i )}, in, i =1, 2, …, W max-1 , W max ; S5.2, initialize four empty sequences, use scrambled chaotic sequences S 6Fill the empty sequence to get the scrambling key CSK 1, CSK 2, CSK 3. CSK 4. The formula is as follows: ; S5.3, scramble the key CSK 1, CSK 2, CSK 3. CSK The elements in 4 are converted to integers to obtain the key stream for column scrambling CSK 1, CSK 2, CSK 3. CSK 4. The formula is as follows: 。 7. The counter mode-based multi-image batch encryption method according to claim 1, characterized in that: Step S6 includes the following steps: S6.
1. Initialize an empty sequence. x 4( W max ) After 100 pre-iterations of the chaotic system, the system continues to run according to the following formula: H max times, we get the scrambled chaotic sequence S 7: S 7={ S 7, x 4( i )}, in, i =1, 2, …, H max-1 , H max ; S6.2, initialize four empty sequences, and use scrambled chaotic sequences S 7 Fill the empty sequence to get the scrambling key RSK 1, RSK 2, RSK 3. RSK 4. The formula is as follows: ; S6.3, scramble the key RSK 1, RSK 2, RSK 3. RSK The elements in 4 are converted to integers to obtain the key stream for row scrambling RSK 1, RSK 2, RSK 3. RSK 4.
8. The counter mode-based multi-image batch encryption method according to claim 1, characterized in that: In step S7, thread 1, thread 2, thread 3 and thread 4 all use a single image encryption algorithm to encrypt P 1. P 2. P 3. P 4. Encryption. The specific steps of encrypting a plaintext image include: S7.1, initialization width is W 1, height is H Empty matrix of 1 TC 1. Order TC 1(0, :)= IV 1 to start encryption at this stage, according to the following formula P 1. Scramble the image horizontally and diffuse it vertically to generate an intermediate ciphertext image. TC 1: ; S7.
2. Order TC 1(:,0)= TC 1(:, W 1) To start encryption at this stage, perform vertical scrambling of the image according to the following formula, and simultaneously complete horizontal diffusion of the image to update the intermediate ciphertext image TC 1: ; S7.3, Order TC 1(0,:)= TC 1( H 1,:) to start encryption at this stage, scramble the image horizontally again according to the following formula, and simultaneously complete the diffusion of the image vertically to update the intermediate ciphertext image TC 1: ; S7.
4. Order TC 1(:,0)= TC 1(:, W 1) To start encryption at this stage, scramble the image vertically again according to the following formula, and simultaneously complete the diffusion of the image horizontally to update the intermediate ciphertext image TC 1: ; S7.
5. Output the updated intermediate ciphertext image in step 7.4 TC 1. Get the final ciphertext image C 1; At the same time, P 2. P 3. P 4. Steps S7.1 to S7.4 are synchronously executed in thread 2, thread 3 and thread 4 to perform encryption. The encryption process is executed in parallel under multiple threads, and the final ciphertext image is output. C 2, C 3. C 4.
Citation Information
Patent Citations
Novel image scrambling method based on chaotic technology
CN105931175A
Color image encryption method based on Latin square scrambling
CN108696666A