Data processing method and device based on hash algorithm, equipment and storage medium
Patent Information
- Application Number
- CN202510860102.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2045-06-25
AI Technical Summary
[0003]然而,在杂凑算法运算过程中,扩展函数和压缩函数的计算过程中会产生大量的旁路信息,通过侧信道攻击手段,可以分析并倒推出原始消息以及中间变量值,导致杂凑算法在运算过程中存在着信息泄露的风险
[0015]As described above, this application provides a data processing method, apparatus, device, and storage medium based on a hash algorithm. During the hash operation, this application introduces a randomly generated message mask for each message block to ensure that the original data is hidden before the expansion operation. Simultaneously, the random mask is fully covered throughout the message expansion and compression iterations. This full coverage of the random mask decouples physical characteristics such as power consumption and electromagnetic properties from sensitive data, significantly increasing the difficulty for attackers to extract keys or intermediate states through side-channel attacks. Furthermore, the iterative binding of the initial digest value further enhances contextual randomness and resists replay attacks. This application can effectively resist side-channel attacks, reduce the risk of information leakage, improve information security, and solve the technical problem of poor data security in existing hash algorithms during operation.
Smart Images

Figure CN120729507B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of security encryption, and in particular to a data processing method, apparatus, device and storage medium based on a hash algorithm. Background Technology
[0002] Hash algorithms, also known as hash algorithms, are primarily used in many security fields such as data digest calculation, digital signature verification, and message authentication. They are among the most widely used cryptographic algorithms in practice. Commonly used cryptographic algorithms both domestically and internationally include the SHA series (including SHA1-160, SHA2-224, SHA2-256, SHA2-384, SHA2-512, SHA2-512 / 224, and SHA2-512 / 256) and the SM3 algorithm.
[0003] However, during the hash algorithm operation, the calculation of the expansion function and the compression function generates a large amount of side-channel information. Through side-channel attack methods, the original message and intermediate variable values can be analyzed and deduced, resulting in the risk of information leakage during the hash algorithm operation. Summary of the Invention
[0004] This application provides a data processing method, apparatus, device, and storage medium based on a hash algorithm. By masking message blocks and covering the entire process of message expansion and compression iterations with a random mask, this application can effectively block side-channel attacks and reduce the risk of information leakage.
[0005] In a first aspect, this application provides a data processing method based on a hash algorithm, the method comprising: Each message block in the message block set is received sequentially, the message block set including multiple message blocks; Each time the message block is received, the target message block received this time and the randomly generated message mask are masked to obtain a masked message. The masked message and the message mask are simultaneously expanded and then spatially converted to obtain the message expansion value. Compression operations are performed based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain the mask hash value and the final mask. A hash value is generated based on the mask hash value and the final mask, which is used to calculate the hash value corresponding to the next message block. The initial digest value is generated based on the hash value obtained after processing the previous message block. The first message block corresponds to a preset initial digest value.
[0006] The step of performing a spatial transformation on the masked message and the message mask simultaneously after expansion operations to obtain the message expansion value includes: The masked message and the message mask are simultaneously expanded to obtain the masked expanded value and the message mask expanded value, respectively. The masked extended value and the message mask extended value are converted to arithmetic space to obtain the message extended value.
[0007] The step of synchronously expanding the masked message and the message mask to obtain the masked expanded value and the message mask expanded value respectively includes: Based on arithmetic and logical transformations, the masked message and the message mask are simultaneously subjected to a first preset number of rounds of direct assignment operations and a second preset number of rounds of recursive operations based on historical operation results, respectively obtaining the masked extended value corresponding to the masked message and the message mask extended value corresponding to the message mask.
[0008] The step of converting the masked extended value and the message mask extended value to arithmetic space to obtain the message extended value includes: After performing an XOR operation on the masked extended value and the message masked extended value, the result of the XOR operation is converted to the arithmetic space based on arithmetic transformation to obtain the message extended value.
[0009] The step of performing compression operations based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain the mask hash value and the final mask includes: The initial value of the summary is XORed with the mask of the randomly generated intermediate variable to obtain the masked state variable. Based on the message extension value, the intermediate variable mask, and the masked state variable, compression iteration is performed to obtain the mask hash value and the final mask.
[0010] The step of compressing and iterating based on the message extension value, the intermediate variable mask, and the masked state variable to obtain the mask hash value and the final mask includes: Based on the message extension value and the masked state variable, a third preset number of compression iterations based on logical and arithmetic transformations are performed. In each compression iteration, the masked state variable and its corresponding intermediate variable mask are updated, and the masked state variable and its corresponding intermediate variable mask after the last compression iteration are used as the mask hash value and the final mask, respectively.
[0011] The step of updating the masked state variable and its corresponding intermediate variable mask during each round of compression iteration includes: Based on the message extension value, round constant, and masked state variable of the current round, the first intermediate variable and the second intermediate variable are updated through logical transformation and arithmetic transformation; Based on the updated first intermediate variable and the updated second intermediate variable, the masked state variable of the current round is updated through arithmetic-Boolean field transformation, and the intermediate variable mask of the current round is updated synchronously through arithmetic transformation. The updated masked state variables and the updated intermediate variable masks are passed to the next round of compression iterations.
[0012] Secondly, this application provides a data processing apparatus based on a hash algorithm, the apparatus comprising: A message block receiving module is configured to sequentially receive each message block in a message block set, wherein the message block set includes multiple message blocks. The message extension module is configured to perform masking processing on the target message block and the randomly generated message mask after each message block is received to obtain a masked message. Then, after performing extension operations on the masked message and the message mask, a space transformation is performed to obtain the message extension value. The message compression module is configured to perform compression operations based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain a mask hash value and a final mask. A hash value is generated based on the mask hash value and the final mask for calculating the hash value corresponding to the next message block. The initial digest value is generated based on the hash value obtained after processing the previous message block. The first message block corresponds to a preset initial digest value.
[0013] Thirdly, this application provides a data processing device based on a hash algorithm, the data processing device based on a hash algorithm including a processor and a memory; The memory is configured to store computer programs and transfer the computer programs to the processor; The processor is configured to execute the hash-based data processing method as described in the first aspect, according to instructions in the computer program.
[0014] Fourthly, this application provides a storage medium for storing computer-executable instructions, which, when executed by a computer processor, are configured to perform the data processing method based on a hash algorithm as described in the first aspect.
[0015] As described above, this application provides a data processing method, apparatus, device, and storage medium based on a hash algorithm. During the hash operation, this application introduces a randomly generated message mask for each message block to ensure that the original data is hidden before the expansion operation. Simultaneously, the random mask is fully covered throughout the message expansion and compression iterations. This full coverage of the random mask decouples physical characteristics such as power consumption and electromagnetic properties from sensitive data, significantly increasing the difficulty for attackers to extract keys or intermediate states through side-channel attacks. Furthermore, the iterative binding of the initial digest value further enhances contextual randomness and resists replay attacks. This application can effectively resist side-channel attacks, reduce the risk of information leakage, improve information security, and solve the technical problem of poor data security in existing hash algorithms during operation. Attached Figure Description
[0016] Figure 1 A flowchart of a data processing method based on a hash algorithm provided in an embodiment of the present invention.
[0017] Figure 2 This is a schematic diagram illustrating the principle of performing hash operations on a target message block, as provided in an embodiment of the present invention.
[0018] Figure 3 This is a schematic diagram of a data processing device based on a hash algorithm provided in an embodiment of the present invention.
[0019] Figure 4 This is a schematic diagram of the framework of a data processing system based on a hash algorithm, provided for an embodiment of the present invention.
[0020] Figure 5 This is a schematic diagram of the framework of another data processing system based on a hash algorithm provided in an embodiment of the present invention.
[0021] Figure 6 This is a schematic diagram of the structure of a data processing device based on a hash algorithm, provided in an embodiment of the present invention. Detailed Implementation
[0022] The following description and accompanying drawings fully illustrate specific embodiments of this application to enable those skilled in the art to practice them. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. The scope of embodiments of this application includes the entire scope of the claims and all available equivalents of the claims. In this document, each embodiment may be referred to individually or collectively by the term "invention," which is merely for convenience and is not intended to automatically limit the scope of the application to any single invention or inventive concept if more than one invention is disclosed. Relational terms such as "first" and "second" are used herein only to distinguish one entity or operation from another, without requiring or implying any actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed. The various embodiments in this document are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the structures, products, etc., disclosed in the embodiments, since they correspond to the disclosed parts, the descriptions are relatively simple; relevant details can be found in the method section.
[0023] Hash algorithms, also known as hash algorithms, are primarily used in many security fields such as data digest calculation, digital signature verification, and message authentication. They are among the most widely used cryptographic algorithms in practice. Commonly used cryptographic algorithms both domestically and internationally include the SHA series (including SHA1-160, SHA2-224, SHA2-256, SHA2-384, SHA2-512, SHA2-512 / 224, and SHA2-512 / 256) and the SM3 algorithm.
[0024] However, hardware-implemented cryptographic chips can be compromised through side-channel attacks to obtain keys and critical information. A cryptographic side-channel attack refers to the collection and analysis of side-channel information (including power consumption, electromagnetic radiation, sound, and storage access characteristics) leaked from the hardware or embedded software computing platform during cryptographic computation to obtain keys and critical information. During hash algorithm computation, the calculation of the expansion and compression functions generates a large amount of side-channel information. Through side-channel attacks, the original message and intermediate variable values can be analyzed and deduced, leading to a risk of key information leakage during hash digest calculations. Furthermore, in identity authentication, the initial message can be tampered with and identity information forged through side-channel attacks and collision attacks.
[0025] Therefore, in order to solve the above-mentioned technical problems, embodiments of the present invention provide a data processing method based on a hash algorithm, such as... Figure 1 As shown, Figure 1 This is a flowchart illustrating a data processing method based on a hash algorithm, provided in an embodiment of the present invention. The data processing method based on a hash algorithm provided in this embodiment can be executed by a data processing device based on a hash algorithm (hereinafter referred to as the data processing device). This data processing device can be implemented through software and / or hardware, and can consist of two or more physical entities, or a single physical entity. The data processing method based on a hash algorithm provided in this embodiment is applicable to various hash algorithms, typically such as SHA1, SHA2, SHA384, SHA512, SM3, etc. The method includes the following steps: Step 101: Receive each message block in the message block set in sequence. The message block set includes multiple message blocks.
[0026] In this embodiment, each message block in the message block set needs to be received sequentially. The message block set includes multiple message blocks, which are obtained by an external device or external processor dividing the message to be hashed into multiple message blocks after data padding. The external device or external processor will then sequentially send each message block in the message block set to the data processing device for hash operation.
[0027] Step 102: After each message block is received, the target message block and the randomly generated message mask are masked to obtain a masked message. The masked message and the message mask are expanded synchronously and then spatially converted to obtain the message expansion value.
[0028] Each time a message block is received, the target message block needs to be masked (XORed) with the randomly generated message mask to obtain a masked message. For example, assuming message block Mt consists of 16 64-bit message words (t=0,1,2…,15), the target message block Mt is XORed with the message mask maskt, and the target message block is transferred into the logical space, resulting in the masked message Mt′= Mt ^ maskt. It should be noted that the message mask can be generated by a true random number generator or a pseudo-random number generator. The noise source of the random number generator can be a physical noise source or a pseudo-random sequence generated by a linear feedback shift register, depending on the actual needs. It is understood that the message mask will be different when processing different message blocks.
[0029] After obtaining the masked message, both the masked message and the message mask need to be expanded synchronously. This expansion operation uses an expansion function to extend the shorter input data into a longer dataset suitable for hash processing. The expansion function also increases the complexity and security of the hash calculation, minimizing the possibility of different inputs producing the same hash value, making it more difficult to reverse engineer or use a codebook attack. After the expansion operation, the expanded results of the masked message and the message mask need to be spatially transformed to obtain the expanded message value.
[0030] Based on the above embodiments, step 102 involves performing a spatial transformation on the masked message and the message mask synchronously after expansion operations to obtain the message expansion value, including: Step 1021: Perform expansion operations on the masked message and the message mask synchronously to obtain the masked expansion value and the message mask expansion value, respectively.
[0031] After performing simultaneous expansion operations on the masked message and the message mask, the masked expansion value and the message mask expansion value can be obtained respectively. For example, 80 expansion words are generated based on the masked message Mt′, resulting in the masked expansion value Wt′ (t=0~79). During the expansion operation on the masked message, the same rules are also used to simultaneously perform expansion operations on the message mask to obtain the message mask expansion value. Specifically, based on arithmetic and logical transformations, the masked message and the message mask are simultaneously subjected to a first preset number of rounds of direct assignment operations and a second preset number of rounds of recursive operations based on historical operation results, respectively obtaining the masked expansion value corresponding to the masked message and the message mask expansion value corresponding to the message mask. For example, this embodiment uses the SHA2-512 hash algorithm as an example for illustration. The first preset number of rounds is 16, and the second preset number of rounds is 64. That is, in the generated masked extended values Wt′ (t=0~79), the first 16 Wt′ are directly copied from Mt′ (i.e., W0′→W15′=M0′~M15′); the last 64 Wt′ (t=16~79) are generated recursively through a σ function and arithmetic transformations, where the σ function is a bitwise operation function specifically designed for message extension. In one embodiment, the process of performing extension operations on the masked message is as follows: Input: Mt' = Mt ^ maskt, t = 0, 1, 2, ..., 15; S1: for t=0 to 15
[0032] S2: for t=16 to 63
[0033] Where A2B is a logical transformation function and B2A is an arithmetic transformation function. / The bit rotation function W is defined for hash operations. express The extended word of the first i positions.
[0034] S3: for t=0 to 79
[0035] Output: , t=0,1,2…,79.
[0036] The transformation process of the arithmetic transformation function is as follows: Input: A, WMMt (the message mask extension value corresponding to the current iteration step t), C, M, N.
[0037] Where C = 0 or 0xFFFFFFFF, M is a random number, and N is a random number. A is a masked variable in the arithmetic space, such as the one mentioned above. W '、 , Intermediate results of extended functions, etc.
[0038] The conversion steps are as follows: T=C^WMMt T = T + M S1=A^C S1=S1+N S2 = S1 + T S2=S2-M S3 = S2 - C S3 = S3 - N Output = S3^T The logic conversion module conversion process is as follows: Input: X_m, WMMt (the message mask extension value corresponding to the current iteration step t), C, M, N.
[0039] Where X_m represents the result of a calculation from the arithmetic space, such as the one mentioned above. + B2A(W ')wait.
[0040] The conversion steps are as follows: T=C^WMMt T=T^M S1=T^X_m S1=S1^M S2=S1-T S2 = S2 + N S3 = S2 + C S3 = S3 - N Output = S3^C It should be noted that the C, M, and N used in the arithmetic and logical transformation functions can be generated using multiple random sources or a single random source, depending on the actual computation speed. By introducing random numbers C, M, and N, the computation path can be dynamically disrupted and intermediate value dependencies can be obfuscated, effectively blocking the data correlation of side-channel attacks and ensuring the security and randomness of the entire mask protection link.
[0041] During the expansion process, the message mask is expanded synchronously to obtain the expanded message mask value WMMt. An example expansion process is shown below:
[0042] Where WMMEXt is the message mask extension value for the current iteration step t, WMMt -i For intermediate calculation variables, the initial WMM 0~15 =mask0~mask015.
[0043] Step 1022: Convert the masked extended value and the message mask extended value to arithmetic space to obtain the message extended value.
[0044] After obtaining the mask extension value and the message extension value, it is necessary to further transform them into arithmetic space for use in the compression iteration process. Specifically, after performing an XOR operation on the mask extension value and the message extension value, the result of the XOR operation is transformed into arithmetic space based on arithmetic transformation to obtain the message extension value. The specific formula is as follows:
[0045] in For message extension values, ⊕ indicates bitwise XOR.
[0046] Step 103: Perform compression operation based on message extension value, initial digest value and randomly generated intermediate variable mask to obtain mask hash value and final mask. Generate hash value based on mask hash value and final mask for use in calculating hash value corresponding to the next message block. Initial digest value is generated based on hash value obtained after processing the previous message block. The first message block corresponds to the preset initial digest value.
[0047] After expanding the target message block, further compression is required. In hash algorithms, "compression computation" refers to the crucial step of processing input data (messages) of arbitrary length through a specific function and compressing it into a fixed-length output (digest). This process uses mathematical operations to reduce data size while ensuring the uniqueness, collision resistance, and irreversibility of the output. Essentially, it removes redundant information, reduces data dimensionality using hash mapping, and maintains a constant output length for easy storage and transmission. In this embodiment, a randomly generated intermediate variable mask is introduced during compression computation. This intermediate mask variable is used to mask the initial digest value during the compression computation. It should be noted that during the processing of the target message block, the initial digest value corresponding to the target message block is obtained based on the hash value generated after hashing the previous message block. The first message block corresponds to a preset initial digest value, which can be set by the user or generated by the data processing device according to preset rules. For example, the input message expansion value is first combined with the masked state variable and processed by a compression function (which typically includes non-linear operations and bit manipulations); then the masked state variable is obfuscated and diffused using an intermediate variable mask, and the masked state variable is updated; after multiple iterations, the final mask hash value and the final mask are output.
[0048] Based on the above embodiments, compression operations are performed using the message extension value, the initial digest value, and a randomly generated intermediate variable mask to obtain the mask hash value and the final mask, including: Step 1031: Perform an XOR operation between the initial value of the summary and the randomly generated intermediate variable mask to obtain the masked state variable.
[0049] In this embodiment, the initial value of the digest and the randomly generated intermediate variable mask first need to be masked, i.e., an XOR operation is performed to obtain the masked state variable, which is then transferred to the logic space. For example, the specific formula is as follows: a0 = H0^ r 0,a b0 = H1^r 0,b c0 = H2^r 0,c d0 = H3^ r 0,d e0 = H4^ r 0,e f0 = H5^ r 0,f g0 = H6^ r 0,g h0 = H7^ r 0,h Where H0~H7 are the initial values of the abstract, r 0,a ~ r 0,h a0 is an intermediate variable mask. ~h0 This is a masked state variable.
[0050] Step 1032: Perform compression iteration based on message extension value, intermediate variable mask, and masked state variable to obtain mask hash value and final mask.
[0051] After obtaining the masked state variables, compression iterations can be performed based on the message extension value, intermediate variable mask, and masked state variables. In each compression iteration, the message extension value, the current intermediate variable mask, and the masked state variables are input into the compression function (which typically includes nonlinear logic operations, shifting, and modulo addition operations), updating the masked state variables and intermediate variable masks. After multiple rounds of processing, the final output is the mask hash value and the final mask. In one embodiment, the specific process of compression iteration is as follows: Based on the message extension value and the masked state variable, a third preset number of compression iterations based on logical and arithmetic transformations are performed. During each compression iteration, the masked state variable and its corresponding intermediate variable mask are updated, and the masked state variable and its corresponding intermediate variable mask after the last compression iteration are used as the mask hash value and the final mask, respectively.
[0052] In one embodiment, during the compression iteration process, based on the message extension value and the current masked state variable, logical transformations (such as XOR, AND / OR) and arithmetic transformations are alternately performed in a third preset number of rounds (e.g., 64 rounds in SM3) to dynamically update the masked state variable. Simultaneously, a new intermediate variable mask is generated in each round to ensure that the state value is always protected by a random mask. Finally, the masked state variable output in the last round serves as the mask hash value, and the corresponding intermediate variable mask serves as the final mask, ensuring both the irreversibility of the hash result and defense against side-channel attacks through end-to-end masking.
[0053] Specifically, during each compression iteration, the masked state variables and their corresponding intermediate variable masks are updated, including: Step 10321: Based on the message extension value, round constant, and masked state variable of the current round, update the first intermediate variable and the second intermediate variable through logical transformation and arithmetic transformation.
[0054] In each compression iteration, the first and second intermediate variables need to be updated first and second based on the message extension value, round constant and current masked state variable through logical transformation (such as XOR, AND, OR) and arithmetic transformation. The first and second intermediate variables refer to the temporary values generated during the internal calculation of the compression function.
[0055] We begin the compression iteration, assuming the compression operation has t iterations. d , t d The range is 0 to 63.
[0056]
[0057] in, As the first intermediate variable, Let Ch() be the second intermediate variable, Ch() be the selection function, and Maj() be the majority function. For wheel constants, For the same global mask, ~ For the tth d The masked state variables corresponding to the wheel.
[0058] Step 10322: Based on the updated first intermediate variable and the updated second intermediate variable, update the masked state variable of the current round through arithmetic-Boolean field transformation, and at the same time update the mask of the intermediate variable of the current round through arithmetic transformation.
[0059] The first intermediate variable was updated in this round. and the updated second intermediate variable Then, it can be further based on the updated first intermediate variable. and the updated second intermediate variable Update the masked state variable for the current round. For example, the specific update process is as follows: h td+1 = g td ; g td+1 = f td '; f td+1 '= e td '; e td+1 = A2B(d td '+ T1'); d td+1 = c td '; c td+1 = b td '; b td+1 = a td '; a td+1 =A2B (T1'+ T2').
[0060] Among them, a td '~h td a is the masked state variable for the current round. td+1 '~h td+1 This is the updated masked state variable.
[0061] Simultaneously, the intermediate variable mask for the current round is updated synchronously through arithmetic transformation. The specific update process is as follows: r td+1,h = r td,g ; rtd+1,g = r td,f ; r td+1,f = r td,e ; r td+1,e = r td,d +mask T1 ; r td+1,d = r td,c ; r td+1,c = r td,b ; r td+1,b = r td,a ; r td+1,a =mask T1 +mask T2。
[0062] Where, r td,a ~ r td,h r is the intermediate variable mask for the current round. td+1,a ~ r td+1,h mask is the updated intermediate variable mask. T1 and mask T2 These correspond to the arithmetic perturbation values of T1' and T2', respectively.
[0063] Step 10323: Pass the updated masked state variables and the updated intermediate variable mask to the next round of compression iteration.
[0064] After compression iterations are performed in the above manner, the updated masked state variables and their corresponding intermediate variable masks can be passed to the next round of compression iterations until all rounds of iterations are completed. The masked state variables updated in the last round are then used as the mask hash value, and the corresponding intermediate variable masks are used as the final mask.
[0065] After obtaining the mask hash value and the final mask, a demasking operation can be performed on the mask hash value based on the final mask to obtain the hash value corresponding to the target message of this iteration. This hash value then needs to be used in the hash calculation process of the next message block, so that an initial digest value can be generated based on the hash value obtained in this iteration when processing the next message block. The iteration can stop after generating the hash value corresponding to the last message block.
[0066] For example, such as Figure 2 As shown, Figure 2 This is a schematic diagram illustrating the principle of performing hash operations on a target message block according to an embodiment of the present invention. Figure 2In the process, after the target message block Mt is XORed with the message mask maskt to obtain the masked message Mt′, Write APB writes the masked message Mt′ into a register. Then, the masked message Mt′ is input into the expansion function Msgexpansion for expansion operations to calculate the masked expansion value Wt′, and the message mask expansion value is calculated simultaneously. Next, the mask extension value Wt′ and the message mask extension value WMMt are converted to arithmetic space to obtain the message extension value. Expand the message value , masked state variable a0 ~h0 and the intermediate variable mask r 0,a ~ r 0,h The input is fed into the compression function F Function for multiple rounds of compression iterations (not shown in the figure), and the final mask hash value a is output. ~h and the final mask r a ~ r h Finally, the mask hash value a ~h and the final mask r a ~ r h After performing the XOR operation, the hash value is obtained. The specific process can be found in the description of the above embodiments, and will not be repeated here.
[0067] It should also be noted that different masking methods need to be selected depending on the algorithm being implemented. The selection is based on the computational methods involved in the expansion process. If only logical operations are involved, masking can be performed in the arithmetic space, and the logical operations are first performed in the logical space, and then the masked message is expanded before being converted back to the arithmetic space. Alternatively, masking can be performed in the logical space and logical operations can be performed directly, and the logical mask can be maintained after the masked message is expanded.
[0068] If the message contains both logical and arithmetic operations, it can be masked in the arithmetic space and calculated directly during arithmetic masking. However, logical operations require conversion to the logical space for calculation, and the message is then converted back to the arithmetic space after masked message expansion. Alternatively, masking can be performed in the logical space, with logical operations conducted directly. However, arithmetic operations require conversion to the arithmetic space for calculation, and the message is then converted back to the logical space after masked message expansion. In other words, the masking method chosen for the masked message before expansion determines the conversion to the corresponding masking space after expansion.
[0069] As described above, this invention provides a data processing method based on a hash algorithm. During the hash operation, a randomly generated message mask is introduced for each message block to ensure that the original data is hidden before the expansion operation. Furthermore, in the compression iteration, by introducing an intermediate variable mask and dynamically updating it, information leakage caused by a fixed mask can be avoided, enhancing resistance to differential power analysis (DPA). This invention fully covers the random mask throughout the message expansion and compression iterations. This full coverage of the random mask decouples power consumption, electromagnetic properties, and other physical characteristics from sensitive data, significantly increasing the difficulty for attackers to extract keys or intermediate states through side-channel attacks. Additionally, the iterative binding of the initial digest value further strengthens contextual randomness and resists replay attacks. This invention effectively resists side-channel attacks, reduces the risk of information leakage, improves information security, and solves the technical problem of poor data security in existing hash algorithms during operation.
[0070] This invention also provides a data processing device based on a hash algorithm, such as... Figure 3 As shown, Figure 3 This is a schematic diagram of the structure of a data processing device based on a hash algorithm provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the data processing device based on the hash algorithm includes: The message block receiving module 201 is configured to receive each message block in the message block set in sequence, and the message block set includes multiple message blocks. The message extension module 202 is configured to perform masking processing on the target message block received this time and the randomly generated message mask after each message block is received to obtain a masked message. After performing extension operations on the masked message and the message mask synchronously, a space conversion is performed to obtain the message extension value. The message compression module 203 is configured to perform compression operations based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain the mask hash value and the final mask. It generates a hash value based on the mask hash value and the final mask, which is used to calculate the hash value corresponding to the next message block. The initial digest value is generated based on the hash value obtained after processing the previous message block. The first message block corresponds to the preset initial digest value.
[0071] The message extension module 202 includes: The synchronous extension submodule is configured to perform extension operations on masked messages and message mask synchronization to obtain masked extension values and message mask extension values, respectively. The space transformation submodule is configured to transform the masked extended value and the message masked extended value to the arithmetic space to obtain the message extended value.
[0072] Specifically, the synchronous extension submodule is configured to perform a first preset number of direct assignment operations and a second preset number of recursive operations based on historical operation results on the masked message and the message mask, based on arithmetic and logical transformations, respectively, to obtain the masked extension value corresponding to the masked message and the message mask extension value corresponding to the message mask.
[0073] Specifically, the space conversion submodule is configured to perform an XOR operation on the masked extended value and the message masked extended value, and then convert the XOR operation result to the arithmetic space based on arithmetic conversion to obtain the message extended value.
[0074] The message compression module 203 includes: The state variable generation submodule is configured to perform an XOR operation between the initial value of the digest and the mask of a randomly generated intermediate variable to obtain a masked state variable. The output submodule is configured to perform compression iteration based on message extension value, intermediate variable mask, and masked state variable to obtain mask hash value and final mask.
[0075] Specifically, the result output submodule is configured to perform a third preset number of compression iterations based on logical and arithmetic transformations, based on the message extension value and the masked state variable. In each compression iteration, the masked state variable and its corresponding intermediate variable mask are updated, and the masked state variable and its corresponding intermediate variable mask after the last compression iteration are used as the mask hash value and the final mask, respectively.
[0076] The result output submodule includes: The variable update unit is configured to update the first and second intermediate variables based on the message extension value, round constant and the masked state variable of the current round through logical transformation and arithmetic transformation; The intermediate variable update unit is configured to update the masked state variable of the current round through arithmetic-Boolean field transformation based on the updated first intermediate variable and the updated second intermediate variable, and simultaneously update the mask of the intermediate variable of the current round through arithmetic transformation. The result passing unit is configured to pass the updated masked state variables and the updated intermediate variable masks to the next round of compression iteration.
[0077] The data processing apparatus based on the hash algorithm provided in this embodiment of the invention is included in the data processing device based on the hash algorithm and can be used to execute the data processing method based on the hash algorithm provided in the above embodiment, and has corresponding functions and beneficial effects.
[0078] It is worth noting that in the above embodiments of the data processing device based on the hash algorithm, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy distinction between each other and are not used to limit the scope of protection of the present invention.
[0079] This invention also provides a data processing system based on a hash algorithm, such as... Figure 4 As shown, Figure 4 This is a schematic diagram of the framework of a data processing system based on a hash algorithm provided in an embodiment of the present invention. The data processing system 30 based on a hash algorithm provided in this embodiment includes a general interface module 301, a logic control module 302, a hash operation module 303, a general data storage module 304, and an operation conversion module 305. The general interface module 301 is connected to the logic control module 302 and the general data storage module 304. The logic control module 302 is connected to the hash operation module 303. The hash operation module 303 is connected to the operation conversion module 305 and the general data storage module 304. The operation conversion module 305 is connected to the general data storage module 304.
[0080] The general interface module 301 is configured to connect to an external processor, receive multiple message blocks sent by the external processor in sequence, and transmit the message blocks to the general data storage module 304; and receive control signals sent by the external processor and transmit the control signals to the logic control module 302.
[0081] Specifically, in this embodiment, the general interface module 301 is a module for communication between the hash algorithm-based data processing system 30 and an external processor. It communicates with the external processor via various bus interfaces such as AXI, AHB, and APB. Its main function is to receive message blocks sent by the external processor and transmit them to the general data storage module 304. It can be understood that the general interface module 301 can also read data from the general data storage module 304. In addition, the general interface module 301 is also used to receive control signals sent by the external processor. In this embodiment, the external processor can use control signals to start operations, pause operations, poll the end status of operations, or select algorithm types. After receiving the control signal, the general interface module 301 further transmits the control signal to the logic control module 302.
[0082] The general-purpose data storage module 304 is configured to store message blocks and intermediate values generated during hash operations, including masked messages Mt′, message masks mask0~mask15, masked state variables, and intermediate variable masks. In one embodiment, to accelerate data read / write and access speeds, the general-purpose data storage module 304 can be implemented using registers. However, the general-purpose data storage module 304 is not limited to registers; it can also be an NVM-type non-volatile memory such as FLASH, SRAM, or ROM. This embodiment does not impose specific limitations.
[0083] The logic control module 302 is configured to receive control signals, convert the control signals into control commands, and send them to the hash operation module 303.
[0084] The logic control module 302 is used to receive control signals and convert them into control instructions to control the hash operation module 303. The logic control module 302 can be implemented by a hardware circuit state machine or by using a general microcode instruction set. No specific limitation is made in this embodiment.
[0085] The hash operation module 303 is configured to read and write data in the general data storage module 304, and to execute or pause the above-mentioned data processing method based on the hash algorithm based on the control instructions sent by the logic control module 302.
[0086] The hash operation module 303 is used to read and write data from the general data storage module 304, such as reading the target message block and message masks mask0~mask15, and writing intermediate values generated during the operation into the general data storage module 304 for storage. The hash operation module 303 is also used to execute or pause the hash algorithm according to the control instructions sent by the logic control module 302.
[0087] The operation conversion module 305 is configured to convert data between the arithmetic space and the logical space during the execution of the hash algorithm, so as to adapt to different calculation methods in the process of extended operation or compression iteration.
[0088] In one embodiment, such as Figure 5 As shown, Figure 5 This is a schematic diagram of the framework of another data processing system based on a hash algorithm provided in an embodiment of the present invention. Figure 5 In the general data storage module 304, there are message block storage areas and IV (initial digest) variable storage areas. The message block storage area is used to store message blocks, while the IV variable storage area is used to store the initial digest values during the iteration process. Additionally... Figure 5The intermediate logic control module 302 is also connected to the general-purpose data storage module 304, and is used to drive the general-purpose data storage module 304 to perform data reading and writing according to the control signals of the external processor. The hash operation module 303 includes an extended calculation unit and a compression calculation unit, which are used to perform extended calculation and compression calculation, respectively. The operation conversion module 305 includes a logic conversion unit and an arithmetic conversion unit, which are used to perform logic conversion and arithmetic conversion, respectively. It is understood that the specific process of each module can be referred to the process of the data processing method based on the hash algorithm provided in the above embodiments, and will not be repeated here.
[0089] As described above, in the hash operation process, this embodiment of the invention introduces a randomly generated message mask for each message block to ensure that the original data is hidden before the expansion operation. Simultaneously, the random mask is fully covered throughout the message expansion and compression iterations. This full coverage of the random mask decouples physical characteristics such as power consumption and electromagnetic properties from sensitive data, significantly increasing the difficulty for attackers to extract keys or intermediate states via side channels. Furthermore, the iterative binding of the initial digest value further enhances contextual randomness and resists replay attacks. This embodiment of the invention effectively resists side-channel attacks, reduces the risk of information leakage, improves information security, and solves the technical problem of poor data security in existing hash algorithms during operation.
[0090] This invention also provides a data processing device based on a hash algorithm, such as... Figure 6 As shown, Figure 6 This is a schematic diagram of the structure of a data processing device based on a hash algorithm provided in an embodiment of the present invention. The data processing device 40 based on the hash algorithm includes a processor 400 and a memory 401. Memory 401 is used to store computer program 402 and transfer computer program 402 to processor 400; The processor 400 is used to execute the steps in the above-described embodiment of a data processing method based on a hash algorithm, according to the instructions in the computer program 402.
[0091] For example, computer program 402 may be divided into one or more modules / units, one or more of which are stored in memory 401 and executed by processor 400 to complete this application. One or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 402 in hash-based data processing device 40.
[0092] The data processing device 40 based on the hash algorithm can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. The data processing device 40 based on the hash algorithm may include, but is not limited to, a processor 400 and a memory 401. Those skilled in the art will understand that... Figure 6 This is merely an example of a hash-based data processing device 40 and does not constitute a limitation on the hash-based data processing device 40. It may include more or fewer components than shown, or combine certain components, or different components. For example, the hash-based data processing device 40 may also include input / output devices, network access devices, buses, etc.
[0093] The processor 400 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0094] The memory 401 can be an internal storage unit of the hash-based data processing device 40, such as a hard disk or RAM of the hash-based data processing device 40. The memory 401 can also be an external storage device of the hash-based data processing device 40, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the hash-based data processing device 40. Furthermore, the memory 401 can include both internal storage units and external storage devices of the hash-based data processing device 40. The memory 401 is used to store computer programs and other programs and data required by the hash-based data processing device 40. The memory 401 can also be used to temporarily store data that has been output or will be output.
[0095] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0096] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0097] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0098] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0099] If the integrated unit is implemented as 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, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing computer programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0100] This invention also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a data processing method based on a hash algorithm. The data processing method based on the hash algorithm includes the following steps: Each message block in the message block set is received sequentially; the message block set includes multiple message blocks. Each time a message block is received, the target message block and the randomly generated message mask are masked to obtain a masked message. The masked message and the message mask are expanded synchronously and then spatially converted to obtain the message expansion value. Compression is performed based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain the mask hash value and the final mask. A hash value is generated based on the mask hash value and the final mask, which is used to calculate the hash value corresponding to the next message block. The initial digest value is generated based on the hash value obtained after processing the previous message block. The first message block corresponds to the preset initial digest value.
[0101] Note that the above are merely preferred embodiments and the technical principles applied in this invention. Those skilled in the art will understand that the embodiments of this invention are not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the protection scope of this invention. Therefore, although the embodiments of this invention have been described in detail above, the embodiments of this invention are not limited to the above embodiments. More other equivalent embodiments may be included without departing from the concept of the embodiments of this invention, and the scope of the embodiments of this invention is determined by the scope of the appended claims.
Claims
1. A data processing method based on a hash algorithm, characterized in that, The method includes: Each message block in the message block set is received sequentially, the message block set including multiple message blocks; Each time the message block is received, the target message block received this time and the randomly generated message mask are masked to obtain a masked message. The masked message and the message mask are simultaneously expanded and then spatially converted to obtain the message expansion value. Compression is performed based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain the mask hash value and the final mask. A hash value is generated based on the mask hash value and the final mask for calculating the hash value corresponding to the next message block. The initial digest value is generated based on the hash value obtained after processing the previous message block. The first message block corresponds to a preset initial digest value. The step of performing a spatial transformation on the masked message and the message mask simultaneously after expansion operations to obtain the message expansion value includes: The masked message and the message mask are simultaneously expanded to obtain the masked expanded value and the message mask expanded value, respectively. The masked extended value and the message mask extended value are converted to arithmetic space to obtain the message extended value; The step of performing compression operations based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain the mask hash value and the final mask includes: The initial value of the summary is XORed with the mask of the randomly generated intermediate variable to obtain the masked state variable. Based on the message extension value, the intermediate variable mask, and the masked state variable, a compression iteration is performed, and the masked state variable after the last round of compression iteration and its corresponding intermediate variable mask are used as the mask hash value and the final mask, respectively.
2. The data processing method based on hash algorithm according to claim 1, characterized in that, The step of performing synchronous expansion operations on the masked message and the message mask to obtain the masked expansion value and the message mask expansion value respectively includes: Based on arithmetic and logical transformations, the masked message and the message mask are simultaneously subjected to a first preset number of rounds of direct assignment operations and a second preset number of rounds of recursive operations based on historical operation results, respectively obtaining the masked extended value corresponding to the masked message and the message mask extended value corresponding to the message mask.
3. The data processing method based on a hash algorithm according to claim 1, characterized in that, The step of converting the masked extended value and the message masked extended value to arithmetic space to obtain the message extended value includes: After performing an XOR operation on the masked extended value and the message masked extended value, the result of the XOR operation is converted to the arithmetic space based on arithmetic transformation to obtain the message extended value.
4. The data processing method based on hash algorithm according to claim 1, characterized in that, The compression iteration based on the message extension value, the intermediate variable mask, and the masked state variable, using the masked state variable and its corresponding intermediate variable mask after the last compression iteration as the mask hash value and the final mask, respectively, includes: Based on the message extension value and the masked state variable, a third preset number of compression iterations based on logical and arithmetic transformations are performed. In each compression iteration, the masked state variable and its corresponding intermediate variable mask are updated, and the masked state variable and its corresponding intermediate variable mask after the last compression iteration are used as the mask hash value and the final mask, respectively.
5. The data processing method based on a hash algorithm according to claim 4, characterized in that, The step of updating the masked state variable and its corresponding intermediate variable mask during each round of compression iteration includes: Based on the message extension value, round constant, and masked state variable of the current round, the first intermediate variable and the second intermediate variable are updated through logical transformation and arithmetic transformation; Based on the updated first intermediate variable and the updated second intermediate variable, the masked state variable of the current round is updated through arithmetic-Boolean field transformation, and the intermediate variable mask of the current round is updated synchronously through arithmetic transformation. The updated masked state variables and the updated intermediate variable masks are passed to the next round of compression iterations.
6. A data processing device based on a hash algorithm, characterized in that, The device includes: A message block receiving module is configured to sequentially receive each message block in a message block set, wherein the message block set includes multiple message blocks. The message extension module is configured to perform masking processing on the target message block and the randomly generated message mask after each message block is received to obtain a masked message, and then perform space transformation on the masked message and the message mask simultaneously to obtain the message extension value. The message compression module is configured to perform compression operations based on the message extension value, the initial digest value, and the randomly generated intermediate variable mask to obtain a mask hash value and a final mask. A hash value is generated based on the mask hash value and the final mask for calculating the hash value corresponding to the next message block. The initial digest value is generated based on the hash value obtained after processing the previous message block. The first message block corresponds to a preset initial digest value. The message extension module includes: The synchronous extension submodule is configured to perform synchronous extension operations on the masked message and the message mask to obtain the masked extension value and the message mask extension value, respectively. The space conversion submodule is configured to convert the masked extended value and the message masked extended value to the arithmetic space to obtain the message extended value; The message compression module includes: The state variable generation submodule is configured to perform an XOR operation between the initial value of the digest and the mask of the randomly generated intermediate variable to obtain the masked state variable. The result output submodule is configured to perform compression iteration based on the message extension value, the intermediate variable mask, and the masked state variable, and use the masked state variable and its corresponding intermediate variable mask after the last round of compression iteration as the mask hash value and the final mask, respectively.
7. A data processing device based on a hash algorithm, characterized in that, The data processing device based on the hash algorithm includes a processor and a memory; The memory is configured to store computer programs and transfer the computer programs to the processor; The processor is configured to execute the data processing method based on the hash algorithm as described in any one of the claims 1-5 according to the instructions in the computer program.
8. A storage medium for storing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are configured to perform the data processing method based on a hash algorithm as described in any one of claims 1-5.
Citation Information
Patent Citations
Anti-bypass attack method based on SM3 password hash algorithm
CN115883064A
Operation method, operation device and security chip in hash function
CN117278191A