Encryption method, device, equipment, medium and program product
By using nonlinear encoding and key tables for iterative encryption and transformation in the white box SM4 algorithm, the problem of high cost and low security for encrypting data in the white box SM4 algorithm is solved, achieving higher data protection security and lower encryption costs.
Patent Information
- Application Number
- CN202411853378.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-11
AI Technical Summary
The white box SM4 algorithm has high cost of encrypting data and low data protection security.
By obtaining plaintext data and using nonlinear encoded data and key table for L round iterative encryption, obfuscated ciphertext data are obtained. Then affine transformation and mixed nonlinear transformation are performed on the obfuscated ciphertext data to offset the nonlinear encoded data introduced by multiple rounds of iterative encryption to obtain the encrypted data.
It improves the security of data protection, effectively resists attacks from external encoding, reduces the cost of data encryption, and is universal.
Smart Images

Figure CN119808115A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular, relates to an encryption method, device, equipment, medium and program product. Background Art
[0002] With the diversification of payment methods and the complexity of payment scenarios, the challenges faced by key protection are becoming increasingly severe. More and more payment service terminals have begun to use white-box cryptography to improve key security in untrusted environments. White-box cryptography is a technology that uses lookup table technology to encode and protect keys, hides keys in lookup tables, and encrypts data. Based on this, the national secret SM4 algorithm can be embedded in a complex white-box environment to obtain the white-box SM4 algorithm, and the general white-box SM4 algorithm can be used to encrypt keys and other sensitive data to ensure that sensitive data will not be leaked even in untrusted environments.
[0003] In the related technology, a chip of white-box cryptography technology can be set in the encryption device to realize a trusted environment to improve the security of encrypted sensitive data, or random data can be added to the lookup table to increase the confusion of the key and increase the difficulty of cracking the white-box SM4 algorithm. However, the former requires adding a chip of the white-box algorithm to the encryption device, which increases the cost of data encryption and lacks versatility; the latter, since the filling position of the random data is fixed, the attacker only needs to eliminate the random data at the corresponding position to restore it to the standard white-box algorithm, making the white-box SM4 algorithm easy to crack, thereby reducing the security of data protection. Summary of the invention
[0004] The embodiments of the present application provide an encryption method, apparatus, device and storage medium, which can solve the problems of high cost of data encryption and low security of data protection in the white box SM4 algorithm in the related art.
[0005] In a first aspect, an embodiment of the present application provides an encryption method, which may include:
[0006] Get plaintext data;
[0007] According to the plaintext data, the nonlinear coding data and the key table, L rounds of iterative encryption are performed to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes an input nonlinear inverse code and an output nonlinear code, the input nonlinear inverse code is used to offset the output nonlinear code added by the preceding operation, and the output nonlinear code is used to be offset in the subsequent operation, and L is an integer greater than 1;
[0008] Affine transformation and mixed nonlinear transformation are performed on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, and the encrypted data is the data after the nonlinear coding data introduced by multiple rounds of iterative encryption is offset.
[0009] In a second aspect, an embodiment of the present application provides an encryption device, which may include:
[0010] An acquisition module, used to obtain plaintext data;
[0011] The encryption module is used to perform L rounds of iterative encryption according to the plaintext data, the nonlinear coding data and the key table to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes an input nonlinear inverse code and an output nonlinear code, the input nonlinear inverse code is used to offset the output nonlinear code added by the preceding operation, and the output nonlinear code is used to be offset in the subsequent operation, and L is an integer greater than 1;
[0012] The transformation module is used to perform affine transformation and mixed nonlinear transformation on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data. The encrypted data is the data after the nonlinear coding data introduced by multiple rounds of iterative encryption is offset.
[0013] In a third aspect, an embodiment of the present application provides a computer device, the computer device comprising: a processor and a memory storing computer program instructions;
[0014] When the processor executes the computer program instructions, the encryption method shown in the first aspect is implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a computer storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the encryption method shown in the first aspect is implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the encryption method shown in the first aspect.
[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the encryption method shown in the first aspect.
[0018] The encryption method, device, equipment and storage medium of the embodiment of the present application can obtain plaintext data; perform L rounds of iterative encryption according to the plaintext data, nonlinear coding data and key table to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes input nonlinear inverse coding and output nonlinear coding, the input nonlinear inverse coding is used to offset the output nonlinear coding added by the preceding operation, and the output nonlinear coding is used to be offset in the subsequent operation, and L is an integer greater than 1; perform affine transformation and mixed nonlinear transformation on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, and the encrypted data is the data after offsetting the nonlinear coding data introduced by multiple rounds of iterative encryption. In this way, by obfuscating the affine transformation data and the key table with the nonlinear coding data, the obfuscation and protection of the affine transformation data and the key table can be achieved, the security of data protection is improved, and the input nonlinear inverse coding is used to offset the coding added by the preceding operation, and the output nonlinear coding is offset in the subsequent operation. After the nonlinear coding is obfuscated, it can effectively resist attacks from the external coding end, improve the security of the white box SM4 algorithm, and do not need to add a chip of the white box algorithm in the encryption device, reduce the cost of data encryption, and have universal applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 This is a schematic diagram of the Xiao-Lai white box SM4 algorithm principle;
[0021] Figure 2 This is a schematic diagram of the external encoding of the white-box SM4 algorithm;
[0022] Figure 3 Schematic diagram of the L-transform expansion principle in the WSISE algorithm;
[0023] Figure 4 A schematic diagram of a flow chart of an encryption method provided in an embodiment of the present application;
[0024] Figure 5 A schematic diagram of 2-bit non-linear coding of an encryption method provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram of converting an affine transformation of an encryption method provided in an embodiment of the present application into four groups of block operations;
[0026] Figure 7 A schematic diagram of a flow chart of using an affine table in an encryption method provided in an embodiment of the present application;
[0027] Figure 8 A schematic diagram of non-linear encoding of an affine table according to an encryption method provided in an embodiment of the present application;
[0028] Fig. 9 A schematic diagram of nonlinear coding of four groups of affine tables for input coding of an encryption method provided in an embodiment of the present application;
[0029] Fig.10 A schematic diagram of non-linear coding based on the XOR lookup table principle of an encryption method provided in an embodiment of the present application;
[0030] Fig.11 A schematic diagram of an input coding operation process of an encryption method provided in an embodiment of the present application;
[0031] Fig.12 A schematic diagram of an intermediate algorithm round iteration process of an encryption method provided in an embodiment of the present application;
[0032] Fig.13 A schematic diagram of an affine transformation operation flow of an intermediate algorithm round of an encryption method provided in an embodiment of the present application;
[0033] Fig.14 Schematic diagram of the key table operation of the Xiao-Lai white box SM4 algorithm;
[0034] Fig.15 A combination of an encryption method provided in an embodiment of the present application P" i+4 Schematic diagram of the key table operation of the operation;
[0035] Fig.16 A combination of an encryption method provided in an embodiment of the present application P" i+4 Schematic diagram of the white-box algorithm after operation;
[0036] Fig.17 A combination of an encryption method provided in an embodiment of the present application P" i+4 Schematic diagram of the key table operation after operation;
[0037] Fig.18 A schematic diagram of input data of a key table of an encryption method provided in an embodiment of the present application;
[0038] Fig.19 A schematic diagram of adding nonlinear coding to an XOR operation of an intermediate algorithm round of an encryption method provided in an embodiment of the present application;
[0039] Fig. 20 For the existing synthesis transformation principle;
[0040] Fig.21A schematic diagram of a synthesis transformation used in an algorithm of an encryption method provided in an embodiment of the present application;
[0041] Fig. 22 A schematic diagram of an output encoding operation flow of an encryption method provided in an embodiment of the present application;
[0042] Fig.23 is a schematic diagram of the structure of an encryption device provided by an embodiment of the present application;
[0043] Fig.24 It is a schematic diagram of the structure of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0044] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0045] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0046] The acquisition, storage, use, and processing of data (including but not limited to the features and information in the text) in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0047] The basic principle of the white-box SM4 algorithm is as follows: Figure 1 As shown, the algorithm replaces the encryption and decryption operations in each round of the SM4 algorithm with 4 sets of lookup tables, thereby hiding the key in the lookup table. During the encryption and decryption process, the key will not appear in the memory in any plaintext form, and the encryption process is protected by the lookup table.
[0048] Among them, the white-box SM4 algorithm exposes major deficiencies in terms of security and encryption efficiency, specifically including the following aspects.
[0049] First, if Figure 2 As shown, the white-box SM4 algorithm has the problem of not protecting the external coding. Here, the external coding in the embodiment of the present application refers to the coding process other than the intermediate algorithm rounds executed on the client, such as the input coding stage and the output coding stage. Specifically, the algorithm uses scrambling coding between each encryption round in the intermediate algorithm round to protect the intermediate data. In actual use, it is necessary to add external coding before the first round and after the last round to offset the scrambling information mixed in the first and last rounds. It can be proved that when the input coding or output coding is known, only O(2 20.4 ) can crack the round key hidden in the lookup table of the white-box cryptographic algorithm under an attack complexity of . Although the external code is indispensable for the encryption and decryption operations of the white-box algorithm and seriously threatens the security of the algorithm, the aforementioned encryption method does not protect the external code. It is usually assumed that the code runs on a secure platform and is invisible to attackers. However, in actual applications, there is often no ideal security platform to specifically protect the external code, which greatly limits the application scenarios of the algorithm and is also a major security risk that cannot be ignored in the actual application of the algorithm. Although, the external code can be protected by using a security chip to improve encryption security. However, it is necessary to add a new security chip to the encryption device, which puts higher requirements on the hardware, increases the cost of data encryption, and lacks versatility.
[0050] Secondly, the white-box SM4 algorithm has problems with the protection of intermediate algorithm rounds and low computational efficiency. Specifically, the attack method for Xiao-Lai SM4 white-box is to vertically merge some modules, eliminate the confusion of network coding, construct an algebraic expression with affine relationship, and add additional methods such as differential analysis and solving linear equations. It can be used in at most O(2 47 ) to extract the key within the time complexity of the algorithm. This attack method uses synthetic transformation to offset or partially offset adjacent coded information in the algorithm, thereby extracting key intermediate data and obtaining the functional relationship between the input and output of the synthetic transformation, thereby recovering E i Then, according to the data relationship before and after the key table operation, a linear equation system is established, and the equation system is solved by E i The round keys contained in the key table are solved by using the same data. Based on this, the white box SM4 algorithm introduces affine transformation to protect the intermediate data. The algorithm's 32 rounds of encryption and decryption operations and external encoding contain a total of 168 affine transformations. Each affine transformation consists of a 32-order matrix multiplication and a 32-bit XOR operation. Since matrix multiplication consumes a lot of performance, the encryption and decryption efficiency of this algorithm is much lower than that of the standard algorithm.
[0051] Third, the WSISE algorithm can be used. This algorithm expands the 32bit×32bit L matrix in the Shaw-Lay white box SM4 algorithm to 64bit×64bit, and adds random numbers to the lookup table to confuse the key. The security of the algorithm is improved by increasing the confusion of the key table data. The principle of L matrix expansion is as follows: Figure 3 As shown in the figure. However, the WSISE algorithm adds random data to the key table after expanding the L transformation to confuse the intermediate product. However, since the expansion position of the L transformation is fixed, it means that the filling position of the random data is also fixed. The attacker only needs to eliminate the corresponding random data to restore it to the standard Shaw-Lay white box algorithm. Therefore, this improved algorithm can increase the difficulty of cracking the key to a certain extent, but the security of the algorithm has not been substantially improved.
[0052] Fourth, in order to improve the efficiency of encryption and decryption, an improved algorithm of the Shaw-Lai SM4 white-box algorithm is proposed, which simplifies the affine transformation of 32 iterations of the intermediate algorithm round to affine transformation of 16 iterations, thereby reducing the computational complexity and improving the efficiency of encryption and decryption. However, although this method can improve the efficiency of encryption and decryption, it will greatly reduce the security of the algorithm.
[0053] In order to solve the problems in the related art, the embodiment of the present application proposes an encryption method of white box SM4 based on nonlinear coding for the Xiao-Lai white box SM4 algorithm. By using nonlinear coding data to confuse affine transformation data such as a radiometric lookup table and key table data, the white box SM4 algorithm can resist attacks from external coding and improve the security of the algorithm. In addition, the embodiment of the present application uses different and random nonlinear coding data to confuse affine transformation data and key tables, and uses an XOR table to implement XOR operations on encoded data, and adds input nonlinear inverse coding to the input end of the protected data and output nonlinear coding to the output end, so as to achieve obfuscation and protection of affine transformation data and key table data. Among them, the input nonlinear inverse coding is used to offset the nonlinear coding data added by the preceding operation, and the output nonlinear coding is offset in the subsequent operation. In this way, after the nonlinear coding data is obfuscated, it can effectively resist attacks from the external coding end and improve the security of the algorithm.
[0054] Based on this, the following will combine the attached Figures 4 to 24 , describes in detail the encryption method, apparatus, computer equipment, storage medium and computer program product of the embodiments of the present application. It should be noted that these embodiments are not intended to limit the scope of the present application.
[0055] First, combine Figure 4 The encryption method provided in the embodiment of the present application is described in detail.
[0056] Figure 4 A flowchart of an encryption method provided in an embodiment of the present application.
[0057] like Figure 4 As shown, the encryption method can be applied to a computer device, and the computer device can be the encryption method which specifically can include the following steps:
[0058] Step 410, obtaining plaintext data; Step 420, performing L rounds of iterative encryption according to the plaintext data, nonlinear coding data and key table to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes input nonlinear inverse coding and output nonlinear coding, the input nonlinear inverse coding is used to offset the output nonlinear coding added by the preceding operation, the output nonlinear coding is used to be offset in the subsequent operation, and L is an integer greater than 1. Step 430, performing affine transformation and mixed nonlinear transformation on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, the encrypted data is the data after the nonlinear coding data introduced by multiple rounds of iterative encryption is offset.
[0059] In this way, by confusing the affine transformation data and the key table with nonlinear coding data, the confusion and protection of the affine transformation data and the key table can be achieved, thereby improving the security of data protection. In addition, the input nonlinear inverse coding is used to offset the coding added by the previous operation, and the output nonlinear coding is offset in subsequent operations. After the nonlinear coding obfuscation, it can effectively resist attacks from the external coding end, thereby improving the security of the white box SM4 algorithm. At the same time, there is no need to add a new white box algorithm chip in the encryption device, thereby reducing the cost of data encryption and having universal applicability.
[0060] The above steps are described in detail below, as shown below.
[0061] First, in step 410, the content of the plaintext data can be determined according to the application scenario. For example, in a payment scenario, the plaintext data may include but is not limited to payment information; in a user login scenario, the plaintext data may include but is not limited to user identity information, which will not be illustrated one by one here. All plaintext data that needs to be encrypted and protected are within the protection scope of the embodiments of this application.
[0062] Secondly, in step 420, in the embodiment of the present application, the affine table and the key table in the improved algorithm are obfuscated and protected by nonlinear coding to improve the security of the algorithm. Figure 5 Nonlinear encoding will be described.
[0063] The nonlinear coding in the embodiments of the present application refers to a coding method that does not satisfy the linear superposition principle, and the data related to the coding method are all nonlinear coding data. When this coding method processes data, there is no linear relationship between its output and input, that is, its output cannot be predicted or described by a simple linear combination. Figure 5 As shown in the example diagram of 2-bit nonlinear coding, the nonlinear coding can map 2-bit data 0, 1, 2, 3 to another 2-bit data, and its nonlinear inverse coding is the reverse mapping relationship. The nonlinear coding can be saved in the form of a lookup table. For n-bit nonlinear coding, there are 2n! combinations. In the embodiment of the present application, a 4-bit random nonlinear coding table data can be used for obfuscation.
[0064] Based on this, in some embodiments of the present application, step 420 may specifically include step 4201 and step 4202.
[0065] Step 4201, perform affine transformation and mixed nonlinear transformation on the plaintext data and the nonlinear coded data to obtain obfuscated plaintext data.
[0066] Step 4202, by obfuscating the plaintext data, the non-linearly coded data and the key table, L rounds of iterative encryption are performed to obtain obfuscated ciphertext data.
[0067] Furthermore, the embodiment of the present application is an improvement on the algorithm performance, that is, the operation form of the affine transformation is modified. That is, a large number of affine transformations are used in the Shaw-Lay white box SM4 algorithm to protect intermediate data. In order to improve the encryption and decryption efficiency of the algorithm, the embodiment of the present application converts the affine transformation into a lookup table to reduce the performance consumption caused by the affine transformation operation.
[0068] Based on this, the plaintext data includes multiple plaintext data blocks, and the above step 4201 can specifically include steps 42011 to 42014, which can protect the input code, as shown below.
[0069] Step 42011, split each plaintext data block to obtain N groups of data blocks, each group of data blocks includes M data sub-blocks, the values of N and M are related to the size of the matrix data of the plaintext data block, N and M are integers greater than 1, and each data sub-block corresponds to an input nonlinear inverse code and an output nonlinear code.
[0070] For example, Figure 6 As shown, the plaintext data X before conversion can be plaintext data, and the size of the matrix data of the plaintext data can be 32×1. After step 42011, the plaintext data is split, that is, 4 groups of data blocks, namely X, are obtained. 0 , X 1 , X 2 , X3 , the size of the matrix data of each data block is the same, both are 8×1.
[0071] Step 42012, perform affine transformation on each data sub-block and the corresponding output non-linear code to obtain affine data of each data sub-block.
[0072] Exemplarily, the affine transformation in the embodiments of the present application refers to a composite operation form including matrix multiplication and vector addition, which can be expressed by the following formula (1):
[0073] P(x) = l[P](x) ⊕ c[P] (1)
[0074] Among them, P(x) is the input code; l[P] represents the linear part of the input code, which is a matrix and can be a 32×32 reversible matrix; x is the object to be affine transformed, that is, the plaintext data, which can be a data block or a data sub-block; c[P] represents the vector part, which can be a 32-bit constant; ⊕ is the XOR operation. Affine transformation data is randomly generated. If the matrix part or the vector part is directly obfuscated, it is equivalent to replacing the corresponding multiple groups of affine transformations with new random data, which does not add obfuscation in essence.
[0075] The embodiment of the present application first converts the affine transformation into the form of a lookup table, and then confuses the lookup table. Since the 32nd-order affine transformation is a 32-bit to 32-bit operation, if the lookup table is used directly for replacement, a table of 232×32=16GB is required for storage, which will take up a large amount of storage space of the encryption device in practical applications. Therefore, the embodiment of the present application splits the entire operation into several smaller operations, and then uses the form of a lookup table to represent these operations, that is, splits the plaintext data block to obtain N groups of data blocks, and splits each data block to obtain M data sub-blocks of each data block.
[0076] For reference Figure 6 As shown, the affine transformation before conversion is shown in the following formula (2), the derivation from before conversion to after conversion can be shown in formula (3), and the operation form of the radiation transformation after conversion is shown in Figure (4):
[0077] P(x) = l[P](x) ⊕ c[P] (2)
[0078] P(x) = (l[P] 0 l[P] 1 l[P] 2 l[P] 3 ) (x 0 x 1 x 2 x 3 )-1 ⊕ c[P] (3)
[0079] P(x)=(l[P] 0 ·x 0 )⊕(l[P] 1 ·x 1 )⊕(l[P] 2 ·x 2 )⊕(l[P] 3 ·x 3 ⊕c[P]) (4)
[0080] Where l[P] i Indicates splitting the original 32×32 data block into 4 groups of 32×8 data sub-blocks, x i It means splitting the 32-bit plaintext data x into 4 groups of 8-bit data blocks. It should be noted that the data blocks, data sub-blocks, data block pairs, ciphertext data blocks, ciphertext data sub-blocks, compound XOR data blocks, compound XOR data sub-blocks, etc. in the embodiments of the present application can be represented by matrices or vectors, which will not be repeated here.
[0081] After the above transformation, the block operation l[P] i ·x i It becomes a matrix multiplication of 32×8 and 8×1, and the result is 32 bits. The original affine transformed data block c[P] needs to be XORed with the result of any group of data block operations. In the embodiment of the present application, it can be combined with the last group of data block operations, such as Figure 6 As shown in the figure, after the above operations, the original 32-order affine transformation is split into 4 groups of 32×8 and 8×1 matrix multiplications and 4 32-bit XOR operations, i.e., XOR operations. Each group of 8-bit data blocks is traversed to generate a lookup table with 8-bit input and 32-bit output, which is called an affine table.
[0082] During encryption operations, the input 32-bit plaintext data can be split into four groups of 8-bit data blocks, and four groups of affine tables are used for table lookup operations. Then, the four groups of 32-bit output data are XORed with each other to generate the same result as the original affine transformation operation, such as Figure 7 As shown in Figure 2, the original 32-order affine transformation is converted into a 4-order affine table and 3 XOR operations, where the 4-order affine table is the affine table T 0 , T 1 , T 2 , T 3 , and 3 XOR operations, namely T 0 and T 1 The output data of the 2 , T 3 The output data are XORed with each other, and T 0and T 1 The output data after XORing each other and T 2 , T 3 The output data of the first transformation are mutually exclusive-ORed, which not only greatly reduces the amount of calculation during encryption and decryption, but also creates conditions for adding obfuscation information later. In terms of volume occupancy, the four affine tables of each affine transformation require a total of 28×32×4=4K of space. In this way, the operations of the entire white-box SM4 algorithm are transformed into table lookup operations and exclusive-OR operations, which can improve encryption efficiency.
[0083] It should be noted that the conversion in the embodiment of the present application is to change the operation form of matrix multiplication and vector addition of affine transformation into table lookup and XOR operation, which is essentially an efficient implementation form of affine transformation. The security is equivalent to that before the conversion. At the operational level, it is an optimization strategy of exchanging space for time.
[0084] Step 42013, combine the affine data of each data sub-block in each group of data blocks to obtain an affine table for each group of data blocks. Here, the affine table is a lookup table in the white box cryptographic algorithm, which can be used to find the affine data for each round of encryption, and will not be described in detail here.
[0085] For example, the affine transformation of each group of data blocks corresponds to one group of affine tables, that is, four groups of data blocks correspond to four groups of affine tables, and each affine table contains 256 32-bit table data. Before obfuscation, multiple groups of 4-bit nonlinear coding tables and their inverse coding tables are randomly generated. Then, each 32-bit search data is encoded. Taking the first group of affine tables as an example, that is, l[P] 0 ·x 0 The corresponding operation, coded as Figure 8 As shown, originally l[P] 0 ·x 0 The corresponding operation is converted into 8-bit input and 32-bit output affine table data. Different 8-bit input x corresponds to 32-bit output x'. When using non-linear coding, the 32-bit table data is split into 8 groups of 4-bit data. Each group of data is encoded and obfuscated using the corresponding non-linear coding table and saved as new 32-bit table data.
[0086] Based on this, the encoding effect of the 4 sets of affine tables corresponding to the entire affine transformation is as follows Fig. 9 As shown, Fig. 9 As shown in 0 For example, M data sub-blocks are 8 groups of 4-bit data with 4bit+A 0 Taking the data sub-block as an example, A 0 For output nonlinear coding, that is, nonlinear coding at the output end, please refer to Fig.10 , A 0 -14bit+A 0 The input non-linear inverse encoding of the data sub-blocks.
[0087] Step 42014, according to the input nonlinear inverse code corresponding to each data sub-block, the affine tables of the N groups of data blocks are XORed to obtain obfuscated plaintext data.
[0088] Exemplarily, the affine table of the input code is added with nonlinear coding information at the output end, so the nonlinear coding must be eliminated before the XOR operation is performed on the output of these lookup tables. Since each nonlinear code is related to the security of the algorithm and cannot be directly exposed, it is necessary to use an 8-bit in 4-bit out XOR table to replace the original XOR operation. Therefore, the embodiment of the present application adds input nonlinear inverse coding to the input end of the protected data and output nonlinear coding to the output end to achieve obfuscation and protection of affine transformation data. Among them, the input nonlinear inverse coding is used to offset the nonlinear change data added by the preceding operation, and the output nonlinear coding is offset in subsequent operations. After the nonlinear coding obfuscation, it can effectively resist attacks from the external coding end, so that the security of the algorithm is significantly enhanced.
[0089] In some embodiments of the present application, the above step 42011 may specifically include:
[0090] Based on the size of the matrix data of the plaintext data block, each plaintext data block is split according to the reference splitting condition to obtain N groups of data blocks;
[0091] Among them, the reference splitting conditions include that the number of split plaintext data blocks complies with the matrix operation rules and at least one of the following: the data volume of the split data blocks is less than or equal to the preset data volume, and the matrix operation calculation performance index value is greater than the preset calculation performance index value.
[0092] For example, the 32nd-order affine transformation is split into 4 groups of 32×8 and 8×1 matrix multiplications and 4 32-bit XOR operations, i.e., XOR operations. The number of the split plaintext data blocks conforms to the matrix operation rules. Since the data volume is too large when split into 16×2, the splitting method is not considered.
[0093] In some embodiments of the present application, N groups of data blocks include a data block pair, a data block pair includes a first group of data blocks and a second group of data blocks, and the above-mentioned step 42014 may specifically include steps 420141 to 420144, as shown below.
[0094] Step 420141, according to the affine data of the ith data sub-block in the affine table of the first group of data blocks and the input nonlinear inverse code corresponding to the ith data sub-block, and the affine data of the jth data sub-block in the affine table of the second group of data blocks and the input nonlinear inverse code corresponding to the jth data sub-block, perform an XOR operation on the affine data of the ith data sub-block and the affine data of the jth data sub-block to obtain the XOR data of the ith data sub-block and the jth data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1].
[0095] For example, the operation flow of the XOR table is as follows: Fig.10 As shown in the figure, two 32-bit data after nonlinear coding are each split into 8 groups of 4-bit data, and each two 4-bit data are combined into 8-bit new data as the input of the XOR table, where i and j are both 0. The affine data of the 0th data sub-block in the affine table of the first group of data blocks is 4bit+A. 0 , the input nonlinear inverse code corresponding to the 0th data sub-block is A 0 -1 The affine data of the 0th data sub-block in the affine table of the second group of data blocks is 4bit+B 0 , the input nonlinear inverse code corresponding to the 0th data sub-block is B 0 -1 Based on this, the XOR table uses the corresponding input nonlinear inverse coding for the high 4 bits and the low 4 bits to eliminate the newly added input nonlinear coding of the input in the affine table, and then performs the XOR operation, and then uses the nonlinear coding to encode the XOR result.
[0096] Step 420142, add the output nonlinear code corresponding to the i-th data sub-block or the j-th data sub-block to the XOR data of the i-th data sub-block and the j-th data sub-block, and obtain the XOR data of the combined data block of the i-th data sub-block and the j-th data sub-block.
[0097] For example, reference may still be made to Fig.10 As shown, the output nonlinear code C corresponding to the 0th data sub-block or the 0th data sub-block is added to the XOR data of the 0th data sub-block and the 0th data sub-block. 0 , we can get the combined data block of the 0th data sub-block and the 0th data sub-block, that is, 4bit+C 0 The data block where the XOR data of the combined data block can be 4bit+C 0 .
[0098] Step 420143, combine the XOR data of the combined data blocks of the same bit data sub-blocks in the first group of data blocks and the second group of data blocks to obtain an XOR lookup table corresponding to a data block pair.
[0099] For example, reference may still be made to Fig.10 As shown, the combined data block of 8 identical bit data sub-blocks can be combined, that is, from 4bit+C 0 To 4bit+C 7 , we can get Fig.10 The rightmost XOR lookup table.
[0100] Step 420144, combine the XOR data in the XOR lookup table corresponding to a data block to obtain obfuscated plaintext data.
[0101] For example, reference may still be made to Fig.10 As shown, by combining the XOR data in the XOR lookup table, the obfuscated plaintext data can be obtained, for example, Fig.11 The last one is X'+G.
[0102] In some embodiments of the present application, the above embodiment is still used as an example, that is, the above XOR table operation is finally saved as an 8-bit input 4-bit output XOR table, in which the nonlinear coding data is used as an intermediate value and is not retained after use. 4 ! =2.1×10 13 It is very difficult for an attacker to restore the nonlinear coding information from the XOR table. So far, the operation flow of a complete set of input codes is as follows: Fig.11 As shown, each group of input coded data is distributed into 4 groups of 8-bit-input 32-bit-output affine tables and 24 groups of 8-bit-input 4-bit-output XOR tables, from which it is difficult for attackers to recover the input code, thereby achieving protection of the input code. After this operation, the output XOR result also adds a new nonlinear code. Based on this, the N groups of data blocks include at least two data block pairs, and the at least two data block pairs include a first data block pair and a second data block pair. The above step 42014 can specifically include steps 420145 to 420148 as shown below.
[0103] Step 420145, perform an XOR operation on the XOR data of the u-th combined data block and the XOR data of the v-th combined data block in the XOR lookup table corresponding to the first data block and the input non-linear inverse coding corresponding to the v-th combined data block, and perform an XOR operation on the XOR data of the u-th combined data block and the XOR data of the v-th combined data block to obtain the XOR data of the u-th combined data block and the v-th combined data block, wherein the value of u is equal to the value of v, u∈[0,M-1], v∈[0,M-1].
[0104] For example, reference may still be made to Fig.11 , if u and v are 0, the first data block pair can be X0 and X 1 The corresponding data block pair, XOR lookup table 0th combination data block XOR data 4bit + E 0 , XOR data 4bit+E 0 The corresponding input nonlinear inverse code E corresponding to the 0th combined data block 0 -1 The second data block pair can be X 2 and X 3 The corresponding data block pair, XOR lookup table 0th combination data block XOR data 4bit + F 0 , and the input nonlinear inverse code F corresponding to the 0th combined data block 0 -1 .
[0105] Step 420146, add the output nonlinear code corresponding to the u-th combined data block or the v-th combined data block to the XOR data of the u-th combined data block and the v-th combined data block to obtain the XOR data of the u-th combined data block and the v-th combined data block.
[0106] For example, reference may still be made to Fig.11 , add the output nonlinear code G corresponding to the 0th bit combination data block or the 0th bit combination data block to the XOR data of the 0th bit combination data block and the 0th bit combination data block 0 , get the XOR data of the 0th combined data block and the 0th combined data block, that is, 4bit+G 0 .
[0107] Step 420147, combine the XOR data of the combined data blocks of the same bit data sub-blocks in the two data blocks in the first data block pair and the second data block pair, and obtain the XOR lookup table corresponding to the first data block pair and the second data block pair.
[0108] For example, reference may still be made to Fig.11 As shown, we can get 4bit+G 0 Up to 4bit+G 7 Construct an XOR lookup table.
[0109] Step 420148, looping through the XOR operation until a XOR lookup table of a data block pair is obtained, and combining the XOR data in the XOR lookup table corresponding to a data block pair to obtain obfuscated plaintext data. The XOR operation step may include the above steps 420145 to 420147.
[0110] Exemplarily, since the XOR operation in the embodiment of the present application is to aggregate the XOR data in the XOR lookup table of two data blocks, i.e., a data block pair, the XOR operation is performed on the data in the XOR lookup table of multiple data block pairs until the XOR data in the XOR lookup table is left. Fig.11 The two data blocks shown in the figure are a data block pair XOR lookup table, and an XOR data table can be obtained. At this time, the XOR data in the XOR data table can be summarized to obtain the obfuscated plaintext data, such as Fig.11 X'+G shown.
[0111] In some other embodiments of the present application, the obfuscated plaintext data includes a plurality of obfuscated ciphertext data blocks. Based on this, step 4202 may specifically include:
[0112] An encryption operation is performed on each round of L iterations, and ciphertext data obtained in the last round of L iterations is determined as obfuscated ciphertext data.
[0113] For example, Fig.12 As shown, what is added to the input is the input nonlinear inverse code N corresponding to the previous operation. -1 i , to offset the output nonlinear coding N added in the previous round i In the embodiment of the present application, L can take a value of 32.
[0114] The encryption operation may include steps 510 to 560:
[0115] Step 510: split each obfuscated ciphertext data block to obtain P groups of ciphertext data blocks, each group of ciphertext data blocks includes at least two ciphertext data sub-blocks, and P is an integer greater than 1.
[0116] For example, Fig.13 As shown, if P is 4, 4 groups of ciphertext data blocks, one group of ciphertext data blocks includes at least two ciphertext data sub-blocks, which can be 4bit+G 0 The ciphertext data sub-block and 4bit+G 1 The ciphertext data sub-block.
[0117] Step 520: Perform a composite affine transformation on each ciphertext data sub-block and the corresponding input nonlinear inverse code to obtain composite affine data of each ciphertext data sub-block.
[0118] For example, still taking the above as an example, you can refer to Fig.13 As shown, 4bit+G 0 The nonlinear inverse code of the input corresponding to the ciphertext data sub-block is G 0 -1 , 4bit+G 1 The nonlinear inverse code of the input corresponding to the ciphertext data sub-block is G 1 -1 Based on this, the composite affine data 4bit+K of the ciphertext data sub-block is obtained 0 .
[0119] Step 530, combining the composite affine data of each ciphertext data sub-block in each group of ciphertext data blocks to obtain a composite affine table for each group of ciphertext data blocks.
[0120] For example, still taking the above as an example, you can refer to Fig.13 As shown, the composite affine data of the ciphertext data sub-block is summarized, such as 4bit+K 0 , 4bit+K 1 , 4bit+K 2 , 4bit+K 3 , 4bit+K 4 , 4bit+K 5 , 4bit+K 6 , 4bit+K 7 , and obtain the composite affine table.
[0121] Step 540, based on the input nonlinear inverse coding of each ciphertext data sub-block, perform an XOR operation on the composite affine table of the P group of data blocks to obtain a composite XOR table of at least two data blocks in the P group of data blocks, each composite XOR table includes multiple composite XOR data blocks, and each composite XOR data block includes at least two composite XOR data sub-blocks.
[0122] For example, still taking the above as an example, you can refer to Fig.13 As shown, the composite affine table of the four groups of data blocks is XORed to obtain at least two data blocks such as X in the four groups of data blocks. 0 and X 1 Composite XOR table, such as 4bit+O 0 , 4bit+O 1 , 4bit+O 2 , 4bit+O 3 , 4bit+O 4 , 4bit+O 5 , 4bit+O 6 , 4bit+O 7 , and X 3 and X 4 Composite XOR table, such as 4bit+P 0 , 4bit+P 1 , 4bit+P 2 , 4bit+P 3 , 4bit+P 4 , 4bit+P 5 , 4bit+P 6 , 4bit+P 7 .
[0123] Step 550, based on each composite XOR data sub-block and the input nonlinear inverse code corresponding to each composite XOR data sub-block, and the key table, a hybrid nonlinear transformation is performed to obtain the key table of each composite XOR data block. The key table is a lookup table in the white box cryptographic algorithm, which can be used to find the round key of each round of encryption, and will not be described in detail here. The composite affine transformation data is the composite affine transformation data in the white box cryptographic algorithm.
[0124] For example, still taking the above as an example, you can refer to Fig.13 As shown, nonlinear inverse coding can be integrated, such as O 0 -1 , Q 0 -1 And the key table is mixed nonlinearly transformed to obtain the key table of each composite XOR data block, such as 4bit+Q 0 , 4bit+Q 1 , 4bit+Q 2 , 4bit+Q 3 , 4bit+Q 4 , 4bit+Q 5 , 4bit+Q 6 , 4bit+Q 7 .
[0125] Step 560, performing an XOR operation on the key table of the P group of data blocks according to the input nonlinear inverse coding of each composite XOR data sub-block to obtain ciphertext data.
[0126] For example, still taking the above as an example, you can refer to Fig.13 As shown, the ciphertext data Y i +Q.
[0127] In some embodiments, the P group of data blocks in the embodiments of the present application includes at least one data block pair, each data block pair in the at least one data block pair includes a third group of data blocks and a fourth group of data blocks, and the above step 540 can specifically include steps 5401 to 5403.
[0128] Step 5401, based on the composite affine data of the i-th ciphertext data sub-block and the input nonlinear inverse code corresponding to the i-th ciphertext data sub-block in the composite affine table of the third group of data blocks, and the composite affine data of the j-th ciphertext data sub-block and the input nonlinear inverse code corresponding to the j-th ciphertext data sub-block in the composite affine table of the fourth group of data blocks, perform an XOR operation on the composite affine data of the i-th ciphertext data sub-block and the composite affine data of the j-th ciphertext data sub-block to obtain the composite XOR data of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1].
[0129] Step 5402, adding the output nonlinear code corresponding to the i-th ciphertext data sub-block or the j-th ciphertext data sub-block to the composite XOR data of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block, to obtain the composite XOR data of the combined data block of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block.
[0130] Step 5403, combine the composite XOR data of the combined data blocks of the same bit ciphertext data sub-blocks in the third group of data blocks and the fourth group of data blocks to obtain the composite XOR lookup table corresponding to the third group of data blocks and the fourth group of data blocks.
[0131] Therefore, the embodiment of the present application can convert the affine transformation operations of the Shaw-Lai white-box SM4 algorithm, including input coding, output coding, and intermediate algorithm round composite affine transformation, into table lookup and XOR operations, that is, convert each affine transformation data into 4 groups of 8-bit input and 32-bit output lookup tables. During the operation, the input data is split into 4 groups of 8-bit data, and table lookup operations are performed separately and then XOR operations are performed to generate the same result as the original affine transformation, thereby reducing the amount of calculation and improving the execution efficiency of the algorithm.
[0132] In some embodiments, the above step 550 may specifically include steps 5501 to 5503.
[0133] Step 5501: Add the input nonlinear inverse code corresponding to each composite XOR data sub-block to the composite XOR data of each composite XOR data sub-block to obtain composite obfuscated data of each composite XOR data sub-block.
[0134] Step 5502: multiply the composite obfuscated data of each composite XOR data sub-block by the linear data in the mixed nonlinear transformation process to obtain composite XOR affine data of each composite XOR data sub-block.
[0135] Step 5503, combining the composite XOR affine data of each composite XOR data sub-block in each composite XOR data block to obtain a key table for each composite XOR data block.
[0136] For example, Fig.14 As shown in the figure, it is the protection of the affine transformation data of the intermediate algorithm round, and the P -1 i P' i+4 and The composite affine transformation including is transformed by operation, and nonlinear coding information is added to the input and output of the affine table. Specifically, after the key table lookup operation, the Shaw-Lai white box SM4 algorithm, such as Fig.15 As shown, through Q -1 i P” i+4 The compound operation will P" i+4Separated from the table lookup operation, the four groups of 32-bit data output by the lookup table can be multiplied by the linear part of the composite affine transformation, and one group can be added with the constant part C to obtain Q at the output. -1 i Part of the effect is offset, and it becomes directly related to P" i+4 affine transformation of , and save the operation as a new key table. Fig.16 As shown, after the above operation, it is equivalent to replacing Q in the key table operation. -1 i Replaced by "P" i+4 Operation.
[0137] Here, since the operation is directly generated based on the existing data in the original algorithm, the two algorithm forms are equivalent in terms of security. i+4 The operation can simplify the original five groups of affine transformation operations in each round into four groups, which improves the encryption and decryption performance to a certain extent and reduces the volume occupied by the affine table accordingly.
[0138] In some embodiments, the P group of data blocks in the embodiments of the present application includes at least one data block pair, and each data block pair in the at least one data block pair includes a fifth group of data blocks and a sixth group of data blocks. Based on this, the above step 560 can specifically include steps 5601 to 5604.
[0139] Step 5601, according to the key data of the ith compound XOR data sub-block in the key table of the fifth group of data blocks and the input non-linear inverse code corresponding to the ith compound XOR data sub-block, as well as the key data of the jth compound XOR data sub-block in the key table of the fifth group of data blocks and the input non-linear inverse code corresponding to the jth data sub-block, perform an XOR operation on the key data of the ith data sub-block and the key data of the jth data sub-block to obtain the composite key XOR data of the ith compound XOR data sub-block and the jth compound XOR data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1].
[0140] Step 5602, adding the output nonlinear code corresponding to the ith composite XOR data sub-block or the jth composite XOR data sub-block to the composite key XOR data of the ith composite XOR data sub-block and the jth composite XOR data sub-block, to obtain the composite key XOR data of the combined data block of the ith composite XOR data sub-block and the jth composite XOR data sub-block.
[0141] Step 5603, combine the composite key XOR data of the combined data blocks of the same bit composite XOR data sub-blocks in the fifth group of data blocks and the sixth group of data blocks to obtain the composite XOR lookup table corresponding to the fifth group of data blocks and the sixth group of data blocks.
[0142] Step 5604, execute the XOR operation in a loop until a composite XOR lookup table corresponding to the two groups of data blocks is obtained, and the XOR data in the composite XOR lookup table corresponding to the two groups of data blocks are combined to obtain the ciphertext data.
[0143] It should be noted that, in the embodiment of the present application, each round of iteration of the key table can refer to the above content. Based on this, the key table can be transformed by using output nonlinear coding, and at least one set of input nonlinear inverse coding is used at the input end of the key table, such as Fig.18 As shown. The corresponding nonlinear inverse coding is added at the input of the key table operation to offset the affine transformation P -1 i+1 、E -1 i The non-linear coding added later. Since the key table input is 8 bits and the non-linear coding is 4 bits, two sets of non-linear coding are needed at the input to offset the coding information added by the previous operation.
[0144] In addition, if Fig.19 As shown in the figure, the XOR table output corresponding to the XOR operation at the end of each intermediate algorithm round also needs to add nonlinear coding to offset the nonlinear inverse coding of the input end in the next round of affine table. After the improvement, the external coding is protected by random nonlinear coding, making it difficult for attackers to strip the obfuscated information, and thus unable to use this as a weak point to attack the white box algorithm. Fig. 20 As shown, it is currently necessary to establish equations based on the principle of synthetic transformation to extract E -1 i+1 The input X of the equation is before the key table of the previous round, and the output Y is before the key table of the next round. -1 i+4 、E -1 i+1 After that, the algorithm is improved, and the equation relationship established using synthetic transformation is as follows: Fig.21 As shown. The nonlinear inverse code N at the input of the previous round of key table -1 A and the next round of composite affine transformation P -1 i+4 、E -1 i+1 Nonlinear encoding at the output C It cannot be eliminated. After the output result Y is obfuscated by these codes, it is impossible to extract E from the relationship. -1 i+1 Without such information, it is impossible to subsequently establish a valid system of linear equations and crack the round keys in the key table. Therefore, the algorithm can resist the attack method proposed by Lin Tingting.
[0145] Therefore, the embodiment of the present application can convert the key table and the composite affine transformation Q in the Xiao-Lai white box SM4 algorithm into-1 i ,P” i+4 Merge into a new key table, improve the execution efficiency and space utilization of the algorithm, and through this operation, P" i+4 The operations are merged into the key table, which reduces the amount of computation and space occupied by the affine transformation in the intermediate algorithm round.
[0146] Then, it comes to step 430. In an embodiment of the present application, the obfuscated ciphertext data includes multiple obfuscated ciphertext data blocks. Based on this, steps 4301 to 4305 are specifically as follows.
[0147] Step 4301, split each obfuscated ciphertext data block to obtain T groups of ciphertext data blocks, each group of ciphertext data blocks includes R ciphertext data sub-blocks, the values of T and R are related to the size of the matrix data of the plaintext data block, T and R are integers greater than 1, and each ciphertext data sub-block corresponds to an input nonlinear inverse code and an output nonlinear code.
[0148] Step 4302, performing a composite affine transformation on each ciphertext data sub-block and the corresponding input nonlinear inverse code to obtain composite affine data of each ciphertext data sub-block.
[0149] Step 4303, combining the composite affine data of each ciphertext data sub-block in each group of ciphertext data blocks to obtain a composite affine table for each group of ciphertext data blocks.
[0150] Step 4304, based on the input nonlinear inverse coding of each ciphertext data sub-block, perform an XOR operation on the composite affine table of the T groups of data blocks to obtain a composite XOR table.
[0151] Step 4305, execute the XOR operation in a loop until the XOR lookup table corresponding to the two groups of ciphertext data blocks is obtained, and the XOR data in the XOR lookup table corresponding to the two groups of ciphertext data blocks are combined to obtain the encrypted data corresponding to the plaintext data.
[0152] For example, Fig.21 As shown in the figure, it is to protect the output code. That is, the output code is transformed by nonlinear coding, and nonlinear coding information is added to the input and output of the affine table. Since the data output after the output coding operation is composed of plain text or ciphertext, it cannot contain obfuscated information. Therefore, the output of the XOR table operation corresponding to the output code does not contain nonlinear coding.
[0153] Therefore, through the encryption method provided in the embodiment of the present application, security and execution efficiency can be improved.
[0154] Specifically, in terms of security, the external code is the weak point of the Shaw-Lai white box. In the absence of protection, it only takes O(2 20.4) time complexity to extract the key. The embodiment of the present application uses nonlinear coding to confuse the externally encoded data, which can hide the real externally encoded information and effectively prevent these data from leaking key intermediate information, thereby preventing attackers from using this as a breakthrough to crack the algorithm. In addition, random nonlinear coding is used to encode and protect the input and output ends of the affine transformation data and the key table, thereby improving the security of the algorithm, and by adding input nonlinear inverse coding and output nonlinear coding to the intermediate algorithm round affine transformation and the key table, the synthetic transformation always contains obfuscated information that cannot be eliminated, thereby preventing the establishment of subsequent analysis equations and achieving effective resistance to the analysis method. In addition, by using nonlinear coding to confuse the affine transformation data in the external code, it is possible to effectively prevent these data from leaking key intermediate information, thereby preventing attackers from using this as a breakthrough to extract the key. By strengthening the weaknesses of the algorithm in the above manner, the overall security of the algorithm is improved to O(2 47 ) above the time complexity.
[0155] In terms of encryption and decryption efficiency, affine transformation is a huge performance-consuming operation. The embodiment of the present application optimizes the operation efficiency by converting the affine transformation into an efficient table lookup form and using the strategy of exchanging space for time. At the same time, the amount of calculation is reduced by converting the affine transformation into a table lookup operation and merging some operations of the intermediate algorithm round into the key table, thereby further improving the operation efficiency. In addition, by changing the operation form of the affine transformation, the performance-consuming matrix multiplication is converted into an efficient table lookup operation, thereby improving the efficiency of encryption and decryption. In addition, by merging the affine transformation after the key table operation into the key table, the number of affine transformations is simplified, further improving the execution efficiency of encryption and decryption.
[0156] The present application also provides an encryption device, specifically in combination with Fig.23 Provide detailed explanation.
[0157] Fig.23 It is a schematic diagram of the structure of an encryption device provided by an embodiment of the present application.
[0158] In some embodiments of the present application, Fig.23 The encryption device shown can be set in the computer device provided in the embodiment of the present application.
[0159] Based on this, Fig.23 As shown, the encryption device 230 may specifically include:
[0160] An acquisition module 2301 is used to acquire plain text data;
[0161] The encryption module 2302 is used to perform L rounds of iterative encryption according to the plaintext data, the nonlinear coding data and the key table to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes an input nonlinear inverse code and an output nonlinear code, the input nonlinear inverse code is used to offset the output nonlinear code added by the preceding operation, and the output nonlinear code is used to be offset in the subsequent operation, and L is an integer greater than 1;
[0162] The transformation module 2303 is used to perform affine transformation and mixed nonlinear transformation on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, where the encrypted data is the data after the nonlinear coding data introduced by multiple rounds of iterative encryption is offset.
[0163] In this way, the encryption device in the embodiment of the present application can obtain plaintext data; perform L rounds of iterative encryption according to the plaintext data, nonlinear coding data and key table to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes input nonlinear inverse coding and output nonlinear coding, the input nonlinear inverse coding is used to offset the output nonlinear coding added by the preceding operation, and the output nonlinear coding is used to be offset in the subsequent operation, and L is an integer greater than 1; perform affine transformation and mixed nonlinear transformation on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, and the encrypted data is the data after offsetting the nonlinear coding data introduced by multiple rounds of iterative encryption. In this way, by confusing the affine transformation data and the key table with the nonlinear coding data, the obfuscation and protection of the affine transformation data and the key table can be achieved, the security of data protection is improved, and the input nonlinear inverse coding is used to offset the coding added by the preceding operation, and the output nonlinear coding is offset in the subsequent operation. After the nonlinear coding is obfuscated, it can effectively resist attacks from the external coding end, improve the security of the white box SM4 algorithm, and do not need to add a chip of the white box algorithm in the encryption device, reduce the cost of data encryption, and have universal applicability.
[0164] The encryption device 230 in the embodiment of the present application is described in detail below.
[0165] In some embodiments of the present application, the transformation module 2303 may also be used to perform affine transformation and mixed nonlinear transformation according to the plaintext data and the nonlinear coded data to obtain obfuscated plaintext data;
[0166] The encryption module 2302 can also be used to perform L rounds of iterative encryption by obfuscating plaintext data, non-linear coded data and a key table to obtain obfuscated ciphertext data.
[0167] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include a splitting module, a combining module and an operating module; wherein,
[0168] A splitting module is used for splitting each plaintext data block to obtain N groups of data blocks when the plaintext data includes multiple plaintext data blocks, each group of data blocks includes M data sub-blocks, the values of N and M are related to the size of the matrix data of the plaintext data block, N and M are integers greater than 1, and each data sub-block corresponds to an input nonlinear inverse code and an output nonlinear code;
[0169] The transformation module 2303 may also be used to perform an affine transformation on each data sub-block and the corresponding output non-linear code to obtain affine data of each data sub-block;
[0170] A combining module, used for combining the affine data of each data sub-block in each group of data blocks to obtain an affine table of each group of data blocks;
[0171] The operation module is used to perform an XOR operation on the affine tables of the N groups of data blocks according to the input nonlinear inverse coding corresponding to each data sub-block to obtain obfuscated plaintext data.
[0172] In some embodiments of the present application, the splitting module may also be used to split each plaintext data block according to a reference splitting condition based on the size of the matrix data of the plaintext data block to obtain N groups of data blocks;
[0173] Among them, the reference splitting conditions include that the number of split plaintext data blocks complies with the matrix operation rules and at least one of the following: the data volume of the split data blocks is less than or equal to the preset data volume, and the matrix operation calculation performance index value is greater than the preset calculation performance index value.
[0174] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include an operation module, an adding module and a combining module; wherein,
[0175] An operation module is used for, when the N groups of data blocks include a data block pair, and the data block pair includes a first group of data blocks and a second group of data blocks, performing an XOR operation on the affine data of the i-th data sub-block and the affine data of the j-th data sub-block according to the affine data of the i-th data sub-block and the input nonlinear inverse code corresponding to the i-th data sub-block in the affine table of the first group of data blocks, and the affine data of the j-th data sub-block and the input nonlinear inverse code corresponding to the j-th data sub-block in the affine table of the second group of data blocks, so as to obtain XOR data of the i-th data sub-block and the j-th data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1];
[0176] An adding module, used for adding an output nonlinear code corresponding to the i-th data sub-block or the j-th data sub-block to the XOR data of the i-th data sub-block and the j-th data sub-block, so as to obtain XOR data of a combined data block of the i-th data sub-block and the j-th data sub-block;
[0177] A combining module, used for combining XOR data of combined data blocks of the same bit data sub-blocks in the first group of data blocks and the second group of data blocks to obtain an XOR lookup table corresponding to a pair of data blocks;
[0178] The combination module is also used to combine the XOR data in the XOR lookup table corresponding to a data block to obtain obfuscated plaintext data.
[0179] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include an operation module, an addition module, a combination module and a circulation module; wherein,
[0180] An operation module is used for performing an XOR operation on the XOR data of the u-th combined data block and the XOR data of the v-th combined data block in the XOR lookup table corresponding to the first data block pair and the input nonlinear inverse code corresponding to the u-th combined data block, and the XOR data of the v-th combined data block and the input nonlinear inverse code corresponding to the v-th combined data block in the XOR lookup table corresponding to the second data block pair, to obtain the XOR data of the u-th combined data block and the v-th combined data block, where the value of u is equal to the value of v, u∈[0,M-1], v∈[0,M-1];
[0181] An adding module is used to add an output nonlinear code corresponding to the u-th combined data block or the v-th combined data block to the XOR data of the u-th combined data block and the v-th combined data block to obtain the XOR data of the u-th combined data block and the v-th combined data block;
[0182] A combining module, used for combining XOR data of combined data blocks of same bit data sub-blocks in two data blocks in the first data block pair and the second data block pair, to obtain an XOR lookup table corresponding to the first data block pair and the second data block pair;
[0183] The loop module is used for looping the XOR operation until an XOR lookup table of a data block pair is obtained, and the XOR data in the XOR lookup table corresponding to a data block pair are combined to obtain obfuscated plaintext data.
[0184] In some embodiments of the present application, the encryption device 230 in the embodiment of the present application may further include a determination module, which is used to perform an encryption operation on each round of L rounds of iterations when the obfuscated plaintext data includes multiple obfuscated ciphertext data blocks, and determine the ciphertext data obtained in the last round of iterations in the L rounds of iterations as the obfuscated ciphertext data:
[0185] Cryptographic operations include:
[0186] Splitting each obfuscated ciphertext data block to obtain P groups of ciphertext data blocks, each group of ciphertext data blocks including at least two ciphertext data sub-blocks;
[0187] Performing a composite affine transformation on each ciphertext data sub-block and the corresponding input nonlinear inverse code to obtain composite affine data of each ciphertext data sub-block;
[0188] Combining the composite affine data of each ciphertext data sub-block in each group of ciphertext data blocks to obtain a composite affine table of each group of ciphertext data blocks;
[0189] According to the input nonlinear inverse coding of each ciphertext data sub-block, the composite affine table of the P group of data blocks is XORed to obtain composite XOR tables of at least two data blocks in the P group of data blocks, each composite XOR table includes a plurality of composite XOR data blocks, and each composite XOR data block includes at least two composite XOR data sub-blocks;
[0190] Performing a hybrid nonlinear transformation based on each composite XOR data sub-block and the input nonlinear inverse code corresponding to each composite XOR data sub-block, and the key table to obtain the key table of each composite XOR data block;
[0191] According to the input nonlinear inverse coding of each composite XOR data sub-block, the key table of the P group of data blocks is XOR-operated to obtain the ciphertext data.
[0192] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include an adding module, a calculating module and a combining module; wherein,
[0193] An adding module is used to add the input nonlinear inverse code corresponding to each composite XOR data sub-block to the composite XOR data of each composite XOR data sub-block to obtain composite obfuscated data of each composite XOR data sub-block;
[0194] A calculation module, used for multiplying the composite obfuscated data of each composite XOR data sub-block with the linear data in the mixed nonlinear transformation process to obtain composite XOR affine data of each composite XOR data sub-block;
[0195] The combining module is used for combining the composite XOR affine data of each composite XOR data sub-block in each composite XOR data block to obtain a key table of each composite XOR data block.
[0196] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include an operation module, an adding module and a combining module; wherein,
[0197] an operation module, configured to, when the P group of data blocks includes at least one data block pair, and each data block pair in the at least one data block pair includes a third group of data blocks and a fourth group of data blocks, perform an XOR operation on the composite affine data of the i-th ciphertext data subblock and the composite affine data of the j-th ciphertext data subblock according to the composite affine data of the i-th ciphertext data subblock in the composite affine table of the third group of data blocks and the input nonlinear inverse code corresponding to the i-th ciphertext data subblock, and the composite affine data of the j-th ciphertext data subblock in the composite affine table of the fourth group of data blocks and the input nonlinear inverse code corresponding to the j-th ciphertext data subblock, so as to obtain composite XOR data of the i-th ciphertext data subblock and the j-th ciphertext data subblock, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1];
[0198] An adding module is used to add an output nonlinear code corresponding to the i-th ciphertext data sub-block or the j-th ciphertext data sub-block to the composite XOR data of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block, so as to obtain composite XOR data of a combined data block of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block;
[0199] The combining module is used to combine the composite XOR data of the combined data blocks of the same bit ciphertext data sub-blocks in the third group of data blocks and the fourth group of data blocks to obtain the composite XOR lookup table corresponding to the third group of data blocks and the fourth group of data blocks.
[0200] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include an operation module, an addition module, a combination module and a circulation module; wherein,
[0201] an operation module, configured to, when the P group of data blocks includes at least one data block pair, and each data block pair in the at least one data block pair includes a fifth group of data blocks and a sixth group of data blocks, perform an XOR operation on the key data of the i-th composite XOR data sub-block and the key data of the j-th composite XOR data sub-block according to the key data of the i-th composite XOR data sub-block and the input non-linear inverse code corresponding to the i-th composite XOR data sub-block in the key table of the fifth group of data blocks, and the key data of the j-th composite XOR data sub-block and the input non-linear inverse code corresponding to the j-th data sub-block in the key table of the fifth group of data blocks, so as to obtain composite key XOR data of the i-th composite XOR data sub-block and the j-th composite XOR data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1];
[0202] An adding module is used to add the output nonlinear code corresponding to the i-th composite XOR data sub-block or the j-th composite XOR data sub-block to the composite key XOR data of the i-th composite XOR data sub-block and the j-th composite XOR data sub-block, so as to obtain the composite key XOR data of the combined data block of the i-th composite XOR data sub-block and the j-th composite XOR data sub-block;
[0203] A combining module, used for combining the composite key XOR data of the combined data blocks of the same bit composite XOR data sub-blocks in the fifth group of data blocks and the sixth group of data blocks, to obtain the composite XOR lookup table corresponding to the fifth group of data blocks and the sixth group of data blocks;
[0204] The loop module is used for looping the XOR operation until a composite XOR lookup table corresponding to the two groups of data blocks is obtained, and the XOR data in the composite XOR lookup table corresponding to the two groups of data blocks are combined to obtain the ciphertext data.
[0205] In some embodiments of the present application, the encryption device 230 in the embodiments of the present application may also include a splitting module, a combining module, an operating module and a circulation module; wherein,
[0206] A splitting module is used for splitting each obfuscated ciphertext data block to obtain T groups of ciphertext data blocks when the obfuscated ciphertext data includes multiple obfuscated ciphertext data blocks, each group of ciphertext data blocks includes R ciphertext data sub-blocks, the values of T and R are related to the size of the matrix data of the plaintext data block, T and R are integers greater than 1, and each ciphertext data sub-block corresponds to an input nonlinear inverse code and an output nonlinear code;
[0207] The transformation module 2303 may also be used to perform a composite affine transformation on each ciphertext data sub-block and the corresponding input nonlinear inverse code to obtain composite affine data of each ciphertext data sub-block;
[0208] A combining module, used for combining the composite affine data of each ciphertext data sub-block in each group of ciphertext data blocks to obtain a composite affine table of each group of ciphertext data blocks;
[0209] An operation module, configured to perform an XOR operation on the composite affine table of the T groups of data blocks according to the input nonlinear inverse coding of each ciphertext data sub-block, to obtain a composite XOR table;
[0210] The loop module is used to loop through the XOR operation until the XOR lookup table corresponding to the two groups of ciphertext data blocks is obtained, and the XOR data in the XOR lookup table corresponding to the two groups of ciphertext data blocks are combined to obtain the encrypted data corresponding to the plaintext data.
[0211] Based on the same inventive concept, the present application also provides a computer device. Fig.24 Provide detailed explanation.
[0212] Fig.24 It is a schematic diagram of the structure of a computer device provided by an embodiment of the present application.
[0213] like Fig.24 As shown, the computer device may include at least one of the following involved in the embodiments of the present application: a computer device at the user end, a computer device at the server end. The computer device may include a processor 2401 and a memory 2402 storing computer program instructions.
[0214] Specifically, the processor 2401 may include a central processing unit (CPU), or an application specific integrated circuit (Application Specific Integrated Circuit (ASTC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0215] The memory 2402 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 2402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 2402 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 2402 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 2402 is a non-volatile solid-state memory. In a specific embodiment, the memory 2402 includes a solid-state storage (ROM). In appropriate cases, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these.
[0216] The processor 2401 implements any one of the encryption methods in the above embodiments by reading and executing computer program instructions stored in the memory 2402 .
[0217] In one example, the computer device may further include a communication interface 2403 and a bus 2410. Fig.24 As shown, the processor 2401, the memory 2402, and the communication interface 2403 are connected via a bus 2410 and communicate with each other.
[0218] The communication interface 2403 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0219] Bus 2410 includes hardware, software or both, and the parts of flow control device are coupled to each other.For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard system (ETSA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard system (TSA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel system (MCA) bus, peripheral component interconnection (PCT) bus, PCT-Express (PCT-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 2410 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.
[0220] The data processing device can execute the encryption method in the embodiment of the present application, thereby realizing the combination Figures 1 to 5 Described encryption method and apparatus.
[0221] In addition, in combination with the encryption method in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the encryption methods in the above embodiment is implemented.
[0222] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0223] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0224] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0225] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. An encryption method, comprising: Get plaintext data; According to the plaintext data, the nonlinear coding data and the key table, L rounds of iterative encryption are performed to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes an input nonlinear inverse code and an output nonlinear code, the input nonlinear inverse code is used to offset the output nonlinear code added by the preceding operation, the output nonlinear code is used to be offset in the subsequent operation, and L is an integer greater than 1; Affine transformation and mixed nonlinear transformation are performed on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, wherein the encrypted data is data after the nonlinear coding data introduced by the multiple rounds of iterative encryption is offset.
2. The method according to claim 1, wherein: The method of performing L rounds of iterative encryption according to the plaintext data, the nonlinear coding data and the key table to obtain obfuscated ciphertext data includes: Performing affine transformation and mixed nonlinear transformation according to the plaintext data and the nonlinear coded data to obtain obfuscated plaintext data; The obfuscated plaintext data, the nonlinear coded data and the key table are encrypted through L rounds of iterative encryption to obtain the obfuscated ciphertext data.
3. The method according to claim 2, wherein: The plaintext data includes a plurality of plaintext data blocks; The step of performing affine transformation and mixed nonlinear transformation on the plaintext data and the nonlinear coded data to obtain obfuscated plaintext data includes: Splitting each of the plaintext data blocks to obtain N groups of data blocks, each group of the data blocks includes M data sub-blocks, the values of N and M are related to the size of the matrix data of the plaintext data block, N and M are integers greater than 1, and each of the data sub-blocks corresponds to an input nonlinear inverse code and an output nonlinear code; Performing affine transformation on each of the data sub-blocks and the corresponding output nonlinear code to obtain affine data of each of the data sub-blocks; Combining the affine data of each of the data sub-blocks in each group of the data blocks to obtain an affine table for each group of the data blocks; According to the input nonlinear inverse coding corresponding to each of the data sub-blocks, the affine tables of the N groups of data blocks are subjected to an XOR operation to obtain the obfuscated plaintext data.
4. The method according to claim 3, wherein: The step of splitting each of the plaintext data blocks to obtain N groups of data blocks includes: Based on the size of the matrix data of the plaintext data block, and according to the reference splitting condition, split each of the plaintext data blocks to obtain the N groups of data blocks; Among them, the reference splitting conditions include that the number of plaintext data blocks split complies with the matrix operation rules and at least one of the following: the data volume of the split data blocks is less than or equal to the preset data volume, and the matrix operation calculation performance index value is greater than the preset calculation performance index value.
5. The method according to claim 3 or 4, wherein: The N groups of data blocks include a data block pair, wherein the data block pair includes a first group of data blocks and a second group of data blocks; performing an XOR operation on the affine tables of the N groups of data blocks according to the input nonlinear inverse coding corresponding to each of the data sub-blocks to obtain the obfuscated plaintext data, comprises: According to the affine data of the i-th data sub-block in the affine table of the first group of data blocks and the input nonlinear inverse code corresponding to the i-th data sub-block, and the affine data of the j-th data sub-block in the affine table of the second group of data blocks and the input nonlinear inverse code corresponding to the j-th data sub-block, an XOR operation is performed on the affine data of the i-th data sub-block and the affine data of the j-th data sub-block to obtain XOR data of the i-th data sub-block and the j-th data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1]; Adding an output nonlinear code corresponding to the i-th data sub-block or the j-th data sub-block to the XOR data of the i-th data sub-block and the j-th data sub-block to obtain XOR data of a combined data block of the i-th data sub-block and the j-th data sub-block; Combining XOR data of combined data blocks of the same bit data sub-blocks in the first group of data blocks and the second group of data blocks to obtain an XOR lookup table corresponding to the one data block pair; The XOR data in the XOR lookup table corresponding to the one data block are combined to obtain the obfuscated plaintext data.
6. The method according to claim 5, wherein: The N groups of data blocks include at least two data block pairs, and the at least two data block pairs include a first data block pair and a second data block pair; performing an XOR operation on the affine tables of the N groups of data blocks according to the input nonlinear inverse coding corresponding to each of the data sub-blocks to obtain the obfuscated plaintext data, including: Perform an XOR operation on the XOR data of the u-th combined data block in the XOR lookup table corresponding to the first data block and the input nonlinear inverse coding corresponding to the u-th combined data block, and perform an XOR operation on the XOR data of the u-th combined data block and the XOR data of the v-th combined data block in the XOR lookup table corresponding to the second data block to obtain the XOR data of the u-th combined data block and the v-th combined data block, wherein the value of u is equal to the value of v, u∈[0,M-1], v∈[0,M-1]; Adding the output nonlinear code corresponding to the u-th combined data block or the v-th combined data block to the XOR data of the u-th combined data block and the v-th combined data block to obtain the XOR data of the u-th combined data block and the v-th combined data block; Combining XOR data of combined data blocks of same bit data sub-blocks in two data blocks in the first data block pair and the second data block pair to obtain XOR lookup tables corresponding to the first data block pair and the second data block pair; The XOR operation is performed cyclically until an XOR lookup table of a data block pair is obtained, and the XOR data in the XOR lookup table corresponding to the data block pair are combined to obtain the obfuscated plaintext data.
7. The method according to claim 2, wherein: The obfuscated plaintext data includes a plurality of obfuscated ciphertext data blocks; The method of performing L rounds of iterative encryption on the obfuscated plaintext data, the nonlinearly encoded data and the key table to obtain the obfuscated ciphertext data includes: Perform an encryption operation on each round of the L rounds of iterations, and determine the ciphertext data obtained from the last round of iterations in the L rounds of iterations as the obfuscated ciphertext data: The encryption operation includes: Splitting each obfuscated ciphertext data block to obtain P groups of ciphertext data blocks, each group of ciphertext data blocks including at least two ciphertext data sub-blocks; Performing a composite affine transformation on each of the ciphertext data sub-blocks and the corresponding input nonlinear inverse code to obtain composite affine data of each of the ciphertext data sub-blocks; Combining the composite affine data of each of the ciphertext data sub-blocks in each group of the ciphertext data blocks to obtain a composite affine table of each group of the ciphertext data blocks; According to the input nonlinear inverse coding of each ciphertext data sub-block, the composite affine table of the P group of data blocks is subjected to an XOR operation to obtain a composite XOR table of at least two data blocks in the P group of data blocks, each of the composite XOR tables including a plurality of composite XOR data blocks, and each of the composite XOR data blocks including at least two composite XOR data sub-blocks; Performing a hybrid nonlinear transformation based on each of the composite XOR data sub-blocks, the input nonlinear inverse code corresponding to each of the composite XOR data sub-blocks, and the key table to obtain a key table for each of the composite XOR data blocks; According to the input nonlinear inverse coding of each of the composite XOR data sub-blocks, the key table of the P group of data blocks is XOR-operated to obtain ciphertext data.
8. The method according to claim 7, wherein: The step of performing a hybrid nonlinear transformation based on each of the composite XOR data sub-blocks and the corresponding input nonlinear inverse coding and the key table to obtain the key table of each of the composite XOR data blocks includes: Adding the input nonlinear inverse code corresponding to each of the composite XOR data sub-blocks to the composite XOR data of each of the composite XOR data sub-blocks to obtain composite obfuscated data of each of the composite XOR data sub-blocks; Multiplying the composite obfuscated data of each of the composite XOR data sub-blocks with the linear data in the mixed nonlinear transformation process to obtain composite XOR affine data of each of the composite XOR data sub-blocks; The composite XOR affine data of each of the composite XOR data sub-blocks in each of the composite XOR data blocks are combined to obtain a key table of each of the composite XOR data blocks.
9. The method according to claim 7, wherein: The P group of data blocks includes at least one data block pair, each data block pair in the at least one data block pair includes a third group of data blocks and a fourth group of data blocks; the composite affine table of the P group of data blocks is subjected to an XOR operation according to the input nonlinear inverse encoding of each of the ciphertext data sub-blocks to obtain a composite XOR table of at least two data blocks in the P group of data blocks, including: According to the composite affine data of the i-th ciphertext data sub-block in the composite affine table of the third group of data blocks and the input nonlinear inverse code corresponding to the i-th ciphertext data sub-block, and the composite affine data of the j-th ciphertext data sub-block in the composite affine table of the fourth group of data blocks and the input nonlinear inverse code corresponding to the j-th ciphertext data sub-block, an XOR operation is performed on the composite affine data of the i-th ciphertext data sub-block and the composite affine data of the j-th ciphertext data sub-block to obtain composite XOR data of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1]; Adding the output nonlinear code corresponding to the i-th ciphertext data sub-block or the j-th ciphertext data sub-block to the composite XOR data of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block to obtain composite XOR data of a combined data block of the i-th ciphertext data sub-block and the j-th ciphertext data sub-block; The composite XOR data of the combined data blocks of the same-bit ciphertext data sub-blocks in the third group of data blocks and the fourth group of data blocks are combined to obtain a composite XOR lookup table corresponding to the third group of data blocks and the fourth group of data blocks.
10. The method according to claim 7, wherein: The P group of data blocks includes at least one data block pair, each data block pair in the at least one data block pair includes a fifth group of data blocks and a sixth group of data blocks; The step of performing an XOR operation on the key table of the P group of data blocks according to the input nonlinear inverse coding of each of the composite XOR data sub-blocks to obtain ciphertext data includes: According to the key data of the i-th composite XOR data sub-block in the key table of the fifth group of data blocks and the input non-linear inverse code corresponding to the i-th composite XOR data sub-block, and the key data of the j-th composite XOR data sub-block in the key table of the fifth group of data blocks and the input non-linear inverse code corresponding to the j-th data sub-block, an XOR operation is performed on the key data of the i-th data sub-block and the key data of the j-th data sub-block to obtain composite key XOR data of the i-th composite XOR data sub-block and the j-th composite XOR data sub-block, wherein the value of i is equal to the value of j, i∈[0,M-1], j∈[0,M-1]; Adding the output nonlinear code corresponding to the i-th composite XOR data sub-block or the j-th composite XOR data sub-block to the composite key XOR data of the i-th composite XOR data sub-block and the j-th composite XOR data sub-block to obtain the composite key XOR data of the combined data block of the i-th composite XOR data sub-block and the j-th composite XOR data sub-block; Combining composite key XOR data of the combined data blocks of the same-bit composite XOR data sub-blocks in the fifth group of data blocks and the sixth group of data blocks to obtain composite XOR lookup tables corresponding to the fifth group of data blocks and the sixth group of data blocks; The XOR operation is performed cyclically until a composite XOR lookup table corresponding to the two groups of data blocks is obtained, and the XOR data in the composite XOR lookup table corresponding to the two groups of data blocks are combined to obtain the ciphertext data.
11. The method according to claim 1 or 2, wherein: The obfuscated ciphertext data includes a plurality of obfuscated ciphertext data blocks; the affine transformation and the mixed nonlinear transformation are performed on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, including: Each obfuscated ciphertext data block is split to obtain T groups of ciphertext data blocks, each group of the ciphertext data blocks includes R ciphertext data sub-blocks, the values of T and R are related to the size of the matrix data of the plaintext data block, T and R are integers greater than 1, and each ciphertext data sub-block corresponds to an input nonlinear inverse code and an output nonlinear code; Performing a composite affine transformation on each of the ciphertext data sub-blocks and the corresponding input nonlinear inverse code to obtain composite affine data of each of the ciphertext data sub-blocks; Combining the composite affine data of each of the ciphertext data sub-blocks in each group of the ciphertext data blocks to obtain a composite affine table of each group of the ciphertext data blocks; According to the input nonlinear inverse coding of each ciphertext data sub-block, performing an XOR operation on the composite affine table of the T groups of data blocks to obtain a composite XOR table; The XOR operation is performed cyclically until the XOR lookup table corresponding to the two groups of ciphertext data blocks is obtained, and the XOR data in the XOR lookup table corresponding to the two groups of ciphertext data blocks are combined to obtain encrypted data corresponding to the plaintext data.
12. An encryption device, comprising: An acquisition module, used to obtain plaintext data; An encryption module, used for performing L rounds of iterative encryption according to the plaintext data, the nonlinear coding data and the key table to obtain obfuscated ciphertext data; wherein the nonlinear coding data includes an input nonlinear inverse code and an output nonlinear code, the input nonlinear inverse code is used to offset the output nonlinear code added by the preceding operation, the output nonlinear code is used to be offset in the subsequent operation, and L is an integer greater than 1; The transformation module is used to perform affine transformation and mixed nonlinear transformation on the obfuscated ciphertext data to obtain encrypted data corresponding to the plaintext data, wherein the encrypted data is the data after the nonlinear coding data introduced by the multiple rounds of iterative encryption is offset.
13. A computer device, the device comprising: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the steps of the encryption method according to any one of claims 1 to 11 are implemented.
14. A storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the steps of the encryption method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The program product is stored in a storage medium, and the program product is executed by at least one processor to implement the steps of the encryption method according to any one of claims 1 to 11.
Citation Information
Cited By
Data encryption and key generation method for online payment
CN121966865A