A side channel attack resistant masking method and system based on circulant matrix
By using a cyclic matrix to generate a random mask set and performing out-of-order computation in the AES algorithm, the vulnerability of the AES algorithm to side-channel attacks in IoT devices is solved, thus achieving protection of intermediate values and enhanced security of sensitive data.
Patent Information
- Application Number
- CN202411574875.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-11-06
AI Technical Summary
Existing AES algorithms are vulnerable to side-channel attacks in IoT devices, especially related power consumption attacks (CPA), which can lead to the leakage of keys and plaintext information, necessitating effective protection measures.
A mask protection method based on cyclic matrix is adopted. By generating a random matrix and a permutation array, the S-box is calculated in an out-of-order manner, and a mask is added at the intermediate value position to protect the security of the intermediate value.
It effectively resists first-order CPA attacks, reduces the implementation cost of traditional masks, ensures the security of sensitive data during encryption and decryption, and improves the AES algorithm's resistance to side-channel attacks.
Smart Images

Figure CN119583050B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data security technology, and in particular to a method and system for resisting side-channel attack masking based on a cyclic matrix. Background Technology
[0002] Side-channel attacks, proposed by Kocher in the 1990s, have become an increasingly significant area of research in cryptography due to the development of side-channel technology and its growing threat to cryptographic device security. In implementing a side-channel attack, attackers analyze the thermal power consumption data leaked during encryption and decryption operations, build suitable models, and find statistical relationships between different power consumption values and the encrypted / decrypted data, thereby guessing the correct key and plaintext. It has been proven that many cryptographic devices are susceptible to power consumption attacks, forcing cryptographic algorithm design to shift towards side-channel resistance. Power consumption attacks are mainly divided into two types: the first is Simple Power Analysis (SPA), which involves obtaining the power consumption curve of the cryptographic device and directly observing the waveform to guess the key; the second is statistically based power consumption attacks, such as Correlation Power Attack (CPA) and Differential Power Attack (DPA). CPA, due to its ease of implementation and effectiveness, has been widely studied and is a key attack method that must be defended against in cryptographic algorithm design.
[0003] Block ciphers are widely used in various IoT devices due to their fast encryption and decryption speeds. However, insecure operating environments make side-channel attacks a greater threat to these devices. A block cipher algorithm is a symmetric cryptographic algorithm that divides plaintext data into blocks, combines each block with a corresponding key, and then iterates through multiple rounds. A block cipher algorithm generally consists of three sub-algorithms: a key expansion algorithm, an encryption algorithm, and a decryption algorithm. Block ciphers have various structures, but all must satisfy the design principles of confusion and diffusion. Taking the SPN (Substitution-Permutation Network) structure as an example, the round function consists of a nonlinear confusion layer and a linear diffusion layer, and the encryption or decryption algorithm is formed by iterating through the round function. The AES cryptographic algorithm is a typical SPN structure algorithm, and its encryption algorithm is as follows: Figure 1 As shown, the S-box is the only non-linear component in the AES algorithm and a key location for energy leakage in side-channel attacks; therefore, protecting the S-box is particularly important.
[0004] AES algorithm has three versions, namely AES-128, AES-192 and AES-256. The three versions represent different key lengths and iteration rounds, AES-128 packet length is 128 bits, iteration 10 rounds; AES-192 packet length is 192 bits, iteration 12 rounds; AES-256 packet length is 256 bits, iteration 14 rounds. The application takes AES-128 as the object, the packet length is 128 bits, and an 4*4 state matrix is composed of 8-bit elements, all operations in the round function of AES are performed on the state matrix. In the first round, the plaintext matrix is first XORed with the round key, and then S-box transformation, row shift and column mixing are performed; the intermediate round is sequentially subjected to S-box transformation, row shift, column mixing and round key XOR; the final round is subjected to S-box transformation, row shift and round key XOR. AES algorithm is still safe in theory, but there have been many successful cases of attacks on AES algorithm in side channel attacks, and there have been a series of mature attack methods for Internet of Things devices equipped with AES algorithm. Therefore, it is necessary to design an anti-side channel protection for the AES algorithm running on the small password device of the Internet of Things. SUMMARY
[0005] The embodiment of the application provides a cyclic matrix-based anti-side channel attack mask protection method and system, which updates a mask set through cyclic shift of a matrix, simultaneously generates a permutation array using the matrix, performs disordered calculation on an S-box, and finally adds different masks to intermediate values at different positions to achieve the purpose of protecting the intermediate values.
[0006] The embodiment of the application provides a cyclic matrix-based anti-side channel attack mask protection method, which comprises the following steps:
[0007] generating a random matrix, and generating a random permutation array based on the generated random matrix, wherein the random matrix only contains 1 and 0 elements;
[0008] generating a mask set through cyclic shift of the matrix based on the generated random matrix;
[0009] performing disordered calculation on an S-box according to the generated random permutation array, and adding masks to intermediate values at different positions based on the generated mask set.
[0010] Optionally, the random matrix is generated by the following steps:
[0011] repeatedly generating a unit matrix of a preset order, and performing random transformation on the unit matrix multiple times to obtain a random reversible matrix;
[0012] combining the obtained multiple random reversible matrices into a high-order matrix as the random matrix.
[0013] Optionally, generating a random permutation array based on the generated random matrix comprises:
[0014] Randomly generating a number b
[0015] Given an initial permutation array of a number associated with the random matrix;
[0016] Selecting an invertible matrix according to the generated number b to update the permutation array;
[0017]
[0018] Outputting the obtained random permutation array.
[0019] Optionally, generating a mask set based on the generated random matrix by cyclic shift of the matrix comprises:
[0020] Taking the random matrix as a generating matrix of random masks;
[0021] Converting each row row i and each column col i of the generating matrix into a corresponding decimal number according to a set order, respectively, to obtain a mask value m j , i is the number of rows or columns of the generating matrix;
[0022] Connecting the mask values m j obtained based on the generating matrix to obtain a random mask set mask = mask r || mask c , where mask r is the mask value obtained for each row row i of the generating matrix, and mask c is the mask value obtained for each column col i of the generating matrix;
[0023] Generating a random offset R, and cyclically shifting the random matrix according to the random offset R to obtain a new matrix M R , the new matrix M R is used to generate a new mask set.
[0024] Optionally, according to the generated random permutation array, performing permutation calculation on the S-box in the AES encryption algorithm, and adding masks to intermediate values at different positions based on the generated mask set comprises:
[0025] The mask in the first round of AES encryption comprises:
[0026] According to the matrix M 0 as a generating matrix of random masks, and generating a random offset R1;
[0027] generating a random permutation P on ;
[0028] XORing the given plaintext state matrix with the mask matrix by element position to obtain an initialization data matrix mask0 is the matrix M 0 generated mask matrix;
[0029] The initialization data matrix is combined with the round key to obtain the input matrix of the S-box
[0030] Let S(x) be the S-box of AES, S m (x) is the S-box calculated with mask, then the input and output of the first round encryption with mask S-box satisfy:
[0031]
[0032] where t∈{0,1,…,15}, is the number input, and the execution is disordered using the random permutation P;
[0033] For the overall input data The output of the new S-box represents
[0034]
[0035] Performing row shift SR, column mixing MC, including:
[0036]
[0037] Adding the round key of the next round to obtain
[0038] Removing the output mask of the S-box
[0039] Adding the input mask of the next round
[0040] Optionally, according to the generated random permutation array, the S-box of the AES encryption algorithm is disordered, and the mask is added to the intermediate value in different positions based on the generated mask set, including:
[0041] The mask in the intermediate round encryption of AES includes:
[0042] The input data matrix of the i-th round is The random matrix M is generated according to R i a new mask matrix, and a random offset Ri+1 , matrix M i The generated mask matrix is:
[0043]
[0044] The input data is XORed with the mask, and the input of the S-box is
[0045] For the overall input data The newly calculated S-box satisfies:
[0046]
[0047] After row shifting and column mixing, the data is obtained
[0048]
[0049] Add the round key of the next round to obtain
[0050] Remove the output mask of the S-box
[0051] Add the input mask of the next round
[0052]
[0053] Optionally, according to the generated random permutation array, the S-box is calculated in the AES encryption algorithm, and the mask is added to the intermediate value at different positions based on the generated mask set, including:
[0054] The mask in the AES tail round encryption includes:
[0055] The input data matrix of this round is The random matrix M is generated according to R i A new mask matrix is generated, and a random offset R i+1 , matrix M i The generated mask matrix is:
[0056]
[0057] The input data is XORed with the mask, and the input of the S-box is
[0058] A random permutation Q on is generated;
[0059] S(x) is the S-box of AES, S m (x) is the S-box calculated with the mask, and the input and output of the S-box with the mask in the final round encryption satisfy:
[0060]
[0061] where t∈{0,1,…,15}, is a number input, using random permutation Q to reorder execution;
[0062] For the whole input data The S-box satisfies:
[0063]
[0064] After row shift, the data is obtained:
[0065]
[0066] Add round key
[0067] Remove the output mask of the S-box:
[0068]
[0069] Output the encrypted ciphertext state matrix
[0070] The embodiment of the application also proposes a cyclic matrix-based side channel attack-resistant masking protection system, comprising a processor and a memory, wherein the memory stores a computer program, and the computer program is executed by the processor to realize the steps of the cyclic matrix-based side channel attack-resistant masking protection method as described above.
[0071] The method of the embodiment of the application updates the mask set through cyclic shift of the matrix, simultaneously generates a permutation array by using the matrix, and is used for out-of-order calculation of the S-box, finally adds different masks on the intermediate values at different positions, and achieves the purpose of protecting the intermediate values.
[0072] The above description is only a summary of the technical solutions of the application, in order to more clearly understand the technical means of the application, the content of the specification can be implemented, and in order to make the above and other purposes, characteristics and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS
[0073] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not meant to limit the present application. Moreover, the same reference numerals in the attached drawings refer to the same or like components throughout the several drawings. In the drawings:
[0074] Figure 1 Flowchart of the prior art AES encryption algorithm
[0075] Figure 2 Flowchart of the AES algorithm mask scheme based on the cyclic matrix of the embodiments of the present application;
[0076] Figure 3 Generation of the random 0, 1 matrix of the embodiments of the present application;
[0077] Figure 4 Generation of the random permutation array of the embodiments of the present application. DETAILED DESCRIPTION
[0078] Exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure can be more thoroughly understood, and the scope of the present disclosure can be accurately conveyed to those skilled in the art.
[0079] The embodiments of the present application provide a side-channel attack resistant mask protection method based on a cyclic matrix, as shown in Figure 2 The method comprises the following steps:
[0080] In step S101, a random matrix is generated, and a random permutation array is generated based on the generated random matrix, wherein the random matrix only contains 1 and 0 elements. In some examples, generating a random matrix comprises:
[0081] A unit matrix of a preset order is repeatedly generated, and the unit matrix is subjected to random transformation for multiple times to obtain a random reversible matrix. The present application and subsequent examples take the generation of 16 mask values from an 8-order 0, 1 matrix as an example for illustration, and other applications can be adjusted according to actual needs. In a specific example, generating a random matrix comprises generating a 4-order unit matrix, and performing 32 random row transformations on the matrix to obtain a random reversible matrix.
[0082] The obtained multiple random reversible matrices are combined into a high-order matrix as a random matrix. Based on the foregoing example, as shown in Figure 3 Step 1 is repeated 4 times to obtain 4 reversible matrices M0, M1, M2, and M3, which are combined into an 8-order matrix The matrix is recorded as follows:
[0083]
[0084] In some embodiments, generating a random permutation array based on the generated random matrix comprises:
[0085] Randomly generating a number
[0086] Given an initialization out-of-order array of a number associated with the random matrix, for example, initialize the out-of-order array S = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] based on the foregoing example.
[0087] According to the generated number b, select a reversible matrix to update the out-of-order array;
[0088]
[0089] wherein M b mod 4 represents selecting a 4-order reversible matrix from , the operator represents an affine transformation, as shown in Figure 4 , and finally output to obtain a random permutation array.
[0090] In step S102, based on the generated random matrix, a mask set is generated by cyclic shift of the matrix.
[0091] In some embodiments, generating a mask set based on the generated random matrix by cyclic shift of the matrix includes:
[0092] The random matrix is taken as the generation matrix of the random mask, and a 0, 1 random matrix M of size 8x8 is set as the generation matrix of the random mask based on the foregoing example.
[0093] Each row row i (i∈{0,1,2,3,4,5,6,7}) and each column col i of the generation matrix is taken as a Boolean function truth table, respectively, and converted into a corresponding decimal number in the order set to obtain a random mask value m j (j∈{0,1,2,3,4,5,6,7}), for example, converted into a corresponding 8-bit decimal number in the order of left high bit and right low bit, to obtain 8 random mask values m j (j∈{0,1,2,3,4,5,6,7}), m j (j∈{8,9,10,11,12,13,14,15}) are respectively denoted as arrays mask r , array mask c , and i is the number of rows or columns of the generation matrix.
[0094] The mask values m j obtained based on the generation matrix are concatenated to obtain a random mask set mask = mask r ||mask c , wherein mask r is each row rowi The obtained mask value, mask c For each column col of the generated matrix i The obtained mask value.
[0095] Generate a random offset R, where R ≤ 32 for an 8th order matrix. The random matrix is then cyclically shifted according to the random offset R to obtain a new matrix M. R New matrix M R Used to generate new mask sets.
[0096] In step S103, based on the generated random permutation array, the S-box is scrambled in the AES encryption algorithm, and a mask is added based on the median value of the generated mask set at different positions.
[0097] In some embodiments, the process of performing scrambling calculations of the S-box in the AES encryption algorithm based on the generated random permutation array, and adding a mask based on the median value of the generated mask set at different positions, includes:
[0098] The mask in the first round of AES encryption includes:
[0099] According to matrix M 0 The generator matrix serves as the random mask, and a random offset R1 is generated, requiring R1 ≤ 32.
[0100] Generate a A random permutation P on;
[0101] X is a 4×4 plaintext state matrix, where each element is 8 bits. The initialization data matrix is obtained by XORing the given plaintext state matrix with the mask matrix element by element. mask0 is matrix M 0 The generated mask matrix:
[0102]
[0103] The initial data matrix is then combined with the round key to obtain the input matrix of the S-box.
[0104] Let S(x) be the S-box of AES, S m (x) is the masked S-box. Then the input and output of the masked S-box in the first round of encryption satisfy:
[0105]
[0106] Where t∈{0,1,…,15}, Given a number as input, execute it out of order using a random permutation P.
[0107] For the whole 128-bit input data The output of the new S-box represents
[0108]
[0109] The execution of the row shift (denoted as SR) and the column mixing (denoted as MC) operations are linear transformations, and the data already contains a mask, so the corresponding transformations are directly performed to obtain:
[0110] The next round of the round key is added to obtain
[0111] The output mask of the S-box is removed
[0112] The input mask of the next round is added
[0113] In some embodiments, according to the generated random permutation array, the S-box calculation of the AES encryption algorithm is disordered, and the mask is added to the intermediate value at different positions based on the generated mask set, including:
[0114] The mask in the intermediate round encryption of AES includes:
[0115] The input data matrix of the i-th round is
[0116] The random matrix M is generated according to R i A new mask matrix is formed, and a random offset R i+1 is generated, and the matrix M i The generated mask matrix is:
[0117] The input data is XORed with the mask, and the input of the S-box is
[0118] For the whole 128-bit input data
[0119] The newly calculated S-box satisfies:
[0120] The data obtained after the row shift and the column mixing is:
[0121]
[0122] The next round of the round key is added to obtain
[0123]
[0124] Remove the output mask of S-box
[0125] Add the input mask of next round
[0126]
[0127] In some embodiments, according to the generated random permutation array, the AES encryption algorithm performs the disorder calculation of S-box, and the mask is added to the intermediate value at different positions based on the generated mask set, including:
[0128] The mask in the AES tail round encryption includes:
[0129] The input data matrix of this round is The random matrix M is generated according to R i A new mask matrix is formed, and a random offset R i+1 is generated, and the matrix M i The generated mask matrix is:
[0130]
[0131] The input data is XORed with the mask, and the input of the S-box is
[0132] A random permutation Q on is generated;
[0133] S(x) is the S-box of AES, S m (x) is the S-box calculated with mask, and the input and output of the S-box with mask of the final round encryption satisfy:
[0134]
[0135] Where t∈{0,1,…,15}, is the number input, and the random permutation Q is used to perform disorder;
[0136] For the overall 128-bit input data The S-box satisfies:
[0137]
[0138] The data obtained after row shifting is:
[0139]
[0140] Add round key
[0141] Remove the output mask of S-box:
[0142]
[0143] outputting the encrypted ciphertext state matrix
[0144] The application provides a low-entropy mask protection scheme applied to an AES algorithm, which can resist a first-order CPA attack while using a small random number and reducing the implementation cost. The application also provides an implementation method of the mask protection scheme combined with the AES algorithm, which ensures the security of sensitive data in the encryption and decryption process and reduces the implementation cost of the traditional mask. The application introduces a 64-bit random 0, 1 matrix to realize the random generation and update of a mask set with a mask entropy of 4, greatly reduces the implementation cost compared with the traditional lookup table mask, and can resist the first-order CPA attack, thereby having strong security.
[0145] The application also provides a cyclic matrix-based side channel attack resistant mask protection system, which comprises a processor and a memory, and the memory stores a computer program, and the computer program is executed by the processor to realize the steps of the cyclic matrix-based side channel attack resistant mask protection method.
[0146] It should be noted that in the embodiments of the application, the terms "comprising", "containing" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.
[0147] The serial numbers of the above embodiments of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0148] From the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be realized by means of software and necessary general hardware platforms, of course, they can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) execute the methods described in the embodiments of the application.
[0149] The embodiments of the present application are described above with reference to the accompanying drawings, but the present application is not limited to the specific embodiments described above, and the specific embodiments described above are merely illustrative, but not restrictive, and a person of ordinary skill in the art can make many forms under the inspiration of the present application without departing from the purpose of the present application and the scope protected by the claims, and these all belong to the protection of the present application.
Claims
1. A cyclic matrix based side-channel attack resistant masking protection method, characterized in that, include: Generate a random matrix, and generate a random permutation array based on the generated random matrix, wherein the random matrix contains only 1 and 0 elements; Based on the generated random matrix, a mask set is generated by cyclically shifting the matrix; Based on the generated random permutation array, the S-box is shuffled in the AES encryption algorithm, and a mask is added based on the median value of the generated mask set at different positions. Generating random matrices includes: Repeatedly generate an identity matrix of a preset order, and perform multiple random transformations on the identity matrix to obtain a random invertible matrix; The obtained multiple random invertible matrices are combined into a higher-order matrix, which is used as the random matrix. Generating a random permutation array based on the generated random matrix includes: Random number generation ; Given an initial random array of a number associated with the random matrix; Choose an invertible matrix based on the generated number b to update the disordered array; The output is a random permutation array.
2. The side-channel attack protection method based on a cyclic matrix as described in claim 1, characterized in that, Based on the generated random matrix, a mask set is generated by cyclically shifting the matrix, including: The random matrix is used as the generator matrix of the random mask; Each row of the generated matrix Each column Each is treated as a truth table for a Boolean function, and converted to the corresponding decimal number in a predetermined order to obtain a random mask value. , i The number of rows or columns of the generated matrix; Connect the mask values obtained based on the generated matrix To obtain a random mask set ,in For each row of the generated matrix The obtained mask value, For each column of the generated matrix The obtained mask value; Generate a random offset The random matrix is based on a random offset. Global cyclic displacement to obtain a new matrix New matrix Used to generate new mask sets.
3. The side-channel attack protection method based on a cyclic matrix as described in claim 2, characterized in that, Based on the generated random permutation array, the S-box is shuffled using the AES encryption algorithm, and a mask is added based on the median value of the generated mask set at different positions, including: The mask in the first round of AES encryption includes: According to the matrix The generator matrix serves as the random mask, and the generator matrix generates random offsets. ; Generate a random permutations on ; The initialization data matrix is obtained by XORing the given plaintext state matrix and the mask matrix element by element. , For matrix The generated mask matrix; The initial data matrix is then combined with the round key to obtain the input matrix of the S-box. ; make For AES S-box, Given an S-box calculated with a mask, the input and output of the masked S-box in the first round of encryption satisfy the following: in , The input is a number, and random permutations are used. Out-of-order execution; For the overall input data The output of the new S-box represents Perform line shift Mixed columns ,include: Add the round key for the next round to get ; Remove the output mask of the S-box ; Add the input mask for the next round. .
4. The side-channel attack protection method based on a cyclic matrix as described in claim 3, characterized in that, Based on the generated random permutation array, the S-box is shuffled using the AES encryption algorithm, and a mask is added based on the median value of the generated mask set at different positions, including: The mask in AES intermediate wheel encryption includes: No. The input data matrix of the wheel is random matrix according to Generate a new mask matrix and then generate a random offset. ,matrix The generated mask matrix is: The input data is XORed with the mask, then the input to the S-box is... ; For the overall input data The newly calculated S-box satisfies: Data obtained after row shifting and column mixing Add the round key for the next round to get ; Remove the output mask of the S-box ; Add the input mask for the next round. 。 5. The side-channel attack protection method based on a cyclic matrix as described in claim 4, characterized in that, Based on the generated random permutation array, the S-box is shuffled using the AES encryption algorithm, and a mask is added based on the median value of the generated mask set at different positions, including: The mask in AES tailwheel encryption includes: The input data matrix for this round is: random matrix according to Generate a new mask matrix and then generate a random offset. ,matrix The generated mask matrix is: The input data is XORed with the mask, then the input to the S-box is... ; Generate a random permutations on ; For AES S-box, For the masked S-box, the final round of encrypted masked S-box input and output satisfy: in , The input is a number, and random permutations are used. Out-of-order execution; For the overall input data The S-box satisfies: The data is obtained after row shifting: Add round key ; Remove the output mask of the S-box: Output the encrypted ciphertext state matrix .
6. A side-channel attack protection system based on a circular matrix, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, implements the steps of the side-channel attack protection method based on a cyclic matrix as described in any one of claims 1 to 5.
Citation Information
Patent Citations
SM4 white box implementation method based on interference wheel and external coding
CN111884794A
Anti-side-channel AES white box encryption method and related equipment
CN116192364A