Encryption method and device based on symmetric algorithm
By transforming the plaintext key to obtain the white box key and transforming the S box of the symmetric algorithm to generate a new encrypted S box, the problem of key leakage risks and inconvenient key replacement of the symmetric encryption algorithm under white box attack is solved, and higher security and flexibility are achieved.
Patent Information
- Application Number
- CN202010231647.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-27
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2040-03-27
AI Technical Summary
When existing symmetric encryption algorithms face white box attacks, the risk of key leakage is high and key replacement is inconvenient.
By performing a first transformation of the plaintext key, and performing a second transformation of the S box of the symmetric algorithm, a new encrypted S box SE' is generated to realize standard symmetric encryption processing.
Effectively hide the original key, increase the difficulty of cracking, can resist white box attacks, and support dynamic key replacement, improving the security of symmetric encryption algorithms.
Smart Images

Figure CN113452505B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of encryption technology, and in particular to an encryption method and device based on a symmetric algorithm. Background Art
[0002] Symmetric encryption algorithms are encryption algorithms that were used earlier and have mature technology. In symmetric encryption algorithms, the data sender processes the plaintext (original data) and the encryption key together through a special encryption algorithm, and then turns it into a complex encrypted ciphertext and sends it out. After the recipient receives the ciphertext, if he wants to interpret the original text, he needs to use the encryption key and the inverse algorithm of the same algorithm to decrypt the ciphertext to restore it to readable plaintext. In symmetric encryption algorithms, only one key is used, and both the sender and the receiver use this key to encrypt and decrypt data, which requires the decryptor to know the encryption key in advance. Symmetric encryption algorithms refer to encryption algorithms that use the same key for encryption and decryption. AES is an Advanced Encryption Standard (AES), a type of symmetric encryption algorithm. A black box attack is when the attacker does not have substantial access to the key (the algorithm that performs encryption or decryption) or any internal operations, but can only observe some external information or operations. This information includes plaintext (input) or ciphertext (output) in the system, and it is assumed that code execution and dynamic encryption cannot be observed. A white-box attack is when the attacker can completely control the entire encryption process, such as understanding the encryption algorithm, modifying the memory value during the encryption process, and so on. White-box cryptography is that the complete original key does not appear in the operating environment, which can resist white-box attacks and prevent attackers from cracking the original key. The encryption algorithm mainly relies on the security of the key. If the key is leaked, it will cause serious losses to the user. Therefore, how to store the key is called the key. Generally speaking, the key can be written in the code and compiled into the final binary file, or simply encrypted and decrypted when used, etc. These methods are relatively safe for black-box attacks, but cannot resist white-box attacks. Once the attacker controls the operating environment of the device, including memory, disk, registers, etc., he can find the key in the memory or binary file. Therefore, white-box cryptography technology has been developed.
[0003] A common way to implement white-box cryptography is the lookup table method. The main idea of the lookup table method is to use the idea of obfuscation to hide the key information so that the key information will not be exposed during the execution of the cryptographic algorithm. A commonly used obfuscation method is scrambling coding (which can be simply referred to as coding). The specific method is: for an existing block cipher, select a key, and then scramble the mapping from plaintext to ciphertext, and make the scrambled mapping into a lookup table. In this way, the calculation process of the cryptographic algorithm is transformed into a table lookup process, and the entire cryptographic algorithm is transformed into a series of table lookup processes. Since the key is hidden in the lookup table, the attacker can only know the output corresponding to the input of the lookup table, and the corresponding relationship and key information hidden inside cannot be known.
[0004] 1. The lookup table is large and is divided into an encryption lookup table and a decryption lookup table;
[0005] 2. It is inconvenient to change the key. One key is bound to a lookup table. If you want to change the key, you have to change the lookup table. Since the lookup table is very large, this brings a lot of inconvenience to changing the key.
[0006] In summary, the prior art obviously has inconveniences and defects in practical use, so it is necessary to improve it. Summary of the invention
[0007] In view of the above-mentioned defects, the purpose of the present invention is to provide an encryption method and device based on a symmetric algorithm to resist white box attacks and improve the security of the symmetric encryption algorithm.
[0008] In order to achieve the above object, the present invention provides an encryption method based on a symmetric algorithm, the method comprising the following steps:
[0009] Performing a first transformation on the plaintext key to obtain a white-box key;
[0010] Performing a second transformation on the S-box of the symmetric algorithm to obtain a new encryption S-box SE', wherein the second transformation is a reversible transformation of the first transformation;
[0011] Based on the new encryption S-box SE', standard symmetric encryption processing is performed on the plaintext and the white-box key to output ciphertext.
[0012] According to the encryption method, the first transformation of the plaintext key includes:
[0013] Calculating the plaintext key through the symmetric algorithm to obtain a first key, and performing the first transformation on the first key;
[0014] The second transformation of the S-box of the symmetric algorithm comprises:
[0015] The second transformation is performed on the encryption S-box SE in the operation of searching the encryption S-box in the symmetric algorithm for the white box key.
[0016] According to the encryption method, the output ciphertext includes:
[0017] Perform the second transformation on the decryption S-box SD of the symmetric algorithm to obtain a new decryption S-box SD';
[0018] Based on the SD', standard symmetric decryption processing is performed on the ciphertext and the white-box key, and a plaintext corresponding to the ciphertext is output.
[0019] According to the encryption method, performing the second transformation on the decryption S-box SD of the symmetric algorithm includes:
[0020] The second transformation is performed on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key.
[0021] According to the encryption method, the symmetric algorithm is AES, DES, 3DES and / or SM4 symmetric algorithm;
[0022] The reversible transformation operation is an XOR operation;
[0023] The first key is a round key.
[0024] According to the encryption method, performing the second transformation on the encryption S box SE in the operation of searching the encryption S box in the symmetric algorithm for the white box key includes:
[0025] In the encryption S-box lookup operation in the symmetric algorithm for the white box key, the position of the input byte a is searched from the encryption S-box SE to obtain the output byte b, so that b=SE(a);
[0026] Perform the second transformation on the SE(a) to obtain b'=SE(R(a)), so that SE'(a)=SE(R(a)), and generate a new S-box SE';
[0027] The performing the second transformation on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key comprises:
[0028] The output byte SD(a) is searched from the decryption S-box SD in the decryption S-box operation of the white box key in the symmetric algorithm, so that SD(a)=b', the second transformation is performed on the SD(a) to obtain SD'(a), and finally the input byte a is obtained.
[0029] According to the encryption method, the symmetric algorithm consists of multiple rounds, and the parameters of the reversible transformation operation in each round are the same or different.
[0030] In order to achieve another object of the present invention, the present invention further provides an encryption device based on a symmetric algorithm, comprising:
[0031] A key processing module, used for performing a first transformation on the plaintext key to obtain a white-box key;
[0032] A white box library, used for performing a second transformation on the S box of the symmetric algorithm to obtain a new encryption S box SE', wherein the second transformation is a reversible transformation of the first transformation; and
[0033] It is used to perform standard symmetric encryption processing on the plaintext and the white box key based on the new encryption S box SE', and output ciphertext.
[0034] In order to achieve another object of the present invention, the present invention further provides an electronic device, the electronic device comprising:
[0035] processor, and
[0036] A memory arranged to store computer executable instructions, which when executed cause the processor to perform any of the methods described above.
[0037] In order to achieve another inventive object of the present invention, the present invention also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, they implement any of the methods described above.
[0038] The present invention obtains a white box key by performing a first transformation on the plaintext key; performs a second transformation on the S box of the symmetric algorithm to obtain a new encryption S box SE', wherein the second transformation is a reversible transformation of the first transformation; performs standard symmetric encryption processing on the plaintext and the white box key based on the new encryption S box SE', and outputs a ciphertext. Since the plaintext key is first subjected to a T transformation and then an R transformation, the R and T transformations cancel each other out, thereby achieving the purpose of hiding the original key. The R and T transformations are diverse, as long as they are reversible transformation operations. Moreover, since the symmetric encryption algorithm has many rounds, the RT transformations of each round can be different, the combination rules can be customized, and the key can be replaced at any time; the original key will not appear during the operation, which increases the difficulty of cracking and can resist white box attacks; the original key will not appear during effective protection of memory operations; the white box key can be safely stored in the hard disk, and attackers cannot infer the original key, thereby improving the security of the symmetric encryption algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a flow chart of an encryption method based on a symmetric algorithm provided in an embodiment of the present invention;
[0040] Figure 2 It is a schematic diagram of the encryption operation process of the encryption method based on the symmetric algorithm provided in an embodiment of the present invention;
[0041] Figure 3 It is a schematic diagram of the encryption operation process of the encryption method based on the symmetric algorithm provided in an embodiment of the present invention;
[0042] Figure 4 It is a schematic diagram of the composition of an encryption device based on a symmetric algorithm provided by an embodiment of the present invention;
[0043] Figure 5 It is a schematic diagram of the composition of an encryption device based on a symmetric algorithm provided by an embodiment of the present invention;
[0044] Figure 6 is a schematic diagram of the composition of an electronic device provided by an embodiment of the present invention;
[0045] Figure 7 It is a schematic diagram of the structure of a computer-readable storage medium provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0047] It should be noted that references to "one embodiment", "embodiment", "example embodiment", etc. in this specification refer to the embodiment described, which may include specific features, structures or characteristics, but not every embodiment must include these specific features, structures or characteristics. In addition, such expressions do not refer to the same embodiment. Furthermore, when describing specific features, structures or characteristics in conjunction with an embodiment, whether or not there is an explicit description, it has been shown that it is within the knowledge of those skilled in the art to combine such features, structures or characteristics into other embodiments.
[0048] In addition, certain words are used in the specification and subsequent claims to refer to specific components or parts. Those with ordinary knowledge in the relevant field should understand that manufacturers can use different nouns or terms to refer to the same component or part. This specification and subsequent claims do not use differences in names as a way to distinguish components or parts, but use differences in the functions of components or parts as the criteria for distinction. "Including" and "including" mentioned throughout the specification and subsequent claims are open-ended terms and should be interpreted as "including but not limited to". In addition, the word "connected" here includes any direct and indirect electrical connection means. Indirect electrical connection means include connection through other devices.
[0049] See also Figure 1 In one embodiment of the present invention, an encryption method based on a symmetric algorithm is provided, the method comprising the following steps:
[0050] In step S101, a first transformation is performed on the plaintext key to obtain a white-box key;
[0051] In step S102, a second transformation is performed on the S-box of the symmetric algorithm to obtain a new encryption S-box SE', wherein the second transformation is a reversible transformation of the first transformation;
[0052] In step S103, standard symmetric encryption processing is performed on the plaintext and the white box key based on the new encryption S box SE' to output ciphertext.
[0053] In the process of encrypting the plaintext, the plaintext key is subjected to a first transformation, and a white-box key is output; the white-box key is input into the white-box library, and the S-box of the symmetric algorithm is subjected to a second transformation in the white-box library that is a reversible transformation operation with the first transformation, to obtain a new encryption S-box SE', that is, in order to better hide the R transformation, the R transformation can be integrated into the S-box. Finally, the plaintext and the white-box key are subjected to standard symmetric encryption processing based on the new encryption S-box SE', and the white-box library outputs the ciphertext. The actual processing scheme is to perform a transformation T (i.e., the first transformation) on the plaintext key to obtain the white-box key, and first perform a transformation R (i.e., the second transformation) on the input in the white-box library to offset T, thereby obtaining the correct output result. The reversible transformation operation can be an XOR operation, but is not limited to an XOR operation, as long as the two are mutually reversible operations. When an attacker obtains the white-box key, he cannot infer the original plaintext key. Therefore, the original key will not appear in the operation process, which can resist white-box attacks. In this embodiment, the encryption algorithm is a symmetric encryption algorithm such as AES (Advanced Encryption Standard), DES (Data Encryption Standard, a block algorithm using key encryption), 3DES (or Triple DES, a generic name for a triple data encryption algorithm (TDEA) block cipher), SM4 (a packet data algorithm for wireless LAN standards), etc.;
[0054] In one embodiment of the present invention, the first transformation of the plaintext key includes:
[0055] The plaintext key is calculated by the symmetric algorithm to obtain a first key, and the first key is subjected to the first transformation; the plaintext key is the original key, and the first key is obtained by using the symmetric algorithm, and then the first transformation is performed;
[0056] The second transformation of the S-box of the symmetric algorithm comprises:
[0057] The second transformation is performed on the encryption S box SE in the operation of searching the encryption S box in the symmetric algorithm for the white box key. The second transformation which is the inverse of the transformation is performed on the S box to obtain a new S box SE'.
[0058] After the ciphertext is output, the decryption method of the encrypted ciphertext is the reverse of the encryption step. Specifically, the output ciphertext includes:
[0059] Perform the second transformation on the decryption S-box SD of the symmetric algorithm to obtain a new decryption S-box SD';
[0060] Based on the SD', standard symmetric decryption processing is performed on the ciphertext and the white-box key, and a plaintext corresponding to the ciphertext is output.
[0061] Specifically, performing the second transformation on the decryption S-box SD of the symmetric algorithm includes:
[0062] The second transformation is performed on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key.
[0063] The first transformation and the second transformation are reversible transformation operations, and the reversible transformation operation is an exclusive-OR operation;
[0064] The first key is a round key.
[0065] When a byte replacement operation is used in the operation of searching the encryption S box in the symmetric algorithm for the white box key, performing the second transformation on the encryption S box SE in the operation of searching the encryption S box in the symmetric algorithm for the white box key includes:
[0066] In the encryption S-box lookup operation in the symmetric algorithm for the white box key, the position of the input byte a is searched from the encryption S-box SE to obtain the output byte b, so that b=SE(a);
[0067] Perform the second transformation on the SE(a) to obtain b'=SE(R(a)), so that SE'(a)=SE(R(a)), and generate a new S-box SE';
[0068] The second transformation of the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key includes:
[0069] The output byte SD(a) is searched from the decryption S-box SD in the decryption S-box operation of the white box key in the symmetric algorithm, so that SD(a)=b', the second transformation is performed on the SD(a) to obtain SD'(a), and finally the input byte a is obtained.
[0070] See also Figure 2 In one embodiment of the present invention, the AES algorithm is taken as an example to illustrate the encryption method based on the symmetric algorithm provided by the present invention for encrypting data:
[0071] AES-128 consists of ten rounds, each of which consists of four parts: byte substitution, row shift, column shuffling, and round key addition.
[0072] Byte replacement: The main function of byte replacement is to complete the mapping from one byte to another byte through the S box.
[0073] Row shift: Row shift is a permutation of bytes within a 4x4 matrix to provide diffusion of the algorithm.
[0074] Column confusion: Also used to provide diffusivity to the algorithm.
[0075] Round key plus: XOR the input with the round key.
[0076] Round key: The original key is obtained by a key expansion algorithm.
[0077] Among them, the first key is the round key, and the round key addition operation is used for the white box key in the lookup encryption S-box operation in the symmetric algorithm; the round key is used in the round key addition, so if the round key is T-transformed in advance to obtain w'[0,…,43], in each round of round key addition, the input plaintext is pre-processed by R transformation to offset the T transformation of w', ensuring that the actual input of the round key addition is consistent with that before the TR transformation, and the correct output can be obtained.
[0078] The TR transformations used here are all XOR operations, which have the following properties:
[0079]
[0080]
[0081]
[0082] Right now:
[0083] Example:
[0084] If the input of the round key addition before the first round is 4 words of plaintext m[0,…,3] and 4 words of round key w[0,…,3], the output is It is an XOR operation.
[0085] Assume that TR transformations are all XOR x[0,…,3]
[0086] 1. First, perform T transformation on the round key w[0,…,3] to obtain the new round key
[0087] This step can be done by Figure 4 The key processing module 401 shown implements
[0088] 2. Perform R transformation on the input parameter plaintext added by the round key to obtain the new plaintext This step is completed in the white box library 402;
[0089] 3. The result of round key addition before the first round in the white box library 402 can be obtained
[0090]
[0091] From the properties of XOR, we can get:
[0092]
[0093] The correct result is obtained. At the same time, since the new round key w'[0,…,3] has undergone T transformation, the attacker obtains w'[0,…,3] and cannot infer the original round key w[0,…,3].
[0094] However, at this time, the R transformation is still in the white box library 402, and the R and T transformations are reversible to each other. Therefore, if the attacker obtains the R transformation, he can definitely deduce the T transformation, and thus deduce the value of w[0,…,3].
[0095] In one embodiment of the present invention, in order to better hide the R transformation, the R transformation can be integrated into the S box, that is, the plaintext is not processed in the round key addition, but the input is processed in the byte replacement.
[0096] Byte replacement is to find the position of the input byte a in the S box and obtain the output byte b, that is, b=SE(a). At this time, the byte replacement can be transformed, that is, b'=SE(R(a)), that is, SE'(a)=SE(R(a)) to generate a new S box SE'. Since the input of the byte replacement is the output of the round key addition in the previous round, there must be a T transformation in a, that is, b'=b. Since there is no byte replacement after the round key addition in the 10th round, the byte replacement in the 10th round needs to be transformed once more to offset the T transformation of w[40,…,43]. In the entire encryption process, there are a total of 11 T transformations and 11 R transformations. These RT transformations can be different in each round, and even randomly combined for each encryption. Therefore, even if the original key is the same, the white box key obtained after the above-mentioned first transformation processing is different. The present invention proposes an encryption method based on a symmetric algorithm, which does not require a lookup table and can dynamically change the key.
[0097] In addition, in the encryption and decryption operations of multiple embodiments of the present invention, the symmetric encryption algorithm consists of multiple rounds, and the parameters of the reversible transformation operation in each round are the same or different.
[0098] Wherein, in one embodiment of the present invention, the performing of the second transformation on the encryption S-box SE in the operation of searching the encryption S-box for the white box key in the symmetric algorithm is performed in the last round of the symmetric algorithm;
[0099] The second transformation of the new S-box S' by the white box key in the second preset operation in the symmetric algorithm is performed in the first round of the symmetric algorithm.
[0100] See also Figure 3 In one embodiment of the present invention, decryption is also based on the same principle as the encryption method in the above embodiment. Taking AES as an example, the whole process of the present invention is explained. Figure 3 This is the encryption and decryption process of the ordinary AES algorithm, ignoring the results of row shift, column confusion, reverse row shift, and reverse column confusion.
[0101] Assume that the input plaintext is m[0,…,3]4 words (16 bytes), the round key is w[0,…,43]44 words, the 10 rounds of bytes in the original AES encryption algorithm use the same S-box, all are S, and the 10 rounds of bytes in the present invention use the same S-box, and the 10 rounds of inverse bytes in the original AES decryption algorithm use the same inverse S-box, all are S', and the 10 rounds of inverse bytes in the present invention use the inverse S-box, 0<=i<=9.
[0102] 1. Encryption
[0103] 1. T transformation processing Assume that T transformation is XOR x[j], 0<=j<=10, a total of 11 bytes. Perform T transformation processing on the round key w[0,…,43] in the following way:
[0104]
[0105] XOR each word of w with x[j].
[0106] 2. R transformation processing
[0107] Processing the S-box
[0108]
[0109]
[0110] Processing the inverse S-box
[0111]
[0112]
[0113] Generate a new S-box S[0,…,10] and a new inverse S-box S'[0,…,10]
[0114] 3. Encryption
[0115] The first 9 rounds of round keys are added and byte replaced: 0<=i<=8, where c[] is the output after byte replacement, and c[40,41,42,43] is the final ciphertext
[0116] Original algorithm:
[0117] The algorithm of the present invention:
[0118]
[0119] Round 10:
[0120] Original algorithm:
[0121]
[0122] The algorithm of the present invention:
[0123]
[0124] The ciphertext finally obtained by the algorithm of the present invention is the same as that of the original algorithm.
[0125] (II) Decryption
[0126] c'[40,41,42,43]=c[40,41,42,43]
[0127] The first 9 rounds of round keys are added and replaced by reverse bytes: 0 <= i <= 8
[0128] Original algorithm:
[0129] The algorithm of the present invention:
[0130]
[0131] Round 10:
[0132] Original algorithm:
[0133] The algorithm of the present invention:
[0134]
[0135] The original text finally obtained by the algorithm of the present invention is the same as that of the original algorithm.
[0136] See also Figure 4 In one embodiment of the present invention, an encryption device 400 based on a symmetric algorithm is provided, comprising:
[0137] The key processing module 401 is used to perform a first transformation on the plaintext key to obtain a white-box key;
[0138] A white box library 402, configured to perform a second transformation on the S box of the symmetric algorithm to obtain a new encryption S box SE', wherein the second transformation is a reversible transformation of the first transformation; and
[0139] It is used to perform standard symmetric encryption processing on the plaintext and the white box key based on the new encryption S box SE', and output ciphertext.
[0140] In this embodiment, the dynamic white box package 400 for symmetric encryption algorithm includes a key processing module 401 and a white box library 402. The key processing module 401 processes the ordinary plaintext key and outputs the white box key. The white box key is used in conjunction with the white box library 401. When an attacker obtains the white box key, since the white box key has undergone the first transformation, the attacker does not know the corresponding reversible transformation operation, and therefore cannot infer the original plaintext key. The white box library 401 is a white box cryptographic algorithm library that provides encryption and decryption functions. The input parameters are plaintext / ciphertext and white box key, and the output is ciphertext / plaintext.
[0141] During the encryption process, a transformation T is performed on the plaintext key in the key processing module 401 to obtain a white box key, and a transformation R is first performed on the input in the white box library 402 to cancel T, and a second transformation is performed on the S box of the symmetric algorithm to obtain a new encryption S box SE', thereby obtaining the correct output result. (The R and T transformations are reversible transformations, which can cancel each other, and using them simultaneously is equivalent to not performing any transformation.) There is no longer a white box table, which reduces the size of the white box library.
[0142] See also Figure 5 In one embodiment of the present invention, the key processing module 401 includes:
[0143] The key processing submodule 4011 is used to calculate the original key through the symmetric algorithm to obtain the first key, and perform the first transformation on the first key to obtain the white-box key;
[0144] A first output submodule 4012, configured to output the white box key to the white box library 402;
[0145] The white box library 402 includes:
[0146] A first transformation submodule 4021 is configured to perform the second transformation on the encryption S-box SE in the operation of searching the encryption S-box in the symmetric algorithm for the white box key;
[0147] Performing the second transformation on the white box key in a byte replacement operation in the symmetric encryption algorithm to obtain the ciphertext;
[0148] The second output submodule 4022 is used to output the ciphertext.
[0149] In addition, the white box library 402 is further used to perform the second transformation on the decryption S box SD of the symmetric algorithm to obtain a new decryption S box SD'; and
[0150] Based on the SD', standard symmetric decryption processing is performed on the ciphertext and the white-box key, and a plaintext corresponding to the ciphertext is output.
[0151] Specifically, the white box library 402 also includes:
[0152] A second transformation submodule 4023, configured to perform the second transformation on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key;
[0153] The third output submodule 4024 is used to output the plain text.
[0154] Among them, the symmetric algorithm is AES, DES, 3DES and / or SM4 symmetric algorithm; the reversible transformation operation is an XOR operation; and the first key is a round key.
[0155] In one embodiment of the present invention, in the operation of searching the encryption S box in the symmetric algorithm for the white box key, a byte replacement operation is used, and the first transformation submodule 4021 performs the second transformation on the encryption S box SE in the operation of searching the encryption S box in the symmetric algorithm for the white box key, including:
[0156] In the encryption S-box lookup operation in the symmetric algorithm for the white box key, the position of the input byte a is searched from the encryption S-box SE to obtain the output byte b, so that b=SE(a);
[0157] Perform the second transformation on the SE(a) to obtain b'=SE(R(a)), so that SE'(a)=SE(R(a)), and generate a new S-box SE';
[0158] In the operation of searching the decryption S box in the symmetric algorithm for the white box key, a reverse byte replacement operation is used, and the second transformation submodule 4023 performs the second transformation on the decryption S box SD in the operation of searching the decryption S box in the symmetric algorithm for the white box key, including:
[0159] The output byte SD(a) is searched from the decryption S-box SD in the decryption S-box operation of the white box key in the symmetric algorithm, so that SD(a)=b', the second transformation is performed on the SD(a) to obtain SD'(a), and finally the input byte a is obtained.
[0160] Specifically, the symmetric algorithm is composed of multiple rounds, and the parameters of the reversible transformation operation in each round are the same or different. In one embodiment of the present invention, the first transformation submodule 4021 performs the second transformation on the encryption S box SE in the operation of searching the encryption S box in the symmetric algorithm for the white box key in the symmetric algorithm in the last round of the symmetric algorithm; the second transformation submodule 4023 performs the second transformation on the decryption S box SD in the operation of searching the decryption S box in the symmetric algorithm for the white box key in the symmetric algorithm in the first round of the symmetric algorithm.
[0161] It can be seen that when the dynamic white box 400 suitable for the symmetric encryption algorithm is used to encrypt data, the key can be replaced at any time; the original key will not appear during the operation, and the white box attack can be resisted; the dynamic white box 400 suitable for the symmetric encryption algorithm is divided into a white box library 402 and a key processing module 401, the key processing module performs T transformation on the 401 key, and the white box library 402 performs R transformation, and the R and T transformations cancel each other out, thereby achieving the purpose of hiding the original key. R and T transformations are diverse, as long as they are reversible to each other. Moreover, since the symmetric encryption algorithm has many rounds, the RT transformation of each round can be different, and the combination rules can be customized to increase the difficulty of cracking. The original key will not appear during the effective protection of memory operation; the white box key can be safely stored in the hard disk, and the attacker cannot infer the original key.
[0162] See also Figure 6 In one embodiment of the present invention, an electronic device 500 is provided, the electronic device comprising:
[0163] processor 501, and
[0164] The memory 502 is arranged to store computer executable instructions, which, when executed, cause the processor 501 to execute the above method. The memory 502 has a storage space for storing program codes.
[0165] See also Figure 7 In one embodiment of the present invention, a computer-readable storage medium 600 is provided, which stores one or more programs. When the one or more programs are executed by a processor, the above method is implemented.
[0166] The present invention also provides a storage medium for storing Figure 1 to Figure 3And a computer program of any of the methods described in the above multiple embodiments. For example, when a computer program instruction is executed by a computer, the method and / or technical solution according to the present application can be called or provided through the operation of the computer. The program instruction for calling the method of the present application may be stored in a fixed or removable storage medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium and / or stored in a storage medium of a computer device running according to the program instruction. Here, according to an embodiment of the present application, a computer program instruction may be provided. Figure 6 The electronic device 500 shown preferably includes a storage medium 600 for storing a computer program, a memory 502 and a processor 501 for executing the computer program, wherein when the computer program is executed by the processor 501, the electronic device 500 is triggered to execute the methods and / or technical solutions based on the aforementioned multiple embodiments.
[0167] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the above steps or functions. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0168] The method according to the present invention can be implemented on a computer as a computer-implemented method, or implemented in dedicated hardware, or implemented in a combination of the two. The executable code or part thereof for the method according to the present invention can be stored on a computer program product. The example of a computer program product includes a memory device, an optical storage device, an integrated circuit, a server, online software, etc. Preferably, the computer program product includes a non-temporary program code component stored on a computer-readable medium so as to perform the method according to the present invention when the program product is executed on a computer.
[0169] In a preferred embodiment, the computer program comprises computer program code means adapted to perform all the steps of the method according to the invention when the computer program is run on a computer.Preferably, the computer program is embodied on a computer readable medium.
[0170] In summary, the present invention obtains a white box key by performing a first transformation on the plaintext key; performs a second transformation on the S box of the symmetric algorithm to obtain a new encryption S box SE', wherein the second transformation is a reversible transformation of the first transformation; performs standard symmetric encryption processing on the plaintext and the white box key based on the new encryption S box SE', and outputs a ciphertext. Since the plaintext key is first subjected to a T transformation and then an R transformation, the R and T transformations cancel each other out, thereby achieving the purpose of hiding the original key. The R and T transformations are diverse, as long as they are reversible transformation operations. Moreover, since the symmetric encryption algorithm has many rounds, the RT transformations of each round can be different, the combination rules can be customized, and the key can be replaced at any time; the original key will not appear during the operation, which increases the difficulty of cracking and can resist white box attacks; the original key will not appear during effective protection of memory operations; the white box key can be safely stored in the hard disk, and attackers cannot infer the original key, thereby improving the security of the symmetric encryption algorithm.
[0171] Of course, the present invention may have many other embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art may make various corresponding changes and modifications based on the present invention, but these corresponding changes and modifications should all fall within the scope of protection of the claims attached to the present invention.
Claims
1. An encryption method based on a symmetric algorithm, characterized in that: The method comprises the following steps: Performing a first transformation on the plaintext key to obtain a white-box key; Performing a second transformation on the S-box of the symmetric algorithm to obtain a new encryption S-box SE', wherein the second transformation is a reversible transformation of the first transformation; Perform standard symmetric encryption processing on the plaintext and the white box key based on the new encryption S box SE', and output ciphertext; The first transformation of the plaintext key comprises: Calculating the plaintext key through the symmetric algorithm to obtain a first key, and performing the first transformation on the first key; Performing a second transformation on the S-box of the symmetric algorithm comprises: Performing the second transformation on the encryption S-box SE in the operation of searching the encryption S-box in the symmetric algorithm for the white box key; The performing the second transformation on the encryption S-box SE in the operation of searching the encryption S-box in the symmetric algorithm for the white box key comprises: In the encryption S-box lookup operation in the symmetric algorithm for the white box key, the position of the input byte a is searched from the encryption S-box SE to obtain the output byte b, so that b=SE(a); The second transformation is performed on the SE(a) to obtain b'=SE(R(a)), so that SE'(a)=SE(R(a)), and a new S-box SE' is generated.
2. The encryption method according to claim 1, characterized in that: The output ciphertext then includes: Perform the second transformation on the decryption S-box SD of the symmetric algorithm to obtain a new decryption S-box SD'; Based on the SD', standard symmetric decryption processing is performed on the ciphertext and the white-box key, and a plaintext corresponding to the ciphertext is output.
3. The encryption method according to claim 2, characterized in that: The performing the second transformation on the decryption S-box SD of the symmetric algorithm comprises: The second transformation is performed on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key.
4. The encryption method according to claim 3, characterized in that: The symmetric algorithm is AES, DES, 3DES and / or SM4 symmetric algorithm; The reversible transformation operation is an XOR operation; The first key is a round key.
5. The encryption method according to claim 4, characterized in that: The performing the second transformation on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key comprises: The output byte SD(a) is searched from the decryption S-box SD in the decryption S-box operation of the white box key in the symmetric algorithm, so that SD(a)=b', the second transformation is performed on the SD(a) to obtain SD'(a), and finally the input byte a is obtained.
6. The encryption method according to claim 5, characterized in that: The symmetric algorithm consists of multiple rounds, and the parameters of the reversible transformation operation in each round are the same or different.
7. An encryption device based on a symmetric algorithm, characterized in that: include: A key processing module, used for performing a first transformation on the plaintext key to obtain a white-box key; A white box library, used for performing a second transformation on the S box of the symmetric algorithm to obtain a new encryption S box SE', wherein the second transformation is a reversible transformation of the first transformation; and Used to perform standard symmetric encryption processing on the plaintext and the white box key based on the new encryption S box SE', and output ciphertext; The key processing module comprises: A key processing submodule, configured to obtain a first key by calculating the original key through the symmetric algorithm, and perform the first transformation on the first key to obtain the white-box key; A first output submodule, configured to output the white box key to the white box library; The white-box library includes: A first transformation submodule, configured to perform the second transformation on the encryption S-box SE in the operation of searching the encryption S-box for the white box key in the symmetric algorithm; A second output submodule, used to output the ciphertext; The performing the second transformation on the encryption S-box SE in the operation of searching the encryption S-box in the symmetric algorithm for the white box key comprises: In the encryption S-box lookup operation in the symmetric algorithm for the white box key, the position of the input byte a is searched from the encryption S-box SE to obtain the output byte b, so that b=SE(a); The second transformation is performed on the SE(a) to obtain b'=SE(R(a)), so that SE'(a)=SE(R(a)), and a new S-box SE' is generated.
8. The encryption device according to claim 7, characterized in that: The white box library is further used to perform the second transformation on the decryption S box SD of the symmetric algorithm to obtain a new decryption S box SD'; and Based on the SD', standard symmetric decryption processing is performed on the ciphertext and the white-box key, and a plaintext corresponding to the ciphertext is output.
9. The encryption device according to claim 8, characterized in that: The white box library also includes: A second transformation submodule, configured to perform the second transformation on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key; The third output submodule is used to output the plain text.
10. The encryption device according to claim 9, characterized in that: The symmetric algorithm is AES, DES, 3DES and / or SM4 symmetric algorithm; The reversible transformation operation is an XOR operation; The first key is a round key.
11. The encryption device according to claim 10, characterized in that: Performing the second transformation on the decryption S-box SD in the operation of searching the decryption S-box in the symmetric algorithm for the white box key comprises: The output byte SD(a) is searched from the decryption S-box SD in the decryption S-box operation of the white box key in the symmetric algorithm, so that SD(a)=b', the second transformation is performed on the SD(a) to obtain SD'(a), and finally the input byte a is obtained.
12. The encryption device according to claim 11, characterized in that: The symmetric algorithm consists of multiple rounds, and the parameters of the reversible transformation operation in each round are the same or different.
13. An electronic device, characterized in that: The electronic device includes: processor, and A memory arranged to store computer executable instructions which, when executed, cause the processor to perform a method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
White-box SM4 cryptographic algorithm scheme and system
CN108809626A