A dynamic Latin square construction method based on S-box and computer equipment
By obtaining a 2-bit dynamic control parameter and three S-boxes, a dynamic Latin square is constructed, which solves the problems of fixed Latin square being vulnerable to attacks and having a large storage size. A dynamic Latin square with reduced storage size and good cryptographic properties is achieved, which is suitable for multiple design fields.
Patent Information
- Application Number
- CN202411548115.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-11-01
AI Technical Summary
Existing cryptographic algorithms that use fixed Latin squares as components are vulnerable to deterministic attacks, and the storage size of dynamic components is large, which is not conducive to algorithm implementation.
By obtaining a 2-bit dynamic control parameter and three S-boxes, a dynamic Latin square is constructed. By using different values of the dynamic control parameter, an n-order Latin square with good cryptographic properties is generated, reducing the storage size.
The constructed dynamic Latin square has good cryptographic properties and the storage size is reduced from n*n to 3*n-2. It is suitable for combinatorial design, engineering test design, cryptographic design and wireless communication simulation design.
Smart Images

Figure CN119583049B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of symmetric cryptographic algorithms, and more specifically, to a dynamic Latin square construction method based on an S-box, a computer device, a computer-readable storage medium, and a computer program product. Background Art
[0002] The Latin square is a special square matrix, that is, each element appears only once in each row and column. It has good cryptographic properties and is used in the design of symmetric cryptographic algorithms to play a role in obfuscation and diffusion.
[0003] At present, the 16-order Latin square is the most commonly used in cryptographic algorithms. The design using fixed cryptographic components is vulnerable to deterministic attacks. The design of cryptographic algorithms using dynamic components can effectively improve the anti-attack capabilities of cryptographic algorithms. However, as nonlinear dynamic components, the storage size is large, which is not conducive to algorithm implementation. Summary of the Invention
[0004] In order to solve the problem of large storage size when Latin square is used as a component in current cryptographic algorithm design, the present invention provides a dynamic Latin square construction method based on S-box, a computer device, a computer-readable storage medium and a computer program product, which will reduce the data storage size required for Latin square application, and the constructed dynamic Latin square has good cryptographic properties.
[0005] To achieve the above object, according to a first aspect of the present invention, a method for constructing a dynamic Latin square based on an S-box is provided, the method comprising:
[0006] Get the dynamic control parameter, which is a 2-bit number;
[0007] Get the first S-box, the second S-box, and the third S-box. The first S-box and the second S-box are tables with one row and n-1 columns, and the third S-box is a table with one row and n columns.
[0008] Assign values to the target matrix according to the first S-box. The target matrix is a square matrix with n-1 rows and n-1 columns.
[0009] Assign values to the first Latin square according to the target matrix and the second S-box. The first Latin square is a square matrix with n rows and n columns.
[0010] The first Latin square is permuted according to the third S-box to obtain a second Latin square, which is a square matrix with n rows and n columns;
[0011] When the second Latin square meets the set conditions, the second Latin square is used as the target Latin square;
[0012] When the second Latin square does not meet the set condition, the first S-box, the second S-box, and the third S-box are re-acquired until the second Latin square meets the set condition.
[0013] Furthermore, assigning values to the target matrix according to the first S-box includes assigning values to the target matrix according to the following rules:
[0014] When the dynamic control parameter is set to 0, SS (i,j) =S1 ((j-1)-(i-1)×1)%(n-1)+1 ;
[0015] When the dynamic control parameter is set to 1, SS (i,j) =S1 ((j-1)-(i-1)×2)%(n-1)+1 ;
[0016] When the dynamic control parameter is set to 2, SS (i,j) =S1 ((j-1)-(i-1)×(n-3))%(n-1)+1 ;
[0017] When the dynamic control parameter is set to 3, SS (i,j) =S1 ((j-1)-(i-1)×(n-2))%(n-1)+1 ;
[0018] Among them, % represents the remainder operation, S1 i is the element value of the i-th column of the first S-box, SS (i,j) is the element value in the i-th row and j-th column of the target matrix, 1≤i,j≤n-1.
[0019] Furthermore, the first Latin square is assigned values according to the target matrix and the second S-box, including assigning values to a first part of elements of the first Latin square (latin′) according to the following rules:
[0020] latin′[i][j]=0,1≤i,j≤n,latin′[S2 j +1][SS (i,j) +1]=i,1≤i,j≤n-1,
[0021] Among them, SS (i,j) is the element value of the target matrix in row i and column j, S2 j is the element value of the jth column of the second S-box, latin′[S2 j +1][SS (i,j) +1] is the S2th of the first Latin square (latin′) j +1 row SS (i,j) +1 column element value;
[0022] When the dynamic control parameter is set to a different value, the second part of the elements of the first Latin square are assigned values according to the corresponding rule.
[0023] Furthermore, when the value of the dynamic control parameter is set to different values, the second part of the elements of the first Latin square are assigned values according to the corresponding rules, including when the value of the dynamic control parameter is set to 0 or 2, the second part of the elements of the first Latin square are assigned values according to the following rules:
[0024] latin′[S2 n-i +1][SS (i,n-i) +1]=0,1≤i≤n-1;
[0025] latin′[S2 n-i +1][1]=i, 1≤i≤n-1;
[0026] latin′[1][SS (i,n-i) +1]=i, 1≤i≤n-1;
[0027] When the dynamic control parameter is set to 1 or 3, the second element of the first Latin square is assigned values according to the following rules:
[0028] latin′[S2 i +1][SS (i,i( +1]=0,1≤i≤n-1;
[0029] latin′[S2 i +1][1]=i, 1≤i≤n-1;
[0030] latin′[1][SS (i,i) +1]=i, 1≤i≤n-1.
[0031] Furthermore, the first Latin square is permuted according to the third S-box to obtain a second Latin square, including permuting each element in the first Latin square (latin′) according to the following rules to obtain the second Latin square (latin):
[0032] latin[i][j]=S3 (latin′[i][j]) , 1≤i,j≤n;
[0033] Where latin′[i][j] is the element value of the i-th row and j-th column of the first Latin square (latin′), latin[i][j] is the element value of the i-th row and j-th column of the second Latin square (latin), S3 (latin′[i][j]) It is the value of the latin′[i][j] element after the third S-box substitution.
[0034] Furthermore, when the second Latin square meets the set conditions, the second Latin square is used as the target Latin square, including respectively calculating the cryptographic properties of the second Latin square when the dynamic control parameter is set to a value of 0, 1, 2, and 3; if all the cryptographic properties are within a preset numerical range, it is determined that the second Latin square meets the set conditions, and the second Latin square is used as the target Latin square.
[0035] Furthermore, the cryptographic properties include at least one of nonlinearity, differential uniformity, algebraic degree, and algebraic immunity order.
[0036] According to a second aspect of the present invention, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory, and the processor executes the computer program to implement the steps of any one of the above methods.
[0037] According to a third aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0038] According to a fourth aspect of the present invention, there is also provided a computer program product, comprising a computer program, which implements the steps of any one of the above methods when executed by a processor.
[0039] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:
[0040] The present invention provides a method for constructing a dynamic Latin square based on S-boxes. The method obtains a 2-bit dynamic control parameter, a first S-box consisting of n-1 elements, a second S-box, and a third S-box consisting of n elements. Using these three S-boxes, and by setting different values for the dynamic control parameter, an n-order second Latin square corresponding to different dynamic control parameters is obtained. This second Latin square has good cryptographic properties, and only three S-boxes need to be stored during the construction of the Latin square. This reduces the data storage required during the dynamic Latin square construction from n*n to 3*n-2, thereby achieving a small storage size. Furthermore, the constructed dynamic Latin square can be applied to fields such as combinatorial design, engineering test design, cryptographic design, and wireless communication simulation design. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 A flowchart of a dynamic Latin square construction method based on S-boxes provided in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
[0045] The terms "first," "second," "third," and the like in the specification and claims of this application and the accompanying drawings are used to distinguish between different objects, not to describe a particular order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements, but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.
[0046] like Figure 1 As shown, a dynamic Latin square construction method based on S-boxes is provided. This method can be executed by a terminal or a server communicating with the terminal via a network. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, etc. The server can be a standalone server or a server cluster consisting of multiple servers. This method is described using the terminal as an example and includes the following steps:
[0047] Step 101: Acquire a dynamic control parameter, which is a 2-bit number.
[0048] The value of the dynamic control parameter is 0, 1, 2 or 3.
[0049] Step 102: Obtain the first S-box, the second S-box, and the third S-box.
[0050] Among them, the first S box and the second S box are a permutation on the set {1,2,…,n-1}, each including n-1 elements, and the third S box is a permutation on the set {0,1,2,…,n-1}, including n elements. That is, the first S box and the second S box are a table with one row and n-1 columns, and the column count starts from 1, S1 iis the element value of the i-th column of the first S-box, S2 i is the element value of the i-th column of the second S-box, 1≤i≤n-1; the third S-box is a table with one row and n columns, and its column count starts from 0, S3 i is the element value of the i-th column of the third S-box, 0≤i≤n-1.
[0051] For example, two S-boxes containing n-1 elements are randomly selected as the first S-box S1 and the second S-box S2, and one S-box containing n elements is randomly selected as the third S-box S3, which is specifically expressed as follows:
[0052] 1 2 3 … n-1 S1 <![CDATA[S11]]> <![CDATA[S12]]> <![CDATA[S13]]> … <![CDATA[S1 n-1 ]]>
[0053] 1 2 3 … n-1 S2 <![CDATA[S21]]> <![CDATA[S22]]> <![CDATA[S23]]> … <![CDATA[S2 n-1 ]]>
[0054] 0 1 2 3 … n-1 S3 <![CDATA[S30]]> <![CDATA[S31]]> <![CDATA[S32]]> <![CDATA[S33]]> … <![CDATA[S3 n-1 ]]>
[0055] Step 103: Assign values to the target matrix according to the first S-box.
[0056] The target matrix SS is a square matrix with n-1 rows and n-1 columns, and its row and column counts start from 1. (i,j) Represents the element value in the i-th row and j-th column of SS, where 1≤i,j≤n-1.
[0057] Exemplarily, the target matrix is assigned according to the first S-box according to the following rules:
[0058] When the dynamic control parameter is set to 0, SS (i,j) =S1 ((j-1)-(i-1)×1)%(n-1)+1 , 1≤i,j≤n-1, % represents the remainder operation. Taking n=16, i.e. constructing a 16-order Latin square, as an example, the target matrix after assignment is:
[0059]
[0060] When the dynamic control parameter is set to 1, SS (i,j) =S1 ((j-1)-(i-1)×2)%(n-1)+1 , 1≤i,j≤n-1, % represents the remainder operation. Taking n=16, i.e. constructing a 16-order Latin square, as an example, the target matrix after assignment is:
[0061]
[0062] When the dynamic control parameter is set to 2, SS (i,j) =S1 ((j-1)-(i-1)×(n-3))%(n-1)+1 , 1≤i,j≤n-1, % represents the remainder operation. Taking n=16, i.e. constructing a 16-order Latin square, as an example, the target matrix after assignment is:
[0063]
[0064] When the dynamic control parameter is set to 3, SS (i,j) =S1 ((j-1)-(i-1)×(n-2))%(n-1)+1 , 1≤i,j≤n-1, % represents the remainder operation. Taking n=16, i.e. constructing a 16-order Latin square, as an example, the target matrix after assignment is:
[0065]
[0066] Step 104 : Assign values to the first Latin square according to the target matrix and the second S-box. The first Latin square is a square matrix with n rows and n columns, and both row and column counts start from 1.
[0067] Among them, the first Latin square latin′ is an n-order Latin square, that is, a square matrix with n rows and n columns, satisfying that each row and each column is a permutation on the set {0,1,2,…,n-1}, and latin′[i][j] represents the element value of the i-th row and j-th column of the first Latin square latin′, where 1≤i,j≤n.
[0068] Exemplarily, let each element value of the first Latin square be 0, latin′[i][j]=0, 1≤i, j≤n.
[0069] Then, assign values to the first elements of the first Latin square according to the following rules:
[0070] latin′[S2 j +1][SS (i,j) +1]=i,1≤i,j≤n-1,
[0071] Among them, SS (i,j) is the element value of the target matrix in row i and column j, S2 j is the element value of the jth column of the second S-box, latin′[S2 j +1][SS (i,j) +1] is the S2th of the first Latin square (latin′) j +1 row SS (i,j) +1 column element value.
[0072] When the dynamic control parameter is set to 0 or 2, the second element of the first Latin square latin′ is assigned values according to the following rules:
[0073] latin′[S2 n-i +1][SS (i,n-i) +1]=0,1≤i≤n-1;
[0074] latin′[S2 n-i +1][1]=i, 1≤i≤n-1;
[0075] latin′[1][SS (i,n-i) +1]=i, 1≤i≤n-1.
[0076] When the dynamic control parameter is set to 1 or 3, the second element of the first Latin square latin′ is assigned values according to the following rules:
[0077] latin′[S2 i +1][SS (i,i) +1]=0,1≤i≤n-1;
[0078] latin′[S2 i +1][1]=i, 1≤i≤n-1;
[0079] latin′[1][SS (i,i) +1]=i, 1≤i≤n-1.
[0080] Step 105 : permuting the first Latin square according to the third S-box to obtain a second Latin square.
[0081] Exemplarily, the elements in the first Latin square latin′ are permuted according to the following rules to obtain the second Latin square latin:
[0082] latin[i][j]=S3 (latin′[i][j]) , 1≤i,j≤n.
[0083] Where latin′[i][j] is the element value of the i-th row and j-th column of the first Latin square (latin′), latin[i][j] is the element value of the i-th row and j-th column of the second Latin square (latin), S3 (latin′[i][j]) It is the value of the latin′[i][j] element after the third S-box substitution.
[0084] Step 106 : If the second Latin square meets the set conditions, the second Latin square is used as the target Latin square; if the second Latin square does not meet the set conditions, the first S-box, the second S-box, and the third S-box are re-acquired until the second Latin square meets the set conditions.
[0085] Among them, the target Latin square is the second Latin square that meets the set conditions. The target Latin square can be applied to fields such as combinatorial design, engineering test design, cryptographic design and wireless communication simulation design.
[0086] Cryptographic properties include the nonlinearity, differential uniformity, algebraic degree, algebraic immunity order, etc. of components in the design of cryptographic algorithms, and are the indicator requirements for measuring the security of cryptographic algorithms.
[0087] For example, to determine whether the cryptographic properties of the second Latin square are good, only when the cryptographic properties of the second Latin square are good in the four cases where the dynamic control parameter is 0, 1, 2, and 3, the second Latin square calculated when the dynamic control parameter is 0, 1, 2, or 3 is output as the target Latin square.
[0088] Specifically, the cryptographic properties of the second Latin square are calculated when the dynamic control parameter is set to 0, 1, 2, and 3, respectively. If all cryptographic properties are within a preset numerical range, it is determined that the second Latin square meets the set conditions, and the second Latin square is used as the target Latin square. Otherwise, return to step 102, and re-acquire the first S-box, the second S-box, and the third S-box until the second Latin square meets the set conditions.
[0089] In the above-mentioned S-box-based dynamic Latin square construction method, a 2-bit dynamic control parameter, a first S-box including n-1 elements, a second S-box, and a third S-box including n elements are obtained. These three S-boxes are used to set different values of the dynamic control parameter to obtain a second Latin square of order n corresponding to different dynamic control parameters. The second Latin square has good cryptographic properties, and only three S-boxes need to be stored during the construction of the Latin square. The data storage scale required during the dynamic Latin square construction is reduced from n*n to 3*n-2, thereby achieving the purpose of small storage scale.
[0090] In one embodiment, a method for constructing a 16-order dynamic Latin square is provided, comprising:
[0091] Step 1: Set the dynamic control parameter cp to a 2-bit number, i.e., cp∈{0,1,2,3}.
[0092] Step 2: Obtain three S-boxes, namely the first S-box S1, the second S-box S2, and the third S-box S3. Specifically, S1, S2, and S3 are represented as follows.
[0093] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 S1 7 12 4 9 8 11 5 10 14 13 15 3 6 1 2 S2 4 7 1 10 8 3 13 12 14 6 2 11 9 15 5
[0094] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 S3 4 14 1 2 5 3 6 8 7 15 10 11 0 12 13 9
[0095] Step 3: Create the target matrix SS, which is a square matrix with 15 rows and 15 columns. (i,j) Denote the value of the element in row i and column j of SS, where 1≤i,j≤15. Let the value of each element of SS be 0.
[0096] When the dynamic control parameter is set to 0, SS (i,j) =S1 ((j-1)-(i-1)×1)%15+1 , 1≤i,j≤15, the result after assignment is:
[0097]
[0098] When the dynamic control parameter is set to 1, SS (i,j) =S1 ((j-1)-(i-1)×2)%15+1 , 1≤i,j≤15, the result after assignment is:
[0099]
[0100] When the dynamic control parameter is set to 2, SS (i,j) =S1 ((j-1)-(i-1)×13)%15+1 , 1≤i,j≤15, the result after assignment is:
[0101]
[0102] When the dynamic control parameter is set to 3, SS (i,j) =S1 ((j-1)-(i-1)×14)%15+1 , 1≤i,j≤15, the result after assignment is:
[0103]
[0104] Step 4: First, create the first Latin square latin′ of order 16, and set the n*n elements of the first Latin square to all be 0. Then, assign values to the first part of the elements of the first Latin square latin′ according to the different values of the dynamic control parameters. The specific operations are as follows:
[0105] latin′[S2 j +1][SS (i,j) +1]=i, 1≤i, j≤15.
[0106] When the value of the dynamic control parameter is 0, the result after assignment is:
[0107] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 4 7 1 12 6 3 14 15 11 13 2 9 10 8 0 13 12 15 9 5 14 11 7 8 4 6 10 2 3 1 0 8 7 10 4 15 9 6 2 3 14 1 5 12 13 11 0 3 2 5 14 10 4 1 12 13 9 11 15 7 8 6 0 2 1 4 13 9 3 15 11 12 8 10 14 6 7 5 0 12 11 14 8 4 13 10 6 7 3 5 9 1 2 15 0 4 3 6 15 11 5 2 13 14 10 12 1 8 9 7 0 7 6 9 3 14 8 5 1 2 13 15 4 11 12 10 0 15 14 2 11 7 1 13 9 10 6 8 12 4 5 3 0 6 5 8 2 13 7 4 15 1 12 14 3 10 11 9 0 14 13 1 10 6 15 12 8 9 5 7 11 3 4 2 0 10 9 12 6 2 11 8 4 5 1 3 7 14 15 13 0 9 8 11 5 1 10 7 3 4 15 2 6 13 14 12 0 11 10 13 7 3 12 9 5 6 2 4 8 15 1 14 0 1 15 3 12 8 2 14 10 11 7 9 13 5 6 4
[0108] When the dynamic control parameter value is 1, the result after assignment is:
[0109] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 10 4 1 14 11 2 15 8 6 7 9 5 13 12 0 7 14 8 5 3 15 6 4 12 10 11 13 9 2 1 0 12 4 13 10 8 5 11 9 2 15 1 3 14 7 6 0 2 9 3 15 13 10 1 14 7 5 6 8 4 12 11 0 9 1 10 7 5 2 8 6 14 12 13 15 11 4 3 0 14 6 15 12 10 7 13 11 4 2 3 5 1 9 8 0 10 2 11 8 6 3 9 7 15 13 14 1 12 5 4 0 4 11 5 2 15 12 3 1 9 7 8 10 6 14 13 0 8 15 9 6 4 1 7 5 13 11 12 14 10 3 2 0 11 3 12 9 7 4 10 8 1 14 15 2 13 6 5 0 15 7 1 13 11 8 14 12 5 3 4 6 2 10 9 0 13 5 14 11 9 6 12 10 3 1 2 4 15 8 7 0 5 12 6 3 1 13 4 2 10 8 9 11 7 15 14 0 6 13 7 4 2 14 5 3 11 9 10 12 8 1 15 0 1 8 2 14 12 9 15 13 6 4 5 7 3 11 10
[0110] When the dynamic control parameter value is 2, the result after assignment is:
[0111] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 7 13 1 3 6 15 2 9 11 10 8 12 4 5 0 10 3 9 12 14 2 11 13 5 7 6 4 8 15 1 0 5 13 4 7 9 12 6 8 15 2 1 14 3 10 11 0 15 8 14 2 4 7 1 3 10 12 11 9 13 5 6 0 8 1 7 10 12 15 9 11 3 5 4 2 6 13 14 0 3 11 2 5 7 10 4 6 13 15 14 12 1 8 9 0 7 15 6 9 11 14 8 10 2 4 3 1 5 12 13 0 13 6 12 15 2 5 14 1 8 10 9 7 11 3 4 0 9 2 8 11 13 1 10 12 4 6 5 3 7 14 15 0 6 14 5 8 10 13 7 9 1 3 2 15 4 11 12 0 2 10 1 4 6 9 3 5 12 14 13 11 15 7 8 0 4 12 3 6 8 11 5 7 14 1 15 13 2 9 10 0 12 5 11 14 1 4 13 15 7 9 8 6 10 2 3 0 11 4 10 13 15 3 12 14 6 8 7 5 9 1 2 0 1 9 15 3 5 8 2 4 11 13 12 10 14 6 7
[0112] When the dynamic control parameter value is 3, the result after assignment is:
[0113] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 13 10 1 5 11 14 3 2 6 4 15 8 7 9 0 4 5 2 8 12 3 6 10 9 13 11 7 15 14 1 0 9 10 7 13 2 8 11 15 14 3 1 12 5 4 6 0 14 15 12 3 7 13 1 5 4 8 6 2 10 9 11 0 15 1 13 4 8 14 2 6 5 9 7 3 11 10 12 0 5 6 3 9 13 4 7 11 10 14 12 8 1 15 2 0 13 14 11 2 6 12 15 4 3 7 5 1 9 8 10 0 10 11 8 14 3 9 12 1 15 4 2 13 6 5 7 0 2 3 15 6 10 1 4 8 7 11 9 5 13 12 14 0 11 12 9 15 4 10 13 2 1 5 3 14 7 6 8 0 3 4 1 7 11 2 5 9 8 12 10 6 14 13 15 0 7 8 5 11 15 6 9 13 12 1 14 10 3 2 4 0 8 9 6 12 1 7 10 14 13 2 15 11 4 3 5 0 6 7 4 10 14 5 8 12 11 15 13 9 2 1 3 0 1 2 14 5 9 15 3 7 6 10 8 4 12 11 13
[0114] Then, the second part of the elements of the first Latin square latin′ is assigned a value. The specific operation is: when the value of the dynamic control parameter is 0 or 2,
[0115] latin′[S2 16-i +1][SS (i,16-i) +1]=0,1≤i≤15;
[0116] latin′[S2 16-i +1][1]=i, 1≤i≤15;
[0117] latin′[1][SS (i,16-i) +1]=i, 1≤i≤15;
[0118] When the dynamic control parameter value is 1 or 3,
[0119] latin′[S2 i +1][SS (i,i) +1]=0,1≤i≤15;
[0120] latin′[S2 i +1][1]=i, 1≤i≤15;
[0121] latin′[1][SS (i,i) +1]=i, 1≤i≤15.
[0122] Finally, when the dynamic control parameter takes the value of 0, the first Latin square latin′ is:
[0123] 0 9 1 10 7 5 2 8 6 14 12 13 15 11 4 3 13 5 4 7 1 12 6 3 14 15 11 0 2 9 10 8 5 13 12 15 9 0 14 11 7 8 4 6 10 2 3 1 10 8 7 0 4 15 9 6 2 3 14 1 5 12 13 11 15 3 2 5 14 10 4 1 12 13 9 11 0 7 8 6 1 2 0 4 13 9 3 15 11 12 8 10 14 6 7 5 6 12 11 14 8 4 13 10 0 7 3 5 9 1 2 15 14 4 3 6 15 11 5 2 13 0 10 12 1 8 9 7 11 7 6 9 3 14 8 5 1 2 13 15 4 0 12 10 3 15 14 2 11 7 1 13 9 10 6 8 12 4 5 0 12 6 5 8 2 13 7 4 15 1 0 14 3 10 11 9 4 14 13 1 10 6 15 12 8 9 5 7 11 3 0 2 8 10 9 12 6 2 11 0 4 5 1 3 7 14 15 13 9 0 8 11 5 1 10 7 3 4 15 2 6 13 14 12 7 11 10 13 0 3 12 9 5 6 2 4 8 15 1 14 2 1 15 3 12 8 0 14 10 11 7 9 13 5 6 4
[0124] When the dynamic control parameter is 1, the first Latin square latin′ is:
[0125] 0 3 2 5 14 10 4 1 12 13 9 11 15 7 8 6 3 0 10 4 1 14 11 2 15 8 6 7 9 5 13 12 11 7 14 8 5 3 15 6 4 12 10 0 13 9 2 1 6 12 4 13 10 8 5 11 9 2 15 1 3 14 7 0 1 2 9 3 15 13 10 0 14 7 5 6 8 4 12 11 15 9 1 10 7 5 2 8 6 14 12 13 0 11 4 3 10 14 6 15 12 0 7 13 11 4 2 3 5 1 9 8 2 10 0 11 8 6 3 9 7 15 13 14 1 12 5 4 5 4 11 0 2 15 12 3 1 9 7 8 10 6 14 13 13 8 15 9 6 4 1 7 5 0 11 12 14 10 3 2 4 11 3 12 9 7 0 10 8 1 14 15 2 13 6 5 12 15 7 1 13 11 8 14 0 5 3 4 6 2 10 9 8 13 5 14 11 9 6 12 10 3 1 2 4 15 0 7 7 5 12 6 3 1 13 4 2 10 8 9 11 0 15 14 9 6 13 7 4 2 14 5 3 11 0 10 12 8 1 15 14 1 8 2 0 12 9 15 13 6 4 5 7 3 11 10
[0126] When the dynamic control parameter is 2, the first Latin square latin′ is:
[0127] 0 15 1 13 4 8 14 2 6 5 9 7 3 11 10 12 13 14 7 0 1 3 6 15 2 9 11 10 8 12 4 5 5 10 3 9 12 14 2 11 13 0 7 6 4 8 15 1 10 5 13 4 7 9 12 6 8 15 2 1 14 3 0 11 15 0 8 14 2 4 7 1 3 10 12 11 9 13 5 6 1 8 0 7 10 12 15 9 11 3 5 4 2 6 13 14 6 3 11 2 5 7 10 4 0 13 15 14 12 1 8 9 14 7 15 6 9 11 0 8 10 2 4 3 1 5 12 13 11 13 6 12 15 2 5 14 1 8 10 9 7 0 3 4 3 9 2 8 11 13 1 10 12 4 6 5 0 7 14 15 12 6 14 5 8 10 13 7 9 1 3 2 15 4 11 0 4 2 10 1 0 6 9 3 5 12 14 13 11 15 7 8 8 4 12 3 6 0 11 5 7 14 1 15 13 2 9 10 9 12 5 11 14 1 4 13 15 7 0 8 6 10 2 3 7 11 4 10 13 15 3 12 14 6 8 0 5 9 1 2 2 1 9 15 3 5 8 0 4 11 13 12 10 14 6 7
[0128] When the dynamic control parameter is 3, the first Latin square latin′ is:
[0129] 0 15 8 14 2 4 7 1 3 10 12 11 9 13 5 6 3 12 13 10 1 5 11 14 0 2 6 4 15 8 7 9 11 4 5 2 8 12 3 6 10 9 13 0 7 15 14 1 6 9 10 7 13 2 8 11 15 14 3 1 12 5 4 0 1 14 1 5 12 3 7 13 0 5 4 8 6 2 10 9 11 15 0 1 13 4 8 14 2 6 5 9 7 3 11 10 12 10 5 6 3 9 13 4 7 11 0 14 12 8 1 15 2 2 13 14 11 0 6 12 15 4 3 7 5 1 9 8 10 5 10 11 8 14 3 9 12 1 15 4 2 13 6 0 7 13 2 3 15 6 10 1 4 8 7 11 9 5 0 12 14 4 11 12 9 15 0 10 1 3 2 1 5 3 14 7 6 8 12 3 4 1 7 11 2 5 9 8 0 10 6 14 13 15 8 7 0 5 11 15 6 9 13 12 1 14 10 3 2 4 7 8 9 6 12 1 0 10 14 13 2 15 11 4 3 5 9 6 7 4 10 14 5 8 12 11 15 13 0 2 1 3 14 1 2 0 5 9 15 3 7 6 10 8 4 12 11 13
[0130] Step 5: Query S3 and permute each element in the first Latin square latin′. The specific operation is: latin[i][j] = S3 (latin′[i][j]) , 1≤i, j≤16; the result after permutation (i.e., the second Latin square) is as follows.
[0131] When the dynamic control parameter is 0, the second Latin square is:
[0132] 4 15 14 10 8 3 1 7 6 13 0 12 9 11 5 2 12 3 5 8 14 0 6 2 13 9 11 4 1 15 10 7 3 12 0 9 15 4 13 11 8 7 5 6 10 1 2 14 10 7 8 4 5 9 15 6 1 2 13 14 3 0 12 11 9 2 1 3 13 10 5 14 0 12 15 11 4 8 7 6 14 1 4 5 12 15 2 9 11 0 7 10 13 6 8 3 6 0 11 13 7 5 12 10 4 8 2 3 15 14 1 9 13 5 2 6 9 11 3 1 12 4 10 0 14 7 15 8 11 8 6 15 2 13 7 3 14 1 12 9 5 4 0 10 2 9 13 1 11 8 14 12 15 10 6 7 0 5 3 4 0 6 3 7 1 12 8 5 9 14 4 13 2 10 11 15 5 13 12 14 10 6 9 0 7 15 3 8 11 2 4 1 7 10 15 0 6 1 11 4 5 3 14 2 8 13 9 12 15 4 7 11 3 14 10 8 2 5 9 1 6 12 13 0 8 11 10 12 4 2 0 15 3 6 1 5 7 9 14 13 1 14 9 2 0 7 4 13 10 11 8 15 12 3 6 5
[0133] When the dynamic control parameter is set to 1, the second Latin square is:
[0134] 4 2 1 3 13 10 5 14 0 12 15 11 9 8 7 6 2 4 10 5 14 13 11 1 9 7 6 8 15 3 12 0 11 8 13 7 3 2 9 6 5 0 10 4 12 15 1 14 6 0 5 12 10 7 3 11 15 1 9 14 2 13 8 4 14 1 15 2 9 12 10 4 13 8 3 6 7 5 0 11 9 15 14 10 8 3 1 7 6 13 0 12 4 11 5 2 10 13 6 9 0 4 8 12 11 5 1 2 3 14 15 7 1 10 4 11 7 6 2 15 8 9 12 13 14 0 3 5 3 5 11 4 1 9 0 2 14 15 8 7 10 6 13 12 12 7 9 15 6 5 14 8 3 4 11 0 13 10 2 1 5 11 2 0 15 8 4 10 7 14 13 9 1 12 6 3 0 9 8 14 12 11 7 13 4 3 2 5 6 1 10 15 7 12 3 13 11 15 6 0 10 2 14 1 5 9 4 8 8 3 0 6 2 14 12 5 1 10 7 15 11 4 9 13 15 6 12 8 5 1 13 3 2 11 4 10 0 7 14 9 13 14 7 1 4 0 15 9 12 6 5 3 8 2 11 10
[0135] When the dynamic control parameter is set to 2, the second Latin square is:
[0136] 4 9 14 12 5 7 13 1 6 3 15 8 2 11 10 0 12 13 8 4 14 2 6 9 1 15 11 10 7 0 5 3 3 10 2 15 0 13 1 11 12 4 8 6 5 7 9 14 10 3 12 5 8 15 0 6 7 9 1 14 13 2 4 11 9 4 7 13 1 5 8 14 2 10 0 11 15 12 3 6 14 7 4 8 10 0 9 15 11 2 3 5 1 6 12 13 6 2 11 1 3 8 10 5 4 12 9 13 0 14 7 15 13 8 9 6 15 11 4 7 10 1 5 2 14 3 0 12 11 12 6 0 9 1 3 13 14 7 10 15 8 4 2 5 2 15 1 7 11 12 14 10 0 5 6 3 4 8 13 9 0 6 13 3 7 10 12 8 15 14 2 1 9 5 11 4 5 1 10 14 4 6 15 2 3 0 13 12 11 9 8 7 7 5 0 2 6 4 11 3 8 13 14 9 12 1 15 10 15 0 3 11 13 14 5 12 9 8 4 7 6 10 1 2 8 11 5 10 12 9 2 0 13 6 7 4 3 15 14 1 1 14 15 9 2 3 7 4 5 11 12 0 10 13 6 8
[0137] When the dynamic control parameter is set to 3, the second Latin square is:
[0138] 4 9 7 13 1 5 8 14 2 10 0 11 15 12 3 6 2 0 12 10 14 3 11 13 4 1 6 5 9 7 8 15 11 5 3 1 7 0 2 6 10 15 12 4 8 9 13 14 6 15 10 8 12 1 7 11 9 13 2 14 0 3 5 4 14 13 9 0 2 8 12 4 3 5 7 6 1 10 15 11 9 4 14 12 5 7 13 1 6 3 15 8 2 11 10 0 10 3 6 2 15 12 5 8 11 4 13 0 7 14 9 1 1 12 13 11 4 6 0 9 5 2 8 3 14 15 7 10 3 10 11 7 13 2 15 0 14 9 5 1 12 6 4 8 12 1 2 9 6 10 14 5 7 8 11 15 3 4 0 13 5 11 0 15 9 4 10 12 1 14 3 2 13 8 6 7 0 2 5 14 8 11 1 3 15 7 4 10 6 13 12 9 7 8 4 3 11 9 6 15 12 0 14 13 10 2 1 5 8 7 15 6 0 14 4 10 13 12 1 9 11 5 2 3 15 6 8 5 10 13 3 7 0 11 9 12 4 1 14 2 13 14 1 4 3 15 9 2 8 6 10 7 5 0 11 12
[0139] Step 6: Determine the cryptographic properties of the second Latin square.
[0140] When the value of the dynamic control parameter is 0, the nonlinearity of the second Latin square is 100, the differential uniformity is 38, the algebraic degree is 6, and the algebraic immunity order is 3; when the value of the dynamic control parameter is 1, the nonlinearity of the second Latin square is 100, the differential uniformity is 38, the algebraic degree is 6, and the algebraic immunity order is 3; when the value of the dynamic control parameter is 2, the nonlinearity of the second Latin square is 100, the differential uniformity is 38, the algebraic degree is 6, and the algebraic immunity order is 3; when the value of the dynamic control parameter is 3, the nonlinearity of the second Latin square is 100, the differential uniformity is 38, the algebraic degree is 6, and the algebraic immunity order is 3.
[0141] It can be seen that the second Latin square meets the set conditions, and the second Latin square is taken as the target Latin square.
[0142] In this embodiment, constructing a 16th-order Latin square only requires 15*2+16=46 data storage spaces, significantly reducing the data storage footprint compared to the current 16th-order Latin square, which requires 16*16=256 data storage spaces. Using the three S-boxes S1, S2, and S3, a 16th-order Latin square is obtained by varying the values of the dynamic control parameters. Different dynamic control parameters correspond to different 16th-order Latin squares. The resulting 16th-order Latin squares all exhibit excellent cryptographic properties and can be applied to cryptographic algorithms as nonlinear cryptographic components.
[0143] The present application also provides a computer device, the internal structure diagram of which can be as follows: Figure 2As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a dynamic Latin square construction method based on an S-box is implemented.
[0144] Those skilled in the art will understand that Figure 2 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0145] like Figure 2 As shown, the present application also provides a computer device, which includes a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the steps in the above-mentioned method embodiments.
[0146] The present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method embodiments. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a microdrive, a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.
[0147] The present application also provides a computer program product, including a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.
[0148] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0149] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0150] The above description is merely an exemplary embodiment of the present disclosure and is not intended to limit the scope of the present disclosure. That is, any equivalent changes and modifications made in accordance with the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure herein, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not recorded in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
[0151] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0152] It will be easily understood by those skilled in the art that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements 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 dynamic Latin square construction method based on S-box, characterized in that: include: Obtaining a dynamic control parameter, where the dynamic control parameter is a 2-bit number; Obtain a first S-box, a second S-box, and a third S-box, wherein the first S-box and the second S-box are tables with one row and n-1 columns, and the third S-box is a table with one row and n columns; Assign values to a target matrix according to the first S-box, where the target matrix is a square matrix with n-1 rows and n-1 columns, including: When the dynamic control parameter is set to 0, ; When the dynamic control parameter is set to 1, ; When the dynamic control parameter is set to 2, ; When the dynamic control parameter is set to 3, ; Among them, % represents the remainder operation. is the element value of the i-th column of the first S-box, is the element value of the target matrix in row i and column j, ; Assigning a value to a first Latin square according to the target matrix and the second S-box, where the first Latin square is a square matrix with n rows and n columns; Permuting the first Latin square according to the third S-box to obtain a second Latin square, where the second Latin square is a square matrix with n rows and n columns; The cryptographic properties of the second Latin square are calculated respectively when the value of the dynamic control parameter is set to 0, 1, 2, and 3; if all cryptographic properties are within a preset value range, it is determined that the second Latin square meets the set conditions, and the second Latin square is used as the target Latin square; otherwise, the first S-box, the second S-box, and the third S-box are re-obtained until the second Latin square meets the set conditions.
2. The method according to claim 1, wherein The assigning a value to the first Latin square according to the target matrix and the second S-box includes: The first Latin square is calculated according to the following rules Assign the first part of the elements: , , , , in, is the element value of the target matrix in row i and column j, is the element value of the j-th column of the second S-box, The first Latin square No. Rank The element value of the column; When the value of the dynamic control parameter is set to different values, the second part of elements of the first Latin square are assigned values according to the corresponding rules.
3. The method according to claim 2, wherein When the value of the dynamic control parameter is set to a different value, assigning values to the second part of elements of the first Latin square according to the corresponding rule includes: When the value of the dynamic control parameter is set to 0 or 2, the second part of the elements of the first Latin square are assigned values according to the following rules: ; ; ; When the value of the dynamic control parameter is set to 1 or 3, the second part of the elements of the first Latin square are assigned values according to the following rules: ; ; 。 4. The method according to claim 1, wherein The permuting the first Latin square according to the third S-box to obtain a second Latin square includes: The first Latin square is calculated according to the following rules Permutate each element in to get the second Latin square : ; in, The first Latin square No. Rank The element value of the column, The second Latin square No. Rank The element value of the column, for The value of the element after the third S-box replacement.
5. The method according to claim 1, wherein The cryptographic properties include at least one of nonlinearity, differential uniformity, algebraic degree, and algebraic immunity order.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 5.
7. 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 5 are implemented.
8. A computer program product comprising a computer program, 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 5 are implemented.