A data encryption processing method, device, medium and product
By performing data format conversion and random number control group expansion calculation of HMAC-SM3 algorithm, adjusting the timing relationship, the security problem of the algorithm under differential power consumption analysis attack is solved, and efficient encryption and security guarantee of data information is achieved.
Patent Information
- Application Number
- CN202411001894.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2044-07-25
AI Technical Summary
The HMAC-SM3 algorithm is insecurity under differential power consumption analysis attacks and is easily deciphered, resulting in the security of data information being affected.
By converting data format and filling the data to be processed, random numbers are obtained in real time and using enable signals to control packet expansion calculations, adjust the timing relationship between packet expansion and iterative compression, and randomize the algorithm power consumption and prevent power consumption. Analyze attacks.
Effectively resist differential power consumption analysis attacks, improve algorithm security, ensure data information security, and maintain computing efficiency.
Smart Images

Figure CN118573357B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data encryption processing method, device, medium and product. Background Art
[0002] The Hash-based Message Authentication Code (HMAC) algorithm is a keyed message authentication code algorithm used to verify data integrity and source legitimacy, and is applicable to security services in any security architecture, process, or application. When the hash function in the HMAC algorithm uses the SM3 (a cryptographic hash function standard) algorithm, it can be called the HMAC-SM3 algorithm, which is a relatively secure algorithm, but there are still many attacks to obtain key information.
[0003] Among them, Differential Power Analysis (DPA) is the most commonly used method. It is a side channel attack that aims to obtain keys or other sensitive information by analyzing the power leakage (power consumption curve) of the device under different input or operation conditions. This attack method does not require direct access to the internal information of the device, but infers keys or other sensitive information by observing the power consumption changes of the device during operation, which leads to a decrease in algorithm security and has a great impact on the security of data information. Summary of the invention
[0004] The purpose of the present invention is to provide a data encryption processing method, device, medium and product, which can realize the randomization of algorithm power consumption, make it impossible to decipher key information through power consumption analysis method, thereby improving the security of the algorithm and ensuring the security of data information.
[0005] In order to solve the above technical problems, the present invention provides a data encryption processing method, comprising:
[0006] Perform data format conversion and message filling on the data to be processed to obtain filled data;
[0007] Obtaining a first random number and a second random number in real time;
[0008] generating an enable signal according to the first random number, and using the enable signal to control the padding data to perform group extension calculation in combination with the second random number;
[0009] At the same time, adjust the timing relationship between group expansion and iterative compression;
[0010] According to the adjusted timing relationship between group expansion and iterative compression, the data after group expansion calculation is subjected to iterative compression calculation of the corresponding group to obtain the encrypted data result.
[0011] In a first aspect, in the above-mentioned data encryption processing method provided by the present invention, using the enable signal to control the padding data to perform group extension calculation in combination with the second random number includes:
[0012] Under the control of the enable signal, the data to be calculated in the padding data is grouped; the data length of the data to be calculated is 512 bits;
[0013] Each group of data after grouping is combined with the second random number to perform a decomposition operation of grouping extension calculation in two consecutive clock cycles.
[0014] On the other hand, in the data encryption processing method provided by the present invention, the decomposition operation of performing grouping extension calculation on each grouped data in combination with the second random number according to two consecutive clock cycles includes:
[0015] In a first clock cycle, each group of data and the second random number are subjected to a first decomposition operation of grouping extension calculation by a first setting function to obtain a first variable;
[0016] Perform a second decomposition operation of grouping expansion calculation on each group of data and the second random number through a second setting function to obtain a second variable;
[0017] In the second clock cycle, an XOR operation is performed on the first variable and the second variable to obtain data after group expansion calculation.
[0018] On the other hand, in the above data encryption processing method provided by the present invention, the expression of the first setting function is:
[0019] temp_1=P1(W j-16 ⊕W j-9 ⊕(W j-3 <<15))⊕random_b;
[0020] The expression of the second setting function is:
[0021] temp_2=(W j-13 <<7)⊕W j-6 ⊕random_b;
[0022] Where temp_1 is the first variable and temp_2 is the second variable; let X=W j-16 ⊕W j-9 ⊕(W j-3<<15), P1(X)=X⊕(X<<<15)⊕(X<<<23); ⊕ represents an XOR operation, << represents a left shift operation, <<< represents a left circular shift, the data after << and <<< represents the number of bits shifted, and random_b represents the second random number.
[0023] On the other hand, in the above-mentioned data encryption processing method provided by the present invention, the two clock cycles corresponding to the group expansion are less than or equal to the time of a single iterative compression;
[0024] When the time ratio between two clock cycles corresponding to group expansion and a single iteration compression is n:1, the length of the first random number is n / 2 bits; wherein n is an integer.
[0025] On the other hand, in the data encryption processing method provided by the present invention, adjusting the timing relationship between group expansion and iterative compression includes:
[0026] The time between adjacent group expansion calculations is adjusted to a random state so that the group expansion calculation is completed before the iterative compression calculation of the corresponding group;
[0027] The time between adjacent group extension calculations is greater than or equal to 0.
[0028] On the other hand, in the above-mentioned data encryption processing method provided by the present invention, in the process of performing iterative compression calculation of the corresponding group on the data after the group expansion calculation, it includes:
[0029] Determining the relationship between completed group expansion rounds and iterative compression rounds;
[0030] If the completed group expansion round is equal to the iterative compression round plus 1 or 2, directly set the enable of group expansion calculation to 1;
[0031] If the completed group expansion round is less than the iterative compression round plus 2 and not equal to the iterative compression round plus 1, determining whether an error occurs in the first random number;
[0032] If yes, set the enable of group extension calculation to 1; if no, set the enable of group extension calculation to 0.
[0033] On the other hand, the data encryption processing method provided by the present invention further includes:
[0034] Obtaining a third random number in real time;
[0035] During the iterative compression process, the round jump of the iterative compression is controlled by controlling the switch according to the third random number.
[0036] On the other hand, in the data encryption processing method provided by the present invention, controlling the round jump of iterative compression by controlling a switch according to the third random number includes:
[0037] Dividing the third random number into a first sub-random number part and a second sub-random number part;
[0038] Compare the first sub-random number part and the second sub-random number part, use the larger value as the jump starting round and the smaller value as the jump destination round;
[0039] When the control switch is in the on state, when the iterative compression round reaches the jump start round, it switches to the jump destination round to perform iterative compression calculation again.
[0040] On the other hand, in the above data encryption processing method provided by the present invention, when the length of the third random number is 12 bits, the third random number is divided into a first sub-random number part and a second sub-random number part by using the following formula:
[0041] random_c_1 = random_c[5:0];
[0042] random_c_2 = random_c[11:6];
[0043] Among them, random_c is the third random number, random_c_1 is the first sub-random number part, random_c_2 is the second sub-random number part, random_c[5:0] is the part corresponding to the 1st bit to the 6th bit in the third random number, and random_c[11:6] is the part corresponding to the 7th bit to the 12th bit in the third random number.
[0044] On the other hand, in the data encryption processing method provided by the present invention, controlling the round jump of iterative compression by controlling the switch according to the third random number further includes:
[0045] The time period between the time when the target wheel is switched to and the time when the wheels are returned to the starting wheel is calculated one by one as the idle wheel calculation time;
[0046] During the idle round calculation time, the control switch is turned off and no calculation of group expansion is performed;
[0047] When the calculation returns to the jump start round, the control switch is turned on to start the calculation of the group extension.
[0048] On the other hand, in the above-mentioned data encryption processing method provided by the present invention, obtaining the encrypted data result includes:
[0049] Output the data after 64 rounds of iterative compression and generate a summary value as the encrypted data result;
[0050] Alternatively, the data after 64 rounds of iterative compression is used as the initial value of the next set of data for further calculation to obtain the encrypted data result.
[0051] In order to solve the above technical problems, the present invention further provides a data encryption processing device, comprising:
[0052] Memory for storing computer programs;
[0053] A processor is used to implement the steps of the above-mentioned data encryption processing method when executing the computer program.
[0054] In order to solve the above technical problem, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above data encryption processing method are implemented.
[0055] In order to solve the above technical problem, the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the above data encryption processing method when executed by a processor.
[0056] It can be seen from the above technical scheme that the present invention provides a data encryption processing method, which includes: performing data format conversion and message filling on the data to be processed to obtain filling data; obtaining a first random number and a second random number in real time; generating an enable signal according to the first random number, and using the enable signal to control the filling data to perform group expansion calculation in combination with the second random number; adjusting the timing relationship between group expansion and iterative compression at the same time; according to the adjusted timing relationship between group expansion and iterative compression, performing iterative compression calculation on the data after the group expansion calculation for the corresponding group to obtain the encrypted data result.
[0057] The beneficial effect of the present invention lies in that the above-mentioned data encryption processing method provided by the present invention, after performing data format conversion and message filling on the data to be processed, uses random numbers to add the group expansion calculation process, and simultaneously adjusts the timing relationship between the group expansion and iterative compression to perform iterative compression calculation of the corresponding group on the data after the group expansion calculation, thereby realizing the randomization of the algorithm power consumption, making it impossible to decipher key information through the power consumption analysis method, being able to resist the attack of differential power consumption analysis, and improving the security of the algorithm while ensuring the computing efficiency, having a certain degree of security and protection for the data information, and improving the applicability of data encryption, and can be applied in the fields of security encryption and the like.
[0058] In addition, the present invention also provides corresponding data encryption processing equipment, non-volatile storage media and computer program products for the data encryption processing method, which have the same or corresponding technical features as the above-mentioned data encryption processing method and have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0060] Figure 1 A flowchart of a data encryption processing method provided by an embodiment of the present invention;
[0061] Figure 2 A schematic diagram of the hardware architecture and data flow corresponding to the data encryption processing method provided in an embodiment of the present invention;
[0062] Figure 3 One of the schematic diagrams of the timing relationship between existing group expansion and iterative compression;
[0063] Figure 4 The second schematic diagram of the timing relationship between existing group expansion and iterative compression;
[0064] Figure 5 A schematic diagram of the timing relationship between group expansion and iterative compression provided by an embodiment of the present invention;
[0065] Figure 6 A schematic diagram of iterative compression provided by an embodiment of the present invention;
[0066] Figure 7 A schematic diagram of the structure of a data encryption processing device provided by an embodiment of the present invention;
[0067] Figure 8 A schematic diagram of the structure of a data encryption processing device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Figure 1 A flowchart of a data encryption processing method provided by an embodiment of the present invention, such as Figure 1 As shown, the method includes:
[0070] S101, performing data format conversion and message filling on the data to be processed to obtain filled data.
[0071] It should be noted that the present invention is mainly aimed at the SM3 algorithm. As a cryptographic hash algorithm, the SM3 algorithm has an output message digest value length of 256 bits, a message block length of 512 bits, and 64 iterative compression times.
[0072] When executing step S101, the data to be processed is converted into a data format and filled with a message, so that the length of the obtained filled data is an integer multiple of 512 bits. The data to be processed is also the input data, and the data to be processed can be data to be compressed or data to be verified.
[0073] Figure 2 The hardware architecture and data flow diagram corresponding to the data encryption processing method provided in the embodiment of the present invention. Figure 2 As shown, in the hardware implementation of the algorithm, the data to be processed needs to be converted into a data format and filled with a message first. Since the packet length of the SM3 algorithm is 512 bits (i.e., the data is input 512 bits each time), and it is a big-endian mode (i.e., a high-order low address), the big-endian mode is a data storage method in which the high-order byte of a multi-byte data type is stored at a low address, while the low-order byte is stored at a high address. The little-endian mode is that the high-order byte of a multi-byte data type is stored at a high address, while the low-order byte is stored at a low address. For different input data formats, it is necessary to convert the data width and the big-endian mode. Therefore, in the present invention, the data format conversion of the data to be processed can specifically include: converting the data width and the big-endian mode of the data to be processed. When the converted data is filled, 1 bit of "1", several bits of "0", and a data length of 64 bits can be added after the previous stage data is input, to ensure that the data length of the input data plus the added information is an integer multiple of 512 bits. Such a data processing method can facilitate the calculation of subsequent group expansion and iterative compression, and improve the operation efficiency.
[0074] In addition, it should be pointed out that the data encryption processing method of the present invention may include inputting the data to be processed into the hardware structure of the SM3 algorithm, and then starting to execute step S101.
[0075] S102: Acquire a first random number and a second random number in real time.
[0076] It should be noted that random numbers are a randomly generated sequence that satisfies the characteristics of overall uniform distribution, internal irrelevance / independence, and unpredictability. They can be used in key generation, key exchange, digital signatures, encryption and decryption, and other fields. Random numbers play a vital role in cryptography, encryption and decryption, and information data security.
[0077] like Figure 2 As shown, the first random number and the second random number can be generated by a random number generator; the first random number and the second random number are obtained from the random number generator in real time, so that the subsequent group expansion and iterative compression calculation process has randomization. The random number generator here can use a true random number generator or a pseudo-random number generator, which can be passed to the hardware through software, or generated in other modules of the chip and passed to the encryption calculation unit through an internal hardware link, or a random number generator unit can be directly integrated into the encryption calculation unit. As long as the random number generator can generate multiple groups of random numbers in real time and with high quality, it is not limited here.
[0078] S103: Generate an enable signal according to the first random number, and use the enable signal to control the padding data to perform group extension calculation in combination with the second random number.
[0079] It should be noted that, compared with the traditional packet expansion, the packet expansion of the present invention is optimized. The present invention uses the first random number to generate an enable signal, and uses the enable signal to control the flow of packet expansion calculation, that is, to control when to start the different rounds of packet calculation process, and the packet expansion calculation is performed by filling data combined with random numbers.
[0080] The above step S103 can be executed by the group calculation control module, which mainly generates the message word W required in the group expansion calculation process. j and W j ', the message word needs to be used in the subsequent iterative compression calculation.
[0081] S104. Simultaneously adjust the timing relationship between group expansion and iterative compression.
[0082] In implementation, the present invention adjusts the timing relationship between group expansion and iterative compression in real time while performing group expansion calculations, so that the timing relationship between group expansion and iterative compression is not a fixed one, thereby avoiding the situation where the power consumption changes in the power consumption curve are regular and vulnerable to attacks.
[0083] S105 . According to the adjusted timing relationship between group expansion and iterative compression, perform iterative compression calculation on the corresponding group of data after group expansion calculation to obtain encrypted data results.
[0084] In the above-mentioned data encryption processing method provided by the embodiment of the present invention, after the data format conversion and message filling are performed on the data to be processed, random numbers are used to add the group expansion calculation process, and the timing relationship between the group expansion and the iterative compression is adjusted at the same time to perform iterative compression calculations on the data after the group expansion calculation for the corresponding group. In this way, the power consumption of the algorithm is randomized, making it impossible to decipher key information through the power consumption analysis method, and it can resist the attack of differential power consumption analysis. While ensuring the calculation efficiency, the security of the algorithm is improved, and a certain degree of security and protection is provided for the data information, thereby improving the applicability of data encryption, and it can be applied in the fields of security encryption and the like.
[0085] It should be added that, in specific implementation, the present invention can specifically target the HMAC-SM3 algorithm to implement the design of the HMAC-SM3 algorithm that is resistant to differential power consumption analysis, wherein the HMAC algorithm further verifies the data, and the expression of the HMAC algorithm is:
[0086] HMAC(K0, text)=H(K0⊕opad, H(K0⊕ipad, text));
[0087] Among them, K0 is the key shared in advance by the communicating parties, H is the hash function, text is the data to be verified, and opad and ipad are constants defined by the algorithm.
[0088] Further, in the specific implementation, in the above-mentioned data encryption processing method provided in the embodiment of the present invention, step S103 uses an enable signal to control the padding data to perform group expansion calculation in combination with the second random number, which may specifically include: under the control of the enable signal, grouping the data to be calculated in the padding data; the data length of the data to be calculated is 512 bits; and decomposing each group of data after grouping in combination with the second random number according to two consecutive clock cycles to perform group expansion calculation.
[0089] It should be noted that in the traditional SM3 algorithm, the flow and steps of group expansion calculation are as follows:
[0090] The data to be calculated, data_in, passed from the previous stage, is 512 bits, which are divided into 16 groups according to the bit width of 32 bits, denoted as W0, W1, ..., W 15 ,in:
[0091] W0 = Data_in[31:0];
[0092] W1 = Data_in[63:32];
[0093] W2 = Data_in[95:64];
[0094] By analogy, after completing 16 groups, we can see that after the previous stage inputs 512 bits of data, W0, W1, ..., W 15 It is immediately available without any calculations.
[0095] As for W 16 , W 17 ,……,W 67 , you need to calculate according to the following function:
[0096] W j =P1(W j-16 ⊕W j-9 ⊕(W j-3 <<15))⊕(W j-13 <<7)⊕W j-6 ;
[0097] As for W j =W j ⊕W j+4 , for W0' to W 63 All values between ' are calculated in this way.
[0098] In which, let X = W j-16 ⊕W j-9 ⊕(W j-3 <<15), P1(X)=X⊕(X<<<15)⊕(X<<<23); ⊕ represents XOR operation, << represents left shift operation, <<< represents left circular shift, and the data after << and <<< represents the number of bits to be shifted.
[0099] As mentioned above, each data in the SM3 algorithm needs to undergo 64 rounds of iterative compression calculations. In this process, the input values of each round are different, and they mainly include the following parameters: W j and W j ', where j is the current iterative calculation round, that is, the value corresponding to each round of input; the result V(i+1) of the previous round of iterative compression calculation; the iterative round j and the constant Tj based on the iterative round j.
[0100] It should be emphasized that the present invention takes into account that the computational complexity of iterative compression is higher than that of group expansion, and the computational time is longer. At the same time, after the previous stage data is input, the first 12 groups W j and W j 'The data can be considered to be directly obtained without complex calculations (W j =W j ⊕W j+4 It is easy to calculate), so the time tolerance for group expansion calculation is very high. It only needs to calculate the corresponding round of W before the corresponding iteration round calculation. j and Wj Based on this premise, the present invention specifically optimizes the implementation logic of group expansion and optimizes the pipeline allocation of group expansion calculation and iterative compression calculation.
[0101] In practice, due to W j ' is dependent on W j Simple operation, that is, W j =W j ⊕W j+4 Therefore, the present invention is mainly to W j For W 16 , W 17 ,……,W 67 , decompose the original function calculation into two steps, and perform the decomposition operation of grouping and extending the calculation in two consecutive clock cycles in combination with the second random number. The data bit width of the second random number here can be 32 bits.
[0102] Furthermore, in a specific implementation, in the above-mentioned data encryption processing method provided by an embodiment of the present invention, in the above-mentioned steps, each group of data after grouping is combined with the second random number to perform a decomposition operation of group expansion calculation according to two consecutive clock cycles, which can specifically include: first, in a first clock cycle, each group of data after grouping and the second random number are subjected to a first decomposition operation of group expansion calculation through a first set function to obtain a first variable; each group of data after grouping and the second random number are subjected to a second decomposition operation of group expansion calculation through a second set function to obtain a second variable; then, in a second clock cycle, the first variable and the second variable are subjected to an XOR operation to obtain the data after the group expansion calculation.
[0103] In an implementation, the first clock cycle is consecutive to the second clock cycle.
[0104] The present invention defines two intermediate variables, namely, a first variable temp_1 and a second variable temp_2.
[0105] In the first clock cycle, each group of data and the second random number after grouping are subjected to the first decomposition operation of grouping extension calculation through the first setting function to obtain the first variable temp_1, wherein the expression of the first setting function can be:
[0106] temp_1=P1(W j-16 ⊕W j-9 ⊕(W j-3 <<15))⊕random_b;
[0107] In the first clock cycle, each group of data and the second random number after grouping are subjected to a second decomposition operation of grouping extension calculation through a second setting function to obtain a second variable temp_2, wherein the expression of the second setting function is:
[0108] temp_2=(W j-13 <<7)⊕W j-6 ⊕random_b;
[0109] In the second clock cycle, the first variable and the second variable are XORed to obtain the data after the group expansion calculation. The specific formula is as follows:
[0110] W j =temp_1⊕temp_2;
[0111] Where temp_1 is the first variable and temp_2 is the second variable; let X=W j-16 ⊕W j-9 ⊕(W j-3 <<15), P1(X)=X⊕(X<<<15)⊕(X<<<23); ⊕ represents an XOR operation, << represents a left shift operation, <<< represents a left circular shift, the data after << and <<< represents the number of bits shifted, and random_b represents the second random number.
[0112] In implementation, the corresponding cyclic shift and XOR operation are performed according to the above expression and calculation formula to calculate W j Then calculate W j ', the calculation formula can be: W j =W j ⊕W j+4 . Perform a bitwise XOR operation according to this formula.
[0113] It should be pointed out that the present invention decomposes the calculation process and adds random numbers to make the signal flipping in the calculation process irregular, and at the same time, the number of signal flipping in each cycle is reduced, resulting in a flat and irregular power consumption curve. On the other hand, each group calculation is completed within two clock cycles, and does not exceed the calculation time of one iterative compression, so it does not affect the calculation efficiency (computational bandwidth) of the entire algorithm.
[0114] Furthermore, in the specific implementation, in the above data encryption processing method provided by the embodiment of the present invention, the two clock cycles corresponding to the group expansion are less than or equal to the time of a single iterative compression. When the time ratio between the two clock cycles corresponding to the group expansion and the single iterative compression is n:1, the length of the first random number is n / 2 bits; wherein n is an integer.
[0115] It should be understood that there are two main types of temporal parallel relationships between traditional group expansion calculations and iterative compression calculations. The first is that each group expansion calculation is independent of the iterative compression process; the second is that each group expansion calculation is dependent on the iterative compression process.
[0116] Figure 3 This is one of the existing schematic diagrams of the timing relationship between group expansion and iterative compression. Figure 3 As shown, each group expansion calculation is independent of the iterative compression process, that is, starting from the 12th round, the calculation is continuous without interruption until the last group of calculations is completed. Figure 3 The 12th round of grouping calculation in is based on W j =W j ⊕W j+4 , the calculation of j is explained, at this time W j At the same time, j=16 rounds of calculations are being performed.
[0117] Figure 4 This is the second schematic diagram of the existing timing relationship between group expansion and iterative compression. Figure 4 As shown in the figure, each group expansion calculation depends on the iterative compression process. As long as the two groups of W required are completed by group expansion calculation before the next round of iterative compression calculation begins, j and W j ' data, for example, when iterative compression is performed for 11 rounds, synchronous calculation of group expansion is performed for 12 rounds. Considering that the number of clock cycles of iterative compression calculation is more than that of group expansion in most cases, the group expansion process is not continuous.
[0118] The above two timing relationships have the same problem, that is, they are both implemented using fixed rules, which is reflected in the power consumption curve. The change of power consumption is regular and is easy to be attacked.
[0119] In order to solve the above problem, the present invention introduces a first random number, denoted as random_a. The bit width of the first random number random_a can be 1 bit or multiple bits, which is determined based on the performance of the first random number and the relationship between the calculation time of group expansion and iterative compression. When the ratio of the time of single iterative compression and group expansion is 4:1, random_a can be 2 bits.
[0120] Figure 5 A schematic diagram of the timing relationship between group expansion and iterative compression provided by an embodiment of the present invention. Figure 5As shown, the time between two grouped expansion calculations in the present invention is random. That is, in the process of adjusting the timing relationship between grouped expansion and iterative compression in step S104, the time between adjacent grouped expansion calculations is adjusted to a random state. Among them, the time between adjacent grouped expansion calculations is greater than or equal to 0. That is, the time between adjacent grouped expansion calculations may be 0, that is, continuous, or there may be large or small time intervals. Before the iterative compression calculation of the corresponding group, it is ensured that the grouped expansion calculation is completed, that is, it is ensured that the iterative compression process will not be delayed due to too large a time interval, resulting in a decrease in the speed and performance of the entire algorithm.
[0121] Further, in specific implementation, in the above data encryption processing method provided by the embodiment of the present invention, in the process of performing step S105 to perform iterative compression calculation on the data after grouped expansion calculation for the corresponding group, it may specifically include: determining the relationship between the completed grouped expansion rounds and the iterative compression rounds; if the completed grouped expansion rounds are equal to the iterative compression rounds plus 1 or 2, directly set the enable of the grouped expansion calculation to 1; if the completed grouped expansion rounds are less than the iterative compression rounds plus 2 and not equal to the iterative compression rounds plus 1, then determine whether the first random number appears incorrect; if so, set the enable of the grouped expansion calculation to 1; if not, set the enable of the grouped expansion calculation to 0.
[0122] In implementation, after obtaining the first random number random_a, determine the relationship between the completed grouped expansion rounds ex_i and the iterative compression rounds cf_i; if ex_i = cf_i + 1 or ex_i = cf_i + 2, at this time, directly set the enable ex_en of the grouped expansion calculation to 1, that is, perform one round of grouped expansion calculation. If ex_i < cf_i + 2, then enter the next step, determine the first random number random_a. If random_a = 2'b11 (indicating a memory error), then set the enable ex_en of the grouped expansion calculation to 1, that is, perform one round of grouped expansion calculation. It should be noted that for the 2-bit first random number random_a, the possibilities of the four cases are theoretically equal, so any value can be selected. Otherwise, set the enable ex_en of the grouped expansion calculation to 0, that is, do not perform grouped expansion calculation, and jump to the step of obtaining the first random number random_a to obtain the next group of the first random number random_a. The random numbers of the present invention are updated in real time.
[0123] Further, in specific implementation, in the above data encryption processing method provided by the embodiment of the present invention, it may further include: obtaining a third random number in real time, denoted as random_c; during the iterative compression process, control the round jump of the iterative compression through a control switch according to the third random number.
[0124] In implementation, the optimization of iterative compression in the present invention may take up more clock cycles, that is, increase the calculation time of the data. Therefore, the present invention adds a design of a control switch. When it is needed, turn on this control switch to perform subsequent round jumps. If it is not needed, turn off the switch and do not perform round jumps. In addition, the present invention uses a control switch to implement the iterative compression round jump function based on the third random number, further realizing the averaging and randomization of the algorithm power consumption; wherein the third random number is generated by a random number generator; and the third random number is obtained from the random number generator in real time. This method is suitable for fields or application scenarios that do not require high computing efficiency but have high security requirements.
[0125] Further, in the specific implementation, in the above-mentioned data encryption processing method provided by the embodiment of the present invention, in the above-mentioned steps, controlling the round jump of iterative compression by controlling the switch according to the third random number may specifically include: dividing the third random number into a first sub-random number part and a second sub-random number part; for example: when the length of the third random number is 12 bits, the third random number is divided into the first sub-random number part and the second sub-random number part by using the following formula:
[0126] random_c_1 = random_c[5:0];
[0127] random_c_2 = random_c[11:6];
[0128] Among them, random_c is the third random number, random_c_1 is the first sub-random number part, random_c_2 is the second sub-random number part, random_c[5:0] is the part corresponding to the 1st bit to the 6th bit in the third random number, and random_c[11:6] is the part corresponding to the 7th bit to the 12th bit in the third random number.
[0129] Next, the first sub-random number part random_c_1 and the second sub-random number part random_c_2 are compared, and the larger value is used as the jump start round jump_s, and the smaller value is used as the jump destination round jump_d. When the control switch is turned on, when the iterative compression round reaches the jump start round, it is transferred to the jump destination round for iterative compression calculation again.
[0130] In implementation, after the previous stage data is input, iterative compression calculation is first performed in sequence, that is, the 0th round is performed first, and the 1st round is increased in sequence. When the iterative compression round reaches the jump start round jump_s, it is transferred to the jump destination round jump_d, and then the calculation is performed, and the round calculation is increased in sequence. Since the jump destination round jump_d must be less than or equal to the jump start round jump_s, the parameters required to be input when calculating the jump destination round jump_d round have been calculated in the previous step, and the calculation can be performed directly without waiting for the group expansion calculation.
[0131] Furthermore, in a specific implementation, in the above-mentioned data encryption processing method provided in an embodiment of the present invention, the above-mentioned steps of controlling the round jump of iterative compression through a control switch according to a third random number may also include: taking the time period from adjusting to the jump destination round jump_d to successively calculating back to the jump starting round jump_s as the idle round calculation time; during the idle round calculation time, turning off the control switch and not performing group expansion calculation; when the calculation returns to the jump starting round jump_s, turning on the control switch and starting the group expansion calculation.
[0132] Figure 6 Schematic diagram of iterative compression provided by an embodiment of the present invention. Figure 6 As shown, in implementation, during the period between jumping to the jump destination round jump_d and calculating back to the jump start round jump_s, the group calculation control module can be closed and the group extension calculation is not performed. When the calculation returns to the jump start round jump_s, the group calculation control module is restarted.
[0133] Furthermore, in a specific implementation, in the above-mentioned data encryption processing method provided in an embodiment of the present invention, step S105 obtains the encrypted data result, which may specifically include: outputting the data after 64 rounds of iterative compression, and generating a summary value as the encrypted data result; or, using the data after 64 rounds of iterative compression as the initial value of the next set of data for further calculation to obtain the encrypted data result.
[0134] In implementation, the encrypted data result obtained may be referred to as summary data or a hash value.
[0135] In the above embodiments, the data encryption processing method is described in detail, and the present invention also provides corresponding embodiments of the data encryption processing device and the data encryption processing equipment. It should be noted that the present invention describes the embodiments of the device part from two perspectives, one is based on the functional module perspective, and the other is based on the hardware perspective.
[0136] Figure 7 This is a schematic diagram of the structure of a data encryption processing device provided by an embodiment of the present invention. This embodiment is based on the perspective of functional modules, such as Figure 7 As shown, the device comprises:
[0137] The conversion and filling module 70 is used to perform data format conversion and message filling on the data to be processed to obtain filling data;
[0138] A random number acquisition module 71, used for acquiring a first random number and a second random number in real time;
[0139] A group calculation control module 72, used to generate an enable signal according to the first random number, and use the enable signal to control the padding data in combination with the second random number to perform group expansion calculation;
[0140] A timing adjustment module 73, used to adjust the timing relationship between packet expansion and iterative compression;
[0141] The iterative compression module 74 is used to perform iterative compression calculations on the data after the group expansion calculation according to the adjusted timing relationship between the group expansion and the iterative compression to obtain encrypted data results.
[0142] In the above-mentioned data encryption processing device provided in the embodiment of the present invention, through the interaction of the above-mentioned five modules, the data format conversion and message filling can be performed on the processed data, random numbers can be used to add the group expansion calculation process, and the timing relationship between the group expansion and iterative compression can be adjusted at the same time to perform iterative compression calculation of the corresponding group on the data after the group expansion calculation. In this way, the power consumption of the algorithm is randomized, making it impossible to decipher key information through the power consumption analysis method, and it can resist the attack of differential power consumption analysis. While ensuring the calculation efficiency, the security of the algorithm is improved, and a certain security and protection is provided for the data information, thereby improving the applicability of data encryption, and it can be applied in the fields of security encryption and the like.
[0143] Since the embodiments of the device part correspond to the embodiments of the method part, the embodiments of the device part refer to the description of the embodiments of the method part, which will not be described here. And it has the same beneficial effects as the above-mentioned data encryption processing method.
[0144] Furthermore, in a specific implementation, in the above-mentioned data encryption processing device provided by the embodiment of the present invention, the random number acquisition module 71 can be specifically used to acquire the first random number and the second random number generated by the random number generator in real time.
[0145] Furthermore, in a specific implementation, in the above-mentioned data encryption processing device provided in an embodiment of the present invention, the group calculation control module 72 may specifically include:
[0146] A data grouping unit, used for grouping the data to be calculated in the padding data under the control of the enable signal; the data length of the data to be calculated is 512 bits;
[0147] The decomposition calculation unit is used to combine each group of data after grouping with the second random number to perform a decomposition operation of grouping extension calculation according to two consecutive clock cycles.
[0148] Furthermore, in a specific implementation, in the above-mentioned data encryption processing device provided by an embodiment of the present invention, the decomposition and calculation unit can be specifically used to, within a first clock cycle, perform a first decomposition operation of grouping and expanding calculation on each group of data after grouping and the second random number through a first set function to obtain a first variable; perform a second decomposition operation of grouping and expanding calculation on each group of data after grouping and the second random number through a second set function to obtain a second variable; within a second clock cycle, perform an XOR operation on the first variable and the second variable to obtain data after the group expansion calculation.
[0149] The present invention can make the signal flipping in the calculation process irregular through the operation of the above-mentioned decomposition calculation unit, and at the same time reduce the number of each signal flipping in each cycle, resulting in a flat and irregular power consumption curve. In addition, each group calculation in the present invention is completed within two clock cycles, which does not exceed the calculation time of one iterative compression, and does not affect the calculation efficiency of the entire algorithm.
[0150] Furthermore, in a specific implementation, in the above-mentioned data encryption processing device provided in an embodiment of the present invention, the timing adjustment module 73 can be specifically used to adjust the time between adjacent group expansion calculations to a random state, so as to complete the group expansion calculation before the iterative compression calculation of the corresponding group.
[0151] Furthermore, in a specific implementation, in the above-mentioned data encryption processing device provided by an embodiment of the present invention, the iterative compression module 74 can be specifically used to determine the relationship between the completed group expansion rounds and the iterative compression rounds; if the completed group expansion round is equal to the iterative compression round plus 1 or 2, the enable of the group expansion calculation is directly set to 1; if the completed group expansion round is less than the iterative compression round plus 2 and is not equal to the iterative compression round plus 1, it is determined whether an error occurs in the first random number; if so, the enable of the group expansion calculation is set to 1; if not, the enable of the group expansion calculation is set to 0.
[0152] Furthermore, in a specific implementation, in the above-mentioned data encryption processing device provided by the embodiment of the present invention, the random number acquisition module 71 can also be used to obtain the third random number in real time.
[0153] Correspondingly, the iterative compression module 74 may specifically include:
[0154] The round jump unit is used to control the round jump of iterative compression by controlling the switch according to the third random number during the iterative compression process.
[0155] In implementation, the round jump unit can be specifically used to divide the third random number into a first sub-random number part and a second sub-random number part; compare the first sub-random number part and the second sub-random number part, and use the larger value as the jump start round and the smaller value as the jump destination round; when the control switch is in the on state, when the iterative compression round reaches the jump start round, it is transferred to the jump destination round to perform iterative compression calculation again. The round jump unit can also be specifically used to use the time period from the transfer to the jump destination round to the successive calculation back to the jump start round as the idle round calculation time; during the idle round calculation time, turn off the control switch and do not perform the group expansion calculation; when the calculation returns to the jump start round, turn on the control switch to start the group expansion calculation.
[0156] Figure 8 This is a schematic diagram of the structure of a data encryption processing device provided by an embodiment of the present invention. This embodiment is based on the hardware perspective, such as Figure 8 As shown, the data encryption processing device includes:
[0157] A memory 80, for storing computer programs;
[0158] The processor 81 is used to implement the steps of the data encryption processing method mentioned in the above embodiment when executing the computer program.
[0159] Among them, the processor 81 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 81 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 81 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU; the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 81 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 81 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0160] The memory 80 may include one or more non-volatile storage media, which may be non-transitory. The memory 80 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 80 is at least used to store the following computer program 801, wherein, after the computer program is loaded and executed by the processor 81, it can implement the relevant steps of the data encryption processing method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 80 may also include an operating system 802 and data 803, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 802 may include Windows, Unix, Linux, etc. Data 803 may include, but is not limited to, the data involved in the above-mentioned data encryption processing method, etc.
[0161] In some embodiments, the data encryption processing device may further include a display screen 82, an input / output interface 83, a communication interface 84, a power supply 85, and a communication bus 86. Those skilled in the art will appreciate that Figure 8 The structure shown in does not constitute a limitation on the data encryption processing device, and may include more or fewer components than shown in the figure. The data encryption processing device provided by the embodiment of the present invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the following method: data encryption processing method, the effect is the same as above.
[0162] Finally, the present invention also provides an embodiment corresponding to a non-volatile storage medium. The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0163] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or 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 and executes 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), random access memory (RAM), disk or optical disk and other media that can store program code. The non-volatile storage medium provided by the present invention can implement the above-mentioned data encryption processing method, and the effect is the same as above.
[0164] Finally, the present invention also provides an embodiment corresponding to a computer program product. The computer program product includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps described in the above data encryption processing method embodiment are implemented. The computer program product provided by the present invention can implement the above-mentioned data encryption processing method, and the effect is the same as above.
[0165] It should also be noted that, in this specification, 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 "comprise", "include" 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, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0166] The above is a detailed introduction to the data encryption processing method, device, medium and product provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A data encryption processing method, characterized in that: include: Perform data format conversion and message filling on the data to be processed to obtain filled data; Obtaining a first random number, a second random number and a third random number in real time; generating an enable signal according to the first random number, and using the enable signal to control the padding data to perform group extension calculation in combination with the second random number; At the same time, adjust the timing relationship between group expansion and iterative compression; According to the adjusted timing relationship between group expansion and iterative compression, the data after group expansion calculation is subjected to iterative compression calculation of the corresponding group to obtain the encrypted data result; In the process of iterative compression, the third random number is divided into a first sub-random number part and a second sub-random number part; Compare the first sub-random number part and the second sub-random number part, use the larger value as the jump starting round and the smaller value as the jump destination round; When the control switch is in the on state, when the iterative compression round reaches the jump start round, it switches to the jump destination round to perform iterative compression calculation again.
2. The data encryption processing method according to claim 1, characterized in that: Using the enable signal to control the padding data to perform group extension calculation in combination with the second random number includes: Under the control of the enable signal, the data to be calculated in the padding data is grouped; the data length of the data to be calculated is 512 bits; Each group of data after grouping is combined with the second random number to perform a decomposition operation of grouping extension calculation in two consecutive clock cycles.
3. The data encryption processing method according to claim 2, characterized in that: The decomposition operation of combining each group of grouped data with the second random number and performing group extension calculation according to two consecutive clock cycles includes: In a first clock cycle, each group of data and the second random number are subjected to a first decomposition operation of grouping extension calculation by a first setting function to obtain a first variable; Perform a second decomposition operation of grouping expansion calculation on each group of data and the second random number through a second setting function to obtain a second variable; In the second clock cycle, an XOR operation is performed on the first variable and the second variable to obtain data after group expansion calculation.
4. The data encryption processing method according to claim 3, characterized in that: The expression of the first setting function is: temp_1=P1(W j-16 ⊕W j-9 ⊕(W j-3 <<15))⊕random_b; The expression of the second setting function is: temp_2=(W j-13 <<7)⊕W j-6 ⊕random_b; Where temp_1 is the first variable and temp_2 is the second variable; let X=W j-16 ⊕W j-9 ⊕(W j-3 <<15), P1(X)=X⊕(X<<<15)⊕(X<<<23); ⊕ represents XOR operation, << represents left shift operation, <<< represents left circular shift, the data after << and <<< represents the number of bits shifted, random_b represents the second random number; W j-16 , W j-9 , W j-3 , W j-13 , W j-6 is the grouped data, and j represents the current iterative calculation round.
5. The data encryption processing method according to claim 4, characterized in that: The two clock cycles corresponding to the group expansion are less than or equal to the time of a single iterative compression; When the time ratio between two clock cycles corresponding to group expansion and a single iteration compression is n:1, the length of the first random number is n / 2 bits; wherein n is an integer.
6. The data encryption processing method according to claim 1, characterized in that: Adjust the timing relationship between group expansion and iterative compression, including: The time between adjacent group expansion calculations is adjusted to a random state so that the group expansion calculation is completed before the iterative compression calculation of the corresponding group; The time between adjacent group extension calculations is greater than or equal to 0.
7. The data encryption processing method according to claim 1, characterized in that: The process of performing iterative compression calculation on the data after group expansion calculation for the corresponding group includes: Determining the relationship between completed group expansion rounds and iterative compression rounds; If the completed group expansion round is equal to the iterative compression round plus 1 or 2, directly set the enable of group expansion calculation to 1; If the completed group expansion round is less than the iterative compression round plus 2 and not equal to the iterative compression round plus 1, determining whether an error occurs in the first random number; If yes, set the enable of group extension calculation to 1; if no, set the enable of group extension calculation to 0.
8. The data encryption processing method according to claim 1, characterized in that: When the length of the third random number is 12 bits, the third random number is divided into a first sub-random number part and a second sub-random number part using the following formula: random_c_1 = random_c[5:0]; random_c_2 = random_c[11:6]; Among them, random_c is the third random number, random_c_1 is the first sub-random number part, random_c_2 is the second sub-random number part, random_c[5:0] is the part corresponding to the 1st bit to the 6th bit in the third random number, and random_c[11:6] is the part corresponding to the 7th bit to the 12th bit in the third random number.
9. The data encryption processing method according to claim 8, characterized in that: Controlling the round jump of iterative compression by controlling a switch according to the third random number, further comprising: The time period between the time when the target wheel is switched to and the time when the wheels are returned to the starting wheel is calculated one by one as the idle wheel calculation time; During the idle round calculation time, the control switch is turned off and no calculation of group expansion is performed; When the calculation returns to the jump start round, the control switch is turned on to start the calculation of the group extension.
10. The data encryption processing method according to claim 1, characterized in that: Get the encrypted data results, including: Output the data after 64 rounds of iterative compression and generate a summary value as the encrypted data result; Alternatively, the data after 64 rounds of iterative compression is used as the initial value of the next set of data for further calculation to obtain the encrypted data result.
11. A data encryption processing device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data encryption processing method according to any one of claims 1 to 10 when executing the computer program.
12. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data encryption processing method according to any one of claims 1 to 10 are implemented.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the data encryption processing method according to any one of claims 1 to 10 are implemented.
