A reconfigurable S-box replacement circuit for AES&SM4 against zero-value attacks
By designing a masked anti-zero-value power consumption attack inversion circuit and an improved zero-value detection circuit in the AES and SM4 encryption modules, the security vulnerabilities of AES and SM4 in the zero-value power consumption attack in the existing technology are solved. It improves the security and simplifies the circuit of S box replacement, and enhances the ability to resist side channel attacks.
Patent Information
- Application Number
- CN202210048832.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-01-17
AI Technical Summary
Existing AES and SM4 encryption modules have security vulnerabilities in the face of zero-value power attacks. In particular, the S-box replacement operation has insufficient performance in resisting side-channel attacks, making the keys easy to crack, and the existing protection methods are complicated or There is a security vulnerability.
An AES&SM4 reconfigurable S-box replacement circuit that is resistant to zero-value attacks is designed. It uses a masked anti-zero-value power attack inversion circuit and an improved zero-value detection circuit. Through pre-affine, inversion, and post-imitation Radiation operation and mask correction ensure that the input value is not zero, reducing the difference in power consumption, thereby improving attack resistance.
Effectively prevents zero-value power attacks and differential power attacks, improves the overall security of AES and SM4, simplifies circuit implementation, does not require additional random numbers, reduces circuit area, and enhances resistance to AES and SM4. Channel attack capability.
Smart Images

Figure CN114614971B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security, and in particular to an AES&SM4 reconfigurable S-box replacement circuit resistant to zero-value attacks. Background Art
[0002] With the introduction of side channel attacks, encryption algorithms that are absolutely secure at the mathematical theory level have become very vulnerable to physical attacks. Physical attacks collect information leaked when the encryption chip is working normally, such as power consumption, electromagnetic leakage, sound, temperature, etc. The leaked information has a certain linear relationship with the encrypted intermediate value, so side channel attacks become possible. For example, AES can be easily cracked to obtain the key through means such as correlation energy analysis, differential energy analysis, and zero-value power consumption analysis, which poses a serious threat to password security.
[0003] There are currently few protection measures against zero-value power consumption attacks. For example, the method proposed in the patent "A masked AES encryption method resistant to high-order power consumption analysis" requires the use of random numbers and is complex to implement; the patent "A mask method and mask circuit for resisting energy analysis attacks" only protects when the mask is 0, but usually the mask is not 0, and it does not protect the inverse value, so there are still security vulnerabilities; the method proposed in the patent "A method for defending against zero-value power consumption attacks on cryptographic devices" can effectively resist zero-value power consumption attacks, but the circuit implementation is complex; therefore, the S-box design that resists zero-value power consumption attacks still needs to be optimized and improved.
[0004] In the side channel attack of AES&SM4, the nonlinear S-box replacement operation becomes the target of attack. Therefore, its implementation method determines the performance of AES and SM4 encryption modules in terms of area, speed, power consumption, and resistance to side channel attacks. It is also the main target of differential power consumption attacks and zero-value power consumption attacks. Improving the ability of S-box replacement to protect against side channel attacks is of great significance to the security of AES and SM4. Summary of the invention
[0005] The purpose of the present invention is to provide an AES&SM4 reconfigurable S-box replacement circuit resistant to zero-value attacks, which is used to design the AES&SM4 S-box to resist zero-value power consumption attacks, so as to improve the overall security of AES and SM4.
[0006] In order to achieve the above tasks, the present invention adopts the following technical solutions:
[0007] An AES&SM4 reconfigurable S-box circuit resistant to zero-value attacks comprises a front affine unit, a first selector, a masked zero-value power consumption attack resistant inversion circuit, a first mask correction unit, a rear affine unit, an affine unit, a second mask correction unit, and a second selector, wherein:
[0008] The front affine unit is used to perform the front affine operation of SM4 on the masked input value x+m and the mask m to obtain the result after the affine operation and the masks x1+m1 and m1;
[0009] The first selector is used to determine the inverted input x2+m2 and the mask m2 according to the aes_sm4 selection signal; if aes_sm4 is 1, indicating that the AES operation is performed, then x2+m2=x+m, m2=m; if aes_sm4 is 0, indicating that the SM4 operation is performed, then x2+m2=x1+m1, m2=m1;
[0010] The masked anti-zero power consumption attack inversion circuit is used to invert x2+m2 and m2, and combine the correction value to obtain the inverted result x2 -1 +m2;
[0011] The first mask correction unit is used to correct the inverse result x2 -1 +m2 performs mask correction operation, corrects the mask from m2 to m, and obtains x2 -1 +m;
[0012] The post-affine unit is used to transform x2 -1 +m, mask m, and perform SM4 post-affine operation to obtain L(x -1 )+m3;
[0013] Affine unit, used to transform x2 -1 +m, mask m, and perform AES affine operation to obtain L(x -1 )+m4;
[0014] The second selector is used to determine the mask output L(x) according to the aes_sm4 selection signal -1 )+m5 and mask m5; if aes_sm4 is 1, then m5=m4; if aes_sm4 is 0, then m5=m3;
[0015] The second mask correction unit is used to modify L(x -1 )+m5 performs mask correction operation, correcting the mask from m5 to m. The corrected value is the masked S-box replacement output value L(x -1 )+m.
[0016] Furthermore, the inversion processing process of the masked zero-power consumption attack resistant inversion circuit is as follows:
[0017] Perform zero-value detection on the masked input value x+m and the mask m through a zero-value detection circuit to obtain δ(x);
[0018] Add the obtained δ(x) to x+m, and map x to a non-zero value x+m+δ(x);
[0019] Multiply the non-zero value x+m+δ(x) by the mask value m to obtain [x+δ(x)+m]m;
[0020] Pass m through the squarer to get m2, and add it to [x+δ(x)+m]m to get [x+δ(x)]m;
[0021] Directly invert [x+δ(x)]m to obtain [x+δ(x)] -1 m -1 ;
[0022] for [x+δ(x)] -1 m -1 Add 1, and we get [x+δ(x)] -1 m -1 +1;
[0023] [x+δ(x)] -1 m -1 +1 multiplied by m, we get [x+δ(x)] -1 +m;
[0024] Add the correction value n to get x -1 +m; where the correction value n = [x + δ(x)] -1 +x -1 .
[0025] Furthermore, the zero value detection circuit is used to detect whether x+m is equal to m, thereby determining whether x is 0; if the input x+m is equal to m, then the output δ(x)=1, otherwise it is 0.
[0026] Furthermore, the zero value detection circuit includes 8 2-input XOR gates, 7 2-input OR gates, including 4 first OR gates, 2 second OR gates, and 1 third OR gate; wherein:
[0027] The 8 2-input XOR gates are divided into four pairs. The inputs of each pair are the bits corresponding to x+m and m respectively. The output of each pair is used as the input of a first OR gate. The outputs of every two first OR gates are used as the input of a second OR gate, and the outputs of the two second OR gates are used as the input of a third OR gate. The output of the third OR gate is the zero-value detection result δ(x).
[0028] Furthermore, if and only if x=0, a correction value needs to be added, and the correction value is the finite field inversion (1) -1 =0x01.
[0029] Furthermore, the first mask correction unit is configured to -1 +m2, and then the mask is modified from m2 to m. The second mask modification unit is configured by adding m+m2 to L(x -1)+m5, then m5+m is added to perform mask correction operation, and the mask is corrected from m5 to m.
[0030] Compared with the prior art, the present invention has the following technical features:
[0031] 1. For the S-box structure that is resistant to differential power consumption attacks, whose input is masked, an improved masked inversion circuit structure that is resistant to zero-value power consumption attacks and an improved zero-value detection circuit are proposed; when the input is masked, the non-zero value inversion can still be converted into a non-zero value inversion, effectively preventing the obvious power consumption difference caused by the zero value inversion, thereby improving the attack resistance and security of the entire chip.
[0032] 2. The present invention applies an improved masked inversion circuit structure that is resistant to zero-value power consumption attacks and an improved zero-value detection circuit to the S-box replacement of AES&SM4. In order to reduce the area, a reconfigurable AES&SM4 S-box replacement circuit structure that is resistant to zero-value power consumption attacks is proposed, which can ensure that AES&SM4 will not have zero values. While resisting differential power consumption attacks, it can also resist zero-value power consumption attacks. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 Replace the flow chart for AES&SM4 composite domain S-box;
[0034] Figure 2 The finite field multiplication mask inversion algorithm proposed by Akkar;
[0035] Figure 3 It is an improved masked circuit structure for resisting zero-value power consumption attack;
[0036] Figure 4 It is a zero value detection circuit;
[0037] Figure 5 The circuit structure of S-box replacement for reconfigurable AES&SM4 is resistant to zero-power attack.
[0038] Figure 6 A reconfigurable AES&SM4 composite domain inversion circuit structure. DETAILED DESCRIPTION
[0039] S-box replacement is byte replacement, and its circuit implementation structure is as follows: Figure 1 As shown in the figure, this figure only shows the principle implementation method of resisting zero-value power consumption attack, and does not show the calculation details and other formulas. Figure 1It can be seen that the AES S-box replacement includes finite field inversion and affine operations, among which finite field inversion can be further mapped to the composite field, and then split into isomorphic mapping, composite field inversion, and inverse isomorphic mapping; SM4 S-box replacement includes pre-affine, finite field inversion, and post-affine operations, among which finite field inversion can be further mapped to the composite field, similar to AES. Finite field inversion is the main source of power consumption for S-box replacement operations. If the inversion value is 0, it has a significant difference from the power consumption generated by non-zero value inversion, which is also the focus of zero-value power consumption attacks. Because the input of the first round of AES S-box replacement is By enumerating all possible plaintext values plaintext, when the plaintext value is equal to the key value key, that is, x=0, the power consumption generated will be significantly different, so the key value can be determined.
[0040] Referring to the accompanying drawings, the design process of an AES&SM4 reconfigurable S-box resistant to zero-value attacks of the present invention includes:
[0041] 1. Masked anti-zero power consumption attack inversion circuit
[0042] In order to resist differential power consumption attacks, the encrypted input value x is often protected by adding a mask m, that is, x+m; however, due to the inverse operation (·) -1 Nonlinearity, (x+m) -1 ≠x -1 +m -1 , which is not conducive to mask correction after inversion. -1 =x -1 m -1 Therefore, Akkar used the multiplication mask technique to improve the inversion algorithm on the finite field, and Trichina simplified the design, such as Figure 2 As shown in the figure. The multiplication masking module proposed by Akkar and Trichina is multiplication masking in the inverse operation, which has obvious loopholes. A byte of all zeros is still all zeros after multiplication masking. In terms of power consumption, the power consumption generated by the operation of the all-zero byte through the multiplication masking module is significantly different from the power consumption generated by other non-zero bytes through the multiplication masking module, which gives attackers an opportunity to take advantage of. Therefore, it is necessary to re-improve the design to realize the anti-zero value power consumption attack design of the intermediate value x+m after mask protection, so as to improve the overall security of AES and SM4.
[0043] Depend on Figure 2It can be seen that the input x+m is an additive mask. Before inversion, it will be converted into a multiplication mask x·m. After inversion, it can be found that the multiplication mask has obvious security vulnerabilities. If x=0, then x·m=0 will result. As in the previous analysis, the power consumption generated by the inversion operation of x·m=0 will be significantly different from the power consumption generated by the inversion operation of x·m≠0; therefore, it is very important to design the anti-zero value attack for the inversion with mask. The improved circuit structure of the anti-zero value power consumption attack is as follows: Figure 5 As shown, the zero value detection circuit is as follows Figure 4 shown.
[0044] The function of the zero value detection circuit is to detect whether x+m is equal to m, so as to determine whether x is 0. Its circuit implementation only requires 8 2-input XOR gates and 7 2-input OR gates (4 first OR gates, 2 second OR gates, and 1 third OR gate), as shown in Figure 4 As shown, a-1 to a-8 are 8 bits of the x+m byte, b-1 to b-8 are 8 bits of the m byte, if the input x+m is equal to m, then the output δ(x) = 1, otherwise it is 0;
[0045] The eight 2-input XOR gates of the zero value detection circuit are divided into four pairs. The inputs of each pair are the bits corresponding to the x+m bytes and the m bytes respectively. The output of each pair serves as the input of a first OR gate; the outputs of every two first OR gates serve as the input of a second OR gate, and the outputs of the two second OR gates serve as the input of a third OR gate. The output of the third OR gate is the zero value detection result δ(x).
[0046] See also Figure 5 The steps of inversion processing of the masked zero-power consumption attack-resistant inversion circuit provided by the present invention are as follows:
[0047] 1.1 The masked input value x+m and the mask m are subjected to zero value detection by a zero value detection circuit to obtain δ(x).
[0048] 1.2 Add the obtained δ(x) to x+m (XOR operation) to map x to a non-zero value x+m+δ(x).
[0049] 1.3 Multiply the non-zero value x+m+δ(x) by the mask value m to obtain [x+δ(x)+m]m.
[0050] 1.4m is obtained by the squarer to obtain m2, and is added (XOR operation) to the result of step 1.3, and finally [x+δ(x)]m is obtained; the role of steps 1.3 and 1.4 is to convert the addition mask into a multiplication mask.
[0051] 1.5 Directly invert [x+δ(x)]m to obtain [x+δ(x)] -1 m-1 ; The above steps have ensured that x+δ(x) is a non-zero value.
[0052] 1.6 Add 1 to the result of step 1.5 to get [x+δ(x)] -1 m -1 +1; its purpose is to prevent the subsequent step of demasking from exposing intermediate values.
[0053] 1.7 Multiply the result of 1.6 by m to get [x+δ(x)] -1 +m; This step converts the multiplication mask into an addition mask.
[0054] 1.8 Add the correction value n and get x -1 +m; The purpose of this step is to ensure the correctness of the output. Among them, the correction value n = [x + δ (x)] -1 +x -1 , when x=0,δ(x)=1,x -1 = 0, [x + δ (x)] -1 =0x3E, so we can know that n=0x01, and the correction value needs to be added if and only if x=0.
[0055] 2. AES&SM4 reconfigurable S-box against zero-value attacks
[0056] So far, an improved masked inversion circuit that is resistant to zero-value power consumption attacks is first designed. On this basis, the improved masked inversion circuit that is resistant to zero-value power consumption attacks is applied to the S-box replacement of AES and SM4. In order to reduce the area, a reconfigurable AES&SM4 S-box replacement design that is resistant to zero-value power consumption and differential power consumption attacks is proposed. Its overall structure is as follows: Figure 5 As shown; the reconfiguration in this scheme is mainly reflected in the reconstruction of the finite field inversion, which is Figure 1 It can be seen that the inversion of a finite field can be mapped to the inversion of a composite field. The composite field inversion of AES and SM4 is the same, so they can share the same composite field inversion; however, the isomorphism mapping and inverse isomorphism mapping of AES and SM4 are different, so they need to be calculated separately and selected by the selector. The reconstructible inversion circuit structure is as follows: Figure 6 Therefore, Figure 5 When the reconfigurable S-box shown in the figure is replaced, it is necessary to replace the (·) in the anti-zero power consumption attack inversion module -1 Replace with Figure 6 From Figure 6 It can be seen that the reconfigurable circuit only uses an improved masked composite domain inversion circuit that is resistant to zero-value power consumption attacks.
[0057] The AES&SM4 reconfigurable S-box resistant to zero-value attacks includes a front affine unit, a first selector, a second selector, a masked zero-value power consumption attack inversion circuit, a first mask correction unit, a second mask correction unit, a rear affine unit, and an affine unit; it includes 4 inputs, namely, mask m, masked input value x+m, AES or SM4 selection signal aes_sm4, and correction value input; one output: the masked S-box replaces the output sbox(x)+m. The processing process of the overall structure is as follows:
[0058] 2.1 The masked input value x+m and mask m are subjected to the front affine operation of SM4 through the front affine unit, and the results are x1+m1 and m1. This step is a linear operation.
[0059] 2.2 Select the signal through aes_sm4, and use the first selector to determine the inverse input x2+m2 and mask m2; if aes_sm4 is 1, indicating that an AES operation is performed, then x2+m2=x+m, m2=m; if aes_sm4 is 0, indicating that an SM4 operation is performed, then x2+m2=x1+m1, m2=m1.
[0060] 2.3 Use the masked anti-zero power consumption attack inversion circuit designed above to invert x2+m2 and m2. In addition, the correction value needs to be input. After inversion, the result x2 is obtained. -1 +m2; Through calculation, it can be known that the correction value of AES and SM4 when the S box is replaced is the finite field inversion (1) -1 =0x01.
[0061] 2.4 After the inversion, a mask correction operation is required. The first mask correction unit is used to correct the inverse of x2. -1 +m2, add (m+m2), modify the mask from m2 to m, and get x2 -1 +m.
[0062] 2.5 The masked value x2 -1 +m and mask m are respectively subjected to the post-affine operation of SM4 by the post-affine unit to obtain L(x -1 )+m3, and perform AES affine operation through the affine unit to obtain L(x -1 )+m4; All operations in this step are linear operations. -1 )+m3 where L(·) represents the post-affine operation of SM4, and m3 is the mask obtained by post-affine operation; L(x -1 )+m4 represents the affine operation of AES, and m4 is the mask obtained after affine operation.
[0063] 2.6 Select the signal through aes_sm4 and use the second selector to determine the mask output L(x-1 )+m5 and mask m5; if aes_sm4 is 1, then m5=m4, then L(x -1 )+L(x in m5 -1 ) is the affine operation of AES; if aes_sm4 is 0, then m5=m3, then L(x -1 )+L(x in m5 -1 ) is the post-affine operation of SM4.
[0064] 3.7 Finally, use the second mask to correct the unit L(x -1 )+m5 adds (m5+m) to perform mask correction operation, correcting the mask from m5 to m. The corrected value is the masked S-box replacement output value L(x -1 )+m, denoted as sbox(x)+m.
[0065] The circuit structure designed by the method of the present invention is simple, easy to implement, and does not require additional random numbers; it integrates the design of resistance to differential power consumption attacks and the design of resistance to zero-value power consumption attacks, while ensuring the security under differential power consumption and zero-value power consumption attacks; if the S-box of AES&SM4 is implemented separately, two inversion circuits that are resistant to zero-value power consumption attacks are required; the present invention performs a reconfigurable design on the S-box of AES&SM4, effectively reducing the circuit area.
[0066] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An AES&SM4 reconfigurable S-box circuit resistant to zero-value attacks, characterized in that: It includes a front affine unit, a first selector, a masked anti-zero power consumption attack inversion circuit, a first mask correction unit, a rear affine unit, an affine unit, a second mask correction unit, and a second selector, wherein: The front affine unit is used to perform the front affine operation of SM4 on the masked input value x+m and the mask m to obtain the result after the affine operation and the masks x1+m1 and m1; The first selector is used to determine the inverted input x2+m2 and the mask m2 according to the aes_sm4 selection signal; if aes_sm4 is 1, indicating that the AES operation is performed, then x2+m2=x+m, m2=m; if aes_sm4 is 0, indicating that the SM4 operation is performed, then x2+m2=x1+m1, m2=m1; The masked anti-zero power consumption attack inversion circuit is used to invert x2+m2 and m2, and combine the correction value to obtain the inverted result x2 -1 +m2; The first mask correction unit is used to correct the inverse result x2 -1 +m2 performs mask correction operation, corrects the mask from m2 to m, and obtains x2 -1 +m; The post-affine unit is used to transform x2 -1 +m, mask m, and perform SM4 post-affine operation to obtain L(x -1 )+m3; Affine unit, used to transform x2 -1 +m, mask m, and perform AES affine operation to obtain L(x -1 )+m4; The second selector is used to determine the mask output L(x) according to the aes_sm4 selection signal -1 )+m5 and mask m5; if aes_sm4 is 1, then m5=m4; if aes_sm4 is 0, then m5=m3; The second mask correction unit is used to modify L(x -1 )+m5 performs mask correction operation, correcting the mask from m5 to m. The corrected value is the masked S-box replacement output value L(x -1 )+m; The inversion processing process of the masked anti-zero power consumption attack inversion circuit is as follows: The masked input value x2+m2 and the mask m2 are subjected to zero value detection by a zero value detection circuit to obtain δ(x); Add the obtained δ(x) to x2+m2, and map x2 to a non-zero value x2+m2+δ(x); Multiply the non-zero value x2+m2+δ(x) by the mask value m2 to obtain [x2+δ(x)+m2]m2; Pass m2 through the squarer to get m2 2 , and add it to [x2+δ(x)+m2]m2, finally getting [x2+δ(x)]m2; Directly invert [x2+δ(x)]m2 to obtain [x2+δ(x)] -1 m2 -1 ; For [x2+δ(x)] -1 m2 -1 Add 1, and we get [x2+δ(x)] -1 m2 -1 +1; [x2+δ(x)] -1 m2 -1 +1 multiplied by m2, we get [x2+δ(x)] -1 +m2; Add the correction value n to get x2 -1 +m2; where the correction value n = [x2 + δ(x)] -1 +x2 -1 ; The zero value detection circuit is used to detect whether x2+m2 is equal to m2, thereby determining whether x2 is 0; if the input x2+m2 is equal to m2, then the output δ(x)=1, otherwise it is 0; The zero value detection circuit includes 8 2-input XOR gates and 7 2-input OR gates, including 4 first OR gates, 2 second OR gates, and 1 third OR gate; wherein: The 8 2-input XOR gates are divided into four pairs. The inputs of each pair are the bits corresponding to x2+m2 and m2 respectively. The output of each pair is used as the input of a first OR gate. The outputs of every two first OR gates are used as the input of a second OR gate, and the outputs of the two second OR gates are used as the input of a third OR gate. The output of the third OR gate is the zero value detection result δ(x).
2. The AES&SM4 reconfigurable S-box circuit resistant to zero-value attacks according to claim 1, characterized in that: If and only if x2 = 0, a correction value needs to be added. The correction value is the finite field inversion (1) -1 =0x01.
3. The AES&SM4 reconfigurable S-box circuit resistant to zero-value attacks according to claim 1, characterized in that: The first mask correction unit is obtained by -1 +m2 adds m+m2 to modify the mask from m2 to m; The second mask correction unit is to -1 )+m5, then m5+m is added to perform mask correction operation, and the mask is corrected from m5 to m.
Citation Information
Patent Citations
AES mask encryption method resisting high order power consumption analysis
CN107070633A
Mask method and mask circuit for defending energy analysis attack
CN109302278A
