White box method and device of encryption algorithm, storage medium and electronic equipment

By using implicit equations and Hash algorithm to generate round keys in the encryption algorithm, combined with affine coding transformation, the problems of limited storage space and insufficient security in the existing technology are solved, and an efficient and secure encryption algorithm is realized. Boxed solution.

CN118659872AActive Publication Date: 2024-09-17BEIJING HAITAI FANGYUAN HIGH TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410769268.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-09-17
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

Existing white-box implementations of encryption algorithms rely on lookup tables, resulting in limited storage space, high costs, and unguaranteed security. Attackers can obtain intermediate data recovery keys through reverse engineering, making the data insecure.

Method used

Using a white-box encryption algorithm that does not require a lookup table, the Hash algorithm is used to generate round keys through multiple implicit equations embedded in the software to ensure that the round keys are not related to each other, and affine coding transformation is used to hide the key information. Only the coefficients of the equation system are stored to reduce storage space.

Benefits of technology

It achieves smaller storage space requirements, enhances security, and makes it difficult to recover affine transformations, providing higher security and storage efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118659872A
    Figure CN118659872A
Patent Text Reader

Abstract

The invention discloses a white-box method and device of an encryption algorithm, a storage medium and electronic equipment, and relates to the technical field of information security, the white-box method of the encryption algorithm comprises the following steps: obtaining a white-box key, the white-box key being a plurality of implicit equation sets {F0, F1,..., Fi,..., Fn-1} embedded into software; sequentially solving each implicit equation set Fi (Si + 1, Si) = 0, i = 0, 1,..., n-1, performing (i + 1) th-round encryption on the ciphertext Si obtained by the plaintext P based on the ith-round encryption, and obtaining the (i + 1) th-round ciphertext Si + 1; s0 is equal to P; after the nth round of encryption is completed, an implicit equation set Fn-1 (Sn, Sn-1) = 0 is solved, a ciphertext C = Sn is obtained, and n is an integer; wherein each implicit equation set Fi is generated based on a round key rki of the ith round of encryption, rki = Hash (i, Key), i = 0, 1,..., n-1, and Key is a preset master key of the encryption algorithm. According to the method, only the related equation set coefficients need to be stored, so that the required storage space is small, and high-security SM4 algorithm key protection is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of information security, and in particular to a white-box method, device, storage medium and electronic device for an encryption algorithm. Background Art

[0002] With the popularity of the Internet and smart terminals, all kinds of private data are read and encrypted and decrypted on the terminals, but the environment in which the terminals are located is often uncontrollable. Attackers or malicious users can obtain the intermediate data generated by algorithm encryption and decryption through reverse engineering and other technologies, and then recover the key, causing data insecurity. In order to prevent data leakage, most of them use cryptographic security hardware solutions or trusted execution environment technologies such as TEE, or white box implementations using lookup tables. For example, most of the existing white box implementations of SM4 are implemented using lookup tables, and larger transformations cannot be used due to storage space limitations. Therefore, these solutions still have high costs, limited storage space, and security cannot be guaranteed. Summary of the invention

[0003] The embodiments of the present application provide a white-box method, device, storage medium and electronic device for an encryption algorithm, which does not require a lookup table, that is, does not need to store a large number of lookup tables, but only needs to store the coefficients of the relevant set of equations, and the required storage space is relatively small.

[0004] In a first aspect, an embodiment of the present application provides a white-box method for an encryption algorithm, comprising the following steps:

[0005] Obtain a white box key, wherein the white box key is a set of multiple implicit equations {F0, F1, ...,

[0006] F i ,…,F n-1};

[0007] Solve each of the implicit equations F in turn i (S i+1 ,S i )=0,i=0,1,…,n-1, to realize the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext

[0008] S i+1 ;

[0009] And, S0 = P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n ,S n-1 )=0, and obtain the ciphertext C=S n , n is an integer;

[0010] Wherein, each of the implicit equations F i Based on the round key rk of the i-th round encryption i generate,

[0011] rk i =Hash(i,Key),i=0,1,…,n-1

[0012] Key is the pre-set master key of the encryption algorithm.

[0013] According to this method, due to the unidirectional characteristic of the Hash algorithm, this method can ensure that the round keys of n rounds are not related to each other, that is, it is not feasible to derive the key Key or other round key calculations through one or more round keys.

[0014] In one possible design, the white-box method of the encryption algorithm is characterized in that:

[0015] The encryption algorithm is SM4 algorithm;

[0016] The plaintext P is divided into a plurality of 128-bit blocks;

[0017] The plain text P is based on the implicit equation set {F0, F1, ..., F 31}, using F0, F1, ..., F 31 Perform 32 rounds of encryption to generate ciphertext C;

[0018] Each implicit system of equations F i (X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 )=0;

[0019] The S i+1 =X i+4 , the S i is (X i ,X i+1 ,X i+2 ,X i+3 ) function;

[0020] The X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 They are all 128-bit data blocks divided according to the plaintext P.

[0021] According to the design, the round key of each round is used to generate the implicit equation group of each round, and the round operation of each round is realized by solving the implicit equation group. The round operation is converted into the realization by solving the implicit equation group. Storing the equation group only requires storing the coefficients of the equation group. Affine coding transformation is performed on the equation group, which will not increase the storage space required by the scheme. Therefore, the scheme only requires a smaller storage space.

[0022] In a possible design, the white-box method of the encryption algorithm is characterized in that, in the implicit equation set {F0, F1, ..., F 31}, each of the implicit equations F k (X k ,X k+1 ,X k+2 ,X k+3 ,X k+4 ) has multiple equations, 0≤k≤31, and each equation is of the following form:

[0023]

[0024] in,

[0025] a k,i,j ,v k,j ,u k,i ,b k ∈{0,1},

[0026] (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63 ,x 64 ,…,x 95 ,x 96 ,…,x 127 ),

[0027] X i+4 =(y0,y1,…,y 31 )

[0028] According to the design, the implicit equations of each round are semi-affine equations, so the variables of the equations can be encoded and transformed using 32-order affine transformation or higher-order affine transformation (introducing some random equations based on the 32 equations). Storing the equations only requires storing the coefficients of the equations. After the equations are affine-coded, the required storage space remains almost unchanged, and the storage space required for the solution will not increase.

[0029] In one possible design, the white-box method of the encryption algorithm is characterized in that:

[0030] Each of the implicit equations F k Constructed as follows:

[0031] Step 1, implicit implementation of the inverse function

[0032] Obtain the inverse function on the finite field and convert it into an implicit representation, wherein the conversion into an implicit representation is to convert the inverse function y=x -1 , find a function U(x,y) such that

[0033] Step 2: Implicit realization of the S-box equation set

[0034] Convert the S-box transformation in the SM4 algorithm into the following n equations

[0035]

[0036] k=1,…,n

[0037] Wherein, X is the input of the S-box, Y is the output of the S-box, and the n equations are semi-affine equations about (x, y);

[0038] B and C are constants in the algebraic expression of the S-box, A k ,V k ,U k The associated parameters for the implicit realization of the system of equations for the inverse function in matrix form;

[0039] Step 3: Perform a linear transformation on the implicit realization equations of the S-box to obtain the realization of the implicit equations of the round function.

[0040] For SM4 round function

[0041]

[0042] It can be regarded as a linear transformation of the four S-boxes, and a linear transformation of the implicit realization equations of the S-boxes to obtain the implicit realization of the SM4 round function.

[0043] According to the design, by making linear transformation on the four S-boxes, the implicit realization equation group of the S-boxes can be linearly transformed to obtain the implicit realization of the SM4 round function, which has the characteristics of simple method and easy implementation.

[0044] In one possible design, the white-box method of the encryption algorithm is characterized in that the method also includes a step of performing an affine transformation on the implicit equation group of the S-box to hide the white-box key information carried by the equation group.

[0045] In a second aspect, an embodiment of the present application further provides a white-box device for an encryption algorithm, comprising the following steps:

[0046] An acquisition unit is used to acquire a white box key, wherein the white box key is a plurality of implicit equations {F0, F1, ..., F i ,…,F n-1};

[0047] A processing unit for solving each of the implicit equations F in turn i (S i+1 ,S i )=0,i=0,1,…,n-1, to realize the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext S i+1 ;

[0048] And, S0 = P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n ,S n-1 )=0, and obtain the ciphertext C=S n , n is an integer;

[0049] Wherein, each of the implicit equations F i Based on the round key rk of the i-th round encryption i generate,

[0050] rk i =Hash(i,Key),i=0,1,…,n-1

[0051] Key is the pre-set master key of the encryption algorithm.

[0052] In one possible design, the white-box device of the encryption algorithm is characterized in that:

[0053] The encryption algorithm is SM4 algorithm;

[0054] The plaintext P is divided into a plurality of 128-bit blocks;

[0055] The plain text P is based on the implicit equation set {F0, F1, ..., F 31}, using F0, F1, ..., F 31 Perform 32 rounds of encryption to generate ciphertext C;

[0056] Each implicit system of equations F i (X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 )=0;

[0057] The S i+1 =X i+4 , the Si is (X i ,X i+1 ,X i+2 ,X i+3 ) function;

[0058] The X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 They are all 128-bit data blocks divided according to the plaintext P.

[0059] In a possible design, the white-box device of the encryption algorithm is characterized in that, in the implicit equation set {F0, F1, ..., F 31}, each of the implicit equations F k (X k ,X k+1 ,X k+2 ,X k+3 ,X k+4 ) has multiple equations, 0≤k≤31, and each equation is of the following form:

[0060]

[0061] in,

[0062] a k,i,j ,v k,j ,u k,i ,b k ∈{0,1},

[0063] (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63 ,x 64 ,…,x 95 ,x 96 ,…,x 127 ),

[0064] X i+4 =(y0,y1,…,y 31 )

[0065] In one possible design, the white-box device of the encryption algorithm is characterized in that:

[0066] Each of the implicit equations F k Constructed as follows:

[0067] Step 1, implicit implementation of the inverse function

[0068] Obtain the inverse function on the finite field and convert it into an implicit representation, wherein the conversion into an implicit representation is to convert the inverse function y=x -1 , find a function U(x,y) such that

[0069] Step 2: Obtain the implicit implementation equations of the S-box

[0070] Convert the S-box transformation in the SM4 algorithm into the following n equations

[0071]

[0072] k=1,…,n

[0073] Wherein, X is the input of the S-box, Y is the output of the S-box, and the n equations are semi-affine equations about (x, y);

[0074] B and C are constants in the algebraic expression of the S-box, A k ,V k ,U k The associated parameters for the implicit realization of the system of equations for the inverse function in matrix form;

[0075] Step 3: Perform a linear transformation on the implicit realization equations of the S-box to obtain the realization of the implicit equations of the round function.

[0076] For SM4 round function

[0077]

[0078] It can be regarded as a linear transformation of the four S-boxes, and a linear transformation of the implicit realization equations of the S-boxes to obtain the implicit realization of the SM4 round function.

[0079] In one possible design, the white-box device for the encryption algorithm is characterized in that the method also includes the step of performing an affine transformation on the implicit equation group of the S-box to hide the white-box key information carried by the equation group.

[0080] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method of the first aspect and any one of its designs is implemented.

[0081] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the processor implements the first aspect and any one of the designed methods thereof.

[0082] The technical effects brought about by the second to fourth aspects and any one of their designs can refer to the technical effects brought about by the corresponding design of the first aspect, and will not be repeated here.

[0083] The embodiment of the present application has no restriction on the affine coding order of the implicit equation group of the round function, that is, the affine transformation makes it more difficult for an attacker to recover the affine transformation, thereby providing higher security; in addition, storing the affine equation group only requires storing the coefficients of the related equation group, and the required storage space is small, and the storage space required to store these equation groups remains unchanged after the affine coding transformation is performed on these equation groups. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0085] Figure 1 A schematic flow chart of a white-box method for an encryption algorithm provided in an embodiment of the present application;

[0086] Figure 2 A schematic diagram of the structure of a white-box device for an encryption algorithm provided in an embodiment of the present application;

[0087] Figure 3 A schematic diagram of the structure of a white-box device for an encryption algorithm provided in an embodiment of the present application. DETAILED DESCRIPTION

[0088] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0089] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0090] In the technical solution of this application, the collection, dissemination, and use of data are in compliance with the requirements of relevant national laws and regulations.

[0091] Before introducing a white-box conversion method provided by an embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.

[0092] The SM4 block cipher algorithm was released by the Office of the State Cryptography Administration in 2006, became the cryptography industry standard GM / T 0002-2012 in 2012, became the national standard GB / T 32907-2016 in 2016, and became the international standard ISO / IEC18033-3:2010 / AMD1:2021 in 2021.

[0093] The block length and key length of the SM4 algorithm are both 128 bits, the number of operation rounds is 32, and the algorithm structure of data encryption and data decryption is the same, except that the order of using the round keys is reversed. Therefore, we only need to consider the white box implementation of the SM4 encryption algorithm.

[0094] Assume the plaintext input to the SM4 algorithm is The ciphertext output is The round keys (rk0,rk1,…,rk 31 ),in The SM4 encryption operation process is as follows

[0095] (Y0,Y1,Y2,Y3)=(X 35 ,X 34 ,X 33 ,X 32 )

[0096] Among them, the synthetic permutation T(.) = L(τ(.)), L is a 32-bit linear transformation, and τ is composed of 4 parallel 8-bit S-boxes: τ(a0, a1, a2, a3) = (S(a0), S(a1), S(a2), S(a3)).

[0097] According to the structural characteristics of the key expansion algorithm, only four round keys are needed to calculate other round keys and the master key, resulting in data leakage. In addition, the lookup table-based solution needs to store the lookup table, and the size of the lookup table grows exponentially with the order of the encoding transformation, which means that more storage space is required. Therefore, larger encoding transformations cannot be used, affecting the security of the SM4 white box solution.

[0098] In order to solve the above problems, the present application provides a white-box method, device, storage medium and electronic device for an encryption algorithm, which can have no limit on the affine coding order of the implicit equation group of the round function. The larger the order, the more difficult it is for an attacker to recover the transformation, which means that the security is higher; storing the affine equation group only requires storing the coefficients of the related equation group, and the required storage space is small, and the storage space required to store these equation groups remains unchanged after the affine coding transformation is performed on these equation groups.

[0099] After introducing the technical background of the embodiment of the present application, the white-box method implementation process of the encryption algorithm provided by the embodiment of the present invention is described in detail below.

[0100] Figure 1 A flowchart of a white-box conversion method is shown by way of example.

[0101] Exemplarily, a white box key is obtained, wherein the white box key is a plurality of implicit equations {F0, F1, ..., F i ,…,F n-1};

[0102] Solve each of the implicit equations F in turn i (S i+1 ,S i )=0,i=0,1,…,n-1, to realize the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext S i+1 ;

[0103] And, S0 = P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n ,S n-1 )=0, and obtain the ciphertext C=S n , n is an integer;

[0104] Wherein, each of the implicit equations F iBased on the round key rk of the i-th round encryption i generate,

[0105] rk i =Hash(i,Key),i=0,1,…,n-1

[0106] Key is the pre-set master key of the encryption algorithm.

[0107] refer to Figure 1 The process shown in the figure, the method steps provided in the embodiment of the present application include:

[0108] Step 101, obtaining a white box key, wherein the white box key is a plurality of implicit equation groups embedded in the software.

[0109] Optionally, in step 101, a white box key is obtained, where the white box key is a set of multiple implicit equations {F0, F1, ..., F i ,…,F n-1}.

[0110] In specific implementation, a pre-set white box key may be obtained, or an automatically generated white box key may be obtained. There is no special provision here.

[0111] Step 102, solving each of the implicit equation groups in turn to achieve white-boxing of the key, wherein each of the implicit equation groups Fi is generated based on the round key rki of the i-th round of encryption.

[0112] Optionally, solve each of the implicit equations F in turn i (S i+1 ,S i )=0,i=0,1,…,n-1, to realize the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext S i+1 ;

[0113] And, S0 = P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n ,S n-1 )=0, and obtain the ciphertext C=S n , n is an integer;

[0114] Wherein, each of the implicit equations F i Based on the round key rk of the i-th round encryption i generate,

[0115] rk i =Hash(i,Key),i=0,1,…,n-1

[0116] Hash can be a cryptographic hash algorithm such as SM3. The new key expansion algorithm ensures that the 32 round keys are not related to each other. Due to the unidirectional nature of the hash function, it is not feasible to derive the key Key or other round keys through one or more of the round keys. Key is the pre-set master key of the encryption algorithm.

[0117] Optionally, the encryption algorithm is an SM4 algorithm; the plaintext P is divided into multiple 128-bit blocks;

[0118] The plain text P is based on the implicit equation set {F0, F1, ..., F 31}, using F0, F1, ..., F 31 Perform 32 rounds of encryption to generate ciphertext C; each implicit equation group F i (X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 )=0;the S i+1 =X i+4 , the S i is (X i ,X i+1 ,X i+2 ,X i+3 ) function; the X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 They are all 128-bit data blocks divided according to the plaintext P.

[0119] Exemplarily, the SM4 algorithm outputs information as 32 sets of equations {F0, F1, ..., F 31}, where each set of equations F k There are 32 equations and each equation is of the form

[0120]

[0121] in,

[0122] a k,i,j ,v k,j ,u k,i ,b k ∈{0,1},

[0123] (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63,x 64 ,…,x 95 ,x 96 ,…,x 127 ),

[0124] X i+4 =(y0,y1,…,y 31 ).

[0125] That is, the equation system F k Each equation in is a semi-affine equation (both about x and about y are affine transformations). This is achieved by solving a system of implicit equations.

[0126] Specific examples are:

[0127] For each round of operation Make an implicit transformation, that is, find the equation system Func i , to satisfy The SM4 algorithm outputs information as 32 sets of equations {F0, F1, …, F 31}, where each set of equations F k There are 32 equations and each equation is of the form

[0128]

[0129] in,

[0130] a k,i,j ,v k,j ,u k,i ,b k ∈{0,1},

[0131] (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63 ,x 64 ,…,x 95 ,x 96 ,…,x 127 ),

[0132] X i+4 =(y0,y1,…,y 31 ).

[0133] Furthermore, each of the implicit equations F k Constructed as follows:

[0134] Step 1: Implicit realization of inverse function Obtain the inverse function on the finite field and convert it into an implicit representation. The conversion into an implicit representation is to convert the inverse function y=x -1 , find a function U(x,y) such that

[0135] Furthermore, the S-box in the SM4 algorithm is composed of the inverse function on the finite field and the affine transformation, which converts the inverse function on the finite field into an implicit representation, that is, the inverse function y = x -1 , find a function U(x,y) such that

[0136]

[0137] And for any input x=x0, y can be uniquely solved according to U(x0,y)=0.

[0138] Inverse function The definition is as follows:

[0139]

[0140] Where, m|n. When m=1,

[0141] Given Any basis {α1,…,α n}, we call {β1,…,β n} is {α1,…,α n} dual basis, if

[0142]

[0143] in, For any set of bases, there exists a dual basis. Let {α1,α2,…,α n}for A set of bases, then the matrix is reversible, and the inverse matrix has the form

[0144]

[0145] The first row of the matrix {β1,β2,…,β n} is {α1,α2,…,α n The dual basis of}.

[0146] In which, let {α1,…,α n},{β1,…,β n} is a finite field A pair of dual bases, denoted by x=x1α1+…+x n α n,y=y1α1+…+y n α n , then for any Power Map y = x a satisfy

[0147]

[0148] in,

[0149] We choose a special i,j ,v j Let the right side of the above equation be a linear equation about x, that is,

[0150]

[0151] Next we find n groups of a i,j ,v j , respectively Make

[0152]

[0153] is the linear transformation about x, and the corresponding coefficients are Then we can get the following n linearly independent equations

[0154]

[0155] We express the above equation in matrix form

[0156]

[0157] in,

[0158]

[0159] Thus, we can obtain the above n equations about y based on the input information x, and then solve y by solving the equations. For example, we can randomly generate a set of

[0160]

[0161] And let U k =0, calculate A k The values ​​are as follows

[0162]

[0163] Thus we get a semi-affine equation about (x,y):

[0164] (x2+x3+x5+x6)y1+(x1+x3+x4+x7+x8+1)y2+(x1+x2+x5+x6+x8+1)y3+(x3+x4+x6+x8)y4+(x1+x2+x4+x6+x7+1)y5+(x2+x4+x5+x7+x8+1)y6+(x2+x3+x5+x6+x7+x8)y7+(x1+x3+x4+x5+x6+x7+x8)y8=0 Similarly, we choose 8 sets of linearly independent V k , we can get 8 semi-affine equations about (x,y).

[0165] Based on the above analysis, we can transform the inverse function on the finite field into an implicit representation, and use the implicit equations to solve the output variable y according to the input variable x to realize the implicit calculation of the inverse function.

[0166] Step 2: Obtain the implicit implementation equations of the S-box

[0167] Convert the S-box transformation in the SM4 algorithm into the following n equations

[0168]

[0169] k=1,…,n

[0170] Wherein, X is the input of the S-box, Y is the output of the S-box, and the n equations are semi-affine equations about (x, y);

[0171] B and C are constants in the algebraic expression of the S-box, A k ,V k ,U k The parameters associated with the implicitly realized system of equations for the inverse function expressed in matrix form.

[0172] Furthermore, in this section, we transform the S-box in the SM4 algorithm into an implicit representation, that is, transform the S-box y = S(x) and find the function U(x, y) such that

[0173]

[0174] And for any input x=x0, y can be uniquely solved according to U(x0,y)=0.

[0175] The algebraic expression of the S-box in the SM4 algorithm is

[0176] S(x)=(x T ·B+C) -1 ·B+C

[0177] Among them, addition and multiplication are defined in the finite field GF(2 8 ), the irreducible polynomial is

[0178] f(x)=x 8 +x 7 +x 6 +x 5 +x 4 +x 2 +1

[0179] The matrix B is

[0180]

[0181] The vector C is

[0182] C=(1,1,0,0,1,0,1,1).

[0183] Optional The power function y=x a Transformed into n (=8) linearly independent equations

[0184]

[0185] Among them, B and C are constants in the S-box algebraic expression, that is,

[0186]

[0187] C=(1,1,0,0,1,0,1,1)

[0188] A k ,V k ,U k To represent the relevant parameters of the implicit realization equation group of the inverse function in matrix form, the specific values ​​are determined by the round key and the selected relevant parameters.

[0189] make

[0190] x′ T =x T ·B+C,y′ T =(y T +C)B -1

[0191] but

[0192]

[0193] Thus, we can transform the S-box transformation into the following n equations

[0194]

[0195] k=1,…,n

[0196] It is easy to see that the above equation is still a semi-affine equation about (x, y), so we convert the S-box transformation of SM4 into an implicit implementation.

[0197] Step 3, perform a linear transformation on the implicit realization equation group of the S-box to obtain the realization of the implicit equation group of the round function.

[0198] Specifically, for the round function of SM4

[0199]

[0200] Think of it as a linear transformation of the four S-boxes and a linear transformation of the implicit realization equations of the S-boxes.

[0201] Obtains implicit implementation of SM4 round functions.

[0202] It should be noted that step 3 is to construct an implicit implementation of the round function, and the round function is composed of an S-box transformation and a composite linear transformation. Further, the S-box is composed of an inverse function and a composite affine transformation. Therefore, the whole process is as described: first, the inverse function is implicitly implemented, and then an affine transformation is composited on the implementation to obtain an implicit implementation of the S-box. Further, a linear transformation is composited on the implicit implementation of the S-box to obtain an implicit implementation of the SM4 round function.

[0203] Specifically, the implicit equations are constructed using steps 1, 2, and 3. A specific example is: the S-box expression in the SM4 algorithm is

[0204] S(x)=(x T ·B+C) -1 ·B+C

[0205] The addition and multiplication are defined in the finite field GF(2 8 ), the irreducible polynomial is

[0206] f(x)=x 8 +x 7 +x 6 +x 5 +x 4 +x 2 +1

[0207] That is, the inverse function is GF(2 8 ) modulo f(x) to find the inverse.

[0208] We first implement the implicit conversion of the inverse function, that is, to find a semi-affine system of equations U(x,y)=0, so that given the value of x, we can solve the system of equations to get y, and y=x -1 We can find such an equation

[0209] (x2+x3+x5+x6)y1+(x1+x3+x4+x7+x8+1)y2+(x1+x2+x5+x6+x8+1)y3+(x3+x4+x6+x8)y4+(x1+x2+x 4+x6+x7+1)y5+(x2+x4+x5+x7+x8+1)y6+(x2+x3+x5+x6+x7+x8)y7+(x1+x3+x4+x5+x6+x7+x8)y8=0

[0210] We find 8 of these equations to form a system of equations, thus obtaining the system of equations U(x,y) = 0. Once we have this system of equations, because the system of equations is an affine equation with respect to x or y, in short, we can use a matrix to represent each of the above equations: x·U xy ·y T =0, where x = (x0, x1, ..., x7), y = (y0, y1, ..., y7), U xy is an 8-order binary matrix. Therefore, we perform affine transformation on x and y as needed, that is, x·Q x ·U xy Q y ·y T =0, where Q x ,Q y Can be any reversible affine transformation.

[0211] In the above steps 1, 2, and 3, the implicit realization equation group of the S-box is obtained by performing an affine transformation on the implicit realization equation group of the inverse function, and the affine transformation is the relevant constants in the algebraic expression of S; the implicit realization of the round function is obtained by performing a linear transformation based on the implicit realization of the S-box, and the linear transformation is the linear transformation in the round function of the SM4 algorithm.

[0212] Based on the above steps 1, 2, and 3, we transform the SM4 wheel function into an implicit equation system,

[0213]

[0214] We can hide the key information carried by the implicit equations by performing an affine transformation on the implicit equations.

[0215] U′(x′,y′)=0,x′=Px+p,y′=Qy+q

[0216] Thus, the implicit white-box implementation equation group after the SM4 encoding transformation is obtained.

[0217] In this way, the round key is hidden in the implicit equation group, and the information is encrypted by solving 32 rounds of implicit equations. Since the privacy equation group is a semi-affine equation, storing the equation only requires storing the correlation coefficient, and encoding the implicit equation does not increase the storage space. Therefore, a larger-scale affine encoding transformation can be used to encode and protect the intermediate data, thereby providing higher security.

[0218] Based on the same technical concept, the present application exemplarily provides a white box conversion device. The device can be used to perform the actions described in the above method embodiment. In this embodiment, the structure of the device can be as follows: Figure 2 shown.

[0219] like Figure 2 As shown, the present application exemplarily provides a white-box device for an encryption algorithm, which may include an acquisition unit 201 and a processing unit 202.

[0220] When implementing the functions of the present application, the acquisition unit 201 is used to acquire a white box key, which is a set of multiple implicit equations {F0, F1, ..., F i ,…,F n-1}.

[0221] The processing unit 202 is used to solve each of the implicit equations F in sequence i (S i+1 ,S i )=0,i=0,1,…,n-1, to realize the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext S i+1 ;

[0222] And, S0 = P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n ,S n-1 )=0, and obtain the ciphertext C=S n , n is an integer;

[0223] Wherein, each of the implicit equations F i Based on the round key rk of the i-th round encryption i generate,

[0224] rk i =Hash(i,Key),i=0,1,…,n-1

[0225] Key is the pre-set master key of the encryption algorithm.

[0226] The plaintext P is divided into a plurality of 128-bit blocks;

[0227] The plain text P is based on the implicit equation set {F0, F1, ..., F 31}, using F0, F1, ..., F 31 Perform 32 rounds of encryption to generate ciphertext C;

[0228] Each implicit system of equations F i (X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 )=0;

[0229] The S i+1 =X i+4 ,

[0230] The S i is (X i ,X i+1 ,X i+2 ,X i+3 ) function;

[0231] The X i ,X i+1 ,X i+2 ,X i+3 ,X i+4 They are all 128-bit data blocks divided according to the plaintext P.

[0232] In the implicit equation system {F0, F1, ..., F 31}, each of the implicit equations F k (X k ,X k+1 ,X k+2 ,X k+3 ,X k+4 ) has multiple equations, 0≤k≤31, and each equation is of the following form:

[0233]

[0234] in,

[0235] a k,i,j ,v k,j ,u k,i ,b k ∈{0,1},

[0236] (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63 ,x 64,…,x 95 ,x 96 ,…,x 127 ),

[0237] X i+4 =(y0,y1,…,y 31 )

[0238] Each of the implicit equations F k Constructed as follows:

[0239] Step 1, implicit implementation of the inverse function

[0240] Obtain the inverse function on the finite field and convert it into an implicit representation, wherein the conversion into an implicit representation is to convert the inverse function y=x -1 , find a function U(x,y) such that

[0241] Step 2: Obtain the implicit implementation equations of the S-box

[0242] Convert the S-box transformation in the SM4 algorithm into the following n equations

[0243]

[0244] k=1,…,n

[0245] Wherein, X is the input of the S-box, Y is the output of the S-box, and the n equations are semi-affine equations about (x, y);

[0246] B and C are constants in the algebraic expression of the S-box, A k ,V k ,U k The associated parameters for the implicit realization of the system of equations for the inverse function in matrix form;

[0247] Step 3: Perform a linear transformation on the implicit realization equations of the S-box to obtain the realization of the implicit equations of the round function.

[0248] For SM4 round function

[0249]

[0250] Think of it as a linear transformation of the four S-boxes and a linear transformation of the implicit realization equations of the S-boxes.

[0251] Obtains implicit implementation of SM4 round functions.

[0252] The processing unit 202 also includes performing an affine transformation on the implicit equation group to hide the key information carried by the equation group.

[0253] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. The electronic device can be used to perform the actions described in the above method embodiment. In this embodiment, the structure of the electronic device can be as follows: Figure 3 As shown, it includes a memory 301 and one or more processors 302 .

[0254] The memory 301 is used to store computer programs executed by the processor 302. The memory 301 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0255] The memory 301 may be a volatile memory, such as a random-access memory (RAM); the memory 301 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 301 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 301 may be a combination of the above memories.

[0256] The processor 302 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 302 is used to implement the above method when calling the computer program stored in the memory 301.

[0257] The specific connection medium between the memory 301 and the processor 302 is not limited in the embodiment of the present application. Figure 3 In the embodiment, the memory 301 and the processor 302 are connected via a bus 303. The bus 303 is connected to the processor 302 via a bus 303. Figure 3 The connections between other components are shown in bold lines, and are not intended to be limiting. Bus 303 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0258] Optionally, the processor 302 may be configured to execute any one or more of the above actions executed by the acquisition unit 201 and the processing unit 202 .

[0259] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method in the above embodiment.

[0260] The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0261] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A white-box method for an encryption algorithm, characterized in that: The steps include: Obtain a white box key, which is a set of multiple implicit equations {F0, F1, ..., F i , …, F n-1 }; Solve each of the implicit equations F in turn i (S i+1 , S i )=0,i=0,1,…,n-1,implement the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext S i+1 ; and , S0=P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n , S n-1 )=0, and obtain the ciphertext C=S n , n is an integer; Wherein, each of the implicit equations F i Based on the round key rk of the i-th round encryption i generate, rk i =Hash(i,Key),i=0,1,…,n-1 Key is the pre-set master key of the encryption algorithm.

2. The white-box method of the encryption algorithm according to claim 1, characterized in that: The encryption algorithm is SM4 algorithm; The plaintext P is divided into a plurality of 128-bit blocks; The plain text P is based on the implicit equation set {F0, F1, ..., F 31 }, using F0, F1, ..., F 31 Perform 32 rounds of encryption to generate ciphertext C; Each implicit system of equations F i (X i , X i+1 , X i+2 , X i+3 , X i+4 )=0; The S i+1 =X i+4 , The S i is (X i , X i+1 , X i+2 , X i+3 ) function; The X i , X i+1 , X i+2 , X i+3 , X i+4 They are all 128-bit data blocks divided according to the plaintext P.

3. The white-box method of the encryption algorithm according to claim 2, characterized in that: In the implicit equation system {F0, F1, ..., F 31 }, each of the implicit equations F k (X k , X k+1 , X k+2 , X k+3 , X k+4 ) has multiple equations, 0≤k≤31, and each equation is of the following form: in, a k,i,j ,v k,j ,u k,i ,b k ∈{0,1}, (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63 ,x 64 ,…,x 95 ,x 96 ,…,x 127 ), X i+4 =(y0,y1,…,y 31 )。 4. The white-box method of the encryption algorithm according to claim 3, characterized in that: Each of the implicit equations F k Constructed as follows: Step 1, implicit implementation of the inverse function Obtain the inverse function on the finite field and convert it into an implicit representation, wherein the conversion into an implicit representation is to convert the inverse function y=x -1 , find a function U(x, y) such that Step 2: Obtain the implicit implementation equations of the S-box Convert the S-box transformation in the SM4 algorithm into the following n equations Wherein, X is the input of the S-box, Y is the output of the S-box, and the n equations are semi-affine equations about (x, y); B and C are constants in the algebraic expression of the S-box, A k , V k , U k The associated parameters for the implicit realization of the system of equations for the inverse function in matrix form; Step 3: Perform a linear transformation on the implicit realization equations of the S-box to obtain the realization of the implicit equations of the round function. For SM4 round function It can be regarded as a linear transformation of the four S-boxes, and a linear transformation of the implicit realization equations of the S-boxes to obtain the implicit realization of the SM4 round function.

5. The white-box method of the encryption algorithm according to claim 4, characterized in that: The method also includes the step of performing an affine transformation on the implicit equation group of the S-box to hide the white box key information carried by the equation group.

6. A white-box device for an encryption algorithm, characterized in that: The device comprises: An acquisition unit is used to acquire a white box key, wherein the white box key is a plurality of implicit equations {F0, F1, ..., F i , …, F n-1 }; A processing unit for solving each of the implicit equations F in turn i (S i+1 , S i )=0,i=0,1,…,n-1,implement the ciphertext S obtained by encrypting the plaintext P based on the i-th round i Perform the i+1th round of encryption to obtain the i+1th round of ciphertext S i+1 ; And, S0 = P; after the nth round of encryption is completed, solve the implicit equation group F n-1 (S n , S n-1 )=0, and obtain the ciphertext C=S n , n is an integer; Wherein, each of the implicit equations F i Based on the round key rk of the i-th round encryption i generate, rk i =Hash(i,Key),i=0,1,…,n-1 Key is the pre-set master key of the encryption algorithm.

7. The device according to claim 6, characterized in that The encryption algorithm is SM4 algorithm; The plaintext P is divided into a plurality of 128-bit blocks; The plain text P is based on the implicit equation set {F0, F1, ..., F 31 }, using F0, F1, ..., F 31 Perform 32 rounds of encryption to generate ciphertext C; Each implicit system of equations F i (X i , X i+1 , X i+2 , X i+3 , X i+4 )=0; The S i+1 =X i+4 , The S i is (X i , X i+1 , X i+2 , X i+3 ) function; The X i , X i+1 , X i+2 , X i+3 , X i+4 They are all 128-bit data blocks divided according to the plaintext P.

8. The device according to claim 7, characterized in that In the implicit equation system {F0, F1, ..., F 31 }, each of the implicit equations F k (X k , X k+1 , X k+2 , X k+3 , X k+4 ) has multiple equations, 0≤k≤31, and each equation is of the following form: in, a k,i,j ,v k,j ,u k,i ,b k ∈{0,1}, (X i ,X i+1 ,X i+2 ,X i+3 )=(x0,…,x 31 ,x 32 ,…,x 63 ,x 64 ,…,x 95 ,x 96 ,…,x 127 ), X i+4 =(y0,y1,…,y 31 )。 9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of any one of the methods of claims 1-5.

10. A computer-readable storage medium, characterized in that: It includes program codes. When the program codes are run on an electronic device, the program codes are used to enable the electronic device to execute the steps of any method described in claims 1-5.

Citation Information

Patent Citations

  • SM4 algorithm white box implementation method and device

    CN109951273A

  • 16-wheel SM4-128 / 128 white box password implementation method

    CN110278072A

  • Implementation method of SM4 white box constructed by using self-equivalence coding and implicit function of self-equivalence coding

    CN117997513A