AES-based white box encryption and decryption method, device, storage device and medium
By generating the encryption wheel key table and matrix during the encryption and decryption process of white box AES, the problems of low operation efficiency and excessive memory in the existing technology are solved, and efficient encryption and decryption in industrial Internet applications are achieved to meet the security needs of terminal devices.
Patent Information
- Application Number
- CN202411006450.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2044-07-25
AI Technical Summary
The existing white box AES implementation method has problems such as low operating efficiency, excessive memory and insufficient security in industrial Internet applications, making it difficult to effectively apply on terminal devices.
Each round of loop based on advanced encryption standards is adopted to generate the encryption wheel key table TypeI and the first matrix, and the second matrix is obtained by multiplying the left matrix to find the table TypeI, and the encryption wheel key is key transformed to achieve the balance of the encryption and decryption process.
It achieves a balance between operating efficiency, memory footprint and security in industrial Internet application scenarios, achieves an encryption and decryption speed similar to black box AES, and meets the weak security needs of terminal devices.
Smart Images

Figure CN119449271B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security and cryptography application technology, and more specifically, to a white-box encryption and decryption method, apparatus, storage device, and medium based on AES. Background Art
[0002] Keys are the core of cryptographic systems, and key management and storage are crucial aspects of cryptographic algorithm implementation. When designing cryptographic algorithms, designers often assume they will operate in a black-box environment, meaning that intermediate data is inaccessible during runtime, with only inputs and outputs accessible. However, this assumption is unrealistic in many engineering applications (such as mobile devices), as keys are at risk of being directly leaked from memory and caches. Consequently, white-box implementations of traditional cryptographic algorithms have emerged.
[0003] A white-box environment allows unlimited access to all intermediate data, inputs, and outputs during the execution of a cryptographic algorithm. As the name suggests, a white-box implementation of a traditional cryptographic algorithm involves adapting a traditional cryptographic algorithm designed based on black-box assumptions to maintain good security in a white-box environment.
[0004] Since its release, the Advanced Encryption Standard (AES) has rapidly become the most popular symmetric encryption algorithm, widely used in all aspects of social life and production, including various terminal devices and software and hardware services. Due to its ultra-high security and ultra-fast performance, AES remains an unshakable leader in global use.
[0005] Therefore, white-box AES implementations have initially attracted the attention of researchers. However, while researchers strive to improve the security of white-box AES to the same level of strong black-box AES, they often overlook its feasibility in engineering applications. These white-box AES implementations can lead to issues such as low efficiency (such as the CEJO framework), which causes data refresh delays, and excessive memory usage (such as the Xiao-Lai solution), which can overload terminal devices. Summary of the Invention
[0006] The present application provides a white-box encryption and decryption method, apparatus, storage device, and medium based on AES, which can solve the infeasibility of existing public white-box AES implementation solutions in industrial Internet applications, and achieve a balance between operating efficiency, operating memory, and security in industrial Internet application scenarios.
[0007] In order to achieve the above objectives, the technical solutions adopted in the embodiments of the present application are as follows:
[0008] In a first aspect, an embodiment of the present application provides a white-box encryption and decryption method based on AES, the method comprising:
[0009] Step S1: Generate a table Type II and a first matrix based on the encryption round key in each round of the Advanced Encryption Standard.
[0010] Step S2: Multiply each round of the Advanced Encryption Standard cycle by the first matrix, and then look up the table Type II to obtain the second matrix, thereby completing the encryption of the Advanced Encryption Standard.
[0011] Step S3: performing key transformation on the encryption round key to obtain the decryption round key;
[0012] Step S4: Replace the encryption round key with the decryption round key, and perform steps S1 and S2 in sequence to obtain the second matrix, thereby completing the decryption of the Advanced Encryption Standard.
[0013] In one possible implementation, the step of generating the table Type II and the first matrix according to the encryption round key includes:
[0014] Using the CEJO framework, the table TMC is generated according to the encryption round key i ;
[0015] Select the random linear coding generation table Type ΙΙ in the CEJO framework;
[0016] Add the pre- and post-linear encoding and decoding of round i to table Type II and combine them with table TMC i Perform Advanced Encryption Standard loop with Table Type ΙΙ;
[0017] The first matrix is generated in a loop to implement decoding between rounds.
[0018] In one possible implementation, the method further includes:
[0019] For XOR, use the binary XOR operator in your programming language.
[0020] In a possible implementation, the advanced encryption standard adopts any one of AES-128, AES-192, and AES-256.
[0021] In one possible implementation, the step of performing key transformation on the encryption round key to obtain the decryption round key includes:
[0022] Use the first round encryption key as the last round decryption key;
[0023] Use the inverse operator InvMixColumns to transform the encryption round key of each intermediate round into the decryption round key of each intermediate round in reverse order;
[0024] The encryption round key of the last round is used as the decryption round key of the first round to obtain the decryption round key.
[0025] In a second aspect, an embodiment of the present application further provides an AES-based white box encryption and decryption device, the device comprising:
[0026] A generation module, configured to generate a table Type II and a first matrix according to an encryption round key in each round of the Advanced Encryption Standard;
[0027] An encryption module, configured to perform left multiplication of each round of the Advanced Encryption Standard by the first matrix and then look up the table Type ΙΙ to obtain a second matrix, thereby completing encryption of the Advanced Encryption Standard;
[0028] A key conversion module is used to convert the encryption round key into a decryption round key;
[0029] The decryption module is used to replace the encryption round key with the decryption round key, execute the steps of the generation module and the encryption module in sequence to obtain the second matrix, and complete the decryption of the advanced encryption standard.
[0030] In a possible implementation, the generation module is further configured to:
[0031] Using the CEJO framework, the table TMC is generated according to the encryption round key i ;
[0032] Select the random linear coding generation table Type ΙΙ in the CEJO framework;
[0033] Add the pre- and post-linear encoding and decoding of round i to table Type II and combine them with table TMC i Perform Advanced Encryption Standard loop with Table Type ΙΙ;
[0034] The first matrix is generated in a loop to implement decoding between rounds.
[0035] In a possible implementation, the key transformation module is further configured to:
[0036] Use the first round encryption key as the last round decryption key;
[0037] Use the inverse operator InvMixColumns to transform the encryption round key of each intermediate round into the decryption round key of each intermediate round in reverse order;
[0038] The encryption round key of the last round is used as the decryption round key of the first round to obtain the decryption round key.
[0039] In a third aspect, an embodiment of the present application further provides a storage device comprising: a processor, a memory and a bus, wherein the memory stores program instructions executable by the processor. When the storage device is running, the processor communicates with the memory through the bus, and the processor executes the program instructions to perform the AES-based white box encryption and decryption method as described in any one of the first aspects.
[0040] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the AES-based white-box encryption and decryption method as described in any one of the first aspects is executed.
[0041] The above-mentioned main scheme of this application and its further options can be freely combined to form multiple schemes, all of which are schemes that can be adopted and protected by this application; and in this application, (non-conflicting options) can also be freely combined with each other and with other options. After understanding the scheme of this application, those skilled in the art will understand that there are many combinations based on existing technology and common knowledge, all of which are technical solutions to be protected by this application, and they are not exhaustive here.
[0042] The embodiments of the present application propose a white-box encryption and decryption method, apparatus, storage device, and medium based on AES. First, based on each round of the Advanced Encryption Standard, a table Type ΙΙ and a first matrix are generated according to the encryption round key. Then, each round of the Advanced Encryption Standard is multiplied on the left by the first matrix and then the table Type ΙΙ is looked up to obtain a second matrix to complete the encryption of the Advanced Encryption Standard. Then, a key transformation is performed on the encryption round key to obtain a decryption round key. Finally, the decryption round key is replaced with the encryption round key, and the encryption process of the Advanced Encryption Standard is repeated in sequence to obtain a second matrix to complete the decryption of the Advanced Encryption Standard. Compared with the existing technology, a balance between operating efficiency, operating memory, and security is met, achieving encryption and decryption speeds that are no significantly different from those of black-box AES, negligible additional memory usage, and meeting the weak security requirements in terminal device scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0044] Figure 1 An AES-based white-box encryption and decryption method proposed in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.
[0046] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.
[0047] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0048] It should be noted that, in the absence of conflict, the features in the embodiments of this application can be combined with each other.
[0049] In existing technologies, researchers have focused on improving the security of white-box AES to the strong security of black-box AES, often overlooking its feasibility in engineering applications. These white-box AES implementations often suffer from issues such as low efficiency (e.g., the CEJO framework), which causes data refresh delays, and excessive memory usage (e.g., the Xiao-Lai solution), which causes device overloads.
[0050] Therefore, in order to solve the above-mentioned technical problems, the embodiments of the present application propose a white-box encryption and decryption method, apparatus, storage device and medium based on AES, which satisfies the balance between operating efficiency, operating memory and security in the application scenarios of the industrial Internet, and achieves encryption and decryption speeds that are no significantly different from those of the black-box AES, negligible additional memory usage, and meets the weak security requirements in the terminal device scenario. It is described in detail below.
[0051] Please refer to Figure 1 , Figure 1 The present invention provides a white box encryption and decryption method based on AES, which includes:
[0052] Step S1: Generate a table Type II and a first matrix based on an encryption round key in each round of the Advanced Encryption Standard.
[0053] The steps before generating the table Type II and the first matrix also include:
[0054] The number of encryption rounds and decryption rounds of the Advanced Encryption Standard are set to Nr respectively. Each round of the Advanced Encryption Standard is Roundi (i = 1, ..., Nr), where Nr represents the total number of rounds in the AES encryption or decryption process, and Roundi refers to each specific loop operation, whether it is the i-th round in the encryption or decryption process. The main difference between them lies in the specific operations performed in each round and the order.
[0055] In addition, the four operators included in each round of the Advanced Encryption Standard are set as AddRoundKey, SubBytes, ShiftRows, and MixColumns, and the inverse operators of the operators included in each round of the Advanced Encryption Standard are InvSubBytes, InvShiftRows, and InvMixColumns. If the output of any operator F with input x is denoted as F(x), and the output of any operator G with input x is denoted as G(x), then the composite operator with input x is denoted as The output is The notation of the five tables in the CEJO framework is TypeIa, TypeIb, TypeII, TypeIII, and TypeIV.
[0056] The Advanced Encryption Standard uses any one of AES-128, AES-192, and AES-256.
[0057] In one possible implementation, the step of generating the table Type II and the first matrix according to the encryption round key includes:
[0058] Using the CEJO framework, the table TMC is generated according to the encryption round key i ;
[0059] Select the random linear coding generation table Type ΙΙ in the CEJO framework;
[0060] Add the pre- and post-linear encoding and decoding of round i to table Type II and combine them with table TMC i Perform Advanced Encryption Standard loop with Table Type ΙΙ;
[0061] The first matrix is generated in a loop to implement decoding between rounds.
[0062] This step is the encryption step. Each round of the advanced encryption standard is Roundi, 1≤i≤Nr. According to the encryption round key K of the i-th round i-1 Generate table TypeII and the first matrix M i , using the CEJO framework according to the encryption round key K i-1 Generate table TMC i, the CEJO framework selects random nonlinear coding to select random linear coding to generate table Type II, and adds the pre- and post-linear coding and decoding of round i to table Type II ( and ) and then combine table TMC i And table Type ΙΙ performs the advanced encryption standard cycle, the cycle process is:
[0063]
[0064] This cycle shows the series of steps in the AES encryption process. The AES encryption process is divided into multiple rounds, and each round has specific steps to process the input data. This means that after the last round, the data has been completely encrypted and formed into ciphertext.
[0065] This expression shows the process of multiple rounds of linear encoding, where each round applies a different matrix multiplication, increasing the complexity and security of the cryptosystem.
[0066] Table Type III in the CEJO framework is replaced by the first matrix in the embodiment of the present application. The embodiment of the present application generates the first matrix in a loop to implement decoding between rounds:
[0067] Round 1:M i :=ShiftRows;
[0068]
[0069] This means that the first matrix of the first round is the row shift matrix (ShiftRows), and the first matrix of the i-th round is the decoding of the post-linear encoding of the previous round Sequentially through the row shift matrix (ShiftRows) and this round of post linear coding (L i-1 ) is the matrix obtained.
[0070] Step S2: Multiply each round of the Advanced Encryption Standard cycle by the first matrix on the left, and then look up the table Type II to obtain the second matrix, thereby completing the encryption of the Advanced Encryption Standard.
[0071] For each round of the Advanced Encryption Standard, Roundi (i=1, ..., Nr), multiply the first matrix M on the left i Then search for TypeII to complete the encryption process.
[0072] In one possible implementation, the method further includes:
[0073] For XOR, use the binary XOR operator in your programming language.
[0074] At a certain stage (Roundi), a matrix is first multiplied by the first matrix M on the left. i , and then perform a query based on a certain type of table (Type II). Unlike the other method (CEJO framework), due to the use of random linear encoding, after completing the Type II lookup table operation, when performing the XOR operation on data with a length of 32 bits and 128 bits, the binary XOR operator provided by some programming languages can be directly used, such as the ^ symbol in C++.
[0075] Considering the symmetry of AES encryption and decryption, decryption includes the following steps:
[0076] Step S3: Perform key transformation on the encryption round key.
[0077] In one possible implementation, the step of performing key transformation on the encryption round key to obtain the decryption round key includes:
[0078] Use the first round encryption key as the last round decryption key;
[0079] Use the inverse operator InvMixColumns to transform the encryption round key of each intermediate round into the decryption round key of each intermediate round in reverse order;
[0080] The encryption round key of the last round is used as the decryption round key of the first round to obtain the decryption round key.
[0081] Assume that the encryption round key is K i , the decryption round key is K i ′, the key transformation formula is:
[0082]
[0083] The first line indicates that the first round decryption round key K′0 is equal to the Nrth round encryption round key The second line shows the number of rounds from 1 to N. r The key for round -1 is obtained by applying the inverse mixing column transformation to the key of the previous round. The last row represents the decryption round key for the last round. Equal to the encryption round key K0 of the first round.
[0084] Step S4: Replace the encryption round key with the decryption round key, and perform steps S1 and S2 in sequence to obtain the second matrix, thereby completing the decryption of the Advanced Encryption Standard.
[0085] The following is a verification of the AES-based white box encryption and decryption method proposed in the embodiment of the present application. AES-128 is first used to compare it with the CEJO framework and the Xiao-Lai / Xiao-Lai scheme.
[0086] Different from the CEJO framework, the embodiment of the present application does not require the generation (336kB) and search (2688 times) of Type IV, and the overhead generated by the binary XOR operation instead is negligible.
[0087] Unlike the CEJO framework, considering the impracticality of external input / output encoding in actual product logic and the inconvenience of separate input / output encoding for each table in engineering implementation, the embodiment of the present application does not require the generation (128kB) and search (32 times) of Type Ia and TypeIb.
[0088] Different from the CEJO framework and similar to the Xiao-Lai scheme, the embodiment of the present application uses 10 matrix multiplications to implement decoding between rounds (20kB), and does not require Type III generation (144kB) and search (144 times).
[0089] Similar to the CEJO framework and different from the Xiao-Lai scheme that selects 8 16-bit-32-bit tables TMC (20480kB in 10 rounds), the embodiment of the present application uses 16 8-bit-32-bit tables TMC (160kB in 10 rounds).
[0090] Compared with the prior art, the beneficial effects proposed in the embodiments of the present application are:
[0091] First, in theory, compared with the CEJO framework (3008 table lookups, 752kB) and the Xiao-Lai scheme (80 table lookups, 40 XORs, 11 matrix multiplications, 20502kB), the embodiment of the present application (144 table lookups, 216 XORs, 11 matrix multiplications, 164kB) has the advantages of high efficiency and lightweight, and is very close to the performance of the black box AES (160 table lookups, 152 XORs, 4kB).
[0092] Second, with the CEJO framework (2 22 ) and Xiao-Lai / Xiao-Lai scheme (2 32 ) compared to the embodiment of the present application, the security is about 2 12 to 2 22 It is considered to have weak security, but with the reinforcement of technologies, it is sufficient to meet the needs of mobile terminals.
[0093] Third, after a large number of tests, the embodiments of the present application encrypt / decrypt single plaintext / ciphertext of sizes 500kB, 1mB, and 2mB, respectively, in ECB mode taking 79.1ms, 98.8ms, and 117.8ms, and in CBC mode taking 76.8ms, 99.3ms, and 162.2ms, respectively, without causing visible delays in real-time data refreshes.
[0094] In a second aspect, an embodiment of the present application further provides an AES-based white box encryption and decryption device, the device comprising:
[0095] A generation module, configured to generate a table Type II and a first matrix according to an encryption round key in each round of the Advanced Encryption Standard;
[0096] An encryption module, configured to perform left multiplication of each round of the Advanced Encryption Standard by the first matrix and then look up the table Type ΙΙ to obtain a second matrix, thereby completing encryption of the Advanced Encryption Standard;
[0097] A key conversion module is used to convert the encryption round key into a decryption round key;
[0098] The decryption module is used to replace the encryption round key with the decryption round key, execute the steps of the generation module and the encryption module in sequence to obtain the second matrix, and complete the decryption of the advanced encryption standard.
[0099] In a possible implementation, the generation module is further configured to:
[0100] Using the CEJO framework, the table TMC is generated according to the encryption round key i ;
[0101] Select the random linear coding generation table Type ΙΙ in the CEJO framework;
[0102] Add the pre- and post-linear encoding and decoding of round i to table Type II and combine them with table TMC i Perform Advanced Encryption Standard loop with Table Type ΙΙ;
[0103] The first matrix is generated in a loop to implement decoding between rounds.
[0104] In a possible implementation, the key transformation module is further configured to:
[0105] Use the first round encryption key as the last round decryption key;
[0106] Use the inverse operator InvMixColumns to transform the encryption round key of each intermediate round into the decryption round key of each intermediate round in reverse order;
[0107] The encryption round key of the last round is used as the decryption round key of the first round to obtain the decryption round key.
[0108] This preferred embodiment provides a computer device that can implement the steps of any embodiment of the AES-based white-box encryption and decryption method provided in the embodiments of the present application. Therefore, the beneficial effects of the AES-based white-box encryption and decryption method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0109] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be accomplished by instructions, or by controlling related hardware through instructions. The instructions can 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 storing a plurality of instructions that can be loaded by a processor to execute the steps of any of the embodiments of the AES-based white-box encryption and decryption methods provided in the embodiments of the present application.
[0110] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0111] Since the instructions stored in the storage medium can execute the steps in any of the AES-based white-box encryption and decryption method embodiments provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the AES-based white-box encryption and decryption methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0112] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A white box encryption and decryption method based on AES, characterized in that: The method comprises: Step S1: Generate a table based on the encryption round key in each round of the Advanced Encryption Standard. and the first matrix; Generate table based on encryption round key and the first matrix steps, comprising: Using the CEJO framework, the table is generated according to the encryption round key ; Selecting random linear encoding generation tables in the CEJO framework ; In the table Add the pre- and post-linear encoding and decoding of round i and combine them into table surface Perform the Advanced Encryption Standard cycle, the cycle process is: ; ; ; Indicates the total number of cycles during AES encryption or decryption. For each round of the Advanced Encryption Standard, 1≤i≤Nr, and are the pre-linear encoding and pre-linear decoding of the i-th round, and They are the post-linear encoding and post-linear decoding of the i-th round respectively; Generate the first matrix in the loop to achieve decoding between rounds; Step S2: Multiply each round of the Advanced Encryption Standard by the first matrix and then look up the table Obtain the second matrix and complete the encryption of the Advanced Encryption Standard; Step S3: Use the encryption round key of the first round as the decryption round key of the last round; Use the inverse operator InvMixColumns to transform the encryption round key of each intermediate round into the decryption round key of each intermediate round in reverse order; Use the encryption round key of the last round as the decryption round key of the first round to obtain the decryption round key; Step S4: Replace the encryption round key with the decryption round key, and perform steps S1 and S2 in sequence to obtain the second matrix, thereby completing the decryption of the Advanced Encryption Standard.
2. The AES-based white box encryption and decryption method according to claim 1, characterized in that: The method further comprises: For XOR, use the binary XOR operator in your programming language.
3. The AES-based white box encryption and decryption method according to claim 1, characterized in that: The Advanced Encryption Standard uses any one of AES-128, AES-192, and AES-256.
4. A white box encryption and decryption device based on AES, characterized in that: The device comprises: The generation module is used for each round of the advanced encryption standard, according to the encryption round key generation table Type II and the first matrix, using the CEJO framework, according to the encryption round key generation table ; Selecting random linear encoding generation tables in the CEJO framework ; In the table Add the pre- and post-linear encoding and decoding of round i and combine them into table surface Perform the Advanced Encryption Standard cycle, the cycle process is: ; ; ; Indicates the total number of cycles during AES encryption or decryption. For each round of the Advanced Encryption Standard, 1≤i≤Nr, and are the pre-linear encoding and pre-linear decoding of the i-th round, and They are the post-linear encoding and post-linear decoding of round i respectively; Generate the first matrix in the loop to achieve decoding between rounds; An encryption module, configured to perform encryption of the Advanced Encryption Standard by multiplying each round of the Advanced Encryption Standard cycle by the first matrix and then looking up the table Type II to obtain a second matrix; A key conversion module is used to use the encryption round key of the first round as the decryption round key of the last round; Use the inverse operator InvMixColumns to transform the encryption round key of each intermediate round into the decryption round key of each intermediate round in reverse order; Use the encryption round key of the last round as the decryption round key of the first round to obtain the decryption round key; The decryption module is used to replace the encryption round key with the decryption round key, execute the steps of the generation module and the encryption module in sequence to obtain the second matrix, and complete the decryption of the advanced encryption standard.
5. A storage device, characterized in that: include: A processor, a memory, and a bus, wherein the memory stores program instructions executable by the processor. When the storage device is running, the processor and the memory communicate via the bus, and the processor executes the program instructions to perform the AES-based white box encryption and decryption method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the AES-based white-box encryption and decryption method according to any one of claims 1 to 3 is executed.
Citation Information
Patent Citations
Encryption and decryption method based on white box block cipher
CN112199696A
White box AES implementation
US20190305930A1