SM4 password implementation method and system for finite field equivalent transformation and component reconstruction

Through finite domain equivalent transformation and component reconstruction, the S-box replacement operation in the SM4 cipher algorithm is converted into matrix multiplication, and the wheel key addition and wheel shift operation is optimized, which solves the slow processing speed and resources in the traditional SM4 cipher implementation method. The cost-effective problem has achieved more efficient password processing and hardware platform adaptability.

CN119254411APending Publication Date: 2025-01-03ELECTRIC POWER RES INST OF GUANGXI POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411033550.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The traditional SM4 cryptographic implementation method relies on complex mathematical operations and logical processing, resulting in slow processing speed, high resource consumption, and difficulty in dealing with the differences in hardware platforms, lacking flexibility and scalability.

Method used

Through finite domain equivalent transformation and component reconstruction, the S-box replacement operation is converted to matrix multiplication, the wheel key addition and wheel shift operation is optimized, the calculation efficiency is improved using matrix operations and SIMD instruction sets, and the component deconstruction and reconstruction are used, and the calculation efficiency is improved through component deconstruction and reconstruction. Implement hardware platform independence.

Benefits of technology

It improves password processing speed, enhances algorithm flexibility and scalability, reduces resource consumption, and improves adaptability to hardware platforms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254411A_ABST
    Figure CN119254411A_ABST
Patent Text Reader

Abstract

The invention discloses an SM4 password implementation method and system for finite field equivalent transformation and component reconstruction, and relates to the technical field of information security. The SM4 password implementation method comprises the steps that an SM4 algorithm is analyzed, and equivalent transformation optimization is carried out; carrying out deconstruction and reconstruction on the SM4 algorithm component; and the performance of the new algorithm is verified after the SM4 algorithm is optimized, deconstructed and reconstructed. According to the method, the core operation of the SM4 cryptographic algorithm is subjected to equivalent transformation, and the complex mathematical operation is converted into a simpler form, so that the cryptographic processing speed is increased. Meanwhile, the hardware platform independence of the algorithm is realized by reconstructing the algorithm component, and the flexibility and expandability of the algorithm are enhanced.
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 system for realizing SM4 cryptography of finite field equivalent transformation and component reconstruction. Background Art

[0002] With the rapid development of information technology, information security has become the focus of attention from all walks of life. As an important means to ensure information security, the research and application of cryptography are increasingly valued. The SM4 cryptographic algorithm is a block cipher algorithm independently developed by my country, which is widely used in information encryption in the fields of finance, government, and military. However, the traditional SM4 cryptographic implementation method still has room for optimization in terms of processing speed and resource consumption. Therefore, exploring the rapid implementation technology of SM4 cryptography is of great significance to improving the application level of cryptographic algorithms in my country and ensuring information security. Summary of the invention

[0003] In view of the above-mentioned problems, the present invention is proposed.

[0004] Therefore, the technical problem solved by the present invention is that the traditional SM4 cryptographic implementation method mainly relies on complex mathematical operations and logical processing, which limits the speed of cryptographic processing to a certain extent. At the same time, with the continuous evolution of encryption algorithms, the traditional method faces problems such as large resource consumption and low efficiency when processing large-scale data. In addition, the traditional method is difficult to effectively cope with the differences in hardware platforms during implementation, and lacks flexibility and scalability.

[0005] In order to solve the above technical problems, the present invention provides the following technical solution: a method for implementing SM4 cipher with finite field equivalent transformation and component reconstruction, which comprises the following steps:

[0006] Analyze the SM4 algorithm and perform equivalent transformation optimization; deconstruct and reconstruct the SM4 algorithm components; optimize the SM4 algorithm and verify the performance of the new algorithm after deconstruction and reconstruction.

[0007] As a preferred solution of the SM4 cipher implementation method of finite field equivalent transformation and component reconstruction described in the present invention, the equivalent change optimization includes S-box replacement operation, linear transformation, round key addition and round shift operation.

[0008] The S-box replacement operation is followed by a matrix penalty operation to convert the S-box replacement operation into a matrix multiplication, including designing a matrix, replacing a matrix operation, and calculating an inverse matrix.

[0009] As a preferred solution of the SM4 cipher implementation method of finite field equivalent transformation and component reconstruction described in the present invention, the design matrix is ​​a designed 4×4 matrix, and the nonlinear S-box replacement operation in the SM4 algorithm is equivalently transformed based on the 4×4 matrix.

[0010] The matrix operation is replaced in the encryption and decryption algorithm. If an S-box replacement operation is required on the encrypted and decrypted data, the data is divided according to row vectors, and a 4×4 matrix is ​​used to perform a matrix operation on each row vector to obtain a new row vector, and finally a new 4x4 data block is formed for subsequent operations.

[0011] The inverse matrix calculation includes using the inverse matrix in the decryption operation to perform an inverse S-Box transformation on the matrix obtained in the encryption process.

[0012] As a preferred solution of the SM4 cipher implementation method of finite field equivalent transformation and component reconstruction described in the present invention, the round key addition includes round key generation, round key addition operation and optimization processing.

[0013] The round key generation is based on a key expansion algorithm, by iteratively calculating a master key to generate subkeys used in multiple rounds, and a subkey for round key addition is generated in each round.

[0014] The round key addition operation is to perform an XOR operation on the round key and the current state during each round of encryption and decryption. In the encryption process, the round key and the currently processed data block are XORed bit by bit. In the decryption process, the same round key is used to perform an XOR operation on the ciphertext to restore the original plaintext state.

[0015] As a preferred solution of the SM4 cipher implementation method of the finite field equivalent transformation and component reconstruction described in the present invention, wherein: the iterative operation of the master key is expressed as,

[0016] K i =F(K i-1 ,i)

[0017] Among them, K represents the master key, K i represents the round key, i represents the key of the i-th round, F represents the key expansion function, and the key is adjusted according to the round number i;

[0018] The XOR operation includes if the current state is S=(s1, s2, ..., s n ), round key K i =(k i1 ,k i2 ,…,k in ), then the XOR operation is expressed as

[0019] As a preferred solution of the SM4 cipher implementation method of the finite field equivalent transformation and component reconstruction described in the present invention, the round shift operation includes state separation, byte position, state reorganization and optimization processing.

[0020] The state includes splitting the current 4×4 state matrix into 16 bytes before the round shift operation.

[0021] The byte bit is a shift operation performed on each byte, including in the encryption process, the number of bits of each row of bytes shifted left is related to the row number, the first row is not shifted, the second row is shifted left by 1 bit, the third row is shifted left by 2 bits, and the fourth row is shifted left by 3 bits.

[0022] During the decryption process, the number of bits of each row of bytes shifted right is related to the row number, where the first row is not shifted, the second row is shifted right by 1 bit, the third row is shifted right by 2 bits, and the fourth row is shifted right by 3 bits.

[0023] The state reorganization is to perform a shift operation on each byte and then reorganize it into a new state matrix, and the order of the bytes is kept unchanged during the combination process.

[0024] As a preferred solution of the SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction described in the present invention, the deconstruction and reconstruction include a comprehensive analysis of the original encryption algorithm after equivalent transformation optimization to identify the components of the algorithm, including S-box replacement, round key addition, and round permutation.

[0025] Another object of the present invention is to provide an SM4 cryptographic implementation system for finite field equivalent transformation and component reconstruction, which can replace the traditional table lookup method and enhanced round key encryption mechanism through efficient matrix operations, thereby solving the problems of low efficiency of the existing SM4 algorithm in a hardware resource-constrained environment and susceptibility to side channel attacks.

[0026] To solve the above technical problems, the present invention provides the following technical solutions: an SM4 cryptographic implementation system for finite field equivalent transformation and component reconstruction, including an equivalent transformation optimization module, a deconstruction and reconstruction module, a round key management module and a round shift operation module.

[0027] The equivalent transformation optimization module is responsible for optimizing the nonlinear and linear transformations in the SM4 algorithm.

[0028] The deconstruction and reconstruction module parses and reassembles the various components of the SM4 algorithm.

[0029] The round key management module is responsible for generating and managing the round keys used for each round of encryption or decryption of the algorithm.

[0030] The round shift operation module performs a shift operation on data during the encryption and decryption process.

[0031] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the SM4 cryptographic implementation method of the finite field equivalent transformation and component reconstruction are implemented as described above.

[0032] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as described above.

[0033] Beneficial effects of the present invention: The present invention converts complex mathematical operations into simpler forms by equivalently transforming the core operations of the SM4 cryptographic algorithm, thereby improving the speed of cryptographic processing. At the same time, the present invention also realizes the hardware platform independence of the algorithm by reconstructing the algorithm components, thereby enhancing the flexibility and scalability of the algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0035] Figure 1 This is an overall flow chart of the SM4 cipher implementation method of finite field equivalent transformation and component reconstruction provided in the first embodiment of the present invention.

[0036] Figure 2 The overall framework diagram of the SM4 cryptographic implementation system for finite field equivalent transformation and component reconstruction provided in the second embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0038] Example 1

[0039] Reference Figure 1 , which is an embodiment of the present invention, provides a method for implementing SM4 cipher with finite field equivalent transformation and component reconstruction, characterized in that:

[0040] S1: Analyze the SM4 algorithm and perform equivalent transformation optimization.

[0041] Equivalent change optimization includes S-box replacement operation, linear transformation, round key addition and round shift operation;

[0042] The matrix penalty operation is used after the S-box replacement operation to convert the S-box replacement operation into matrix multiplication, including designing the matrix, matrix operation replacement, and inverse matrix calculation.

[0043] It is further explained that the S-box replacement operation is converted into a matrix multiplication operation by utilizing the finite field equivalent transformation. After the S-box replacement, the matrix multiplication operation can be used, thereby simplifying the linear transformation operation.

[0044] Traditional implementation methods involve complex substitution tables and logical operations, resulting in slow encryption speed. To solve this problem, finite field equivalent transformation technology can be used to convert the S-box substitution operation into a matrix multiplication, thereby saving calculations and improving operation speed. The specific implementation process is as follows:

[0045] The design matrix is ​​a 4×4 matrix, and the nonlinear S-box replacement operation in the SM4 algorithm is equivalently transformed based on the 4×4 matrix.

[0046] Matrix operation is replaced by In the encryption and decryption algorithm, if S-box replacement operation is required for the encrypted and decrypted data, the data is divided according to row vectors, and a 4×4 matrix is ​​used to perform matrix operation on each row vector to obtain a new row vector, and finally a new 4x4 data block is formed for subsequent operations.

[0047] Furthermore, during matrix operations, the SIMD instruction set optimized on modern hardware platforms can be used directly to increase the speed of matrix operations.

[0048] The inverse matrix calculation includes the need to eliminate the effect of the S-box substitution operation when performing the decryption operation. To achieve this goal, the inverse matrix of the matrix can be obtained, and the inverse matrix is ​​used in the decryption operation to perform an "inverse" S-Box transformation on the matrix obtained during the encryption process to achieve the decryption purpose.

[0049] In summary, using finite field equivalent transformation to convert the S-box replacement operation in the SM4 algorithm into a matrix multiplication operation can accelerate the speed of encryption and decryption operations. At the same time, the decryption operation can be realized by calculating the inverse matrix, thereby ensuring the correctness of the encryption and decryption operations.

[0050] Round key addition includes round key generation, round key addition operation and optimization processing.

[0051] The round key generation is based on the key expansion algorithm. By iteratively calculating the master key, subkeys used in multiple rounds are generated, and subkeys used for round key addition are generated in each round.

[0052] The round key addition operation is to perform an XOR operation on the round key and the current state during each round of encryption and decryption. In the encryption process, the round key is XORed with the currently processed data block bit by bit. In the decryption process, the same round key is used to perform an XOR operation on the ciphertext to restore the original plaintext state.

[0053] The iterative operation on the master key is expressed as:

[0054] K i =F(K i-1 ,i)

[0055] Among them, K represents the master key, K i represents the round key, i represents the key of the i-th round, F represents the key expansion function, and the key is adjusted according to the round number i.

[0056] XOR operation includes if the current state is S = (s1, s2, ..., s n ), round key K i =(k i1 ,k i2 ,…,k in ), then the XOR operation is expressed as

[0057] Since the round key addition operation itself is a simple XOR operation, it is easy to be optimized and processed during the implementation process. The optimized SIMD instruction set on modern hardware platforms can be used to implement efficient XOR operations. At the same time, parallel computing can be used in the implementation to process multiple states simultaneously to further improve the speed of encryption and decryption. For example, if the hardware platform supports SIMD operations on 4 data, it can be expressed as: in Indicates the XOR operation supported by the SIMD instruction set.

[0058] Implementation details:

[0059] In actual implementation, it is necessary to select a suitable SIMD instruction set according to the specific hardware platform, such as SSE (Streaming SIMD Extensions) or NEON (for ARM architecture).

[0060] Parallel computing can be achieved through multi-threading or multi-core processing, assigning different states to different processing units.

[0061] The round shift operation includes state separation, byte position, state reorganization and optimization processing.

[0062] The state includes dividing the current 4×4 state matrix into 16 bytes before the round shift operation;

[0063] The byte bit is a shift operation performed on each byte, including in the encryption process, the number of bits of each row of bytes shifted left is related to the row number, the first row is not shifted, the second row is shifted left by 1 bit, the third row is shifted left by 2 bits, and the fourth row is shifted left by 3 bits.

[0064] During the decryption process, the number of bits of each row of bytes shifted right is related to the row number, where the first row is not shifted, the second row is shifted right by 1 bit, the third row is shifted right by 2 bits, and the fourth row is shifted right by 3 bits.

[0065] The state reorganization is to perform a shift operation on each byte and then reorganize it into a new state matrix, and the order of the bytes is kept unchanged during the combination process.

[0066] In summary, the round shift operation is a key step in the SM4 algorithm and can be processed and optimized separately. The round shift operation is achieved by splitting the state matrix, performing a shift operation on each byte, and then recombining the bytes into the state matrix. Through optimization processing, such as using SIMD instruction sets and parallel computing, the efficiency of encryption and decryption can be further improved.

[0067] S2: Deconstruct and reconstruct the SM4 algorithm components.

[0068] Deconstruction and reconstruction include comprehensive analysis of the original encryption algorithm after equivalent transformation optimization to identify the components of the algorithm, including S-box replacement, round key addition, round shift, and round permutation.

[0069] By deconstructing and reconstructing the algorithm components, the algorithm can run efficiently on different hardware platforms. Component reconstruction can achieve the goal of efficient execution of the algorithm on different hardware platforms and improve the portability and scalability of the algorithm. For example, each round of operations of the SM4 algorithm is reconstructed into several component operations, and a more practical hardware implementation strategy is designed for these component operations. In this way, through multi-platform implementation and optimization, it is possible to effectively cope with the differences in hardware platforms and improve the flexibility of the algorithm. Algorithm component deconstruction and reconstruction refers to the process of separating the complete encryption algorithm into multiple components, optimizing and processing these components separately, and finally combining these components into a complete encryption algorithm. The implementation process is as follows:

[0070] (1) Analysis and design: First, the original encryption algorithm needs to be analyzed and designed, and it needs to be decomposed into multiple components, such as round key addition and round permutation. The input and output of each component need to be considered. In this process, it is necessary to ensure that the deconstructed components can be used independently and that their outputs can be used as inputs for other components.

[0071] (2) Separate optimization and processing: Each component is optimized and processed separately. Different optimization strategies can be adopted according to the characteristics of different components, such as using SIMD instruction sets, parallel computing, memory alignment, etc. to improve operating efficiency. At the same time, in order to ensure the independent use of components, the input and output need to be standardized and checked.

[0072] The one-to-one correspondence of the optimization for each component is as follows:

[0073] S-box replacement and linear transformation optimize the content of corresponding S1.

[0074] The round key plus optimization corresponds to the content of S1.

[0075] The wheel shift optimization corresponds to the content of S1.

[0076] The wheel replacement optimization process is as follows:

[0077] (1) Status analysis:

[0078] First, we need to analyze the specific rules of round permutation in the SM4 algorithm. Round permutation usually involves rearranging bytes or bits in a data block.

[0079] Assume that the current state matrix S is a 4×4 matrix, where S ij Represents the element in the i-th row and j-th column of the matrix.

[0080] (2) Replacement operation:

[0081] According to the round permutation rule of the SM4 algorithm, the elements in the state matrix S are rearranged.

[0082] The round permutation can be represented as a permutation matrix P, which defines the new position of each element after the permutation.

[0083] Assuming the state matrix after permutation is S′, the round permutation operation can be expressed as: S′=S·P, where · represents matrix multiplication.

[0084] (3) Optimization processing:

[0085] Hardware acceleration instructions: Use acceleration instructions provided by specific hardware platforms, such as Intel's AVX instruction set or ARM's NEON instruction set, to accelerate matrix multiplication operations.

[0086] Parallel processing: Multiple state matrix permutation operations can be processed simultaneously using a parallel computing framework such as CUDA or OpenCL.

[0087] Data alignment: Ensure data is aligned in memory to reduce cache misses and increase memory access speed.

[0088] (4) Implementation details:

[0089] When implementing a round permutation, you need to consider how to apply the permutation matrix P to the state matrix S. This usually involves swapping rows or columns of the state matrix.

[0090] For example, if the round permutation rule requires swapping rows 1 and 3, then the corresponding rows of the permutation matrix P are also swapped.

[0091] S3: Optimize the SM4 algorithm and verify the performance of the new algorithm after deconstruction and reconstruction.

[0092] Example 2

[0093] Reference Figure 2 , which is an embodiment of the present invention, provides a system for implementing an SM4 cryptographic method of finite field equivalent transformation and component reconstruction. The SM4 cryptographic implementation system of finite field equivalent transformation and component reconstruction includes an equivalent transformation optimization module, a deconstruction and reconstruction module, a round key management module, and a round shift operation module.

[0094] The equivalent transformation optimization module is responsible for optimizing the nonlinear and linear transformations in the SM4 algorithm.

[0095] The deconstruction and reconstruction module parses and reassembles the various components of the SM4 algorithm.

[0096] The round key management module is responsible for generating and managing the round keys used for encryption or decryption in each round of the algorithm.

[0097] The round shift operation module performs shift operations on data during the encryption and decryption process.

[0098] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.

[0099] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.

[0100] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0101] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0102] Example 3

[0103] In this embodiment, in order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.

[0104] The performance of the new algorithm is verified through simulation experiments, including encryption and decryption speed, feasibility and correctness of implementation, etc. Experimental verification is carried out for the application scenarios of the SM4 algorithm, and the experimental results are evaluated and analyzed to ensure the performance of the optimized algorithm. The simulation experiment process is as follows:

[0105] New algorithm performance verification:

[0106] In order to verify the performance of the new SM4 cipher algorithm based on finite field equivalent transformation and component reconstruction, we designed a series of simulation experiments to evaluate the performance of the new algorithm in terms of encryption and decryption speed, resource consumption, feasibility, and correctness.

[0107] Experimental environment:

[0108] Processor: Intel Core i7-8700K

[0109] Memory: 32GB DDR4

[0110] Operating system: Windows 10

[0111] Development language: C++

[0112] Compiler: GCC 9.2

[0113] Experimental methods:

[0114] (1) Benchmarking: First, we use the original SM4 algorithm implementation as a benchmark and measure its encryption and decryption speed under different data sizes.

[0115] (2) New Algorithm Implementation: We then implement the new algorithm based on the previously described techniques based on finite field equivalent transformation and component reconstruction.

[0116] (3) Performance comparison: We compare the proposed algorithm with the original algorithm on the same data set and measure their encryption and decryption speed, memory consumption and other indicators.

[0117] (4) Functional Verification: We also performed functional verification on the algorithm of the present invention to ensure that it is consistent with the original algorithm in terms of encryption and decryption results.

[0118] Experimental results:

[0119] Here are some key data from our experiment:

[0120]

[0121] Result analysis:

[0122] The experimental results show that the new algorithm has significantly improved the encryption and decryption speed compared to the original SM4 algorithm. With a data volume of 100MB, the encryption speed increased by about 48% and the decryption speed increased by about 49%. As the data volume increases, the new algorithm still maintains a high performance. In addition, the memory consumption of the new algorithm is similar to that of the original algorithm, which shows that the optimization has not brought about a significant increase in resource consumption.

[0123] In terms of functional verification, we randomly generated multiple sets of test data and compared the encryption and decryption of the new algorithm with the original algorithm. The experimental results show that the encryption and decryption results of the new algorithm are completely consistent with the original algorithm, verifying the correctness and feasibility of the new algorithm.

[0124] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. The SM4 cipher implementation method of finite field equivalent transformation and component reconstruction is characterized in that: include: Analyze the SM4 algorithm and perform equivalent transformation optimization; Deconstruct and reconstruct SM4 algorithm components; The SM4 algorithm is optimized and the performance of the new algorithm is verified after deconstruction and reconstruction.

2. The SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as claimed in claim 1, characterized in that: The equivalent change optimization includes S-box replacement operation, linear transformation, round key addition and round shift operation; The S-box replacement operation is followed by a matrix penalty operation to convert the S-box replacement operation into a matrix multiplication, including designing a matrix, replacing a matrix operation, and calculating an inverse matrix.

3. The SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as claimed in claim 2, characterized in that: The design matrix is ​​a 4×4 matrix, and the nonlinear S-box replacement operation in the SM4 algorithm is equivalently transformed based on the 4×4 matrix; The matrix operation is replaced by: in the encryption and decryption algorithm, if the S-box replacement operation is required for the encrypted and decrypted data, the data is divided according to the row vector, and a 4×4 matrix is ​​used to perform a matrix operation on each row vector to obtain a new row vector, and finally a new 4x4 data block is formed for subsequent operations; The inverse matrix calculation includes using the inverse matrix in the decryption operation to perform an inverse S-Box transformation on the matrix obtained in the encryption process.

4. The SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as claimed in claim 3, characterized in that: The round key addition includes round key generation, round key addition operation and optimization processing; The round key generation is based on a key expansion algorithm, by iteratively calculating the master key to generate subkeys used in multiple rounds, and each round generates a subkey for round key addition; The round key addition operation is to perform an XOR operation on the round key and the current state during each round of encryption and decryption. In the encryption process, the round key and the currently processed data block are XORed bit by bit. In the decryption process, the same round key is used to perform an XOR operation on the ciphertext to restore the original plaintext state.

5. The SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as claimed in claim 4, characterized in that: The iterative operation on the master key is expressed as: K i =F(K i-1 ,i) Among them, K represents the master key, K i represents the round key, i represents the key of the i-th round, F represents the key expansion function, and the key is adjusted according to the round number i; The XOR operation includes if the current state is S=(s1, s2, ..., s n ), round key K i =k i1 ,k i2 ,…,k in ), then the XOR operation is expressed as 6. The SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as claimed in claim 5, characterized in that: The wheel shift operation includes state separation, byte position, state reorganization and optimization processing; The state includes dividing the current 4×4 state matrix into 16 bytes before the round shift operation; The byte position is to perform a shift operation on each byte, including that during the encryption process, the number of bits of each row of bytes shifted left is related to the row number, the first row is not shifted, the second row is shifted left by 1 bit, the third row is shifted left by 2 bits, and the fourth row is shifted left by 3 bits; During the decryption process, the number of bits of each row of bytes shifted right is related to the row number, where the first row is not shifted, the second row is shifted right by 1 bit, the third row is shifted right by 2 bits, and the fourth row is shifted right by 3 bits; The state reorganization is to perform a shift operation on each byte and then reorganize it into a new state matrix, and the order of the bytes is kept unchanged during the combination process.

7. The SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as claimed in claim 6, characterized in that: The deconstruction and reconstruction include a comprehensive analysis of the original encryption algorithm after equivalent transformation optimization, identifying the components of the algorithm, including S-box replacement, round key addition, and round permutation.

8. A system for implementing the SM4 cipher using the finite field equivalent transformation and component reconstruction method as claimed in any one of claims 1 to 7, characterized in that: It includes an equivalent transformation optimization module, a deconstruction and reconstruction module, a round key management module, and a round shift operation module; The equivalent transformation optimization module is responsible for optimizing the nonlinear and linear transformations in the SM4 algorithm; The deconstruction and reconstruction module parses and reassembles the various components of the SM4 algorithm; The round key management module is responsible for generating and managing the round keys used for each round of encryption or decryption of the algorithm; The round shift operation module performs a shift operation on data during the encryption and decryption process.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction described in 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 SM4 cryptographic implementation method of finite field equivalent transformation and component reconstruction as described in any one of claims 1 to 7 are implemented.