Disclosure of Invention
The application provides an AES-based white-box encryption and decryption method, an AES-based white-box encryption and decryption device, storage equipment and a storage medium, which can solve the problem that the existing public white-box AES implementation scheme is not feasible in industrial Internet application, and realize the balance among operation efficiency, operation memory and security in industrial Internet application scenes.
In order to achieve the above object, the technical scheme adopted by the embodiment of the application is as follows:
In a first aspect, an embodiment of the present application provides a white-box encryption and decryption method based on AES, where the method includes:
Step S1, generating a table Type I and a first matrix according to an encryption round key based on each round of circulation of an advanced encryption standard;
Step S2, the first matrix is multiplied by each round of circulation of the advanced encryption standard, then the look-up table Type I is searched to obtain a second matrix, and encryption of the advanced encryption standard is completed;
s3, carrying out key transformation on the encryption round key to obtain a decryption round key;
And S4, replacing the encryption round key with the decryption round key, and sequentially performing the step S1 and the step S2 to obtain a second matrix, thereby completing the decryption of the advanced encryption standard.
In one possible implementation manner, the step of generating the table Type i and the first matrix according to the encryption round key includes:
Adopting CEJO frames to generate a table TMC i according to the encryption round key;
selecting a random linear coding generation table Type I from CEJO frames;
Adding prepositive and postsitive linear codes of the ith wheel and the ith wheel in the table Type I, decoding, and then carrying out the circulation of the advanced encryption standard by combining the table TMC i and the table Type I;
generating a first matrix in the loop enables decoding from wheel to wheel.
In one possible embodiment, the method further comprises:
Binary exclusive-or operators in a programming language are used for exclusive-or.
In one possible implementation, the advanced encryption standard employs any of AES-128, AES-192, AES-256.
In one possible implementation, the step of performing a key transformation on the encryption round key to obtain the decryption round key includes:
Taking the encryption round key of the first round as the decryption round key of the last round;
The encryption round key of each round in the middle is converted into the decryption round key of each round in the middle of the reverse order by adopting an inverse operator InvMixColumns;
And taking the encryption round key of the last round as the decryption round key of the first round to obtain the decryption round key.
In a second aspect, an embodiment of the present application further provides an AES-based white-box encryption and decryption apparatus, where the apparatus includes:
the generation module is used for generating a table Type I and a first matrix according to the encryption round key based on each round of circulation of the advanced encryption standard;
the encryption module is used for multiplying the first matrix by each round of circulation of the advanced encryption standard, and then looking up the table Type I to obtain a second matrix to complete encryption of the advanced encryption standard;
the key conversion module is used for carrying out key conversion on the encryption round key to obtain a decryption round key;
And the decryption module is used for replacing the encryption round key with the decryption round key, and sequentially executing the steps of the generation module and the encryption module to obtain a second matrix, so as to finish decryption of the advanced encryption standard.
In a possible implementation manner, the generating module is further configured to:
Adopting CEJO frames to generate a table TMC i according to the encryption round key;
selecting a random linear coding generation table Type I from CEJO frames;
Adding prepositive and postsitive linear codes of the ith wheel and the ith wheel in the table Type I, decoding, and then carrying out the circulation of the advanced encryption standard by combining the table TMC i and the table Type I;
generating a first matrix in the loop enables decoding from wheel to wheel.
In one possible implementation, the key transformation module is further configured to:
Taking the encryption round key of the first round as the decryption round key of the last round;
The encryption round key of each round in the middle is converted into the decryption round key of each round in the middle of the reverse order by adopting an inverse operator InvMixColumns;
And taking the encryption round key of the last round as the decryption round key of the first round to obtain the decryption round key.
In a third aspect, an embodiment of the present application further provides a storage device, including a processor, a memory, and a bus, where the memory stores program instructions executable by the processor, and when the storage device is running, the processor communicates with the memory through the bus, and the processor executes the program instructions to execute the AES-based white-box encryption and decryption method according to any one of the first aspect.
In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the computer program is executed by a processor to perform the AES-based white-box encryption and decryption method according to any one of the first aspects.
The inventive arrangements described above and their further alternatives may be freely combined to form a plurality of arrangements, all of which are employable and claimed by the present application, and the present application may be freely combined between (non-conflicting choice) choices and with other choices. Various combinations will be apparent to those skilled in the art from a review of the present disclosure, and are not intended to be exhaustive or all of the present disclosure.
The embodiment of the application provides a white-box encryption and decryption method, device, storage equipment and medium based on AES (advanced encryption standard), which are characterized in that firstly, each round of circulation based on the advanced encryption standard is generated into a table Type I and a first matrix according to the encryption round key, then each round of circulation of the advanced encryption standard is multiplied left by the first matrix, then the table Type I is searched to obtain a second matrix, encryption of the advanced encryption standard is completed, then the encryption round key is subjected to key transformation to obtain a decryption round key, finally, the decryption round key is replaced by the encryption round key, and the encryption process of the advanced encryption standard is sequentially repeated to obtain the second matrix, so that decryption of the advanced encryption standard is completed.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that like reference numerals and letters refer to like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
It should be noted that the features of the embodiments of the present application may be combined with each other without conflict.
In the prior art, since researchers have focused on approaching the security of white-box AES to the strong security of black-box AES, feasibility in engineering applications is often ignored. These white-box AES implementations may suffer from problems of data refresh delay due to inefficient operation (e.g., CEJO frames) and overload of the terminal device due to excessive operating memory (e.g., the Xiao-Lai/schottky scheme).
Therefore, in order to solve the technical problems described above, the embodiments of the present application provide a white-box encryption and decryption method, apparatus, storage device, and medium based on AES, which satisfy the balance among operating efficiency, operating memory, and security in the application scenario of industrial internet, realize encryption and decryption speed without obvious difference, negligible additional memory occupation, and meet the weak security requirement in the terminal equipment scenario compared with black-box AES, and will be described in detail below.
Referring to fig. 1, fig. 1 shows an AES-based white-box encryption and decryption method according to an embodiment of the present application, where the method includes:
step S1, generating a table Type I and a first matrix according to an encryption round key based on each round of circulation of an advanced encryption standard.
The step before generating the table Type i and the first matrix further includes:
The number of encryption and decryption rounds of the advanced encryption standard is set to Nr, respectively, each round of the advanced encryption standard being Roundi (i=1,.,. The number of rounds, nr), where Nr represents the total number of rounds in the AES encryption or decryption process, and Roundi represents each specific round operation, whether the ith round in the encryption or decryption process, the main difference between them being the specific operation content and order performed in each round.
In addition, four operators included in each round of the advanced encryption standard are AddRoundKey, subBytes, shiftRows, mixColumns, and an inverse operator of the operators included in each round of the advanced encryption standard is InvSubBytes, invShiftRows, invMixColumns. If the output of any operator F with input x is F (x) and the output of any operator G with input x is G (x), the complex operator with input x is recordedThe output of (2) isNotation TypeIa, typeIb, typeII, typeIII, typeIV of 5 tables in CEJO frames is followed.
Wherein the advanced encryption standard employs any one of AES-128, AES-192, and AES-256.
In one possible implementation manner, the step of generating the table Type i and the first matrix according to the encryption round key includes:
Adopting CEJO frames to generate a table TMC i according to the encryption round key;
selecting a random linear coding generation table Type I from CEJO frames;
Adding prepositive and postsitive linear codes of the ith wheel and the ith wheel in the table Type I, decoding, and then carrying out the circulation of the advanced encryption standard by combining the table TMC i and the table Type I;
generating a first matrix in the loop enables decoding from wheel to wheel.
The encryption step is that each round of the advanced encryption standard is Roundi, i is more than or equal to 1 and less than or equal to Nr, a table TypeII and a first matrix M i are generated according to an encryption round key K i-1 of the ith round, a CEJO framework is adopted to generate a table TMC i according to an encryption round key K i-1, the random nonlinear coding selected by the CEJO framework is modified to be the random linear coding selected to generate a table TypeII, and the front linear coding, the rear linear coding and the decoding of the ith round are added in the table Type I IIAnd) And then combining the table TMC i and the table Type I to carry out the circulation of the advanced encryption standard, wherein the circulation process is as follows:
The loop shows a series of steps in the AES encryption process, which is divided into rounds, each round having a specific step to process the incoming data. This means that after the last round the data has been fully encrypted, forming ciphertext.
This expression demonstrates the process of multiple rounds of linear encoding, where each round applies a different matrix multiplication, increasing the complexity and security of the cryptosystem.
Table TypeIII in CEJO framework is replaced by a first matrix in an embodiment of the application that generates the first matrix in a loop to effect the round-to-round decoding:
Round1:Mi:=ShiftRows;
this means that the first matrix of the first round is a row shift matrix (ShiftRows), the first matrix of the i-th round is the decoding of the post-linear encoding of the previous round Sequentially passing through a row shift matrix (ShiftRows) and a matrix obtained by the post linear coding (L i-1) of the round.
And S2, multiplying the first matrix by each round of circulation of the advanced encryption standard, and then searching the table Type I to obtain a second matrix, thereby completing encryption of the advanced encryption standard.
Roundi (i=1,) for each round of advanced encryption standard, nr, the encryption flow is completed by looking up TypeII after the first matrix M i is multiplied left.
In one possible embodiment, the method further comprises:
Binary exclusive-or operators in a programming language are used for exclusive-or.
At a particular stage (Roundi), a matrix is first left multiplied by the first matrix M i and then queried according to some type of table (TypeII). Unlike the other approach (CEJO framework), since random linear encoding is employed, binary exclusive-or operators provided by some programming languages, such as the ++symbols in C++, can be used directly when performing exclusive-or operations on data of 32-bits and 128-bits in length after completion of the look-up table TypeII operation.
Considering symmetry of AES encryption and decryption, decryption includes the steps of:
And S3, performing key transformation on the encryption round key to obtain the encryption round key.
In one possible implementation, the step of performing a key transformation on the encryption round key to obtain the decryption round key includes:
Taking the encryption round key of the first round as the decryption round key of the last round;
The encryption round key of each round in the middle is converted into the decryption round key of each round in the middle of the reverse order by adopting an inverse operator InvMixColumns;
And taking the encryption round key of the last round as the decryption round key of the first round to obtain the decryption round key.
Assuming that the encryption round key is K i, the decryption round key is K i', and the formula of the key transformation is:
the first row represents the decryption round key K' 0 for the first round as equal to the encryption round key for the Nr-th round The second row represents the keys from round 1 to round N r -1 by applying an inverse mix column transform to the keys of the previous round, and the last row represents the decryption round key of the last roundEqual to the encryption round key K 0 for the first round.
And S4, replacing the encryption round key with the decryption round key, and sequentially performing the step S1 and the step S2 to obtain a second matrix, thereby completing the decryption of the advanced encryption standard.
The AES-128 is adopted to compare with CEJO frames and the Xiao-Lai/Sho-Lai scheme.
Unlike the CEJO framework, the embodiment of the present application does not require the generation (336 kB) and lookup (2688 times) of TypeIV, and instead the overhead generated by the binary exclusive-or operation is negligible.
Unlike the CEJO framework, embodiments of the present application do not require the generation (128 kB) and lookup (32 times) of Type Ia and Type Ib, taking into account the impractical external input/output coding on actual product logic and the inconvenience of engineering implementation of separate input/output coding for each table.
Unlike the CEJO framework, similar to the Xiao-Lai/sho-coming scheme, the embodiment of the application uses 10 matrix multiplications to achieve the decoding from wheel to wheel (20 kB), without the need for Type III generation (144 kB) and lookup (144 times).
Unlike the CEJO framework, which selects 8 16-bit to 32-bit table TMCs (10 rounds total 20480 kB) similar to the Xiaao-Lai/Sho-Law scheme, the present embodiment uses 16 8-bit to 32-bit table TMCs (10 rounds total 160 kB).
Compared with the prior art, the embodiment of the application has the beneficial effects that:
First, theoretically, compared with CEJO frames (3008 table lookups, 752 kB) and the Xiao-Lai/schottky scheme (80 table lookups, 40 xors, 11 matrix multiplications, 20502 kB), the embodiment of the application (144 table lookups, 216 xors, 11 matrix multiplications, 164 kB) has the advantages of high efficiency and light weight, and is very similar to the performance of black box AES (160 table lookups, 152 xors, 4 kB).
Second, compared with CEJO frames (2 22) and the Xiao-Lai/sho-Lai scheme (2 32), the embodiment of the application has the safety between about 2 12 and 2 22, belongs to weak safety, and is enough to meet the requirements of mobile terminals under the consolidation of reinforcement technology and the like.
Thirdly, through a large number of tests, the encryption/decryption method and device for the single plaintext/ciphertext with the size of 500kB, 1mB and 2mB in the embodiment of the application have the time consumption of 79.1ms, 98.8ms and 117.8ms respectively in the ECB mode, and have the time consumption of 76.8ms, 99.3ms and 162.2ms respectively in the CBC mode, so that macroscopic delay of real-time data refreshing can not be caused.
In a second aspect, an embodiment of the present application further provides an AES-based white-box encryption and decryption apparatus, where the apparatus includes:
the generation module is used for generating a table Type I and a first matrix according to the encryption round key based on each round of circulation of the advanced encryption standard;
the encryption module is used for multiplying the first matrix by each round of circulation of the advanced encryption standard, and then looking up the table Type I to obtain a second matrix to complete encryption of the advanced encryption standard;
the key conversion module is used for carrying out key conversion on the encryption round key to obtain a decryption round key;
And the decryption module is used for replacing the encryption round key with the decryption round key, and sequentially executing the steps of the generation module and the encryption module to obtain a second matrix, so as to finish decryption of the advanced encryption standard.
In a possible implementation manner, the generating module is further configured to:
Adopting CEJO frames to generate a table TMC i according to the encryption round key;
selecting a random linear coding generation table Type I from CEJO frames;
Adding prepositive and postsitive linear codes of the ith wheel and the ith wheel in the table Type I, decoding, and then carrying out the circulation of the advanced encryption standard by combining the table TMC i and the table Type I;
generating a first matrix in the loop enables decoding from wheel to wheel.
In one possible implementation, the key transformation module is further configured to:
Taking the encryption round key of the first round as the decryption round key of the last round;
The encryption round key of each round in the middle is converted into the decryption round key of each round in the middle of the reverse order by adopting an inverse operator InvMixColumns;
And taking the encryption round key of the last round as the decryption round key of the first round to obtain the decryption round key.
The preferred embodiment provides a computer device, which can implement the steps in any embodiment of the AES-based white-box encryption and decryption method provided in the embodiment of the present application, so that the beneficial effects of the AES-based white-box encryption and decryption method provided in the embodiment of the present application can be implemented, which are detailed in the previous embodiments and are not described herein.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor. To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, where the instructions can be loaded by a processor to perform the steps of any one of the embodiments of the AES-based white-box encryption and decryption method provided in the embodiment of the present application.
The storage medium may include a Read Only Memory (ROM), a random access Memory (RAM, randomAccess Memory), a magnetic disk, an optical disk, or the like.
The steps in any AES-based white-box encryption and decryption method embodiment provided by the embodiment of the present application can be executed due to the instructions stored in the storage medium, so that the beneficial effects that any AES-based white-box encryption and decryption method provided by the embodiment of the present application can be achieved, and detailed descriptions of the previous embodiments are omitted here.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any changes or substitutions easily contemplated by those skilled in the art within the scope of the present application should be included in the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.