Method and device for dynamically generating S box in finite field

By performing square calculation and affine transformation on the finite domain of the 256th order, S box is dynamically generated, which solves the problem of fewer algebraic terms in AES S-box, and improves the resistance to algebraic attacks and the generation efficiency.

CN119675846AActive Publication Date: 2025-03-21NORTH CHINA ELECTRICAL POWER RES INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411675433.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-21
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

In the prior art, the algebraic expression of AES S-box has only nine terms, which cannot effectively resist algebraic attacks, and the S box is generated for a long time.

Method used

A dynamic generation method of S-box on a finite domain is proposed. By inputting the first affine transformation variable and the second affine transformation variable, square calculation and affine transformation are performed in the finite domain of the 256th order, S-box is dynamically generated, resisting algebraic attacks, and improving generation efficiency.

Benefits of technology

This method can effectively resist algebraic attacks and efficiently generate dynamic S-boxes, improving the security and computing efficiency of the cryptographic algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119675846A_ABST
    Figure CN119675846A_ABST
Patent Text Reader

Abstract

The invention provides a method and a device for dynamically generating an S box on a finite field, and relates to the technical field of information security. The method comprises the following steps: inputting a first affine transformation variable and a second affine transformation variable, taking an independent variable of an S box as an initialization assignment of the S box, and performing squaring calculation on the initialization assignment in a 256-order finite field, performing first affine transformation in a second-order finite field according to a squaring calculation result, a predetermined target affine matrix and a first affine transformation variable; solving a multiplication inverse element of the first affine transformation result in a 256-order finite field, and performing second affine transformation in a second-order finite field according to the multiplication inverse element, the target affine matrix and the second affine transformation variable to obtain a numerical element of the S box; and traversing each independent variable value until reaching 255. The device executes the method. According to the method and the device provided by the embodiment of the invention, algebraic attacks can be resisted, and the dynamic S box is efficiently generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and in particular to a method and device for dynamically generating an S-box on a finite field. Background Art

[0002] The applications of S-box mainly include the following aspects:

[0003] Cryptography application: The S-box is the only nonlinear component in many block cipher algorithms, and its cryptographic strength determines the security strength of the entire block cipher algorithm. Optimizing the performance of the S-box can improve the overall security of the cryptographic algorithm and prevent it from being cracked.

[0004] Image encryption: The optimized S-box can be applied to the image encryption algorithm. Pseudo-random numbers are generated through chaotic iteration and the sorting structure of the S-box is changed, thereby enhancing the complexity and security of image encryption.

[0005] Parallel computing: Optimizing S-boxes using parallel computing technology can improve computing efficiency. For example, using a master-slave parallel genetic algorithm framework to improve the traditional serial genetic algorithm can optimize high-order S-boxes and increase computing speed.

[0006] Distributed computing: The distributed S-box optimization algorithm based on membrane computing can handle multiple group searches, is suitable for distributed computing environments, and can effectively resist linear cryptanalysis and differential cryptanalysis.

[0007] These applications demonstrate the important role of S-box optimization in improving cryptographic security and computational efficiency.

[0008] The leakage of key data will bring serious threats to individuals. Data confidentiality is listed as a key research topic as a key focus. In the era of rapid development, there are certain requirements for the efficiency of data transmission, so a safe and efficient cryptographic algorithm has been put forward. The permutation, substitution, modular addition and other operations of cryptographic algorithms can be summarized into two basic design principles: obfuscation and diffusion. The role of obfuscation is to interrupt the connection between ciphertext and key, and the role of diffusion is to interrupt the connection between ciphertext and plaintext. Therefore, any cryptographic algorithm that effectively ensures data security has two basic components that play the role of obfuscation and diffusion.

[0009] The S-box is a common nonlinear component that can perform obfuscation and diffusion functions. As the only nonlinear component in many cryptographic algorithms, it plays a key role in protecting ciphertext from linear approximation attacks and algebraic attacks.

[0010] The most typical scheme for generating S-box based on finite fields is AES, whose S-box is defined in GF(2 8) multiplication and GF(2) addition. Although the AES S-box has good nonlinearity, differential uniformity, and linear approximation probability, the algebraic expression of the AES S-box has only nine terms and cannot resist algebraic attacks. Existing technologies use GF(2 8 ) generates random S-Box and inverse S-Box, but does not change the result that its algebraic expression has only nine terms. There are also prior arts that use different irreducible polynomials and affine matrices from those in AES, but do not solve the problem of few algebraic terms in AES S-box. The inventor himself designed an S-box three-layer optimization algorithm based on the artificial jellyfish optimization algorithm, and generated an S-box with a nonlinearity of 113, but it takes a long time to generate the S-box. Summary of the invention

[0011] In view of the problems in the prior art, an embodiment of the present invention provides a method and device for dynamically generating S-boxes over a finite field, which can at least partially solve the problems in the prior art.

[0012] On the one hand, the present invention provides a method for dynamically generating an S-box on a finite field, comprising:

[0013] Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0014] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0015] Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box;

[0016] Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0017] The first assignment before updating is the initialization assignment.

[0018] The step of performing a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable includes:

[0019] Multiplying the target affine matrix by the square calculation result to obtain a first intermediate result;

[0020] Perform an XOR calculation on the first intermediate result and the first affine transformation variable to obtain the first affine transformation result.

[0021] The performing of the second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable comprises:

[0022] Multiplying the target affine matrix by the multiplication inverse element to obtain a second intermediate result;

[0023] Perform an XOR calculation on the second intermediate result and the second affine transformation variable to obtain a numerical element of the S box.

[0024] The method for dynamically generating an S-box on a finite field further includes:

[0025] A pre-stored first reference table is called to perform square calculation on the initialization value in a finite field of order 256.

[0026] The method for dynamically generating an S-box on a finite field further includes:

[0027] The pre-stored second reference table is called to multiply the target affine matrix by the square calculation result to obtain the first intermediate result.

[0028] The method for dynamically generating an S-box on a finite field further includes:

[0029] The pre-stored third reference table is called to solve the multiplication inverse element of the first affine transformation result in a 256-order finite field.

[0030] Wherein, predetermining the target affine matrix includes:

[0031] Irreducible binary polynomials are screened based on nonlinearity to obtain multiple candidate irreducible binary polynomials; multiple candidate affine matrices are selected based on balance and bijectivity;

[0032] Obtain the S-box performance index of each candidate irreducible binary polynomial under each candidate affine matrix;

[0033] According to the comparison results of the S-box performance indicators, a target irreducible binary polynomial is selected from multiple candidate irreducible binary polynomials;

[0034] The target S-box performance indicator comparison result corresponding to the target irreducible binary polynomial is compared, and the target affine matrix is ​​selected from multiple candidate affine matrices.

[0035] On the one hand, the present invention provides a device for dynamically generating an S-box on a finite field, comprising:

[0036] A first transformation unit is used to input a first affine transformation variable and a second affine transformation variable, use an independent variable of an S-box as an initialization value of the S-box, perform a square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to a square calculation result, a predetermined target affine matrix, and the first affine transformation variable;

[0037] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0038] A second transformation unit is used to solve the multiplication inverse element of the first affine transformation result in a finite field of order 256, and perform a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable to obtain a numerical element of the S box;

[0039] a generating unit, configured to add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps, until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0040] The first assignment before updating is the initialization assignment.

[0041] In another aspect, an embodiment of the present invention provides an electronic device, including: a processor, a memory, and a bus, wherein:

[0042] The processor and the memory communicate with each other via the bus;

[0043] The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the following method:

[0044] Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0045] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0046] Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box;

[0047] Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0048] The first assignment before updating is the initialization assignment.

[0049] An embodiment of the present invention provides a non-transitory computer-readable storage medium, including:

[0050] The non-transitory computer-readable storage medium stores computer instructions, which cause the computer to execute the following method:

[0051] Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0052] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0053] Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box;

[0054] Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0055] The first assignment before updating is the initialization assignment.

[0056] The method and device for dynamically generating an S-box on a finite field provided by an embodiment of the present invention input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization assignment of the S-box, perform a square calculation on the initialization assignment in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable; wherein the initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; solve the first affine transformation in a finite field of order 256. The invention relates to a method for generating a multiplication inverse element of an affine transformation result, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, and obtaining a numerical element of an S-box; adding 1 to the independent variable to update the assignment, and using the updated assignment to replace the assignment before the update to perform the square calculation of the initialization assignment in a finite field of order 256 and subsequent steps until the independent variable reaches 255, and using all the numerical elements at this time as the dynamically generated S-box; wherein the first assignment before the update is the initialization assignment, which can resist algebraic attacks and efficiently generate dynamic S-boxes. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0058] Figure 1 It is a flowchart of a method for dynamically generating S-boxes over a finite field provided by an embodiment of the present invention.

[0059] Figure 2 It is a flowchart of a method for dynamically generating S-boxes over a finite field provided by another embodiment of the present invention.

[0060] Figure 3 It is a flowchart of a method for dynamically generating S-boxes over a finite field provided by another embodiment of the present invention.

[0061] Figure 4 It is a schematic diagram of the structure of a device for dynamically generating S-boxes over a finite field provided by one embodiment of the present invention.

[0062] Figure 5 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention. It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other arbitrarily.

[0064] Figure 1 FIG. 1 is a flow chart of a method for dynamically generating an S-box on a finite field provided by an embodiment of the present invention. Figure 1 As shown, the S-box dynamic generation method on a finite field provided by an embodiment of the present invention includes:

[0065] Step S1: input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a 256-order finite field, and perform a first affine transformation in a 2-order finite field according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0066] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256.

[0067] Step S2: Solve the multiplication inverse of the first affine transformation result in a finite field of order 256, perform a second affine transformation in a finite field of order 2 according to the multiplication inverse, the target affine matrix and the second affine transformation variable, and obtain a numerical element of the S box.

[0068] Step S3: adding 1 to the independent variable to update the assignment, and using the updated assignment to replace the assignment before the update to perform the square calculation of the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and using all the numerical elements at this time as the dynamically generated S-box;

[0069] The first assignment before updating is the initialization assignment.

[0070] In the above step S1, the device inputs a first affine transformation variable and a second affine transformation variable, uses an independent variable of an S-box as an initialization value of the S-box, performs a square calculation on the initialization value in a finite field of order 256, and performs a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0071] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256. The apparatus may be a computer device for executing the method. It should be noted that the acquisition and analysis of data involved in the embodiments of the present invention are authorized by the user.

[0072] like Figure 2 As shown, the first affine transformation variable is b, the second affine transformation variable is c, and the independent variable of the S-box is x, x, b, c ∈ Z 256 , b≠0, c≠0. The finite field of order 256 is represented by GF(2 8 ), the finite field of order 2 is denoted by GF(2).

[0073] The independent variable of the S-box is used as the initialization value of the S-box, that is, S(x) is assigned to x, where S(x) = x. The expression of S(x) is as follows:

[0074] S(x)=A(Ax 2 +b) -1 +c (1)

[0075] Among them, A is the affine matrix, and the target affine matrix can be used later.

[0076] The target affine matrix is ​​predetermined, including:

[0077] Irreducible binary polynomials are screened based on nonlinearity to obtain multiple candidate irreducible binary polynomials; multiple candidate affine matrices are selected based on balance and bijectivity;

[0078] Obtain the S-box performance index of each candidate irreducible binary polynomial under each candidate affine matrix;

[0079] According to the comparison results of the S-box performance indicators, a target irreducible binary polynomial is selected from multiple candidate irreducible binary polynomials;

[0080] The target S-box performance indicator comparison result corresponding to the target irreducible binary polynomial is compared, and the target affine matrix is ​​selected from multiple candidate affine matrices.

[0081] An irreducible binary polynomial is a binary polynomial that satisfies the condition that it is only divisible by 1 and itself and has a multiplicative inverse. The general representation of an octal irreducible binary polynomial is as follows:

[0082] {d8x 8 +d7x 7 +d6x 6 +d5x 5 +d4x 4 +d3x3 +d2x 2 +d1x 1 +1};

[0083] Among them, d i ∈{0,1}, there are 30 in total, and their corresponding hexadecimal coefficients are 0X11B, 0X11D, 0X12B, 0X12D, 0X139, 0X13F, 0X14D, 0X15F, 0X163, 0X165, 0X169, 0X171, 0X177, 0X17B, 0X187, 0X18B, 0X18D, 0X19F, 0X1A3, 0X1A9, 0X1B1, 0X1BD, 0X1C3, 0X1CF, 0X1D7, 0X1DD, 0X1E7, 0X1F3, 0X1F5, 0X1F9.

[0084] The highest nonlinearity among the above 30 is 112, as shown in Table 1:

[0085] Table 1

[0086]

[0087] That is, multiple candidate irreducible binary polynomials are x 8 +x 4 +x 3 +x+1,x 8 +x 6 +x 5 +x+1 and x 8 +x 7 +x 6 +x 5 +x 4 +x+1.

[0088] The representation of affine transformation is:

[0089] Ax+b

[0090] Where A is an n×n affine matrix, b∈Z 2n When n is 8, there are 2 64 Affine matrices. Since the S-box must satisfy balance and bijectivity, the affine matrix must meet the above requirements. For example, A1, A2 and A3 are candidate affine matrices (satisfying balance and bijectivity), and their corresponding affine transformations are shown in formulas (2), (3) and (4), respectively. Assume that the affine matrix A is A1 and b is 63, then the expression of the affine transformation is shown in formula (5):

[0091]

[0092]

[0093] According to formula (1), take b∈Z 101 ∩b≠0,c∈Z 11 ∩c≠0, 1000 S-boxes are generated when the irreducible binary polynomials are 0X11B, 0X163, 0X1F3 and the affine matrices are A1, A2 and A3. As shown in Table 2, the performance averages of 1000 S-boxes under different irreducible binary polynomials and affine matrices are shown, where NL, LP, DU, SAC_Offset, BIC_NL and BIC_SAC_Offset represent nonlinearity, linear approximation probability, differential uniformity, strict avalanche criterion offset value, the average of nonlinearity of 56 Boolean functions and the average of strict avalanche criterion offset values ​​of 56 Boolean functions, respectively.

[0094] From Table 2, we can see that when the affine matrix is ​​A1, the S-box does not satisfy the bijective property. When the affine matrix is ​​A2, the irreducible binary polynomial is x 8 +x 4 +x 3 +x+1(0X11B) and x 8 +x 7 +x 6 +x 5 +x 4 +x+1(0X163), the performance of the generated 1000 S-boxes is relatively good, and the irreducible binary polynomial is x 8 +x 4 +x 3 +x+1(0X11B) SAC-Offset of S-box Relative Irreducible Binary Polynomial x 8 +x 7 +x 6 +x 5 +x 4 +x+1(0X163) reduces the performance by 11.15%, while BIC-SAC-Offset improves the performance by 17.07%. Therefore, the irreducible binary polynomial of the present invention uses x 8 +x 4 +x 3 +x+1(0X11B), the target affine matrix is ​​A2.

[0095] Table 2

[0096]

[0097] The S-box dynamic generation method on the finite field also includes:

[0098] The first reference table stored in advance is called to perform square calculation on the initialization value in a finite field of order 256. The first reference table is denoted as T1, as shown in Table 3:

[0099] Table 3

[0100]

[0101] The performing a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable comprises:

[0102] The target affine matrix is ​​multiplied by the square calculation result to obtain a first intermediate result; the square calculation result is recorded as M, and the first intermediate result Temp1 = A 2× M.

[0103] The first intermediate result is XORed with the first affine transformation variable to obtain the first affine transformation result. Figure 3 As shown, the first affine transformation result is recorded as F. The S-box dynamic generation method on the finite field also includes:

[0104] The pre-stored second reference table is called to multiply the target affine matrix by the square calculation result to obtain the first intermediate result. The second reference table is denoted as T2, as shown in Table 4:

[0105] Table 4

[0106]

[0107]

[0108] In the above step S2, the device solves the multiplication inverse element of the first affine transformation result in a finite field of order 256, performs a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, and obtains a numerical element of the S box. The multiplication inverse element is denoted as F -1 , which can also be expressed as H, the second affine transformation is performed in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, including:

[0109] The target affine matrix is ​​multiplied by the multiplication inverse element to obtain a second intermediate result; the multiplication inverse element is denoted as H, and the second intermediate result Temp2 = A 2× H.

[0110] The second intermediate result is XORed with the second affine transformation variable to obtain a numerical element of the S-box. Figure 3 As shown, a numerical element of the calculated S-box.

[0111] The S-box dynamic generation method on the finite field also includes:

[0112] The third reference table stored in advance is called to solve the multiplication inverse element of the first affine transformation result in the finite field of order 256. The third reference table is denoted as T3, as shown in Table 5:

[0113] Table 5

[0114]

[0115] The first reference table, the second reference table and the third reference table are explained as follows:

[0116] The main operation of the S-box is GF(2 8 ) on the square, affine multiplication and multiplicative inverse, the input variable range is x∈Z 256 In order to generate S-boxes more efficiently, the irreducible binary polynomial is selected as x 8 +x 4 +x 3 +x+1(0X11B), when the target affine matrix is ​​A2, the obtained 8×8 size square data, affine multiplication data and multiplication inverse data are listed in Table T1, Table T2 and Table T3. As shown in Table 3, for x 2 As shown in Table 4, there are 256 results for A2x. As shown in Table 5, there are 256 results for the irreducible binary polynomial x. 8 +x 4 +x 3 The 256 inverse elements of the multiplication of x +x+1(0X11B).

[0117] As shown in Table 6, the average time of 100 times of directly calculating and using the table to perform 256 square operations, affine multiplication and multiplication inverse operations is shown in Table 6. As can be seen from Table 6, using table calculation compresses the time of 256 square operations, affine multiplication and multiplication inverse operations, and improves the efficiency of generating S-boxes.

[0118] Table 6

[0119]

[0120] In the above step S3, the device adds 1 to the independent variable to update the assignment, and uses the updated assignment to replace the assignment before the update to perform the square calculation of the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and uses all the numerical elements at this time as the dynamically generated S-box;

[0121] The first assignment before the update is the initialization assignment. The execution process of the present invention is further described as follows:

[0122] Step 1: Variable input. Enter the values ​​of variables b and c.

[0123] Step 2: Initialize the S-box. Assign S(x) to x.

[0124] Step 3: Square. Refer to Table T1 to find the square of x, M.

[0125] Step 4: First affine multiplication calculation: Refer to Table T2 to obtain the first intermediate result Temp1 after the target affine matrix A2 is multiplied by M.

[0126] Step 5: First XOR calculation. XOR Temp1 with variable b to get F.

[0127] Step 6: Multiplication inverse calculation. Solve F according to F -1 , refer to Table T3 to obtain the multiplication inverse element H.

[0128] Step 7: Second affine multiplication calculation: Refer to Table T2 to obtain the second intermediate result Temp2 after the affine matrix A2 is multiplied by H.

[0129] Step 8: Second XOR calculation: XOR Temp2 with variable c to obtain S(x).

[0130] Step 9: Determine whether all x have been processed. If not, execute step 3. If yes, end the S-box generation process and output the S-box Sbox.

[0131] When b=10, c=10, the obtained S-box is denoted as Sbox1, as shown in Table 7:

[0132] Table 7

[0133]

[0134] When x=0, a numerical element of the corresponding S box is "61" in Table 7, and when x=1, a numerical element of the corresponding S box is "9" in Table 7, and so on.

[0135] The present invention analyzes the performance of the S-box through six indicators, including bijectivity, nonlinearity, and differential uniformity, and compares the performance and efficiency of the S-box:

[0136] 1. Bijective analysis:

[0137] When x∈Z 2n With S∈Z 2n When there is a one-to-one correspondence, the S-box satisfies the bijective property. As shown in Table 7, when n=8, the S-box meets the bijective property requirement.

[0138] 2. Nonlinear analysis:

[0139] The nonlinearity of Boolean functions is measured by Walsh transform, so Walsh transform is used to test the nonlinearity of n n-dimensional Boolean functions that make up the S-box. The higher the nonlinearity of the S-box, the stronger its ability to resist linear attacks. After testing, the nonlinearity of the 8 Boolean functions of Sbox1 is 112.

[0140] 3. Differential uniformity analysis:

[0141] The differential uniformity is used to measure the relationship between the input differential and the output differential of the S-box. There should be no obvious statistical characteristics between the input differential and the output differential, that is, the smaller the differential uniformity, the stronger the S-box's ability to resist differential attacks. As shown in Table 8, the differential uniformity of Sbox1 is 4.

[0142] Table 8

[0143]

[0144] 4. Strict avalanche criterion analysis:

[0145] The strict avalanche criterion is used to measure the probability of the change of the S-box input value on the change of the output value. The closer the probability of the change of the input value on the change of the output value is to 0.5, the less likely it is that the output value can be deduced from the input value, that is, the closer the offset value of the strict avalanche effect is to 0, the more the S-box satisfies the strict avalanche effect. As shown in Table 9, it is the SAC correlation matrix of Sbox1, and the average value of the absolute value of the difference between the calculated data and 0.5 is 0.0278, which is very close to 0.

[0146] Table 9

[0147]

[0148] 5. Analysis of bit independence:

[0149] The independence between bits is measured by the nonlinearity and strict avalanche offset value of the Boolean function obtained after XORing different Boolean functions in the S-box. Similarly, the higher the nonlinearity of the Boolean function and the closer the strict avalanche offset value is to 0, the better the independence between bits in the S-box. As shown in Table 10, the nonlinearity after XORing different Boolean functions in Sbox1 is 112.

[0150] Table 10

[0151]

[0152] Table 11 shows the SAC values ​​after XOR of different Boolean functions in Sbox1. After calculation, the average deviation of all SACs from 0.5 is 0.0068.

[0153] Table 11

[0154]

[0155] 6. Generation cycle analysis:

[0156] The longer the iteration cycle of the S-box is, the higher the safety factor of the S-box is. As shown in Table 12, the data in Sbox1 must go through a certain number of iteration cycles to get the original value.

[0157] Table 12

[0158]

[0159]

[0160] 7. Comparison of S-box performance and efficiency:

[0161] As shown in Table 13, the performance and efficiency of the S-box of the present invention are compared with those of the prior art documents. It can be seen that the S-box generated by the present invention not only has better performance but also has high efficiency.

[0162] Table 13

[0163]

[0164] The S-box dynamic generation method on a finite field provided by an embodiment of the present invention inputs a first affine transformation variable and a second affine transformation variable, uses the independent variable of the S-box as the initialization assignment of the S-box, performs a square calculation on the initialization assignment in a finite field of order 256, and performs a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable; wherein the initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; solve the first The multiplication inverse element of the affine transformation result is used to perform a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable to obtain a numerical element of an S-box; adding 1 to the independent variable to update the assignment, and using the updated assignment to replace the assignment before the update to perform the square calculation of the initialization assignment in a finite field of order 256 and subsequent steps until the independent variable reaches 255, and all numerical elements at this time are used as dynamically generated S-boxes; wherein the first assignment before the update is the initialization assignment, which can resist algebraic attacks and efficiently generate dynamic S-boxes.

[0165] Further, performing a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable comprises:

[0166] The target affine matrix is ​​multiplied by the square calculation result to obtain a first intermediate result; this can be described with reference to the above embodiment and will not be described in detail.

[0167] The first intermediate result and the first affine transformation variable are XORed to obtain the first affine transformation result. The above description can be made with reference to the above embodiment, which will not be described in detail.

[0168] Further, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable comprises:

[0169] The target affine matrix is ​​multiplied by the multiplication inverse element to obtain a second intermediate result; this may be described with reference to the above embodiment and will not be described in detail.

[0170] The second intermediate result and the second affine transformation variable are XORed to obtain a numerical element of the S box. The above description can be referred to and will not be repeated here.

[0171] Furthermore, the S-box dynamic generation method on the finite field also includes:

[0172] The pre-stored first reference table is called to perform square calculation on the initialization value in a finite field of order 256. The above description can be referred to in the above embodiment and will not be repeated here.

[0173] Furthermore, the S-box dynamic generation method on the finite field also includes:

[0174] The pre-stored second reference table is called to multiply the target affine matrix by the square calculation result to obtain the first intermediate result. The above embodiment can be referred to for explanation and will not be described in detail.

[0175] Furthermore, the S-box dynamic generation method on the finite field also includes:

[0176] The pre-stored third reference table is called to solve the multiplication inverse element of the first affine transformation result in the finite field of order 256. The above description can be referred to in the above embodiment and will not be repeated here.

[0177] Further, predetermining the target affine matrix includes:

[0178] Based on the nonlinearity, irreducible binary polynomials are screened to obtain multiple candidate irreducible binary polynomials; based on the balance and bijectivity, multiple candidate affine matrices are selected; the description can be made with reference to the above embodiment and will not be repeated here.

[0179] Obtain the S-box performance index of each candidate irreducible binary polynomial under each candidate affine matrix; refer to the above embodiment for description and no further details will be given.

[0180] According to the S-box performance index comparison result, a target irreducible binary polynomial is selected from multiple candidate irreducible binary polynomials; the description may refer to the above embodiment and will not be repeated here.

[0181] The target S-box performance index comparison result corresponding to the target irreducible binary polynomial is compared, and the target affine matrix is ​​selected from multiple candidate affine matrices. The above-mentioned embodiment can be referred to for explanation, and no further description is given.

[0182] Figure 4 FIG. 1 is a schematic diagram of a structure of a device for dynamically generating S-boxes on a finite field provided by an embodiment of the present invention. Figure 4 As shown, the S-box dynamic generation device on a finite field provided by an embodiment of the present invention includes a first transformation unit 401, a second transformation unit 402 and a generation unit 403, wherein:

[0183] The first transformation unit 401 is used to input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, square the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable; wherein the initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; the second transformation unit 402 is used to perform a first affine transformation in a finite field of order 256. Solve the multiplication inverse element of the first affine transformation result, perform a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, and obtain a numerical element of the S-box; the generation unit 403 is used to add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation of the initialization assignment in a finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box; wherein, the first assignment before the update is the initialization assignment.

[0184] Specifically, the first transformation unit 401 in the device is used to input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S box as the initialization value of the S box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable; wherein the initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; the second transformation unit 402 is used to perform square calculation on the initialization value in a finite field of order 256. The multiplication inverse of the first affine transformation result is solved in a finite field, and a second affine transformation is performed in a finite field of order 2 according to the multiplication inverse, the target affine matrix and the second affine transformation variable to obtain a numerical element of the S-box; the generation unit 403 is used to add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation of the initialization assignment in a finite field of order 256 and subsequent steps until the independent variable reaches 255, and all numerical elements at this time are used as the dynamically generated S-box; wherein, the first assignment before the update is the initialization assignment.

[0185] The S-box dynamic generation device on a finite field provided by an embodiment of the present invention inputs a first affine transformation variable and a second affine transformation variable, uses the independent variable of the S-box as the initialization assignment of the S-box, performs a square calculation on the initialization assignment in a finite field of order 256, and performs a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable; wherein the initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; solve the first The multiplication inverse element of the affine transformation result is used to perform a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable to obtain a numerical element of an S-box; adding 1 to the independent variable to update the assignment, and using the updated assignment to replace the assignment before the update to perform the square calculation of the initialization assignment in a finite field of order 256 and subsequent steps until the independent variable reaches 255, and all numerical elements at this time are used as dynamically generated S-boxes; wherein the first assignment before the update is the initialization assignment, which can resist algebraic attacks and efficiently generate dynamic S-boxes.

[0186] The embodiment of the present invention provides an embodiment of an S-box dynamic generation device over a finite field, which can be specifically used to execute the processing flow of the above-mentioned method embodiments. Its functions are not repeated here, and reference can be made to the detailed description of the above-mentioned method embodiments.

[0187] Figure 5A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, such as Figure 5 As shown, the electronic device includes: a processor (processor) 501, a memory (memory) 502 and a bus 503;

[0188] The processor 501 and the memory 502 communicate with each other via a bus 503;

[0189] The processor 501 is used to call the program instructions in the memory 502 to execute the methods provided by the above method embodiments, for example, including:

[0190] Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0191] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0192] Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box;

[0193] Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0194] The first assignment before updating is the initialization assignment.

[0195] This embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can perform the methods provided by the above method embodiments, for example, including:

[0196] Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0197] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0198] Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box;

[0199] Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0200] The first assignment before updating is the initialization assignment.

[0201] This embodiment provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program enables the computer to execute the methods provided by the above method embodiments, for example, including:

[0202] Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable;

[0203] The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256;

[0204] Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box;

[0205] Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box;

[0206] The first assignment before updating is the initialization assignment.

[0207] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0208] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0209] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0210] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

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

[0212] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for dynamically generating S-boxes over a finite field, characterized in that: include: Input a first affine transformation variable and a second affine transformation variable, use the independent variable of the S-box as the initialization value of the S-box, perform square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable; The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; Solving the multiplication inverse element of the first affine transformation result in a finite field of order 256, performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable, to obtain a numerical element of an S-box; Add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box; The first assignment before updating is the initialization assignment.

2. The method for dynamically generating S-boxes over a finite field according to claim 1, characterized in that: The performing a first affine transformation in a finite field of order 2 according to the square calculation result, a predetermined target affine matrix and the first affine transformation variable comprises: Multiplying the target affine matrix by the square calculation result to obtain a first intermediate result; Perform an XOR calculation on the first intermediate result and the first affine transformation variable to obtain the first affine transformation result.

3. The method for dynamically generating S-boxes over a finite field according to claim 2, characterized in that: The performing a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable comprises: Multiplying the target affine matrix by the multiplication inverse element to obtain a second intermediate result; Perform an XOR calculation on the second intermediate result and the second affine transformation variable to obtain a numerical element of the S box.

4. The method for dynamically generating S-boxes over a finite field according to claim 3, characterized in that: The S-box dynamic generation method on the finite field also includes: A pre-stored first reference table is called to perform square calculation on the initialization value in a finite field of order 256.

5. The method for dynamically generating S-boxes over a finite field according to claim 4, characterized in that: The S-box dynamic generation method on the finite field also includes: The pre-stored second reference table is called to multiply the target affine matrix by the square calculation result to obtain the first intermediate result.

6. The method for dynamically generating S-boxes over a finite field according to claim 5, characterized in that: The S-box dynamic generation method on the finite field also includes: The pre-stored third reference table is called to solve the multiplication inverse element of the first affine transformation result in a 256-order finite field.

7. The method for dynamically generating S-boxes over a finite field according to any one of claims 1 to 6, characterized in that: The target affine matrix is ​​predetermined, including: Irreducible binary polynomials are screened based on nonlinearity to obtain multiple candidate irreducible binary polynomials; multiple candidate affine matrices are selected based on balance and bijectivity; Obtain the S-box performance index of each candidate irreducible binary polynomial under each candidate affine matrix; According to the comparison results of the S-box performance indicators, a target irreducible binary polynomial is selected from multiple candidate irreducible binary polynomials; The target S-box performance indicator comparison result corresponding to the target irreducible binary polynomial is compared, and the target affine matrix is ​​selected from multiple candidate affine matrices.

8. A device for dynamically generating S-boxes on a finite field, characterized in that: include: A first transformation unit is used to input a first affine transformation variable and a second affine transformation variable, use an independent variable of an S-box as an initialization value of the S-box, perform a square calculation on the initialization value in a finite field of order 256, and perform a first affine transformation in a finite field of order 2 according to a square calculation result, a predetermined target affine matrix, and the first affine transformation variable; The initial value of the independent variable is 0, and the value range of the independent variable, the first affine transformation variable and the second affine transformation variable is a finite field of order 256; A second transformation unit is used to solve the multiplication inverse element of the first affine transformation result in a finite field of order 256, and perform a second affine transformation in a finite field of order 2 according to the multiplication inverse element, the target affine matrix and the second affine transformation variable to obtain a numerical element of the S box; a generating unit, configured to add 1 to the independent variable to update the assignment, and use the updated assignment to replace the assignment before the update to perform the square calculation on the initial assignment in the finite field of order 256 and subsequent steps, until the independent variable reaches 255, and use all the numerical elements at this time as the dynamically generated S-box; The first assignment before updating is the initialization assignment.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Implementation method and system of SM4 algorithm S box based on basis transformation

    CN111786775A

  • A small hardware implementation of the subbyte function of rijndael

    WO2004056036A1