Image encryption method and image decryption method performing substitution operation by constructing S-boxes
By constructing S-Boxes and local negative integer basis transformations, and combining them with chaotic mapping to generate multiple S-Boxes, dynamic random replacement and diffusion of image encryption are realized, solving the problem of insufficient security in existing technologies and improving the security and selectivity of image encryption.
Patent Information
- Application Number
- CN202310894673.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-07-20
AI Technical Summary
Existing image encryption algorithms cannot meet different security needs and have security vulnerabilities, resulting in limited options.
By constructing S-Boxes and performing replacement operations, multiple S-Boxes are generated using local negative integer basis transformation and chaotic mapping. Combined with row replacement, column replacement, and diffusion operations, S-Boxes are dynamically and randomly selected for image encryption and decryption.
It improves the security of image encryption, provides more security options, and can select to perform different replacement and diffusion operations as needed, effectively eliminating the correlation between adjacent pixels.
Smart Images

Figure CN116760934B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of information security technology, and in particular to an image encryption method and an image decryption method for performing substitution operation by constructing S-Boxes. BACKGROUND
[0002] With the continuous development of multimedia technology, digital images overcome the storage and transmission problems caused by large data volume in the past, and are becoming a mainstream information expression method. The constant occurrence of hacker incidents and online piracy seriously restricts the further development of Internet applications. Therefore, the protection of image data is increasingly valued by society.
[0003] Image and video encryption is an important means of image data protection. There are a large number of image encryption algorithms in the prior art. The most common image encryption method is based on chaos. The basic idea of this method is to use pseudo-random numbers generated by a chaotic system as the operand of the exclusive or or modular operation in the diffusion process, or to apply a chaotic system to construct a permutation algorithm, S-Box, or a pixel replacement algorithm. Nonlinear permutation transformation is another method of image encryption, such as Arnold transformation, cellular automata, knight tour, Latin square, Gray code, Hilbert curve, Fibonacci transformation, magic square and affine transformation. Nonlinear permutation transformation is often used to design spatial position permutation algorithms in the confusion stage or to generate pseudo-random numbers.
[0004] However, the present inventors have found in the implementation of the present application that the use of each of the above image encryption algorithms to encrypt images cannot meet different security requirements, the selectivity is relatively single, and there are still certain security risks after encryption. Therefore, how to provide a completely new image encryption method to improve the security of image encryption and have more choices in improving the security of image encryption has become a problem to be solved. SUMMARY
[0005] The present application aims to provide an image encryption method and an image decryption method for performing substitution operation by constructing S-Boxes, which can effectively solve the above technical problems existing in the prior art.
[0006] To achieve the above-mentioned purpose, the embodiments of the present application provide an image encryption method for performing substitution operation by constructing S-Boxes, comprising the steps of:
[0007] S1, receiving input information including an external key and an original image; wherein the original image is a plaintext image with a size of MxN;
[0008] S2, initializing, generating a key stream and constructing S-Boxes; specifically comprising:
[0009] S21, calculating initial state z and system parameter a
[0010] S22, calculating initial state x and system parameter a
[0011] S3, performing at least one operation including row substitution and column substitution based on the constructed S-Boxes, wherein:
[0012] the row substitution is randomly selecting different S-Boxes for different rows of the input image according to km1 and km2 in the key stream, and then replacing pixel values of the corresponding rows with the selected S-Boxes to obtain a row-substituted image;
[0013] the column substitution is randomly selecting different S-Boxes for different columns of the input image according to kn1 and kn2 in the key stream, and then replacing pixel values of the corresponding columns with the selected S-Boxes to obtain a column-substituted image;
[0014] wherein the input image of the first operation in the operations is the original image, the input image of the other operations in the operations is the image obtained by the previous operation, and the image obtained by the last operation in the operations is the encrypted ciphertext image;
[0015] S4, outputting the encrypted ciphertext image.
[0016] Preferably, in the step S3, at least one operation including row diffusion and column diffusion is further performed, wherein:
[0017] the row diffusion is calculating new pixel values of each row of the input image according to km1 and km2 in the key stream and based on a preset formula, thereby obtaining a row-diffused image;
[0018] the column diffusion is calculating new pixel values of each column of the input image according to kn1 and kn2 in the key stream and based on a preset formula, thereby obtaining a column-diffused image.
[0019] Preferably, the initial state and the system parameter in {x, a x , z, a z} are calculated by the following steps:
[0020] Computing property parameters and
[0021] Convert t1, t2 into binary string, and take 50 bits after the decimal point, thus obtaining two property keys U = {u1u2...u 50} and V = {v1v2...v 50};
[0022] Computing
[0023] Calculate {x, a x , z, a z} by the following formula, and keep to 14 bits after the decimal point:
[0024]
[0025]
[0026]
[0027]
[0028] Preferably, the step S21 specifically comprises:
[0029] S211, input a z and z, calculate 2M+2N+l state values {z1, z2,..., z 2M+2N+l} by the following formula:
[0030] z n+1 = (a z sin(πz n )+(4-a z )cos(barccos(z n )) / 4) mod 1
[0031] S212, calculate km1, km2, kn1 and kn2 by the following formula:
[0032]
[0033]
[0034]
[0035]
[0036] Preferably, the LNBT is a bijective mapping from N to N using NBT, called local negative integer base transformation, NBT is denoted as negative integer base transformation, as shown in the following formula:
[0037]
[0038] where x=(a n a n-1 …a0) -B ; denoted as (a n a n-1 …a0) -B , which represents a -ary integer, where B is a natural number and B>1, and the subset of natural numbers {a,a+1,…,b} is denoted as ;
[0039] LNBT is shown in the following formula:
[0040]
[0041] where L(x;B,μ,p) is a bijective mapping on when q=p, LNBT is also a bijective mapping from to , and the domain of L(x;B,μ,p) is
[0042] The calculation process of LNBT is represented by algorithm 1 and using y=L(x;B,μ,p):
[0043] wherein algorithm 1 is as follows:
[0044]
[0045] The symbol in algorithm 1 represents the smallest integer not less than x;
[0046] wherein the minimum transformation period of LNBT satisfies:
[0047] (1) The minimum transformation period of L(x;B,μ,p) is not greater than B μ ;
[0048] (2) If B=2 k and p is an odd number, the minimum transformation period is B μ ;
[0049] (3) If B is an even number and p=1, the minimum transformation period is also B μ .
[0050] Preferably, in the step S22, the construction process of the plurality of S-Boxes is represented by the following algorithm 3 or algorithm 4 and using sbox = subBox(x, a x , λ, B, p) :
[0051] Wherein, the algorithm 3 is as follows:
[0052]
[0053] Wherein, the algorithm 4 is as follows:
[0054]
[0055] Wherein λ is the gray level of the original image, {B, p} is the parameter of the LNBT as input information; sbox(i, j) represents the jth value in the ith S-Box, sbox(i, :) represents the ith row of sbox, i.e. the ith S-Box, and sbox(1, :) is the initial S-Box constructed in advance.
[0056] Preferably, in the step S3, the column replacement operation process is as follows:
[0057] First, use formula (17):
[0058]
[0059] Calculate an index value v for the jth column, and then use formula (18):
[0060] g(i, j) = sbox(v, f(i, j) + 1) (18)
[0061] Replace the gray value of the pixel f(i, j) in the jth column, where i = 1, 2, …, M;
[0062] The row replacement operation is also realized by the above formula (17) and formula (18), and the specific implementation process
[0063] is first to transpose the image input after the column operation of the previous operation, and then change the parameters kn1 and kn2 of formula (17) to km1 and km2, and then perform the replacement operation by formula (17) and formula (18). The column operation includes column scrambling, column replacement or column diffusion.
[0064] Preferably, in the step S3, the column diffusion operation process is as follows:
[0065] Assuming g is the input image, first use formula (22):
[0066]
[0067] The gray value of each column pixel is calculated from top to bottom to obtain a new image ξ, and then formula (23) is used:
[0068]
[0069] The new gray value h(i,j) is calculated from bottom to top to obtain a new image h; wherein ξ(0,j) = kn1(j), h(N+1,j) = kn2(j), j = 1, 2, …, M, M and N are the row number and column number of the input image respectively;
[0070] The row diffusion operation is also realized by the above formula (22) and formula (23), and the specific implementation process is that the image input after the previous column operation is transposed first, then the new pixel value is calculated by formula (22) and formula (23), and in the calculation process, kn1 and kn2 in formula (22) and formula (23) are replaced by km1 and km2, and ξ(0,j) = km1(j), h(M+1,j) = km2(j).
[0071] The embodiment of the application further discloses an image encryption method for performing a substitution operation by constructing inverse S-Boxes, comprising the steps of:
[0072] S1, receiving input information including a ciphertext image, an external key and an attribute key; the ciphertext image is a ciphertext image with a size of MxN;
[0073] S2, initializing, generating a key stream and constructing inverse S-Boxes; specifically comprising:
[0074] S21, calculating the initial state z and the system parameter az of the chaotic mapping sine-Chebyshev map and generating two key streams km1 and km2 with a length of M and two key streams kn1 and kn2 with a length of N using the input external key and attribute key, wherein M and N represent the row number and column number of the ciphertext image;
[0075] S22, calculating the initial state x and the system parameter ax of the chaotic mapping logistic-sine map using the input external key and attribute key, constructing a plurality of inverse S-Boxes using the chaotic mapping logistic-sine map and LNBT and based on the initial state x and the system parameter ax;
[0076] S3, performing at least one operation including row substitution and column substitution based on the constructed inverse S-Boxes to obtain a decrypted original image, wherein:
[0077] The row substitution is randomly selecting different inverse S-Boxes according to km1 and km2 in the key stream for different rows of the input image, and then replacing pixel values of the corresponding rows with the selected inverse S-Boxes to obtain the image after row substitution.
[0078] The column substitution is randomly selecting different inverse S-Boxes according to kn1 and kn2 in the key stream for different columns of the input image, and then replacing pixel values of the corresponding columns with the selected inverse S-Boxes to obtain the image after column substitution.
[0079] The first operation in the operation is inputted with the ciphertext image, and other operations in the operation are inputted with the image obtained by the previous operation, and the image obtained by the last operation in the operation is the decrypted original image.
[0080] S4, outputting the decrypted original image.
[0081] Compared with the prior art, the image encryption method and the image decryption method provided by the embodiment of the application have the following technical effects:
[0082] (1) A plurality of S-Boxes (or inverse S-Boxes) are constructed by using local negative base transform (LNBT) and chaotic mapping, different S-Boxes (or inverse S-Boxes) can be randomly selected for each row and each column, and the replacement operation of pixel values can be realized. The constructed S-Boxes (or inverse S-Boxes) not only depend on the external key and the plaintext image, but also depend on the parameters B, mu and p, the replacement process is dynamic and random, and the correlation of adjacent pixels can be completely eliminated. In addition, the selection of S-Boxes (or inverse S-Boxes) of each column and each row also depends on the plaintext image, the external key and LNBT, so the replacement operation is dynamic, and the security of image encryption can be effectively improved.
[0083] (2) At least one operation of row substitution and column substitution can be selected for image encryption processing according to different security requirements, so more choices can be provided for improving the security of image encryption.
[0084] (3) On the basis of selecting to perform at least one of row substitution and column substitution, further increase selection to perform at least one of row diffusion and column diffusion to carry out image encryption processing, so as to further improve the security of image encryption and meet the needs of different choices in improving the security of image encryption. BRIEF DESCRIPTION OF DRAWINGS
[0085] In order to more clearly illustrate the technical solutions of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0086] Figure 1a is a flowchart of an image encryption method provided by an embodiment of the present application, which performs substitution operation by constructing S-Boxes.
[0087] Figure 1b is a flowchart of an image decryption method provided by an embodiment of the present application, which performs substitution operation by constructing inverse S-Boxes.
[0088] Figure 2 is an experimental result of comparing the pixel value substitution algorithm in the image encryption method provided by the embodiment of the present application with the traditional AES S-BOX.
[0089] Figure 3 is a test result of comparing the permutation algorithm in the image encryption method provided by the embodiment of the present application with the traditional permutation algorithm.
[0090] Figure 4 is a ciphertext image after encryption of different program modules using the image encryption method provided by the embodiment of the present application.
[0091] Figure 5 is the encryption result and histogram of the 512*512 Lena image and the 1024*1024 Man image after encryption using the image encryption method provided by the embodiment of the present application. DETAILED DESCRIPTION
[0092] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0093] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application. Figure 1a The embodiments of the present application provide an image encryption method for performing a substitution operation by constructing S-Boxes, comprising steps S1-S4:
[0094] S1, receiving input information comprising an external key and an original image; wherein the original image is a plaintext image with a size of MxN;
[0095] S2, initializing, generating a key stream and constructing S-Boxes;
[0096] S3, performing at least one operation comprising row replacement and column replacement based on the constructed S-Boxes to encrypt the original image, to obtain an encrypted ciphertext image; and
[0097] S4, outputting the encrypted ciphertext image.
[0098] The step S2 specifically comprises:
[0099] S21, calculating the initial state z and the system parameter az of the chaotic mapping sine-Chebyshev map and generating two key streams km1 and km2 with a length of M and two key streams kn1 and kn2 with a length of N using the input external key and the original image, wherein M and N represent the number of rows and columns of the original image;
[0100] S22, calculating the initial state x and the system parameter ax of the chaotic mapping logistic-sine map using the input external key and the original image, and constructing a plurality of S-Boxes using the chaotic mapping logistic-sine map and LNBT based on the initial state x and the system parameter ax.
[0101] Specifically, in the step S3:
[0102] The row replacement is to randomly select different S-Boxes for different rows of the input image according to km1 and km2 in the key stream, and then replace the pixel values of the corresponding rows with the selected S-Boxes to obtain a row-replaced image;
[0103] The column replacement is to randomly select different S-Boxes for different columns of the input image according to kn1 and kn2 in the key stream, and then replace pixel values of the corresponding columns with the selected S-Boxes to obtain a column-replaced image.
[0104] The first operation in the operations inputs the original image, and other operations in the operations input images obtained by previous operations, and the image obtained by the last operation in the operations is the encrypted ciphertext image.
[0105] Further, in the step S3, at least one of the row diffusion and the column diffusion is further performed, wherein:
[0106] The row diffusion is to calculate new pixel values of each row of the input image according to km1 and km2 in the key stream and based on a preset formula, thereby obtaining a row-diffused image.
[0107] The column diffusion is to calculate new pixel values of each column of the input image according to kn1 and kn2 in the key stream and based on a preset formula, thereby obtaining a column-diffused image.
[0108] Reference Figure 1b The embodiment of the present application provides an image decryption method for performing a replacement operation by constructing inverse S-Boxes, which comprises steps S1-S4:
[0109] S1', receiving input information comprising a ciphertext image, an external key and an attribute key; the ciphertext image is a ciphertext image with a size of MxN;
[0110] S2', initializing, generating a key stream and constructing inverse S-Boxes;
[0111] S3', performing at least one of row replacement and column replacement based on the constructed inverse S-Boxes to obtain a decrypted original image; and
[0112] S4', outputting the decrypted original image.
[0113] The step S2' specifically comprises:
[0114] S21, calculating an initial state z and a system parameter az of a chaotic map sine-Chebyshev map using the input external key and attribute key, and generating two key streams km1 and km2 with a length of M and two key streams kn1 and kn2 with a length of N, wherein M and N represent the number of rows and columns of the ciphertext image;
[0115] S22, calculate initial state x and system parameter ax of chaotic mapping logistic-sine map using inputted external key and attribute key, construct multiple inverse S-Boxes based on initial state x and system parameter ax using chaotic mapping logistic-sine map and LNBT.
[0116] Specifically, in the step S3':
[0117] Row replacement is that different inverse S-Boxes are randomly selected according to km1 and km2 in the key stream for different rows of the inputted image, then the pixel values of the corresponding rows are replaced with the selected inverse S-Boxes, and a row-replaced image is obtained;
[0118] Column replacement is that different inverse S-Boxes are randomly selected according to kn1 and kn2 in the key stream for different columns of the inputted image, then the pixel values of the corresponding columns are replaced with the selected inverse S-Boxes, and a column-replaced image is obtained;
[0119] Wherein, the image inputted in the first operation in the operations is the ciphertext image, the image inputted in the operations other than the first operation is the image obtained by the previous operation, and the image obtained by the last operation in the operations is the decrypted original image.
[0120] Further, in the step S3', at least one of row diffusion and column diffusion is further performed, wherein:
[0121] Row diffusion is that new pixel values of each row of the inputted image are calculated according to km1 and km2 in the key stream and based on a preset formula, so that a row-diffused image is obtained;
[0122] Column diffusion is that new pixel values of each column of the inputted image are calculated according to kn1 and kn2 in the key stream and based on a preset formula, so that a column-diffused image is obtained.
[0123] The embodiment of the present application discloses a new image encryption method using local negative base transform (LNBT) and chaotic mapping to construct S-Boxes (as a preferred scheme, P-Boxes can also be constructed at the same time, but it can be understood that the construction of P-Boxes does not affect the implementation of the present application).
[0124] First, the local negative base transform (LNBT) is described. In the present application, the LNBT is defined as follows: n a n-1…a0) -B represents a B-ary integer, where B is a natural number and B > 1, and the subset {a, a+1,..., b} of natural numbers is represented by The algorithms involved in this invention will be described using MATLAB syntax rules, the index of any array starts from 1, and the matrix elements are sorted column by column.
[0125] In particular, unlike the positive integer base, in the negative integer base, any negative integer can be represented without using the minus sign "-", which means (a n a n-1 …a0) -B The value of a0may be negative. Therefore, after the sequence of consecutive natural numbers is represented by B-ary numbers, the resulting sequence may be discontinuous (see Table 1). Based on this principle, the invention defines the negative base transform (NBT) as follows in equation (1):
[0126]
[0127] where x = (a n a n-1 …a0) -B Table 1 lists the values of T(x) for the first 8 natural numbers. As can be seen from Table 1, the sequence of natural numbers after NBT conversion is disordered.
[0128] Table 1 Values of T(x; 2)
[0129]
[0130] The NBT defined by equation (1) is a monomorphism from the set of natural numbers to but not an epimorphism. Moreover, there are fixed points, such as 0 and 1. The invention applies NBT to construct a bijective mapping from to called the local negative integer base transform (LNBT), as in equation (2):
[0131]
[0132] where As can be seen from equation (2), LNBT first maps to and then performs a length-p shift transformation. When q = p, L(x; B, μ, p) is a bijective mapping on
[38] . Similarly, LNBT is also a bijective mapping from to is bijective. In the present invention, the domain of L(x; B, μ, p) is always set to be Since L(x; B, μ, p) is bijective, permutation and substitution algorithms for image encryption can be performed using LNBT.
[0133] The calculation of LNBT is described in detail below. The calculation process of LNBT is represented by the following Algorithm 1, which is a conversion method from a decimal integer to a B-ary integer, and the key of the algorithm is the calculation in formula (1).
[0134] Algorithm 1: y = L(x; B, μ, p):
[0135]
[0136] Notations in Algorithm 1 denotes the smallest integer not less than x. For example, Table 2 lists the 16-round LNBT transformation values for each number in where the notation L (k) denotes the kth iteration and L (1) = L. The second row of Table 2 indicates that L(x; 2, 4, 1) is bijective and has no fixed points. However, if p % B μ ≡ 0, fixed points will occur. For example, when p = 0 and B = 2, 0 and 1 are two fixed points. On the other hand, as can be seen from Table 2, L(x; 2, 4, 1) is a full permutation on , i.e., the minimum transformation period of L(x; B, μ, p) is 16.
[0137] Table 2 16-round L(x; 2, 4, 1) values
[0138]
[0139] From Table 2, the conclusion of Proposition 1 is obtained, which is the setting of the minimum transformation period of LNBT.
[0140] Proposition 1: The minimum transformation period of LNBT satisfies the following three conclusions:
[0141] (1) The minimum transformation period of L(x; B, μ, p) is not greater than B μ .
[0142] (2) If B = 2 k and p is an odd number, the minimum transformation period is B μ .
[0143] (3) If B is even and p = 1, the minimum transformation period is also B μ.
[0144] Although the torus image can be recovered with the minimum transform period, the computation of the encryption algorithm will be large when the image size is large, while the complexity of recovering the scrambled image using inverse transform is much smaller. In addition, if LNBT is used to construct S-Boxes, the inverse LNBT must be calculated when constructing inverse S-Boxes. The embodiment uses the symbol L -1 (y; B, μ, p) represents the inverse LNBT, and the following algorithm 2 is the calculation process of the inverse LNBT, wherein the symbol represents the maximum integer not greater than x.
[0145] Algorithm 2: x = L -1 (y; B, μ, p):
[0146]
[0147] Further, in the image encryption method provided in the embodiment, three chaotic maps are respectively applied to generate P-Boxes, S-Boxes and key streams. Compared with other chaotic systems, logistic-sine map, logistic-Chebyshev map and sine-Chebyshev map have simpler structures and higher security, and the three chaotic systems will be used for image encryption.
[0148] The system parameter is a x The logistic-sine map is a one-dimensional chaotic map, which can be defined in mathematics as
[0149]
[0150] When a x ∈ [0, 4], the logistic-sine map will appear chaotic behavior, and is sensitive to the initial state and system parameter a x In the present application, logistic-sine map is used to construct the initial S-Box.
[0151] The following iterative formula
[0152] y n+1 = (a y y n (1-y n )+(4-a y )cos(barccos(y n )) / 4) mod 1 (4)
[0153] is the mathematical definition of logistic-Chebyshev map, wherein the control parameter ay ∈ [0, 4], b is the degree of Chebyshev polynomials. In the present application, it is always assumed that b = 5. When the initial state y0∈ [0, 1] and the system parameter a y ∈ [0, 4], the logistic-Chebyshev map exhibits chaotic behavior. Therefore, the initial P-Box is constructed using the iterative system defined by equation (4).
[0154] The key stream is generated using the sine-Chebyshev map, i.e., using the iterative formula
[0155] z n+1 = (a z sin(πz n )+(4-a z )cos(barccos(z n )) / 4) mod 1 (5)
[0156] A pseudo-random sequence is generated, and then the key stream is generated using the random sequence. If a z ∈ [0, 4], the sine-Chebyshev map is a chaotic map.
[0157] The encryption process of the image in the present embodiment will be described in detail below, including initialization, generation of the key stream, and construction of the S-Box (and optionally the P-Box) and execution of at least one operation including row permutation and row substitution (and optionally column permutation and column substitution), after receiving input information including the external key and the original image.
[0158] First, the initialization is a process of calculating the initial state (x, y, z) and the system parameters (a x , a y , a z ) of the chaotic map using the external key and the plaintext image. The external key is a binary sequence composed of characters 0 and 1 with a length of 264 bits, and is denoted by the symbol W = {w1w2…w 264}, where w j ∈ {0, 1}. It is assumed that is a plaintext image with a size of M x N, then the initial state (x, y, z), the system parameters (a x , a y , a z ), and the attribute key (U, V) can be calculated by the following steps:
[0159] • Calculate the attribute parameters and
[0160] Convert t1 and t2 to binary strings and take the 50 decimal places to obtain two attribute keys U = {u1u2…u...}. 50} and V={v1v2…v 50}
[0161] ·calculate
[0162] • Use the following formula
[0163]
[0164]
[0165]
[0166]
[0167]
[0168]
[0169] Calculate {x,a} x ,y,a y ,z,a z The result is calculated using {W, U, V} and rounded to 14 decimal places. The decryption process uses {W, U, V} to calculate {a, a...}. x ,y,a y ,z,a z}, using the notation [x, a x ,y,a y ,z,a z The initialization process is represented by `InitKey(W,U,V)`. During encryption, this process will use... Calculate and output {U,V,a,a} x ,y,a y ,z,a z},Right now Because of 2 -44 ≈5.6843×10 -14 Furthermore, this algorithm rounds all floating-point numbers to 14 decimal places and uses 10... 14 To quantize all floating-point numbers. Additionally, 2 -50 ≈8.88×10 -16 It can only affect the 14th decimal place. Therefore, it is reasonable to use a 50-bit binary sequence to represent the attribute keys U and V and to round the floating-point numbers to the 14th decimal place.
[0170] Further, the key stream is used as the operand of XOR operation and modulo operation in the diffusion process, and is also used to randomly select the control flow of P-Box and S-Box in the permutation and substitution process. The key stream is composed of two sequences km1, km2 of length M and two sequences kn1, kn2 of length N, where M and N represent the row number and column number of the image. The calculation process of the key stream is represented by the symbol [km1, km2, kn1, kn2] = keyStream(M, N, z, a z ) and can be implemented by the following steps.
[0171] • input a z and z, calculate 2M+2N+l state values {z1, z2,..., z 2M+2N+l} by formula (5), where a z and z are calculated by formula (10) and formula (11).
[0172] • calculate km1, km2, kn1 and kn2 by the following formula
[0173]
[0174]
[0175]
[0176]
[0177] .
[0178] Further, the substitution process will be described below, where the substitution includes row substitution and column substitution.
[0179] In order to improve the security of the image cipher system, the logistic-sine map and LNBT are applied to construct a plurality of (for example, 256) S-Boxes in the embodiment, and in the encryption process, the S-Box is randomly selected for each row and each column according to the key stream, so as to realize the modification operation of the pixel value. The advantage of this process is that the construction and selection of the S-Box depend on the plaintext image and the external key, so that better security is achieved.
[0180] In the embodiment, the symbol sbox is used to represent the matrix composed of a plurality of (for example, 256) S-Boxes, and for the image with 256 gray levels, the size of sbox is 256x256, where sbox(i, j) represents the jth value in the ith S-Box, and sbox(i, :) represents the ith row of sbox, i.e. the ith S-Box.
[0181] Proposition 1 shows that the minimum transformation period of L(x; 2, 8, p) is 256 when p is odd. Therefore, only 255 different S-Boxes can be constructed using LNBT. So an initial S-Box, sbox(l, :), is needed to be constructed in advance and the remaining 255 S-Boxes are constructed using LNBT. On the other hand, if only LNBT is used to construct multiple S-Boxes, the generated S-Boxes will not depend on the external key and the plaintext image. Therefore, in order to improve the security, the logistic-sine map, the sorting operation and LNBT are used to construct 256 S-Boxes in this embodiment. In Algorithm 3, sbox = subBox(x, a x , λ, B, p) is used to represent the construction of S-Boxes, where x and a x are calculated by formula (7) and formula (6), λ is the gray level of the image, and {B, p} is the parameter of LNBT, which can be set as input information.
[0182] If λ and B satisfy log B (λ) is a natural number, then Algorithm 3 can construct λ S-Boxes. Therefore, when λ = 256, {B, μ, p} should satisfy the following two conditions:
[0183] • (B, μ) ∈ {(2, 8), (4, 4), (16, 2), (256, 1)};
[0184] • p is odd and 1 ≤ p ≤ 255.
[0185] This shows that the S-Box also depends on {B, μ, p}, for example, Tables 3 to 5 are constructed by three different sets of parameters {B, p} and have S-Boxes with a gray level λ = 16.
[0186] Algorithm 3: sbox = subBox(x, a x , λ, B, p):
[0187]
[0188] In Algorithm 3, the S-Box constructed not only depends on the external key and the plaintext image, but also depends on the parameters B, μ and p. Therefore, this embodiment has more choices in improving the security of the image cipher system. In addition, since
[0189]
[0190] Equation (16) shows that S-Box can be obtained by iteration L, where i = 2, 3,..., 256, j = 1, 2,..., 256. Therefore, according to equation (16), algorithm 3 can be improved to obtain algorithm 4. If algorithm 4 is used to construct λ S-Boxes, only λ times LNBT and λ(λ-1) times table lookups are required, where the tables looked up are sbox(1,:) and β = {β1, β2,..., β λ}. Compared with algorithm 3, algorithm 4 runs faster. For example, when λ = 256, the calculation time of algorithm 4 is about 1 / 3 of that of algorithm 3. However, algorithm 4 requires additional buffer space to store sbox(1;:) and β.
[0191] Algorithm 4: sbox = subBox(x, a x , λ, B, p):
[0192]
[0193]
[0194] Table 3: subBox(0.4269, 3.9596, 16, 2, 1)
[0195]
[0196] Table 4: subBox(0.4269, 3.9596, 16, 2, 3)
[0197]
[0198] Table 5: subBox(0.4269, 3.9596, 16, 4, 1)
[0199]
[0200]
[0201] Further, according to algorithm 3, when i > 1, the inverse S-Box process can be divided into two steps. The first step performs inverse LNBT operation i-1 times, and the second step is to modify the pixel gray value with the inverse S-Box of sbox(1,:). These two steps are exactly the calculation process of algorithm 5, denoted as isbox = subBox -1 (x, a xLNBT operation and table lookup. When λ = 256, the running time of algorithm 6 is about 1 / 2 of that of algorithm 5.
[0202] Algorithm 5: isbox = subBox -1 (x, a x , λ, B, p):
[0203]
[0204] Algorithm 6: isbox = subBox -1 (x, a x , λ, B, p):
[0205]
[0206]
[0207] Next, the process of pixel value substitution is further explained. The substitution process includes column-by-column substitution and row-by-row substitution. The column substitution process first selects different S-Boxes for different columns according to kn1 and kn2, and then substitutes the pixel values of the corresponding columns with the selected S-Boxes. Specifically, the column substitution process first calculates an index value v for the jth column using the formula
[0208]
[0209] Then, the formula
[0210] g(i, j) = sbox(v, f(i, j) + 1) (18)
[0211] is used to substitute the gray value of the jth column pixel f(i, j) where i = 1, 2,..., M. In the invention, the column substitution process is represented by the symbol g = substitution(f, kn1, kn2, sbox), and the row substitution process is represented by the symbol g = substitution(f, km1, km2, sbox). Similar to column substitution, row substitution only needs to change kn1 and kn2 to km1 and km2, and then transpose the input image (if the previous operation is a column operation, column operation includes column permutation, column substitution or column diffusion), and then use formula (17) and formula (18) to perform the substitution operation. The decryption process and the encryption process have the same substitution operation, except that the decryption process uses inverse S-Boxes, i.e., isbox.
[0212] As known to those skilled in the art, for a certain S-Box, it is not secure because it has a fixed point, for example, the first element of the 10th S-Box (i.e. the 10th row) in Table 3 is a fixed point. However, the embodiment of the present application gives a Latin square composed of multiple S-Boxes, i.e. the elements in each column are not equal to each other, and the elements in each row are also not equal to each other. Moreover, the construction and selection of S-Boxes depend on the plaintext image and the external key, which indicates that the substitution process is dynamic and random, so the proposed substitution process is secure. On the other hand, simply replacing the pixel gray value with a secure S-Box in the prior art cannot completely eliminate the correlation between adjacent pixels. Figure 2 are the experimental results of the pixel value substitution algorithm using the embodiment of the present application compared with the traditional AES S-BOX, wherein, Figure 2 (a) in (a) is the image encryption using one round of AES S-BOX, Figure 2 (b) in (b) is the image encryption using two rounds of AES S-BOX, Figure 2 (c) in (c) is the image encryption using the pixel value substitution algorithm of the embodiment of the present application, and it can be seen from the figure that the encryption effect of the pixel value substitution algorithm of the embodiment of the present application is much better than that of the AES S-BOX.
[0213] Further, the permutation process will be described below, wherein the permutation includes row permutation and column permutation. However, it can be understood that in the present embodiment, the permutation process is only a preferred scheme, and the implementation of the present application is not affected without performing the permutation process.
[0214] The permutation process mainly includes three steps, first, multiple P-Boxes are constructed, then a P-Box is randomly selected for each column and each row according to the specified key stream, and finally the positions of the pixels are rearranged using the selected P-Box, so as to achieve the effect of permutation.
[0215] Similar to the construction of S-Box, first, the initial P-Box is constructed using logistic-Chebyshev map, and then the remaining P-Boxes are constructed using LNBT. Algorithm 7 is the construction method of multiple P-BOX, and the symbol [pbox, r y ] = permMatrix (N, rows, y, a yB, p) represents the construction of P-Box, where the return value pbox is a matrix containing rows rows (it can be understood that the number of rows rows of P-BOX can be set as input information), and each row in the matrix is a P-Box, such as pbox(j, :) representing the jth P-Box. Parameter N is the number of rows or columns of the image, parameters B and p are parameters of LNBT, parameters y and a y are the initial state value and control parameter of formula (4), r y is the state value of the returned logistic-Chebyshev mapping. Two groups of P-Box are constructed using algorithm 7, which are used for column scrambling and row scrambling, respectively, where r y is the initial state of the logistic-Chebyshev mapping when algorithm 7 constructs the second group of P-BOX. When constructing the P-BOX matrix, an initial P-Box needs to be constructed first. In algorithm 7, the symbol logChy(y, a y , 5) represents the logisticChebyshev mapping with parameters {y, a y , 5}.
[0216] Algorithm 7: [pbox, r y ] = permMatrix (N, rows, y, a y , B, p):
[0217]
[0218] Algorithm 8 is the construction method of inverse P-Box, denoted by [ipbox, r y ] = permMatrix -1 (N, rows, y, a y , B, p), where ipbox is the inverse P-Box, and other parameters are the same as algorithm 7.
[0219] Algorithm 8: [ipbox, r y ] = permMatrix -1 (N, rows, y, a y , B, p):
[0220]
[0221] The process of pixel value scrambling will be further explained below. If the pixel positions are scrambled by row and by column respectively, a fast image scrambling algorithm can be obtained. However, if the row coordinates of all columns are scrambled by the same P-Box, the position relationship between horizontally adjacent pixels will not be changed; similarly, if the column coordinates of all rows are scrambled by the same P-Box, the vertical position relationship between adjacent pixels will not be changed either. The scrambling algorithm of the present embodiment constructs multiple P-Boxes and then randomly selects a P-Box for each column and each row, i.e. different scrambling rules are applied to different rows and different columns. Therefore, the encryption algorithm of the present embodiment will rearrange the spatial positions of pixels by selecting different scrambling rules for different rows or columns. For example, the column scrambling process of the present embodiment first uses
[0222] u = (kn1(j) + kn2(j) mod rows) + 1 (19)
[0223] The index number u of the P-Box used in the jthcolumn is calculated, where rows is the number of rows of the P-BOX matrix (i.e. the number of P-BOXes), and then
[0224]
[0225] The new position of each pixel in the jthcolumn is calculated, i.e. is moved to the position specified by the coordinates (mpbox(u, i), j), where mpbox is the P-Box selected for the jthcolumn. The row scrambling process can also be implemented by using equations (19) and (20), i.e. first transpose the image (if the previous operation is a column operation, the column operation includes column scrambling, column substitution or column diffusion), and then replace the parameters {kn1, kn2, mpbox} in equations (19) and (20) with parameters {km1, km2, npbox}, where npbox is the P-Box used for row scrambling. The scrambling process of the present algorithm is shown in the above equations. In the decryption process, the original positions of the pixels can be recovered by using the same method, where the P-Boxes used are the inverse P-Boxes of the P-Boxes used in scrambling.
[0226] It can be understood that the conventional scrambling-only image encryption algorithm is a weak security encryption algorithm, especially in the case of fixed scrambling rules (i.e. static rules). The scrambling algorithm proposed in the present embodiment is dynamic and random, because the construction and selection of the P-Boxes depend on the plaintext image and the external key. On the other hand, since the conventional scrambling algorithm based on static rules often needs to recalculate the pixel positions in each round of encryption, the encryption algorithm can tend to repeat the calculation, increasing the computational complexity. The scrambling algorithm proposed in the present embodiment is actually a dynamic lookup table method, so the calculation time can be saved.
[0227] Table 6 and Figure 3 are the test results of several scrambling algorithms. In Table 6, GD is the average grayscale difference of the 4-neighborhood of the whole image. HC, VC, DC represent the absolute values of the correlation coefficients of the horizontal, vertical and diagonal adjacent pixel sequences, respectively, and the mathematical expression is
[0228]
[0229] Figure 3 (a) in Table 6 is the encryption effect obtained by using the traditional 2D Arnold scrambling algorithm (6 rounds), Figure 3 (b) in Table 6 is the encryption effect obtained by using the traditional Cellular automata scrambling algorithm (13 rounds), Figure 3 (c) in Table 6 is the encryption effect obtained by using the traditional Fibonacci-Q scrambling algorithm (32 rounds), Figure 3 (d) in Table 6 is the encryption effect obtained by using the traditional Hilbert Curve scrambling algorithm (19 rounds), Figure 3 (e) in Table 6 is the encryption effect obtained by using the traditional Magic cube scrambling algorithm (27 rounds), Figure 3 (f) in Table 6 is the encryption effect obtained by using the scrambling algorithm of the embodiment of the present application (1 round).
[0230] From Table 6 and Figure 3 It can be seen that using the scrambling algorithm provided by the embodiment of the present application only needs one round of encryption to achieve the effect of multiple rounds of other algorithms.
[0231] Table 6: Comparison table of image scrambling effects
[0232]
[0233] In this embodiment, in order to further improve the security of image encryption and meet the needs of different choices in improving the security of image encryption, on the basis of selecting to perform at least one of row substitution and column substitution, further increasing the selection of performing at least one of row diffusion and column diffusion for image encryption processing. The diffusion process will be described below, where diffusion includes row diffusion and column diffusion.
[0234] First, in the column diffusion process, assume that g is the input image. First apply
[0235]
[0236] The gray value of each column pixel is calculated from top to bottom to obtain a new image ξ, and then
[0237]
[0238] The new gray value h(i,j) is calculated from bottom to top to obtain a new image h. Wherein ξ(0,j) = kn1(j), h(N+1,j) = kn2(j), j = 1, 2, …, M, M and N are the row number and column number of the image respectively. In the row diffusion process, the input image can be transposed first (if the previous operation is column operation, the column operation includes column permutation, column substitution or column diffusion), and then the new pixel value is calculated by using formula (22) and formula (23). In the calculation process, kn1 and kn2 in formula (22) and formula (23) are replaced by km1 and km2, and ξ(0,j) = km1(j), h(M+1,j) = km2(j).
[0239] The decryption process is very similar to the encryption process. First, use
[0240]
[0241] Calculate ξ, and then use
[0242]
[0243] to calculate the new image g. In the embodiment of the present application, the diffusion operation in the encryption process is represented by the symbol h = diffusion(g, k1, k2, 'E'), and the inverse diffusion operation in the decryption process is represented by the symbol h = diffusion(g, k1, k2, 'D').
[0244] Next, a preferred embodiment of the image encryption method provided by the present application will be described as a specific example.
[0245] In the preferred embodiment, the image encryption method can be divided into three stages in the process of encryption processing for the input image, and only one round of encryption is needed. The first stage is initialization, key stream generation, S-Box construction and P-Box construction. The second stage includes column permutation, column substitution and column diffusion. The third stage includes row diffusion, row substitution and row permutation. Algorithm 9 is the encryption process of the preferred embodiment, and the decryption process is similar to the encryption process and can be implemented by the same program code.
[0246] Algorithm 9: Encryption and decryption
[0247]
[0248]
[0249] As can be seen from the above algorithm 9, in the preferred embodiment, the algorithm 9 involves six independent program modules (operation flows) of row permutation, row substitution, row diffusion, column diffusion, column substitution and column permutation, and the encryption is first performed by column operation (including column permutation, column substitution and column diffusion) and then the secondary encryption is performed by row operation (including row diffusion, row substitution and row permutation), which can obtain very good encryption effect and effectively improve the security. Among them, when the column operation is converted to the row operation, for example, the column diffusion performed in the 18th row of the algorithm 9 is converted to the row diffusion performed in the 19th row, the input image needs to be transposed (from column to row) and then processed. Since the image has been transposed, no image transposition is needed when the row substitution and row permutation are performed.
[0250] It can be understood that, in the preferred embodiment, the encryption can also be first performed by row operation (including row diffusion, row substitution and row permutation) and then the secondary encryption is performed by column operation (including column permutation, column substitution and column diffusion). Similarly, when the row operation is converted to the column operation, the input image needs to be transposed (from row to column) and then processed.
[0251] In addition, it can also be understood that, in addition to the most preferred embodiment disclosed in the algorithm 9, in other embodiments, some modules of the six independent program modules (operation flows) can be selected according to the security requirements to assemble different encryption programs. For example, Figure 4 the ciphertext image after encryption of different program modules, wherein, Figure 4 (a) in the above formula (1) is the original image, Figure 4 (b) in the above formula (1) is the ciphertext image after P encryption, Figure 4 (c) in the above formula (1) is the ciphertext image after S encryption, Figure 4 (d) in the above formula (1) is the ciphertext image after P-D encryption, Figure 4 (e) in the above formula (1) is the ciphertext image after S-D encryption, Figure 4 (f) in the above formula (1) is the ciphertext image after P-S-D encryption, wherein P represents the permutation process (including row permutation or / and column permutation), S represents the substitution process (including row substitution or / and column substitution), and D represents the diffusion process (including row diffusion or / and column diffusion).
[0252] Further,Figure 5 are the encryption results of the 512*512 Lena image and the 1024*1024 Man image after encryption by the present application and histograms. Wherein, Figure 5 (a) in is the original Lena image, Figure 5 (b) in is the ciphertext image after encryption of the original Lena image, Figure 5 (c) in is the original Man image, Figure 5 (d) in is the ciphertext image after encryption of the original Man image, Figure 5 (e) in is the histogram of the original Lena image, Figure 5 (f) in is the histogram of the ciphertext image after encryption of the original Lena image, Figure 5 (g) in is the histogram of the original Man image, Figure 5 (h) in is the histogram of the ciphertext image after encryption of the original Man image. Further, Table 7 is the NIST random test result, wherein a = 0.1. In Table 7, 100 images with sizes of 256*256 and 512*512 are tested, and two groups of parameters {rows = 126, B = 2, p = 1} and {rows = 50, B = 4, p = 3} are selected for testing.
[0253] Table 7: Test result of NIST SP800-22
[0254]
[0255] The above only discloses some preferred embodiments of the present application, and of course cannot limit the scope of the rights of the present application, and those skilled in the art can understand that all or part of the above-mentioned embodiments are implemented, and equivalent changes made according to the claims of the present application still belong to the scope covered by the present application.
Claims
1. An image encryption method of performing a substitution operation by constructing S-Boxes, characterized by, The method comprises the steps of: S1, receiving input information comprising an external key and an original image; wherein the original image is a plaintext image with a size of MxN; S2, initializing, generating a key stream, and constructing S-Boxes; specifically comprising: S21, using the input external key and the original image to calculate the initial state z and system parameter az of a chaotic map sine-Chebyshev map, and generating two key streams km1 and km2 with a length of M and two key streams kn1 and kn2 with a length of N, wherein M and N represent the number of rows and columns of the original image; S22, using the inputted external key and the original image, calculating an initial state x and a system parameter a of a chaotic map logistic-sine map, using the chaotic map logistic-sine map and the LNBT and based on the initial state x and the system parameter a x constructing a plurality of S-Boxes; S3, performing at least one operation comprising row replacement and column replacement based on the constructed S-Boxes, wherein: the row replacement is to randomly select different S-Boxes for different rows of the input image according to km1 and km2 in the key stream, and then replace the pixel values of the corresponding rows with the selected S-Boxes to obtain the image after row replacement; the column replacement is to randomly select different S-Boxes for different columns of the input image according to kn1 and kn2 in the key stream, and then replace the pixel values of the corresponding columns with the selected S-Boxes to obtain the image after column replacement; wherein the image input for the first operation in the operations is the original image, the image input for the other operations in the operations is the image obtained after the previous operation, and the image obtained after the last operation in the operations is the encrypted ciphertext image; S4, outputting the encrypted ciphertext image; In the step S3, at least one operation comprising row diffusion and column diffusion is further performed, wherein: the row diffusion is to calculate the new pixel values of each row of the input image according to km1 and km2 in the key stream and based on a preset formula, thereby obtaining the image after row diffusion; the column diffusion is to calculate the new pixel values of each column of the input image according to kn1 and kn2 in the key stream and based on a preset formula, thereby obtaining the image after column diffusion; Computing property parameters and t1, t2 are converted into binary strings, and the last 50 bits after the decimal point are taken, so that two attribute keys U = {u1u2…u 50} and V = {v1v2…v 50} are obtained; is a plaintext image with a size of MxN; {x, a x , z, a z} are calculated by the following equations and are kept to 14 decimal places: Computing The external key is a 264-bit binary sequence consisting of characters 0 and 1, denoted by the symbol W = {w1w2…w}. 264 } represents the external key, where w j ∈{0,1}; The LNBT is a bijective mapping from N to N constructed by NBT, which is called local negative integer base transformation, and NBT is represented as negative integer base transformation, as shown in the following formula: where x = (a n a n-1 …a0) -B ; a natural number is represented by (a n a n-1 …a0) -B , where B is a natural number and B > 1, and the subset {a, a+1,..., b} of natural numbers is represented by ; The LNBT is as shown in the following formula: wherein L(x; B, μ, p) is a bijection on when q = p LNBT is also a bijection from to and the domain of L(x; B, μ, p) is 2. An image decryption method of performing a substitution operation by constructing inverse S-Boxes, characterized by, The method comprises the steps of: S1, receiving input information comprising a ciphertext image, an external key, and an attribute key; the ciphertext image is a ciphertext image with a size of MxN; S2, initializing, generating a key stream, and constructing inverse S-Boxes; specifically comprising: S21, calculating the initial state z and the system parameter a of a chaotic map sine-Chebyshev map using the input external key and the attribute key z and generate two key streams of length M sequences km1, km2 and two key streams of length N sequences kn1, kn2, where M and N represent the row number and column number of the ciphertext image; S22, calculating initial state x and system parameter a of the chaotic map logistic-sine map using the input external key and attribute key x x constructing a plurality of inverse S-boxes; S3, performing at least one operation comprising row replacement and column replacement based on the constructed inverse S-Boxes, to obtain the decrypted original image, wherein: the row replacement is to randomly select different inverse S-Boxes for different rows of the input image according to km1 and km2 in the key stream, and then replace the pixel values of the corresponding rows with the selected inverse S-Boxes to obtain the image after row replacement; the column replacement is to randomly select different inverse S-Boxes for different columns of the input image according to kn1 and kn2 in the key stream, and then replace the pixel values of the corresponding columns with the selected inverse S-Boxes to obtain the image after column replacement; The image input in the first operation of the operations is the ciphertext image, the image input in the other operations of the operations is the image obtained by the previous operation, and the image obtained by the last operation of the operations is the decrypted original image. S4, output the decrypted original image; In the step S3, at least one of row diffusion and column diffusion is further performed, wherein: The row diffusion is to calculate the new pixel value of each row of the input image according to km1 and km2 in the key stream and based on a preset formula, thereby obtaining the row-diffused image; The column diffusion is to calculate the new pixel value of each column of the input image according to kn1 and kn2 in the key stream and based on a preset formula, thereby obtaining the column-diffused image; The attribute keys U and V are calculated in the image encryption process by the following steps: Computing property parameters and t1, t2 are converted into binary strings, and the last 50 bits after the decimal point are taken, thus obtaining two attribute keys U = {u1u2…u 50} and V = {v1v2…v 50}; is a plaintext image with a size of M x N; {x, a x , z, a z} are calculated by the following equations and are kept to 14 decimal places: Computing The external key is a binary sequence of length 264 bits composed of the characters 0 and 1, denoted by W = {w1w2...w264}, where w 264 ∈ {0, 1} ; and j w264∈ {0, 1}. The LNBT is a bijective mapping from to called local negative integer base transform, NBT is denoted as negative integer base transform, as shown in the following formula: where x = (a n a n-1 …a0) -B ; a natural number in base B, where B is a natural number and B > 1, the subset {a, a+1,..., b} of natural numbers is denoted by n a n-1 …a0) -B ; a natural number in base B, where B is a natural number and B > 1, the subset {a, a+1,..., b} of natural numbers is denoted by ; a natural number in base B, where B is a natural number and B > 1, the subset {a, a+1,..., b} of natural numbers is denoted by LNBT is shown in the following formula: wherein When q = p, L(x; B, μ, p) is a bijection on LNBT is also a bijection from to and the domain of L(x; B, μ, p) is
Citation Information
Patent Citations
Dynamic S box construction and image encryption method based on chaotic mapping
CN108875389A