Additive mask value generator, encryptor and method of generating a stream key

By combining an addition mask value generator and an encryptor, secure addition input and output mask values ​​are generated, solving the problem of data leakage in encryption and decryption applications and realizing data protection for secure addition operations in the ChaCha20 encryptor.

CN116415274BActive Publication Date: 2026-11-24NUVOTON
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211315849.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2021-12-30
Filing Date
2022-10-26
Publication Date
2026-11-24
Estimated Expiration
2042-10-26

AI Technical Summary

Technical Problem

In existing encryption and decryption applications, how can secure addition operations be performed without revealing the original value of the input data, and how can information be prevented from being stolen during the calculation process, especially in protecting confidential information in integrated circuits or electronic products?

Method used

An additive mask value generator and an encryptor are used. The mask value is generated by a random number generator, and the mask operation is performed by the additive mask value generator and the arithmetic unit to generate secure addition input and output mask values. The ChaCha20 encryptor is used for encryption to ensure that the data is not leaked during the calculation process.

Benefits of technology

It enables addition operations to be performed without revealing the original values ​​of the input data, and protects the output data through a mask to prevent information theft and enhance data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116415274B_ABST
    Figure CN116415274B_ABST
Patent Text Reader

Abstract

The present application provides an addition mask value generator, an encryptor and a method for generating a stream cipher key. The first operation circuit of the addition mask value generator obtains first intermediate data according to a first output mask value and a fourth output mask value. The second operation circuit obtains an addition output mask value of a first mask group according to the first intermediate data and a fourth input mask value. The third operation circuit obtains second intermediate data according to a second output mask value and a third output mask value. The fourth operation circuit obtains an addition output mask value of a second mask group according to the second intermediate data and a second input mask value. The first addition input mask value and the second addition input mask value of the first mask group are the first input mask value and the second input mask value respectively. The first addition input mask value and the second addition input mask value of the second mask group are the third input mask value and the first intermediate data respectively.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an encryptor, and more particularly to a ChaCha20 encryptor using a secure adder. Background Technology

[0002] In recent years, encryption and decryption applications (such as add-rotate-xor (ARX)) have been widely used in various electronic products. These applications place great emphasis on protecting confidential information to prevent the analysis and theft of computational data. Addition is a crucial function in many operations, hence adders are widely used in signal processing, data protection, and other applications. Generally, common and effective protection mechanisms are mutual exclusion or masking techniques, which utilize random numbers and critical data (or variables) within the encryption / decryption algorithm to perform mutual exclusion or operations, thus achieving masking protection. Therefore, encryption and decryption applications require a secure adder capable of performing secure addition operations.

[0003] Secure addition refers to a secure adder that can perform addition operations without removing the mask of the input data, without revealing the original value of the input data during the calculation, and providing an output protected by the masked value. Secure adders capable of performing secure addition operations are widely used in various integrated circuits or electronic products that perform encryption and decryption operations to protect the data being processed. Summary of the Invention

[0004] This invention provides an addition mask generator for providing a first addition input mask value, a second addition input mask value, and an addition output mask value for a plurality of mask groups based on a first input mask value, a second input mask value, a third input mask value, a fourth input mask value, a first output mask value, a second output mask value, a third output mask value, and a fourth output mask value. The addition mask generator includes a first arithmetic circuit, a second arithmetic circuit, a third arithmetic circuit, and a fourth arithmetic circuit. The first arithmetic circuit obtains a first intermediate data based on the first output mask value and the fourth output mask value. The second arithmetic circuit obtains the addition output mask value of the first mask group based on the first intermediate data and the fourth input mask value. The third arithmetic circuit obtains a second intermediate data based on the second output mask value and the third output mask value. The fourth operational circuit described above is used to obtain the addition output mask value of a second mask group based on the second intermediate data and the second input mask value. The first addition input mask value of the first mask group is the first input mask value, and the second addition input mask value of the first mask group is the second input mask value. The first addition input mask value of the second mask group is the third input mask value, and the second addition input mask value of the second mask group is the first intermediate data.

[0005] Furthermore, the present invention provides an encryption device. The encryption device includes a mask generator, a controller, and at least one arithmetic unit. The mask generator includes a random number generator, a temporary register, and an addition mask value generator. The random number generator is configured to randomly provide a first output mask value, a second output mask value, a third output mask value, and a fourth output mask value. The temporary register is used to provide a first input mask value, a second input mask value, a third input mask value, and a fourth input mask value. The addition mask value generator is used to provide a first addition input mask value, a second addition input mask value, and an addition output mask value for a plurality of mask groups based on the first input mask value, the second input mask value, the third input mask value, and the fourth input mask value, as well as the first output mask value, the second output mask value, the third output mask value, and the fourth output mask value. The controller is configured to provide a first masked input data, a second masked input data, a third masked input data, and a fourth masked input data based on the first, second, third, and fourth input mask values, respectively. The arithmetic unit is configured to obtain a first masked output data, a second masked output data, a third masked output data, and a fourth masked output data based on the first, second, third, and fourth masked input data, as well as the first, second, and third addition input mask values ​​and the addition output mask values ​​of the plurality of mask groups. The controller provides a stream key conforming to Chacha20 encryption based on the first, second, third, and fourth masked output data, as well as the first, second, third, and fourth output mask values.

[0006] Furthermore, this invention provides a method for generating a streaming key, applicable to chacha20 encryption. Four output mask values ​​are obtained via a random number generator. Masking operations are performed on the four input values ​​according to the four input mask values ​​to obtain individual masked input data. Four mask groups are generated based on the four input mask values ​​and the four output mask values, each mask group including a first addition input mask value, a second addition input mask value, and an addition output mask value. Corresponding quarter-turn operations are performed on the masked input data using the four mask groups to obtain the corresponding masked output data. A streaming key is obtained based on the masked output data and the four output mask values. Attached Figure Description

[0007] Figure 1 This illustrates an encryptor according to some embodiments of the present invention.

[0008] Figure 2 This illustrates the ChaCha20 algorithm according to some embodiments of the present invention.

[0009] Figure 3 This illustrates an arithmetic unit according to some embodiments of the present invention.

[0010] Figure 4 This illustrates a secure adder according to some embodiments of the present invention.

[0011] Figure 5 The present invention describes some embodiments thereof. Figure 1 Additive mask value generator.

[0012] Figure 6 This invention illustrates a method for generating streaming keys according to some embodiments of the present invention, applicable to chacha20 encryption operations.

[0013] Icon labels:

[0014] 10: Controller

[0015] 20: Memory

[0016] 30: Mask generator

[0017] 32: Random Number Generator

[0018] 34: Temporary Register

[0019] 36: Additive Mask Value Generator

[0020] 40_0-40_3: Arithmetic Unit

[0021] 100: Encryptor

[0022] 110_1-110_4: Safe Adder

[0023] 120, 122, 124, 126: Mutual exclusion OR-cyclic shift operation units

[0024] 130-136: Operational Circuits

[0025] 150-156: Mutual exclusion or unit

[0026] 160-166: Circular shift operation unit

[0027] AMG: Masking Value

[0028] AMG_1-AMG_4: Masking Group

[0029] AO0-AO3: Intermediate data

[0030] A',B',C',D': Masked output data

[0031] a',b',c',d': Masked input data

[0032] IM1-IM6: Intermediate Data

[0033] rA, rB, rC, rD: Output mask values

[0034] ra,rb,rc,rd: Input mask values

[0035] rx,ry,rz,rx1-rx4,ry1-ry4,rz1-rz4: Mask values

[0036] S: Calculation result

[0037] S210-S250: Steps

[0038] x', y' are masked data

[0039] XS0-XS3: Intermediate Data Detailed Implementation

[0040] To make the above and other objects, features, and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings:

[0041] Figure 1 An encryptor 100 according to some embodiments of the present invention is shown. The encryptor 100 may be implemented in an integrated circuit (not shown). The encryptor 100 includes a controller (state) 10, a memory (working state) 20, a mask generator 30, and arithmetic units 40_0 to 40_3. In this embodiment, the number of arithmetic units 40_0 to 40_3 is merely an example and is not intended to limit the invention. Furthermore, by using the mask generator 30, the encryptor 100 can perform ChaCha20 encryption calculations without disclosing the operands.

[0042] Figure 2 The ChaCha20 algorithm according to some embodiments of the present invention is shown. Also refer to... Figure 1 and Figure 2The 512-bit state (state[511:0]) of the ChaCha20 algorithm consists of a 128-bit constant (constant[127:0]), a 256-bit key (key[255:0]), a 32-bit counter (counter[31:0]), and a 96-bit non-repeating random value (nonce[95:0]). First, the controller 10 writes the contents of the 512-bit state to the memory 20 as the 512-bit working state (working_state[511:0]). Next, the encryptor 100 uses arithmetic units 40_0 to 40_3 and the mask value AMG from the mask generator 30 to perform 10 computational loops. Each computational loop consists of eight quarter-rounds (Qrounds), totaling two rounds. During each quarter round, four 32-bit input values ​​(i.e., a[31:0], b[31:0], c[31:0], and d[31:0], hereinafter referred to as input values ​​a, b, c, and d) are input to the corresponding arithmetic unit. Each arithmetic unit 40_0 to 40_3 can perform the add-rotate-xor (ARX) operation corresponding to the ChaCha20 algorithm to obtain four 32-bit output values ​​(i.e., A[31:0], B[31:0], C[31:0], and D[31:0], hereinafter referred to as output values ​​A, B, C, and D) and store them in the corresponding working state location in memory 20. After completing 10 calculation cycles, the controller 10 can add 512 bits of state (i.e., state[511:0]) to the 512-bit working state (i.e., working_state[511:0]) to obtain a new 512-bit state and output it sequentially as a stream key for use by other subsequent circuits.

[0043] The mask generator 30 includes a random number generator (RNG) 32, a temporary register (or memory) 34, and an additive mask value generator 36. The random number generator 32 generates multiple random numbers based on signals from the controller 10 (e.g., control signals, clock signals, etc.) to serve as output mask values ​​rA, rB, rC, and rD, which are then provided to the temporary register 34 and the additive mask value generator 36. When the random number generator 32 provides the output mask values ​​rA, rB, rC, and rD to the additive mask value generator 36, the temporary register 34 simultaneously provides the input mask values ​​ra, rb, rc, and rd to the additive mask value generator 36. Therefore, the additive mask value generator 36 can generate mask values ​​AMG based on the output mask values ​​rA, rB, rC, and rD and the input mask values ​​ra, rb, rc, and rd, which are then sent to the arithmetic units 40_0 to 40_3. Furthermore, after providing the input mask values ​​ra, rb, rc, and rd to the adder mask value generator 36, the register 34 stores the output mask values ​​rA, rB, rC, and rD as the input mask values ​​ra, rb, rc, and rd in the next clock cycle (e.g., corresponding to the clock signal from the controller 10). In other words, the input mask values ​​ra, rb, rc, and rd provided to the adder mask value generator 36 are the output mask values ​​rA, rB, rC, and rD obtained in the previous clock cycle (e.g., corresponding to the clock signal from the controller 10). In other words, the mask generator 30 updates the input mask values ​​ra, rb, rc, and rd and the output mask values ​​rA, rB, rC, and rD in each clock cycle. Moreover, each adder in the arithmetic units 40_0 to 40_3 can perform safe addition operations based on the mask values ​​rx, ry, and rz corresponding to that group in the mask value AMG. For each adder, the mask values ​​rx and ry are the addition input mask values, while the mask value rz is the addition output mask value.

[0044] In the encryptor 100, the mask generator 30 can also provide the input mask values ​​ra, rb, rc, and rd of the arithmetic units 40_0 to 40_3 to the controller 10. Then, the controller 10 can perform mask operations on the input values ​​a, b, c, and d according to the input mask values ​​ra, rb, rc, and rd respectively to obtain the masked input data a', b', c', and d', as shown in the following equations (1)-(4):

[0045]

[0046]

[0047] as well as

[0048]

[0049] Next, the controller 10 can store the masked input data a', b', c', and d' in the memory 20 for provision to the arithmetic units 40_0 to 40_3. Furthermore, the output mask values ​​rA, rB, rC, and rD provided by the mask generator 30 are used to mask the original output values ​​A, B, C, and D to obtain the masked output data A', B', C', and D', as shown in the following equations (5)-(8):

[0050]

[0051]

[0052] as well as

[0053]

[0054] Therefore, controller 10 can obtain the original output values ​​A, B, C, and D based on the output mask values ​​rA, rB, rC, and rD from mask generator 30 and the masked output data A', B', C', and D' provided to memory 20 by arithmetic units 40_0 to 40_3. The operation of additive mask value generator 36 and arithmetic units 40_0 to 40_3 will be described later.

[0055] Figure 3 This illustrates an arithmetic unit 40 according to some embodiments of the present invention. The arithmetic unit 40 can be applied to... Figure 1 The encryptor 100 includes arithmetic units 40_0 to 40_3 that perform quarter-turn operations. Arithmetic unit 40 includes secure adders 110_1 to 110_4 and mutually exclusive OR-circular shift units 120, 122, 124, and 126 to sequentially perform eight operations of the quarter-turn operation. The mask value AMG from the mask generator 30 includes mask groups AMG_1, AMG_2, AMG_3, and AMG_4. Each mask group AMG_1, AMG_2, AMG_3, and AMG_4 includes corresponding mask values ​​rx, ry, and rz, and is provided to an individual secure adder. For example, mask value AMG_1 includes mask values ​​rx1, ry1, and rz1 and is provided to secure adder 110_1. Mask value AMG_2 includes mask values ​​rx2, ry2, and rz2 and is provided to secure adder 110_2. Mask value AMG_3 includes mask values ​​rx3, ry3, and rz3 and is provided to secure adder 110_3. Mask value AMG_4 includes mask values ​​rx4, ry4, and rz4 and is provided to secure adder 110_4. Furthermore, secure adders 110_1 through 110_4 have the same circuit configuration.

[0056] In the arithmetic unit 40, mask groups AMG_1, AMG_2, AMG_3, and AMG_4 correspond to secure adders 110_1, 110_2, 110_3, and 110_4, respectively. In this embodiment, each secure adder 110_1 to 110_4 performs an addition operation on two masked data points that have been masked by masking values ​​rx and ry, respectively, and provides the operation result masked by masking value rz. Figure 4 As shown, Figure 4 This illustrates a secure adder 110 according to some embodiments of the present invention. Figure 4 In this process, the secure adder 110 performs an addition operation on the masked data x' corresponding to the mask value rx and the masked data y' corresponding to the mask value ry, and provides the operation result S corresponding to the mask value rz. In some embodiments, the mask value rx is different from the mask value ry. In some embodiments, the mask value rx is the same as the mask value ry. It is worth noting that... Figure 4 The safe adder 110 is merely an example and is not intended to limit the invention. Any adder that can perform addition on masked input data and provide mask protection for the output without removing the mask values ​​can be applied to the present invention.

[0057] Reference Figure 3 In the first operation of the quarter-round operation, the safety adder 110_1 adds the masked input data a' and b' corresponding to the mask values ​​rx1 and ry1 to obtain the intermediate data AO0 corresponding to the mask value rz1. As described in the previous equations (1)-(2), the masked input data a' and b' can be obtained by performing masking operations on the input values ​​a and b according to the input mask values ​​ra and rb respectively. Therefore, the mask values ​​rx1 and ry1 are the input mask values ​​ra and rb respectively, as shown in the following equations (9) and (10):

[0058] rx1 = ra (9); and

[0059] ry1 = rb (10).

[0060] In the second operation of the quarter-round operation, the mutual exclusion OR-circular shift operation unit 120 performs a mutual exclusion OR operation (XOR) on the intermediate data AO0 corresponding to the mask value rz1 and the masked input data d' corresponding to the input mask value rd, and performs a 16-bit left circular shift (<<<16) on the result of the mutual exclusion OR operation to obtain the intermediate data XS0 and its mask value rs1, wherein the mask value rs1 is shown in the following formula (11):

[0061]

[0062] In the third operation of the quarter-round operation, the safety adder 110_2 adds the masked input data c' corresponding to the mask value rx2 and the intermediate data XS0 corresponding to the mask value ry2 to obtain the intermediate data AO1 corresponding to the mask value rz2. As described in the previous equation (3), the masked input data c' can be obtained by performing a masking operation on the input value c according to the input mask value rc. Therefore, the mask value rx2 is the input mask value rc, as shown in the following equation (12):

[0063] rx2 = rc (12).

[0064] Furthermore, for intermediate data XS0, the mask value ry2 is equal to the mask value rs1, as shown in the following formula (13):

[0065] ry2=rs1 (13).

[0066] In the fourth operation of the quarter-round operation, the mutex OR-circular shift operation unit 122 performs a mutex OR operation on the masked input data b' corresponding to the input mask value rb and the intermediate data AO1 corresponding to the mask value rz2, and performs a 12-bit left circular shift (<<<12) on the result of the mutex OR operation to obtain the intermediate data XS1 and its mask value rs2, wherein the mask value rs2 is shown in the following formula (14):

[0067]

[0068] In the fifth operation of the quarter-round operation, the safety adder 110_3 adds the intermediate data AO0 corresponding to the mask value rx3 and the intermediate data XS1 corresponding to the mask value ry3 to obtain the intermediate data AO2 corresponding to the mask value rz3. As previously described, the intermediate data AO0 is provided by the safety adder 110_1 based on the mask value rz1. Therefore, the mask value rx3 is equal to the mask value rz1, as shown in the following formula (15):

[0069] rx3=rz1 (15).

[0070] Furthermore, for intermediate data XS1, the mask value ry3 is equal to the mask value rs2, as shown in the following formula (16):

[0071] ry3 = rs2 (16).

[0072] Furthermore, the masked output data A' corresponding to the output mask value rA is equal to the intermediate data AO2 corresponding to the mask value rz3. Therefore, the mask value rz3 is equal to the output mask value rA, as shown in the following formula (17):

[0073] rz3=rA (17).

[0074] In the sixth operation of the quarter-round operation, the mutual exclusion OR-circular shift operation unit 124 performs a mutual exclusion OR operation on the intermediate data AO2 corresponding to the mask value rz3 and the intermediate data XS0 corresponding to the mask value rs1, and performs an 8-bit left circular shift (<<<8) on the result of the mutual exclusion OR operation to obtain the intermediate data XS2 and its mask value rs3. In addition, the masked output data D' corresponding to the output mask value rD is equal to the intermediate data XS2 corresponding to the mask value rs3. Therefore, according to formula (11), the mask value rs3 is shown in the following formula (18):

[0075]

[0076] Therefore, according to formulas (17) and (18), the value of rz1 can be obtained, as shown in the following formula (19):

[0077]

[0078] In the seventh operation of the quarter-round operation, the safety adder 110_4 adds the intermediate data AO1 corresponding to the mask value rx4 and the intermediate data XS2 corresponding to the mask value ry4 to obtain the intermediate data AO3 corresponding to the mask value rz4. As previously described, the intermediate data AO1 is provided by the safety adder 110_2 based on the mask value rz2. Therefore, the mask value rx4 is equal to the mask value rz2, as shown in the following formula (20):

[0079] rx4=rz2 (20).

[0080] Furthermore, the masked output data D' corresponding to the output mask value rD is equal to the intermediate data XS2 corresponding to the mask value ry4. Therefore, the mask value ry4 is equal to the output mask value rD, as shown in the following formula (21):

[0081] ry4=rD (21).

[0082] Furthermore, the masked output data C' corresponding to the output mask value rC is equal to the intermediate data AO3 corresponding to the mask value rz4. Therefore, the mask value rz4 is equal to the output mask value rC, as shown in the following formula (22):

[0083] rz4=rC (22).

[0084] In the eighth operation of the quarter-round operation, the mutual exclusion OR-circular shift operation unit 126 performs a mutual exclusion OR operation on the intermediate data XS1 corresponding to the mask value rs2 and the intermediate data AO3 corresponding to the output mask value rC, and performs a 7-bit left circular shift (<<<7) on the result of the mutual exclusion OR operation to obtain the intermediate data XS3 and its mask value rs4. Therefore, according to formula (14), the mask value rs4 is shown in the following formula (23):

[0085]

[0086] Furthermore, the masked output data B' corresponding to the output mask value rB is equal to the intermediate data XS3 corresponding to the mask value rs4, as shown in the following formula (24):

[0087] rs4 = rB (24).

[0088] Therefore, according to formulas (23) and (24), the value of rz2 can be obtained, as shown in the following formula (25):

[0089]

[0090] According to equations (11), (13) and (19), the value of ry2 can be obtained, as shown in the following equation (26):

[0091]

[0092] Furthermore, based on equations (14), (16), and (25), the value of ry3 can be obtained, as shown in the following equation (27):

[0093]

[0094] Figure 5 The present invention describes some embodiments thereof. Figure 1 The additive mask value generator 36 generates mask values ​​AMG, including mask groups AMG_1, AMG_2, AMG_3, and AMG_4, based on input mask values ​​ra, rb, rc, and rd and output mask values ​​rA, rB, rC, and rD. The additive mask value generator 36 includes arithmetic circuits 130-136, each of which includes a mutex OR unit and a cyclic shift arithmetic unit.

[0095] As shown in equation (9), the additive mask value generator 36 directly assigns the input mask value ra to the mask value rx1 of mask group AMG_1. Furthermore, according to equation (10), the additive mask value generator 36 directly assigns the input mask value rb to the mask value ry1 of mask group AMG_1 and provides the input mask value rb to the arithmetic circuit 136. According to equation (12), the additive mask value generator 36 directly assigns the input mask value rc to the mask value rx2 of mask group AMG_2. According to equation (17), the additive mask value generator 36 directly assigns the output mask value rA to the mask value rz3 of mask group AMG_3 and provides the output mask value rA to the arithmetic circuit 130. According to formula (22), the additive mask value generator 36 directly assigns the output mask value rC to the mask value rz4 of mask group AMG_4 and provides the output mask value rC to the arithmetic circuit 132. According to formula (21), the additive mask value generator 36 directly assigns the output mask value rD to the mask value ry4 of mask group AMG_4 and provides the output mask value rD to the arithmetic circuit 130.

[0096] The arithmetic circuit 130 includes a circular shift operation unit 160 and a mutex OR unit 150. According to formula (26), the circular shift operation unit 160 performs an 8-bit right circular shift (>>>8) on the output mask value rD to obtain intermediate data IM1. Then, the mutex OR unit 150 performs a mutex OR operation on the intermediate data IM1 and the output mask value rA to obtain intermediate data IM2. The adder mask value generator 36 assigns the intermediate data IM2 as the mask value ry2 of mask group AMG_2. The arithmetic circuit 134 includes a circular shift operation unit 164 and a mutex OR unit 154. According to formula (19), the circular shift operation unit 164 performs a 16-bit right circular shift (>>>16) on the intermediate data IM2 to obtain intermediate data IM3. Next, the mutex OR unit 154 performs a mutex OR operation on the intermediate data IM3 and the input mask value rd to obtain the mask value rz1 of mask group AMG_1 and the mask value rx3 of mask group AMG_3 (as shown in equation (15)). It is worth noting that the operation of the arithmetic circuit 130 corresponds to... Figure 3 The mutually exclusive OR-cyclic shift operation unit 124 performs an 8-bit left circular shift (<<<8), while the circular shift operation unit 160 of the operation circuit 130 performs an 8-bit right circular shift (>>>8). Furthermore, the operation of the operation circuit 134 corresponds to... Figure 3 The mutually exclusive OR-cyclic shift operation unit 120 performs a 16-bit left circular shift (<<<16), while the circular shift operation unit 164 of the operation circuit 134 performs a 16-bit right circular shift (>>>16).

[0097] The arithmetic circuit 132 includes a circular shift operation unit 162 and a mutex OR unit 152. According to formula (27), the circular shift operation unit 162 performs a 7-bit right circular shift (>>>7) on the output mask value rB to obtain intermediate data IM4. Then, the mutex OR unit 152 performs a mutex OR operation on the intermediate data IM4 and the output mask value rC to obtain intermediate data IM5. The adder mask value generator 36 assigns the intermediate data IM5 as the mask value ry3 of the mask group AMG_3. The arithmetic circuit 136 includes a circular shift operation unit 166 and a mutex OR unit 156. According to formula (25), the circular shift operation unit 166 performs a 12-bit right circular shift (>>>12) on the intermediate data IM5 to obtain intermediate data IM6. Next, the mutex OR unit 156 performs a mutex OR operation on the intermediate data IM6 and the input mask value rb to obtain the mask value rz2 of mask group AMG_2 and the mask value rx4 of mask group AMG_4 (as shown in equation (20)). It is worth noting that the operation of the arithmetic circuit 132 corresponds to... Figure 3 The mutually exclusive OR-cyclic shift operation unit 126 performs a 7-bit left circular shift (<<<7), while the circular shift operation unit 162 of the operation circuit 136 performs a 7-bit right circular shift (>>>7). Furthermore, the operation of the operation circuit 136 corresponds to... Figure 3 The mutually exclusive OR-cyclic shift operation unit 122 performs a 12-bit left circular shift (<<<12), while the circular shift operation unit 166 of the operation circuit 136 performs a 12-bit right circular shift (>>>12).

[0098] exist Figure 5 In this process, by using mutex units (or mutex gates) 150, 152, 154 and 156 and cyclic shift operation units (or cyclic shifters) 160, 162, 164 and 166, the addition mask value generator 36 can generate all addition input mask values ​​(e.g., mask values ​​rx1-rx4 and mask values ​​ry1-ry4) and all addition output mask values ​​(e.g., mask values ​​rz1-rz4) required to perform the addition operations in the chacha20 encryption algorithm.

[0099] Figure 6 This invention illustrates a method for generating streaming keys according to some embodiments of the present invention, applicable to chacha20 encryption operations. Figure 6 The method for generating the stream key can be derived from... Figure 1 The encryption is executed by 100.

[0100] First, in step S210, the input mask values ​​ra, rb, rc, and rd, and the output mask values ​​rA, rB, rC, and rD are obtained. As previously described, the output mask values ​​rA, rB, rC, and rD, and the input mask values ​​ra, rb, rc, and rd can be random numbers. Furthermore, the input mask values ​​ra, rb, rc, and rd are the output mask values ​​rA, rB, rC, and rD of the previous clock cycle.

[0101] Next, in step S220, a mask value AMG is generated based on the input mask values ​​ra, rb, rc, and rd and the output mask values ​​rA, rB, rC, and rD. As previously described, the mask value AMG includes mask groups AMG_1, AMG_2, AMG_3, and AMG_4. Furthermore, each mask group AMG_1, AMG_2, AMG_3, and AMG_4 includes corresponding mask values ​​rx, ry, and rz. As previously described, the mask value AMG is generated through four mutually exclusive OR units (e.g., ...). Figure 5 Mutex units 150-156) and four cyclic shift units (e.g. Figure 5 It is generated by circular shift operation units 160-166, wherein the shift direction of each circular shift operation unit is opposite to the direction of the circular shift corresponding to the quarter-turn. In addition, the number of shifts of each circular shift operation unit is the same as the number of shifts of the circular shift corresponding to the quarter-turn.

[0102] In step S230, when the input values ​​a, b, c, and d have not yet been masked, masking operations are performed on the input values ​​a, b, c, and d according to the input mask values ​​ra, rb, rc, and rd, respectively, to obtain the corresponding masked input data a', b', c', and d'. In some embodiments, the order of steps S220 and S230 can be reversed.

[0103] In step S240, the masked input data a', b', c', and d' are processed using the mask value AMG to obtain the masked output data A', B', C', and D'. This process is repeated until all eight quarter-rounds within each calculation loop have been completed.

[0104] In step S250, a new bit working state is obtained based on the masked output data A', B', C', and D' and the output mask values ​​rA, rB, rC, and rD, and the key is output sequentially as a stream. Thus, the encryption operation of chacha20 is completed.

[0105] According to an embodiment of the present invention, during the execution of a quarter-round of ChaCha20, by using a mask generator 30 to generate the addition input mask value and addition output mask value required by the secure adder, the critical variables in the ChaCha20 operation can be protected from being leaked by power analysis attacks.

[0106] Although the present invention has been described above with reference to preferred embodiments, it is not intended to limit the invention. Anyone skilled in the art, including those skilled in the art, may make some modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention shall be determined by the scope of protection of the claims in this application.

Claims

1. An additive mask value generator, characterized in that, A first additive input mask value, a second additive input mask value, and an additive output mask value used to provide multiple mask groups based on a first input mask value, a second input mask value, a third input mask value, a fourth input mask value, a first output mask value, a second output mask value, a third output mask value, and a fourth output mask value, including: A first arithmetic circuit is used to obtain a first intermediate data based on the first output mask value and the fourth output mask value; A second arithmetic circuit is used to obtain the additive output mask value of a first mask group based on the first intermediate data and the fourth input mask value; A third operational circuit is configured to obtain a second intermediate data based on the second output mask value and the third output mask value; and A fourth arithmetic circuit is used to obtain the additive output mask value of a second mask group based on the second intermediate data and the second input mask value; The first addition input mask value of the first mask group is the first input mask value, and the second addition input mask value of the first mask group is the second input mask value; The first additive input mask value of the second mask group is the third input mask value, and the second additive input mask value of the second mask group is the first intermediate data.

2. The additive mask value generator according to claim 1, characterized in that, The first addition input mask value of the third mask group is the same as the addition output mask value of the first mask group, the second addition input mask value of the third mask group is the second intermediate data, and the addition output mask value of the third mask group is the first output mask value.

3. The additive mask value generator according to claim 1, characterized in that, The first addition input mask value of the fourth mask group is the same as the addition output mask value of the second mask group, the second addition input mask value of the fourth mask group is the fourth output mask value, and the addition output mask value of the fourth mask group is the third output mask value.

4. The additive mask value generator according to claim 1, characterized in that, The first operational circuit includes: A first cyclic shifter is used to perform an 8-bit right cyclic shift on the fourth output mask value to obtain a third intermediate data; and A first mutex or gate is provided to receive the third intermediate data and the first output mask value to provide the first intermediate data.

5. The additive mask value generator according to claim 1, characterized in that, The second operational circuit includes: A second circular shifter is used to perform a 16-bit right circular shift on the first intermediate data to obtain a fourth intermediate data; and A second mutex or gate is provided to receive the fourth intermediate data and the fourth input mask value to provide the additive output mask value of the first mask group.

6. An encryption device, characterized in that, include: A mask generator, comprising: A random number generator configured to randomly provide a first output mask value, a second output mask value, a third output mask value, and a fourth output mask value; A register for providing a first input mask value, a second input mask value, a third input mask value, and a fourth input mask value; and An additive mask value generator is used to provide a first additive input mask value, a second additive input mask value, and an additive output mask value for a plurality of mask groups based on a first input mask value, a second input mask value, a third input mask value, and a fourth input mask value, as well as a first output mask value, a second output mask value, a third output mask value, and a fourth output mask value; A controller is configured to provide a first masked input data, a second masked input data, a third masked input data, and a fourth masked input data, respectively, based on the first input mask value, the second input mask value, the third input mask value, and the fourth input mask value; and At least one arithmetic unit is configured to obtain a first masked output data, a second masked output data, a third masked output data, and a fourth masked output data based on the first masked input data, the second masked input data, the third masked input data, the fourth masked input data, and the first addition input mask value, the second addition input mask value, and the addition output mask value of the mask group; The controller provides a stream of keys that conforms to Chacha20 encryption based on the first masked output data, the second masked output data, the third masked output data, and the fourth masked output data, as well as the first output mask value, the second output mask value, the third output mask value, and the fourth output mask value.

7. The encryptor according to claim 6, characterized in that, The additive mask value generator includes: A first arithmetic circuit is used to obtain a first intermediate data based on the first output mask value and the fourth output mask value; A second arithmetic circuit is used to obtain the additive output mask value of a first mask group based on the first intermediate data and the fourth input mask value; A third operational circuit is configured to obtain a second intermediate data based on the second output mask value and the third output mask value; and A fourth arithmetic circuit is used to obtain the additive output mask value of a second mask group based on the second intermediate data and the second input mask value; The first addition input mask value of the first mask group is the first input mask value, and the second addition input mask value of the first mask group is the second input mask value; The first additive input mask value of the second mask group is the third input mask value, and the second additive input mask value of the second mask group is the first intermediate data.

8. The encryptor according to claim 7, characterized in that, Each of the first, second, third, and fourth arithmetic circuits includes a cyclic shifter and a mutex or gate, and each of the cyclic shifters is configured to perform a right cyclic shift of a different number of bits.

9. A method for generating a streaming key, characterized in that, Applicable to Chacha20 encryption, including: Four output mask values ​​are obtained through a random number generator; Perform masking operations on the four input values ​​respectively to obtain individual masked input data; Based on the four input mask values ​​and the four output mask values, four mask groups are generated, wherein each mask group includes a first additive input mask value, a second additive input mask value, and an additive output mask value; The four mask groups are used to perform corresponding quarter-turn operations on the masked input data to obtain the corresponding masked output data; and Based on the masked output data and the four output mask values, a string of gold keys is obtained; The four mask groups respectively correspond to the addition operation in the quarter round.

10. The method for generating a streaming key according to claim 9, characterized in that, The four input mask values ​​are the four output mask values ​​that were randomly generated in the previous clock cycle.

Citation Information

Patent Citations

  • Energy analysis attack resistant addition mask hardware implementation method and circuit

    CN106656465A

  • Encryption apparatus and encryption method

    US20070140478A1