SM4 algorithm operation method, system, device and computer-readable storage medium

By generating and processing the round key and data of the SM4 algorithm in parallel, the computing bandwidth of the SM4 algorithm is improved, the problem of low computing bandwidth in the existing technology is solved, and efficient data encryption processing is achieved.

CN114598451BActive Publication Date: 2024-10-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210242531.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-11
Publication Date
2024-10-15
Estimated Expiration
2042-03-11

AI Technical Summary

Technical Problem

The existing SM4 algorithm operating device constructed with a circular architecture has low computing bandwidth and is difficult to meet the demand for efficient data encryption.

Method used

Each round key of the SM4 algorithm is generated by obtaining the key information, and the data to be calculated is obtained in each round of calculation, and parallel processing is performed based on the round key to improve the calculation bandwidth. Finally, the SM4 calculation result is determined based on the 32nd round calculation result. .

Benefits of technology

It improves the computing bandwidth of the SM4 algorithm, achieves more efficient data encryption processing, and can flexibly adjust the number of data input ports of the encryption module as needed to adapt to different computing needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114598451B_ABST
    Figure CN114598451B_ABST
Patent Text Reader

Abstract

The present application discloses an SM4 algorithm operation method, system, device and computer-readable storage medium, which obtains key information; generates and saves each round key of the SM4 algorithm based on the key information; in each round operation of the SM4 algorithm, obtains the data to be operated in the current round operation, and determines the target round key of the current round operation based on the round key, and performs parallel processing on the data to be operated based on the target round key to obtain and save the operation result of the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation; the corresponding SM4 operation result is determined based on the saved operation result of the 32nd round operation. The present application improves the computational bandwidth of the SM4 algorithm. The SM4 algorithm operation system, device and computer-readable storage medium provided by the present application also solve the corresponding technical problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to an SM4 algorithm operation method, system, device and computer-readable storage medium. Background Art

[0002] Data encryption is one of the important means to ensure information security. The SM4 algorithm has the advantages of strong security, high efficiency, and easy hardware implementation. It is widely used in the field of data encryption. The use of hardware characteristics to efficiently / high-speed implement the SM4 algorithm has become a hot topic in current research.

[0003] For example, the SM4 algorithm running device constructed with a cyclic architecture includes a round key generation module, an encryption module and a control module, wherein the latest round key generated by the round key generation module is directly used in the encryption module without storage, which can save 32 128-bit register resources. Secondly, the round key generation module and the encryption module are executed in parallel. When the key is updated, the round key generation module can calculate the latest round key in real time, and the encryption module does not need to wait. The entire encryption process can be carried out continuously. Finally, the clock cycle required by the round key generation module and the encryption module in the entire packet data encryption process is a constant, which can effectively resist side channel attacks. However, the computing bandwidth of the SM4 algorithm running device constructed with a cyclic architecture is low.

[0004] In summary, how to improve the computational bandwidth of the SM4 algorithm is an urgent problem to be solved by those skilled in the art. Summary of the invention

[0005] The purpose of this application is to provide an SM4 algorithm operation method, which can improve the computing bandwidth to a certain extent. This application also provides an SM4 algorithm operation system, device and computer-readable storage medium.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] An SM4 algorithm operation method, comprising:

[0008] Get key information;

[0009] Generate and save the keys for each round of the SM4 algorithm based on the key information;

[0010] In each round operation of the SM4 algorithm, the data to be operated in the current round operation is obtained, and the target round key of the current round operation is determined based on the round key, and the data to be operated is processed in parallel based on the target round key to obtain and save the operation result of the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation;

[0011] The corresponding SM4 operation result is determined based on the saved operation result of the 32nd round operation.

[0012] Preferably, the processing the data to be calculated in parallel based on the target round key to obtain and save the calculation results of the current round calculations includes:

[0013] Processing the data to be calculated in parallel based on the target round key to obtain the calculation result of the current round calculation;

[0014] The calculation result of the current round-by-round calculation is saved in the storage space corresponding to the current round-by-round calculation.

[0015] Preferably, the step of obtaining the data to be calculated for the current round-by-round calculation includes:

[0016] Obtaining a first signal and a second signal corresponding to the current round operation, wherein the first signal is used to indicate whether the operation result of the previous round operation can be transmitted to the current round operation, and the second signal is used to indicate whether the next round operation can receive the operation result of the current round operation;

[0017] If the first signal corresponding to the current round operation indicates that the operation result of the previous round operation can be transmitted to the current round operation, and the second signal corresponding to the current round operation indicates that the next round operation can receive the operation result of the current round operation, then the data to be calculated of the current round operation is obtained.

[0018] Preferably, if the first signal corresponding to the current round-by-round operation indicates that the operation result of the previous round-by-round operation can be transmitted to the current round-by-round operation, and the second signal corresponding to the current round-by-round operation indicates that the next round-by-round operation can receive the operation result of the current round-by-round operation, then obtaining the data to be operated for the current round-by-round operation includes:

[0019] Generate a third signal corresponding to the current round-by-round operation based on the first signal and the second signal corresponding to the current round-by-round operation by using a first operation formula;

[0020] The first operation formula includes:

[0021] ppen=in_ready&in_valid;

[0022] in_ready=(~out_valid)|out_ready;

[0023] out_valid<=(~in_ready)|in_valid;

[0024] If the third signal corresponding to the current round-by-round operation indicates that data can be obtained, then obtaining the data to be calculated for the current round-by-round operation;

[0025] Among them, ppen represents the third signal corresponding to the current round operation; in_ready represents the second signal corresponding to the previous round operation; & represents and operation; in_valid represents the first signal corresponding to the current round operation; ~ represents no operation; out_valid represents the first signal corresponding to the next round operation; | represents or operation; out_ready represents the second signal corresponding to the current round operation; <= represents the delayed output of the first signal corresponding to the next round operation.

[0026] Preferably, the generating of the third signal corresponding to the current round-by-round operation based on the first signal and the second signal corresponding to the current round-by-round operation by using the first operation formula includes:

[0027] Input the first signal corresponding to the current round of operation to the first signal receiving port of the operator, and input the second signal corresponding to the current round of operation to the second signal input port of the operator;

[0028] Acquire the third signal calculated by the operator;

[0029] Wherein, the operator includes the first signal receiving port, the first signal output port, the second signal input port, the second signal output port, the first NOR gate, the second NOR gate, the AND gate and a register; the first signal receiving port is connected to the first input end of the first NOR gate and the first input end of the AND gate; the output end of the first NOR gate is connected to the input end of the register; the output end of the register is connected to the first signal output port and the NOR gate input end of the second NOR gate; the second signal input port is connected to the first input end of the second NOR gate; the output end of the second NOR gate is connected to the second signal output port, the NOR gate input end of the first NOR gate, and the second input end of the AND gate; the output end of the AND gate is used to output the third signal.

[0030] Preferably, the parallel processing of the data to be operated based on the target round key includes:

[0031] Determine the amount of available computing resources;

[0032] Obtaining a target processing bandwidth of the SM4 algorithm;

[0033] Determining the number of parallel operations based on the available computing resources and the target processing bandwidth;

[0034] According to the parallel operation quantity, the data to be operated are processed in parallel based on the target round key.

[0035] An SM4 algorithm operation system, comprising:

[0036] A first acquisition module, used to acquire key information;

[0037] A first generating module, used to generate and save each round key of the SM4 algorithm based on the key information;

[0038] The encryption module is used to obtain the data to be calculated for the current round-by-round calculation, determine the target round key for the current round-by-round calculation based on the round key, and perform parallel processing on the data to be calculated based on the target round key to obtain and save the calculation result of the current round-by-round calculation; wherein, if the current round-by-round calculation is not the first round-by-round calculation, the corresponding data to be calculated includes the calculation result of the previous round-by-round calculation;

[0039] The first determination module is used to determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation.

[0040] Preferably, the number of the encryption modules is 32.

[0041] An SM4 algorithm running device, comprising:

[0042] Memory for storing computer programs;

[0043] A processor is used to implement the steps of any of the above-mentioned SM4 algorithm operation methods when executing the computer program.

[0044] A computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by a processor, implements the steps of any of the above-mentioned SM4 algorithm operation methods.

[0045] The present application provides a method for running an SM4 algorithm, which obtains key information; generates and saves each round key of the SM4 algorithm based on the key information; in each round operation of the SM4 algorithm, obtains the data to be operated for the current round operation, determines the target round key of the current round operation based on the round key, and processes the data to be operated in parallel based on the target round key, obtains and saves the operation result of the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation; and determines the corresponding SM4 operation result based on the saved operation result of the 32nd round operation. The SM4 algorithm running method of the present application can generate each round key of the SM4 algorithm based on the key information, and in each round operation of the SM4 algorithm, obtains the data to be operated for the current round operation, determines the target round key of the current round operation based on the round key, and processes the data to be operated in parallel based on the target round key, obtains and saves the operation result of the current round operation, thereby improving the computational bandwidth of the SM4 algorithm, and finally only needs to determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation. The SM4 algorithm operating system, device and computer-readable storage medium provided in this application also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0047] Figure 1 A first flow chart of a method for running an SM4 algorithm provided in an embodiment of the present application;

[0048] Figure 2 A second flow chart of an SM4 algorithm operation method provided in an embodiment of the present application;

[0049] Figure 3 It is a schematic diagram of the structure of the operator;

[0050] Figure 4 A schematic diagram of the structure of an SM4 algorithm operation system provided in an embodiment of the present application;

[0051] Figure 5 A schematic diagram of the structure of an SM4 algorithm running device provided in an embodiment of the present application;

[0052] Figure 6 A schematic diagram of the structure of an SM4 algorithm running device provided in an embodiment of the present application;

[0053] Figure 7 Another structural schematic diagram of an SM4 algorithm running device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] See also Figure 1 , Figure 1 This is a first flow chart of an SM4 algorithm operation method provided in an embodiment of the present application.

[0056] An SM4 algorithm operation method provided in an embodiment of the present application may include the following steps:

[0057] Step S101: Obtain key information.

[0058] In actual applications, the key information required for the operation of the SM4 algorithm can be obtained first. The specific content of the key information can be determined according to actual needs, and this application does not make any specific limitations here.

[0059] Step S102: Generate and save the keys for each round of the SM4 algorithm based on the key information.

[0060] In practical applications, after obtaining the key information, each round key of the SM4 algorithm can be generated based on the key information and saved, so that in each subsequent round operation of the SM4 algorithm, corresponding operations can be performed based on the corresponding round keys.

[0061] Step S103: In each round operation of the SM4 algorithm, the data to be operated in the current round operation is obtained, and the target round key of the current round operation is determined based on the round key, and the data to be operated is processed in parallel based on the target round key to obtain and save the operation result of the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation.

[0062] In practical applications, after each round key of the SM4 algorithm is generated and saved based on the key information, the data to be calculated of the current round operation can be obtained in each round operation of the SM4 algorithm, and the target round key of the current round operation can be determined based on the round key, and the data to be calculated can be processed in parallel based on the target round key to obtain the calculation result of the current round operation and save it; wherein, if the current round operation is not the first round operation, the corresponding data to be calculated includes the calculation result of the previous round operation. It should be noted that if the current round operation is the first round operation, the corresponding data to be calculated can be the original input target data, etc.; in specific application scenarios, the type of data to be calculated and the operation mode of the SM4 algorithm can be determined according to actual needs, for example, the data to be calculated can be data to be encrypted, in which case the SM4 algorithm can run the SM4 encryption algorithm, and the data to be calculated can be data to be decrypted, in which case the SM4 algorithm can run the SM4 decryption algorithm, etc. This application does not make specific restrictions here.

[0063] In a specific application scenario, in the process of performing parallel processing on the operation data based on the target round key, the number of parallel operations can be determined based on the amount of computing resources, that is, the available computing resources can be determined; the target processing bandwidth of the SM4 algorithm is obtained; the number of parallel operations is determined based on the available computing resources and the target processing bandwidth; and according to the number of parallel operations, the operation data is processed in parallel based on the target round key.

[0064] Step S104: Determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation.

[0065] In practical applications, after completing 32 rounds of operations of the SM4 algorithm, the corresponding SM4 operation result can be determined based on the saved operation result of the 32nd round of operations.

[0066] The present application provides a method for running an SM4 algorithm, which obtains key information; generates and saves each round key of the SM4 algorithm based on the key information; in each round operation of the SM4 algorithm, obtains the data to be operated for the current round operation, determines the target round key of the current round operation based on the round key, and processes the data to be operated in parallel based on the target round key, obtains and saves the operation result of the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation; and determines the corresponding SM4 operation result based on the saved operation result of the 32nd round operation. The SM4 algorithm running method of the present application can generate each round key of the SM4 algorithm based on the key information, and in each round operation of the SM4 algorithm, obtains the data to be operated for the current round operation, determines the target round key of the current round operation based on the round key, and processes the data to be operated in parallel based on the target round key, obtains and saves the operation result of the current round operation, thereby improving the computational bandwidth of the SM4 algorithm, and finally only needs to determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation.

[0067] See also Figure 2 , Figure 2 A second flow chart of an SM4 algorithm operation method provided in an embodiment of the present application.

[0068] An SM4 algorithm operation method provided in an embodiment of the present application may include the following steps:

[0069] Step S201: Obtain key information.

[0070] Step S202: Generate and save the keys for each round of the SM4 algorithm based on the key information.

[0071] Step S203: In each round operation of the SM4 algorithm, the data to be operated in the current round operation is obtained, and the target round key of the current round operation is determined based on the round key, and the data to be operated is processed in parallel based on the target round key to obtain the operation result of the current round operation; the operation result of the current round operation is saved in the storage space corresponding to the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation.

[0072] In actual application scenarios, in the process of parallel processing of the data to be operated based on the target round key to obtain and save the operation results of the current round operation, the data to be operated can be processed in parallel based on the target round key to obtain the operation results of the current round operation; and the operation results of the current round operation can be saved in the storage space corresponding to the current round operation, so as to quickly know the operation results of each round operation based on the storage space.

[0073] In specific application scenarios, considering that data interaction may be required between rounds of operations, for example, the calculation result of the previous round of operations may be applied to the next round of operations, this means that data interaction is required between rounds of operations. In order to facilitate the data interaction between control rounds, in the process of obtaining the data to be calculated in the current round of operations, the first signal and the second signal corresponding to the current round of operations can be obtained. The first signal is used to characterize whether the calculation result of the previous round of operations can be transmitted to the current round of operations, and the second signal is used to characterize whether the next round of operations can receive the calculation result of the current round of operations; if the first signal corresponding to the current round of operations indicates that the calculation result of the previous round of operations can be transmitted to the current round of operations, and the second signal corresponding to the current round of operations indicates that the next round of operations can receive the calculation result of the current round of operations, then the data to be calculated in the current round of operations is obtained.

[0074] In a specific application scenario, in order to facilitate determination of the data to be calculated based on the first signal and the second signal, if the first signal corresponding to the current round-by-round calculation represents that the calculation result of the previous round-by-round calculation can be transmitted to the current round-by-round calculation, and the second signal corresponding to the current round-by-round calculation represents that the next round-by-round calculation can receive the calculation result of the current round-by-round calculation, then in the process of obtaining the data to be calculated for the current round-by-round calculation, the third signal corresponding to the current round-by-round calculation can be generated based on the first signal and the second signal corresponding to the current round-by-round calculation through the first calculation formula;

[0075] The first operation formula includes:

[0076] ppen=in_ready&in_valid;

[0077] in_ready=(~out_valid)|out_ready;

[0078] out_valid<=(~in_ready)|in_valid;

[0079] If the third signal corresponding to the current round-by-round operation indicates that data can be obtained, then the data to be calculated for the current round-by-round operation is obtained;

[0080] Among them, ppen represents the third signal corresponding to the current round operation; in_ready represents the second signal corresponding to the previous round operation; & represents and operation; in_valid represents the first signal corresponding to the current round operation; ~ represents no operation; out_valid represents the first signal corresponding to the next round operation; | represents or operation; out_ready represents the second signal corresponding to the current round operation; <= represents the delayed output of the first signal corresponding to the next round operation.

[0081] For specific application scenarios, please refer to Figure 3In order to quickly generate the third information, in the process of generating the third signal corresponding to the current round operation based on the first signal and the second signal corresponding to the current round operation through the first operation formula, the first signal corresponding to the current round operation can be input to the first signal receiving port of the operator, and the second signal corresponding to the current round operation can be input to the second signal input port of the operator; the third signal calculated by the operator is obtained;

[0082] Among them, the operator includes a first signal receiving port (also known as in_valid), a first signal output port (also known as out_valid), a second signal input port (also known as out_ready), a second signal output port (also known as in_ready), a first NOR gate, a second NOR gate, an AND gate and a register; the first signal receiving port is connected to the first input end of the first NOR gate and the first input end of the AND gate; the output end of the first NOR gate is connected to the input end of the register; the output end of the register is connected to the first signal output port and the NOT gate input end of the second NOR gate; the second signal input port is connected to the first input end of the second NOR gate; the output end of the second NOR gate is connected to the second signal output port, the NOT gate input end of the first NOR gate and the second input end of the AND gate; the output end of the AND gate is used to output a third signal.

[0083] Step S204: Determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation.

[0084] See also Figure 4 , Figure 4 A schematic diagram of the structure of an SM4 algorithm operation system provided in an embodiment of the present application.

[0085] An SM4 algorithm operation system provided in an embodiment of the present application may include:

[0086] A first acquisition module 101, used to acquire key information;

[0087] A first generating module 102, used to generate and save each round key of the SM4 algorithm based on the key information;

[0088] The encryption module 103 is used to obtain the data to be calculated of the current round-by-round calculation, determine the target round key of the current round-by-round calculation based on the round key, and perform parallel processing on the data to be calculated based on the target round key to obtain and save the calculation result of the current round-by-round calculation; wherein, if the current round-by-round calculation is not the first round-by-round calculation, the corresponding data to be calculated includes the calculation result of the previous round-by-round calculation;

[0089] The first determination module 104 is used to determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation.

[0090] An embodiment of the present application provides an SM4 algorithm operating system, in which the number of encryption modules is 32.

[0091] An SM4 algorithm operation system provided in an embodiment of the present application, the encryption module may include:

[0092] A first processing unit is used to perform parallel processing on the data to be operated based on the target round key to obtain the operation result of the current round operation;

[0093] The first storage unit is used to save the calculation result of the current round-by-round calculation to the storage space corresponding to the current round-by-round calculation.

[0094] An SM4 algorithm operation system provided in an embodiment of the present application, the encryption module may include:

[0095] A first acquisition unit, used to acquire a first signal and a second signal corresponding to the current round operation, the first signal is used to indicate whether the operation result of the previous round operation can be transmitted to the current round operation, and the second signal is used to indicate whether the next round operation can receive the operation result of the current round operation;

[0096] The second acquisition unit is used to acquire the data to be calculated in the current round operation if the first signal corresponding to the current round operation indicates that the calculation result of the previous round operation can be transmitted to the current round operation, and the second signal corresponding to the current round operation indicates that the next round operation can receive the calculation result of the current round operation.

[0097] In an SM4 algorithm operation system provided by an embodiment of the present application, the second acquisition unit may be specifically used to: generate a third signal corresponding to the current round-by-round operation based on the first signal and the second signal corresponding to the current round-by-round operation through the first operation formula;

[0098] The first operation formula includes:

[0099] ppen=in_ready&in_valid;

[0100] in_ready=(~out_valid)|out_ready;

[0101] out_valid<=(~in_ready)|in_valid;

[0102] If the third signal corresponding to the current round-by-round operation indicates that data can be obtained, then the data to be calculated for the current round-by-round operation is obtained;

[0103] Among them, ppen represents the third signal corresponding to the current round operation; in_ready represents the second signal corresponding to the previous round operation; & represents and operation; in_valid represents the first signal corresponding to the current round operation; ~ represents no operation; out_valid represents the first signal corresponding to the next round operation; | represents or operation; out_ready represents the second signal corresponding to the current round operation; <= represents the delayed output of the first signal corresponding to the next round operation.

[0104] An SM4 algorithm operation system provided by an embodiment of the present application, the second acquisition unit can be specifically used to: input the first signal corresponding to the current round of operation to the first signal receiving port of the operator, and input the second signal corresponding to the current round of operation to the second signal input port of the operator; obtain the third signal calculated by the operator; wherein the operator includes a first signal receiving port, a first signal output port, a second signal input port, a second signal output port, a first NOR gate, a second NOR gate, an AND gate and a register; the first signal receiving port is connected to the first input end of the first NOR gate and the first input end of the AND gate; the output end of the first NOR gate is connected to the input end of the register; the output end of the register is connected to the first signal output port and the NOT gate input end of the second NOR gate; the second signal input port is connected to the first input end of the second NOR gate; the output end of the second NOR gate is connected to the second signal output port, the NOT gate input end of the first NOR gate and the second input end of the AND gate; the output end of the AND gate is used to output the third signal.

[0105] An SM4 algorithm operation system provided in an embodiment of the present application, the encryption module may include:

[0106] A first determining unit, configured to determine the amount of available computing resources;

[0107] A third acquisition unit is used to acquire a target processing bandwidth of the SM4 algorithm;

[0108] A second determining unit, configured to determine the number of parallel operations based on the amount of available computing resources and the target processing bandwidth;

[0109] The second processing unit is used to perform parallel processing on the data to be operated based on the target round key according to the number of parallel operations.

[0110] In order to facilitate the understanding of the SM4 algorithm operation scheme provided by the present application, the SM4 algorithm operation scheme provided by the present application is described in combination with the SM4 algorithm operation device in a specific application. Figure 5 , Figure 5 A schematic diagram of the structure of an SM4 algorithm running device provided in an embodiment of the present application.

[0111] An SM4 algorithm running device provided in an embodiment of the present application may include:

[0112] A round key generation module, used to generate each round key of the SM4 algorithm based on the received key information;

[0113] An encryption module connected to the round key generation module, used for performing SM4 operation on the operation data based on the corresponding round key;

[0114] A flexible control system connected to the encryption module, used to store the calculation results of the encryption module;

[0115] Among them, the total number of encryption modules is 32, and the data input port and data output port of each encryption module are the target number.

[0116] It should be noted that Figure 5 The in_data is the data to be calculated, and the number of in_data is the number of parallel calculations; out_data is the calculation result obtained by the 32nd round of calculations; key0-key31 is the round key of each round; the corresponding structure of implementing the SM4 algorithm in the encryption module can refer to the prior art, that is, the specific process of implementing the SM4 algorithm by the SM4 algorithm running device provided in this application can refer to the prior art, and this application will not repeat it here.

[0117] The present application provides an SM4 algorithm operation device, comprising: a round key generation module, used to generate each round key of the SM4 algorithm based on the received key information; an encryption module connected to the round key generation module, used to perform SM4 operation on the data to be operated based on the corresponding round key; an elastic control system connected to the encryption module, used to store the operation result of the encryption module; wherein the total number of encryption modules is 32, and the data input port and data output port of each encryption module are the target number. The SM4 algorithm operation device of the present application can perform SM4 operation on the target number of data to be operated by means of the target number of data input ports of the encryption module, and the calculation bandwidth is high.

[0118] In an SM4 algorithm operation device provided in an embodiment of the present application, in order to facilitate accurate storage of corresponding data of each encryption module, the elastic control system includes subunits corresponding to the encryption modules, and each subunit is connected to the corresponding encryption module. In this way, the data of the corresponding encryption module can be accurately managed with the help of each subunit.

[0119] In an SM4 algorithm operation device provided in an embodiment of the present application, considering that data exchange may be required between encryption modules, for example, the operation result of the previous encryption module may be applied by the next encryption module, which means that data exchange is required between sub-units. In order to facilitate the control of data exchange between sub-units, data exchange can be performed between sub-units through a first signal and a second signal. The first signal is used to represent the transmission of data from the first sub-unit to the second sub-unit, and the second signal is used to represent the transmission of data from the second sub-unit to the first sub-unit. The first signal is also called Figure 5 The valid signal in the second signal is Figure 5 The ready signal in.

[0120] In a specific application scenario, in order to facilitate the first signal and the second signal to play a role, the structure of the subunit can be set, for example, the subunit includes a first signal receiving port, that is, in_valid; a first signal output port, that is, out_valid; a second signal input port, that is, out_ready; a second signal output port, that is, in_ready; a first NOR gate, a second NOR gate, an AND gate and a register;

[0121] The first signal receiving port is connected to the first input of the first NOR gate and the first input of the gate; the output of the first NOR gate is connected to the input of the register; the output of the register is connected to the first signal output port and the NOR gate input of the second NOR gate; the second signal input port is connected to the first input of the second NOR gate; the output of the second NOR gate is connected to the second signal output port, the NOR gate input of the first NOR gate, and the second input of the gate; and the output of the gate is connected to the corresponding encryption module.

[0122] That is, in each sub-unit of the SM4 computing device provided in the present application, in_ready=(~out_valid)|out_ready, where = represents the direct output after the combinational logic calculation is completed, ~ represents the non-operation, and | represents the OR operation; out_valid<=(~in_ready)|in_valid, where <= represents the output of the register after the combinational logic calculation is completed; ppen=in_ready&in_valid, and & represents the AND operation.

[0123] In an SM4 algorithm running device provided in an embodiment of the present application, in order to facilitate the calculation of round keys, a round key generation module may include: a key generation control unit, a key expansion calculation unit and a key storage register connected to the key generation control unit, and the key expansion calculation unit is connected to the key storage register;

[0124] A key generation control unit, used to manage and control the key expansion calculation unit and the key register;

[0125] A key expansion calculation unit, used to calculate a round key based on the key information and preset parameters;

[0126] Key storage register, used to store round keys.

[0127] In a specific application scenario, the round key generation module includes a control instruction input port connected to the key generation control unit, that is, Figure 5 The start port in the key expansion calculation unit; the parameter input port connected to the key expansion calculation unit, that is, Figure 5 The system FK port and information input port in Figure 5 init_key port in;

[0128] The control command input port is used to transmit the control command to the key generation control unit.

[0129] A parameter input port, used to transmit preset parameters to the key expansion calculation unit;

[0130] Information input port, used to transmit key information to the key expansion calculation unit.

[0131] In a specific application scenario, considering that the output of the key expansion calculation unit may be used as an input, the key expansion calculation unit may include a third input port connected to its own output port.

[0132] In an SM4 algorithm running device provided in an embodiment of the present application, each encryption module can be connected to a key storage register so that the encryption module can quickly read the required round key from the key storage register.

[0133] In an SM4 algorithm running device provided in an embodiment of the present application, each encryption module includes a target number of encryption units, and the encryption units are connected to the data input port and the data output port in a one-to-one correspondence, so that the SM4 operation can be performed on each data to be operated with the help of each encryption unit.

[0134] In practical applications, the length of the data input port and the data output port of each encryption module can be 128 bits.

[0135] In order to facilitate understanding of the effect of the SM4 algorithm running device provided by this application, it is assumed that the main frequency of the SM4 algorithm running device is 250M. When the target number is 1, that is, there is only one 128-bit data to be calculated, the computing bandwidth is 32Gb / s, 4GB / s; when the target number is 2, that is, there are 2 128-bit data to be calculated, the computing bandwidth is 64Gb / s, 8GB / s; when the target number is 4, that is, there are 4 128-bit data to be calculated, the computing bandwidth is 128Gb / s, 16GB / s. It can be seen from this that this application can flexibly adjust the number of data input ports of the encryption module to adjust the computing bandwidth as needed, and has good flexibility.

[0136] The present application also provides an SM4 algorithm running device and a computer-readable storage medium, both of which have the corresponding effects of the SM4 algorithm running method provided in the embodiments of the present application. Figure 6 , Figure 6 A schematic diagram of the structure of an SM4 algorithm running device provided in an embodiment of the present application.

[0137] An SM4 algorithm running device provided in an embodiment of the present application includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the steps of the SM4 algorithm running method described in any of the above embodiments are implemented.

[0138] See also Figure 7 , another SM4 algorithm running device provided in the embodiment of the present application may also include: an input port 203 connected to the processor 202, used to transmit commands input from the outside to the processor 202; a display unit 204 connected to the processor 202, used to display the processing results of the processor 202 to the outside; a communication module 205 connected to the processor 202, used to realize the communication between the SM4 algorithm running device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication mode adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (HML), universal serial bus (USB), high-definition multimedia interface (HDMI), wireless connection: wireless fidelity technology (WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.

[0139] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the SM4 algorithm operation method described in any of the above embodiments are implemented.

[0140] The computer-readable storage medium involved in the present application includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the technical field.

[0141] For the description of the relevant parts of the SM4 algorithm operation system, device and computer-readable storage medium provided in the embodiment of the present application, please refer to the detailed description of the corresponding parts in the SM4 algorithm operation method provided in the embodiment of the present application, which will not be repeated here. In addition, the parts of the above technical solutions provided in the embodiment of the present application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.

[0142] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0143] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for running an SM4 algorithm, characterized in that: include: Get key information; Generate and save the keys for each round of the SM4 algorithm based on the key information; In each round operation of the SM4 algorithm, the data to be operated in the current round operation is obtained, and the target round key of the current round operation is determined based on the round key, and the data to be operated is processed in parallel based on the target round key to obtain and save the operation result of the current round operation; wherein, if the current round operation is not the first round operation, the corresponding data to be operated includes the operation result of the previous round operation; Determine the corresponding SM4 operation result based on the saved operation result of the 32nd round operation; The step of performing parallel processing on the data to be operated based on the target round key includes: Determine the amount of available computing resources; Obtaining a target processing bandwidth of the SM4 algorithm; Determining the number of parallel operations based on the available computing resources and the target processing bandwidth; According to the parallel operation quantity, the data to be operated are processed in parallel based on the target round key.

2. The method according to claim 1, characterized in that The processing of the data to be calculated in parallel based on the target round key to obtain and save the calculation results of the current round calculations includes: Processing the data to be calculated in parallel based on the target round key to obtain the calculation result of the current round calculation; The calculation result of the current round-by-round calculation is saved in the storage space corresponding to the current round-by-round calculation.

3. The method according to claim 2, characterized in that The step of obtaining the data to be calculated for the current round-by-round calculation includes: Obtaining a first signal and a second signal corresponding to the current round operation, wherein the first signal is used to indicate whether the operation result of the previous round operation can be transmitted to the current round operation, and the second signal is used to indicate whether the next round operation can receive the operation result of the current round operation; If the first signal corresponding to the current round operation indicates that the operation result of the previous round operation can be transmitted to the current round operation, and the second signal corresponding to the current round operation indicates that the next round operation can receive the operation result of the current round operation, then the data to be calculated of the current round operation is obtained.

4. The method according to claim 3, characterized in that If the first signal corresponding to the current round operation indicates that the operation result of the previous round operation can be transmitted to the current round operation, and the second signal corresponding to the current round operation indicates that the next round operation can receive the operation result of the current round operation, then obtaining the data to be operated of the current round operation includes: Generate a third signal corresponding to the current round-by-round operation based on the first signal and the second signal corresponding to the current round-by-round operation by using a first operation formula; The first operation formula includes: ppen = in_ready & in_valid; in_ready=(~out_valid)|out_ready; out_valid<=(~in_ready)|in_valid; If the third signal corresponding to the current round-by-round operation indicates that data can be obtained, then obtaining the data to be calculated for the current round-by-round operation; Among them, ppen represents the third signal corresponding to the current round operation; in_ready represents the second signal corresponding to the previous round operation; & represents and operation; in_valid represents the first signal corresponding to the current round operation; ~ represents no operation; out_valid represents the first signal corresponding to the next round operation; | represents or operation; out_ready represents the second signal corresponding to the current round operation; <= represents the delayed output of the first signal corresponding to the next round operation.

5. The method according to claim 4, characterized in that The generating, by the first operation formula, a third signal corresponding to the current round-by-round operation based on the first signal and the second signal corresponding to the current round-by-round operation, comprises: Input the first signal corresponding to the current round of operation to the first signal receiving port of the operator, and input the second signal corresponding to the current round of operation to the second signal input port of the operator; Acquire the third signal calculated by the operator; Wherein, the operator includes the first signal receiving port, the first signal output port, the second signal input port, the second signal output port, the first NOR gate, the second NOR gate, the AND gate and a register; the first signal receiving port is connected to the first input end of the first NOR gate and the first input end of the AND gate; the output end of the first NOR gate is connected to the input end of the register; the output end of the register is connected to the first signal output port and the NOR gate input end of the second NOR gate; the second signal input port is connected to the first input end of the second NOR gate; the output end of the second NOR gate is connected to the second signal output port, the NOR gate input end of the first NOR gate, and the second input end of the AND gate; the output end of the AND gate is used to output the third signal.

6. An SM4 algorithm operation system, characterized in that: include: A first acquisition module, used to acquire key information; A first generating module, used to generate and save each round key of the SM4 algorithm based on the key information; The encryption module is used to obtain the data to be calculated for the current round-by-round calculation, determine the target round key for the current round-by-round calculation based on the round key, and perform parallel processing on the data to be calculated based on the target round key to obtain and save the calculation result of the current round-by-round calculation; wherein, if the current round-by-round calculation is not the first round-by-round calculation, the corresponding data to be calculated includes the calculation result of the previous round-by-round calculation; A first determining module, configured to determine a corresponding SM4 operation result based on the saved operation result of the 32nd round operation; Wherein, the encryption module includes: A first determining unit, configured to determine the amount of available computing resources; A third acquisition unit, used to acquire a target processing bandwidth of the SM4 algorithm; A second determining unit, configured to determine the number of parallel operations based on the available computing resources and the target processing bandwidth; The second processing unit is used to perform parallel processing on the data to be operated based on the target round key according to the number of parallel operations.

7. The system according to claim 6, characterized in that The number of the encryption modules is 32.

8. An SM4 algorithm operation device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the SM4 algorithm operation method as described in any one of claims 1 to 5 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the SM4 algorithm operation method according to any one of claims 1 to 5 are implemented.