Dynamic Latin square construction method based on S box and computer equipment
Through the dynamic Latin square construction method based on S box, a dynamic control parameter and three S boxes are used to construct a dynamic Latin square with good cryptographic properties, solving the problem of large storage scale and vulnerability in the existing cryptographic algorithm, achieving a smaller storage scale and higher attack resistance.
Patent Information
- Application Number
- CN202411548115.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-01
AI Technical Summary
The 16th-order Latin side used in existing cryptographic algorithms is vulnerable to deterministic attacks due to the fixed component design and the storage scale of dynamic components is large, which is not conducive to the algorithm implementation.
Using a dynamic Latin square construction method based on the S box, a dynamic Latin square with good cryptographic properties is constructed by obtaining a dynamic control parameter of 2 bits and three S boxes (first S box, second S box and third S box).
The data storage scale required for Latin applications is reduced, from n*n to 3*n-2, which improves the attack resistance of the cryptographic algorithm and maintains good cryptographic properties.
Smart Images

Figure CN119583049A_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] 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 of confusion and diffusion in cryptographic algorithms.
[0003] At present, the 16-order Latin square is the most commonly used in cryptographic algorithms. The design with fixed cryptographic components is vulnerable to deterministic attacks. The design of cryptographic algorithms with dynamic components can effectively improve the anti-attack ability of cryptographic algorithms. However, as nonlinear dynamic components, the storage scale 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 when Latin square is applied, 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 dynamic Latin square construction method based on 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 a table 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, where 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 of 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 satisfy the set condition, the first S-box, the second S-box and the third S-box are re-acquired until the second Latin square satisfies the set condition.
[0013] Further, 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 of the i-th row and j-th column of the target matrix, 1≤i,j≤n-1.
[0019] Further, assigning values to the first Latin square according to the target matrix and the second S-box includes assigning values to the 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 square of the first Latin square (latin′) j +1 line SS (i,j) +1 element value of column;
[0022] 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.
[0023] Further, 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 part of the elements of the first Latin square are 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] Further, 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 rule to obtain a 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 values of the dynamic control parameters are set to 0, 1, 2 and 3; if all the cryptographic properties are within the 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, there is also provided 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 of any one of the above methods.
[0037] According to a third aspect of the present invention, there is also provided a computer-readable storage medium on which a computer program is stored, and 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 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 an S-box, which obtains 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, and uses these three S-boxes to set different values of the dynamic control parameter to obtain an n-order second Latin square corresponding to different dynamic control parameters. The second Latin square has good cryptographic properties, and only three S-boxes need to be stored in the process of constructing the Latin square, reducing the data storage scale required in the process of constructing the dynamic Latin square from n*n to 3*n-2, thereby achieving the purpose of small storage scale. In addition, the constructed dynamic Latin square can be applied to the fields of 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 drawings required for use in the embodiments will be briefly introduced below. 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 paying creative work.
[0042] Figure 1 A flowchart of a dynamic Latin square construction method based on S-box 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 purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain 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 can be combined with each other as long as they do not conflict with each other.
[0045] The terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0046] like Figure 1 As shown, a dynamic Latin square construction method based on S-box is provided, which can be executed by a terminal or a server communicating with the terminal through a network. The terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, etc. The server can be an independent server, or a server cluster composed of multiple servers can be used. Taking the application of the method to the terminal as an example, the method includes the following steps:
[0047] Step 101, obtain a dynamic control parameter, where the dynamic control parameter is a 2-bit number.
[0048] The value of the dynamic control parameter is 0, 1, 2 or 3.
[0049] Step 102, obtaining a first S-box, a second S-box and a third S-box.
[0050] 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] Exemplarily, two S-boxes including n-1 elements are randomly selected, namely the first S-box S1 and the second S-box S2, and then an S-box including n elements is randomly selected as the third S-box S3, which is specifically expressed as:
[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 of 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 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 , assigning values to the first Latin square according to the target matrix and the second S-box, the first Latin square is a square matrix of n rows and n columns, and the row and column counts both 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 part of the 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 square of the first Latin square (latin′) j +1 line SS (i,j) +1 The element value of the column.
[0072] 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 latin′ are 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 part of the elements of the first Latin square latin′ are 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: permute 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, when the second Latin square meets the set condition, the second Latin square is used as the target Latin square; 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.
[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 cryptographic algorithm design, which are the indicators required to measure the security of the cryptographic algorithm.
[0087] Exemplarily, 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 parameters are 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 respectively when the values of the dynamic control parameters are set to 0, 1, 2 and 3; if all the cryptographic properties are within the 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, return to step 102, 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 dynamic Latin square construction method based on S-box, by obtaining 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, using these three S-boxes, by setting different values of the dynamic control parameter, an n-order second Latin square corresponding to different dynamic control parameters is obtained. The second Latin square has good cryptographic properties, and only three S-boxes need to be stored in the process of constructing the Latin square, reducing the data storage scale required in the dynamic Latin square construction process 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) Denotes the value of the element in the i-th row and j-th column of SS, where 1≤i,j≤15. Let each element value of SS be 0.
[0096] When the dynamic control parameter is 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, establish the first Latin square latin′ of order 16, and set the n*n elements of the first Latin square to be 0. Then, assign values to the first part of the elements of the first Latin square latin′ according to different values of the dynamic control parameters. The specific operation is 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 value of the dynamic control parameter 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 value of the dynamic control parameter is 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 value of 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 replace 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 value of 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, only 15*2+16=46 data storage spaces are needed to construct a 16-order Latin square, which greatly reduces the data storage scale compared to the current 16-order Latin square which requires 16*16=256 data storage spaces. By using these three S-boxes S1, S2 and S3, a 16-order Latin square is obtained by changing the value of the dynamic control parameter. Different dynamic control parameters correspond to different 16-order Latin squares, and the obtained 16-order Latin squares have good cryptographic properties and can be applied to cryptographic algorithms as a nonlinear cryptographic component.
[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 those shown in the figure, or combine certain components, or have a different arrangement of components.
[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 on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented. 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 micro drive, and 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 the present application is not limited by the described order of actions, because according to the present 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 the present application.
[0149] In the above embodiments, the description of each embodiment has its own emphasis. 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 is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
[0151] The technical features of the above embodiments may 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 only 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 protection scope 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 a table 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; 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; When the second Latin square meets a set condition, taking the second Latin square as a target Latin square; When the second Latin square does not satisfy the set condition, the first S-box, the second S-box and the third S-box are re-acquired until the second Latin square satisfies the set condition.
2. The method according to claim 1, characterized in that The assigning a value to a target matrix according to the first S-box includes: When the dynamic control parameter is set to 0, SS (i,j) =S1 ((j-1)-(i-1)×1)%(n-1)+1 ; When the dynamic control parameter is set to 1, SS (i,j) =S1 ((j-1)-(i-1)×2)%(n-1)+1 ; When the dynamic control parameter is set to 2, SS (i,j) =S1 ((j-1)-(i-1)×(n-3))%(n-1)+1 ; When the dynamic control parameter is set to 3, SS (i,j) =S1 ((j-1)-(i-1)×(n-2))%(n-1)+1 ; 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 of the i-th row and j-th column of the target matrix, 1≤i,j≤n-1.
3. The method according to claim 1, characterized in that The assigning a value to the first Latin square according to the target matrix and the second S-box includes: Assign values to the first part of the elements of the first Latin square (latin′) according to the following rules: latin′[i][j]=0, 1≤i,j≤n, latin′[S2 j +1][SS (i,j) +1]=i,1≤i,j≤n-1, 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 square of the first Latin square (latin′) j +1 line SS (i,j) +1 element value of 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.
4. The method according to claim 3, characterized in that 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 a 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: latin′[S2 n-i +1][SS (i,n-i) +1]=0,1≤i≤n-1; latin′[S2 n-i +1][1]=i,1≤i≤n-1; latin′[1][SS (i,n-i) +1]=i,1≤i≤n-1; 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: latin′[S2 i +1][SS (i,i) +1]=0,1≤i≤n-1; latin′[S2 i +1][1]=i,1≤i≤n-1; latin′[1][SS (i,i) +1]=i,1≤i≤n-1。 5. The method according to claim 1, characterized in that The step of permuting the first Latin square according to the third S-box to obtain a second Latin square includes: The elements in the first Latin square (latin′) are permuted according to the following rules to obtain a second Latin square (latin): latin[i][j]=S3 (latin′[i][j]) ,1≤i,j≤n; 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.
6. The method according to claim 1, characterized in that The step of taking the second Latin square as a target Latin square when the second Latin square satisfies a set condition includes: respectively calculating the cryptographic properties of the second Latin square when the value of the dynamic control parameter is set to 0, 1, 2 and 3; If both satisfy that the 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.
7. The method according to claim 6, characterized in that The cryptographic properties include at least one of nonlinearity, differential uniformity, algebraic degree, and algebraic immunity order.
8. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
9. 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.
10. 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 7 are implemented.
Citation Information
Patent Citations
Binary linear transformation method for diffusion layer in substitution-permutation network block encryption
CN101944991A
Image encryption method based on 4D chaotic system and improved Josephus ring scrambling
CN117201694A
Optimized Latin square experiment design method, electronic equipment and storage medium
CN118070838A
Low density lattice code generator matrices using mutually orthogonal latin squares
US20100027408A1
Apparatus and method of providing high speed table generation for block encryption
US6035042A