White box SM4 encryption method, device, equipment, system and medium

By using a pre-defined mapping table set in the white-box SM4 algorithm to achieve de-white-boxing, key expansion, and encryption operations, the problems of key vulnerability and high system load are solved, and high-frequency key updates and improved encryption security are achieved.

CN121644069APending Publication Date: 2026-03-10CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-18
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

The existing white-box SM4 algorithm is vulnerable to reverse engineering by attackers during encryption and decryption, which reduces encryption security. It is also difficult to apply in scenarios with high-frequency key updates, causing a surge in backend system load, affecting business stability and increasing modification and maintenance costs.

Method used

It employs white-box de-white-boxing, key expansion, key lookup table generation, and white-box encryption operations to read a preset mapping table set, severing the data association between the original key and the mapping table, avoiding plaintext information leakage, and supporting high-frequency key updates.

Benefits of technology

It improves encryption security, reduces the load on the backend system, and reduces modification and maintenance costs, making it suitable for scenarios that require frequent key updates, such as payment and the Internet of Things.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121644069A_ABST
    Figure CN121644069A_ABST
Patent Text Reader

Abstract

The invention discloses a white box SM4 encryption method, device, equipment, system and medium, and belongs to the field of data processing. The method comprises the following steps: receiving a white box key ciphertext sent by a background system; according to the white-box key ciphertext, obtaining a key ciphertext containing affine transformation information and nonlinear coding information by reading and querying a preset white-box removal operation mapping table set; according to the key ciphertext, reading and querying a preset key expansion operation mapping table set to obtain a round key ciphertext containing nonlinear coding information; according to the round key ciphertext and the traversal parameters, generating an operation mapping table set by reading and querying a preset key lookup table, and obtaining a key lookup table ciphertext containing nonlinear codes; and performing white box encryption on the to-be-encrypted plaintext data based on the key lookup table ciphertext and a preset encryption operation mapping table set to obtain a target ciphertext. According to the embodiment of the invention, the encryption security can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of data processing, and particularly relates to a white-box SM4 encryption method, device, equipment, system and medium. BACKGROUND

[0002] The white-box SM4 algorithm is a technology of combining the SM4 algorithm and the white-box algorithm, encoding and protecting the key by using the affine transformation and the lookup table technology, hiding the key in the lookup table, and thus encrypting data. In the encryption and decryption process of the white-box SM4 algorithm, the key of the SM4 algorithm does not exist in the form of plaintext in the memory.

[0003] In the encryption and decryption process by using the white-box SM4 algorithm, the reverse operation of eliminating the confusion corresponding to the encoding and protection of the key needs to be performed in the client, and the plaintext of the round key needs to be restored. If an attacker inversely analyzes the white-box algorithm by using the static analysis method, or the attacker obtains the memory data when the white-box SM4 algorithm is running by using the dynamic debugging method, the algorithm principle and the plaintext of the round key are obtained, the algorithm principle and the round key are leaked, and the encryption security is greatly reduced. SUMMARY

[0004] The application embodiment provides a white-box SM4 encryption method, device, equipment, system and medium, which can improve the encryption security.

[0005] In a first aspect, the application embodiment provides a white-box SM4 encryption method, which includes the following steps: receiving a white-box key ciphertext sent by a background system, wherein the white-box key ciphertext is obtained by encrypting an original key based on an SM4 algorithm and a root key; obtaining a key ciphertext containing affine transformation information and nonlinear encoding information by reading and querying a preset de-whitening operation mapping table set according to the white-box key ciphertext; obtaining a round key ciphertext containing nonlinear encoding information by reading and querying a preset key expansion operation mapping table set according to the key ciphertext; obtaining a key lookup table ciphertext containing nonlinear encoding by reading and querying a preset key lookup table generation operation mapping table set according to the round key ciphertext and a traversal parameter; and performing white-box encryption on to-be-encrypted plaintext data based on the key lookup table ciphertext and a preset encryption operation mapping table set to obtain a target ciphertext.

[0006] In a second aspect, an encryption device for white-box SM4 is provided, comprising: a receiving module configured to receive a white-box key ciphertext sent by a background system, the white-box key ciphertext being obtained by encrypting an original key based on an SM4 algorithm and a root key; a first lookup table module configured to obtain a key ciphertext containing affine transformation information and nonlinear encoding information by reading and querying a preset de-whitening operation mapping table set according to the white-box key ciphertext; a second lookup table module configured to obtain a round key ciphertext containing nonlinear encoding information by reading and querying a preset key expansion operation mapping table set according to the key ciphertext; a third lookup table module configured to obtain a key lookup table ciphertext containing nonlinear encoding by reading and querying a preset key lookup table generation operation mapping table set according to the round key ciphertext and a traversal parameter; and a fourth lookup table module configured to perform white-box encryption on to-be-encrypted plaintext data based on the key lookup table ciphertext and a preset encryption operation mapping table set to obtain a target ciphertext.

[0007] In a third aspect, an encryption device for white-box SM4 is provided, comprising: a processor and a memory storing computer program instructions; and the processor implements the encryption method for white-box SM4 according to the first aspect when executing the computer program instructions.

[0008] In a fourth aspect, an encryption system for white-box SM4 is provided, comprising: a background system configured to encrypt an original key based on an SM4 algorithm and a root key to obtain a white-box key ciphertext, and send the white-box key ciphertext to the encryption device for white-box SM4 according to the third aspect; and the encryption device for white-box SM4 according to the third aspect.

[0009] In a fifth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the encryption method for white-box SM4 according to the first aspect.

[0010] In a sixth aspect, a computer program product is provided, comprising a computer program, and the computer program is executed by a processor to implement the encryption method for white-box SM4 according to the first aspect.

[0011] This application provides a white-box SM4 encryption method, apparatus, device, system, and medium. A client device can receive a white-box key ciphertext obtained by encrypting the original key using the SM algorithm and a root key from a backend system. Based on the white-box key ciphertext, a key ciphertext is obtained by reading and querying a set of mapping tables with de-white-boxing functionality. Based on the key ciphertext, a round key ciphertext is obtained by reading and querying a set of mapping tables with key expansion functionality. Based on the round key ciphertext and traversal parameters, a key lookup table ciphertext is obtained by reading a set of mapping tables with key lookup table generation functionality. By reading and querying the set of mapping tables with white-box encryption functionality and the key lookup table ciphertext, white-box encryption can be performed on the plaintext data to be encrypted, thereby obtaining the target ciphertext. In this white-box SM4 encryption process, operations such as de-whiteboxing, key expansion, key lookup table generation, and white-box encryption are all implemented by reading and querying the mapping table in the mapping table set. The mapping table only stores data segments with mapping relationships and does not contain the computational process of de-whiteboxing, key expansion, key lookup table generation, or white-box encryption. It also does not contain plaintext of important information such as the original key, system parameters required for key expansion, fixed parameters required for key expansion, and round keys. The data association between the original key and the mapping table is severed. Even if an attacker obtains intermediate data in the white-box SM4 encryption process, they cannot reconstruct the original key from the intermediate data, reducing or even eliminating the risk of exposure of the original key, thus providing higher resistance to attacks and improving encryption security. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 A flowchart illustrating a white-box SM4 encryption method provided in an embodiment of this application; Figure 2 A schematic diagram illustrating an example of nonlinear encoding and inverse nonlinear encoding of a data segment provided in an embodiment of this application; Figure 3 A schematic diagram illustrating an example of an XOR operation provided in an embodiment of this application; Figure 4 This is a schematic diagram illustrating an example of obtaining key ciphertext by reading and querying a set of white-box operation mapping tables according to an embodiment of this application. Figure 5 This is a schematic diagram illustrating an example of obtaining round key ciphertext by reading a set of query key expansion operation mapping tables provided in an embodiment of this application; Figure 6This is a schematic diagram illustrating an example of obtaining ciphertext from a key lookup table by reading a lookup table and generating an operation mapping table, as provided in an embodiment of this application. Figure 7 This is a schematic diagram illustrating an example of obtaining target ciphertext by reading and querying a set of encryption operation mapping tables, as provided in an embodiment of this application. Figure 8 A schematic diagram of the structure of a white-box SM4 encryption device provided in an embodiment of this application; Figure 9 This is a schematic diagram of the structure of a white-box SM4 encryption device provided in an embodiment of this application. Detailed Implementation

[0014] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples. It should be noted that the acquisition, storage, use, and processing of information and data in the embodiments of this application are all authorized by users or relevant organizations and comply with the relevant provisions of national laws and regulations.

[0015] The white-box SM4 algorithm combines the SM4 algorithm with a white-box algorithm, using affine transformations and lookup tables to encode and protect the key, hiding it within the lookup tables to encrypt data. During encryption and decryption, the SM4 key is never in plaintext in memory. Encryption and decryption using the white-box SM4 algorithm require a reverse operation on the client side to deobfuscate the key, restoring the plaintext of the round keys. If an attacker uses static analysis to reverse engineer the white-box algorithm, or uses dynamic debugging to obtain the memory data during the white-box SM4 algorithm's execution, they can obtain the algorithm's principles and the plaintext of the round keys, leading to a significant reduction in encryption security. In the white-box SM4 architecture, the key is deeply bound to the white-box algorithm's logic through obfuscation and encoding techniques before the algorithm is compiled or built, generating numerous lookup tables as a fixed white-box library. However, due to the fixed nature of the white-box library, once the key is updated, the entire white-box library needs to be regenerated and redeployed. In security scenarios requiring frequent key updates, the fixed pattern of white-box libraries is difficult to apply and cannot meet the demand for frequent key updates. The white-box SM4 algorithm requires the backend system to expand the key to obtain the round key, and then perform a white-box operation on the round key using a private obfuscation algorithm. On the one hand, the backend system's execution of key expansion and private obfuscation algorithms leads to a surge in backend system load, easily causing business delays or blockages, affecting business stability. On the other hand, the backend system's private obfuscation algorithm relies on non-standard algorithm implementation logic, requiring different modifications in different business systems to adapt to various software and hardware environments, significantly increasing the modification and maintenance costs of business systems. Furthermore, the data packets sent by the backend system to the client to replace the round key and additional obfuscated data are relatively long, increasing network transmission bandwidth consumption.

[0016] This application provides a white-box SM4 encryption method, apparatus, device, system, medium, and program product. The backend system encrypts the original key using SM4 and sends the encrypted key ciphertext to the client. The client performs de-whiteboxing, key expansion, key lookup table generation, and white-box encryption operations. All three operations—de-whiteboxing, key expansion, key lookup table generation, and white-box encryption—are completed by reading and querying a mapping table. This mapping table does not contain plaintext of important information such as the original key, system parameters required for key expansion, fixed parameters required for key expansion, and round keys, thereby reducing or even eliminating the risk of original key exposure while ensuring the encryption function of the white-box SM4. During the white-box SM4 encryption and decryption process, each mapping table is pre-set. When the original key is updated, the mapping table does not need to be recreated. White-box SM4 encryption and decryption can be performed based on the updated original key and each mapping table, enabling dynamic white-box SM4 key updates. This meets the requirements for high-frequency key updates and can be applied to scenarios with high real-time requirements and high-frequency key update needs, such as payment and IoT applications. Furthermore, the backend system only needs to perform SM4 encryption on the original key, without needing to execute a proprietary obfuscation algorithm. This reduces the CPU usage of the backend system, avoids business blockage, and improves business stability. The backend system also does not need to be modified to adapt the proprietary obfuscation algorithm to various software and hardware environments, reducing the modification and maintenance costs of the business system. The key ciphertext obtained after the backend system performs SM4 encryption on the original key is 128 bits long, which is only one-eighth the length of traditional solutions. This can significantly reduce network bandwidth consumption, making it particularly suitable for bandwidth-constrained scenarios such as mobile payment and the Internet of Things.

[0017] The encryption methods, devices, equipment, systems, media, and program products of the white-box SM4 provided in this application will be described below.

[0018] This application provides a white-box SM4 encryption method, which can be applied to business scenarios requiring data encryption to ensure data security. These scenarios include, but are not limited to, payment, IoT, and secure communication scenarios. The white-box SM4 encryption method can be executed by a white-box SM4 encryption device, equipment, or system. The white-box SM4 encryption device can be implemented as a client device, and is not limited thereto. Figure 1 A flowchart of a white-box SM4 encryption method provided in an embodiment of this application is shown below. Figure 1 As shown, the encryption method of the white box SM4 may include steps S101 to S105.

[0019] In step S101, the white-box key ciphertext sent by the backend system is received.

[0020] The white-box key ciphertext is obtained by encrypting the original key using the SM4 algorithm and the root key. After generating the original key according to business requirements, the backend system can encrypt it using the SM4 algorithm and the root key to obtain the white-box key ciphertext. For example, the white-box key ciphertext can be represented as c = SM4_Enc (A, a), where c is the white-box key ciphertext, A is the root key, a is the original key, and SM4_Enc() represents the SM4 algorithm. The backend system can send the white-box key ciphertext to the client device through an encrypted channel. The white-box key ciphertext obtained by encrypting using the SM4 algorithm relies on the cryptographic strength of the SM4 algorithm and has strong resistance to differential analysis and linear analysis. Even if an attacker obtains the white-box key ciphertext, it will be difficult to crack the plaintext of the original key. The root key can be 128 bits long, and the white-box key ciphertext can be 16 bytes long. That is, the white-box key ciphertext is 128 bits long, which is relatively short. It is only one-eighth the length of the data transmitted from the backend system to the client device in other common white-box encryption algorithms, which can significantly reduce the network bandwidth consumption between the backend system and the client device.

[0021] In step S102, based on the white-box key ciphertext, the key ciphertext containing affine transformation information and nonlinear coding information is obtained by reading and querying the preset set of de-white-boxing operation mapping tables.

[0022] The de-whiteboxing operation mapping table set is a pre-set collection of multiple mapping tables used to implement the de-whiteboxing operation and obtain the de-whiteboxed key ciphertext. The de-whiteboxing operation function can be implemented by reading and querying the mapping tables in the de-whiteboxing operation mapping table set. Each mapping table in the de-whiteboxing operation mapping table set is similar in form to a key-value table. Each mapping table can record two sets of data segments with a mapping relationship; any data segment in one set is mapped to a data segment in the other set. The de-whiteboxing operation mapping table set hides the specific computation of the de-whiteboxing operation through its multiple mapping tables. The data segments that should be output by the sub-operations of the de-whiteboxing operation can be found through these multiple mapping tables, and the found data segments are non-plaintext data segments. During the process of reading and querying the de-whiteboxing operation mapping table set, the plaintext of the original key and the plaintext of the parameters in the de-whiteboxing operation computation will not be encountered. By using a set of white-boxing operation mapping tables, the core logic of encryption / decryption and affine transformation operations in white-boxing operations can be preserved. Reading and querying the set of white-boxing operation mapping tables can save a lot of computation and improve the efficiency of white-boxing operations.

[0023] The white-box de-encoding operation may include sub-operations such as input encoding processing, obfuscation operations, XOR processing, and S-box operations. Input encoding processing may include affine transformations and non-linear encoding, while S-box operations may include inverse non-linear encoding, obfuscation transformations, S-box processing, shifting, affine transformations, and non-linear encoding. Each sub-operation can be implemented using one or more mapping tables. It should be noted that the mapping tables do not record the computational process of the sub-operations. Data segments obtained as intermediate data by reading and querying the white-box de-encoding operation mapping table set are all non-plaintext, posing no risk of plaintext data leakage. Even if an attacker obtains data segments during the process of reading and querying the white-box de-encoding operation mapping table set, it is difficult to decipher them and obtain the plaintext.

[0024] By reading the set of query de-whiteboxing operation mapping tables, the key ciphertext can finally be obtained. The key ciphertext is the ciphertext obtained by de-whiteboxing the whitebox key ciphertext and then encrypting it again. The key ciphertext contains affine transformation information and nonlinear coding information, that is, the key ciphertext is the product of affine transformation and nonlinear coding. Affine transformation information can be added through affine transformation. Affine transformation refers to a composite operation form that includes matrix multiplication and vector addition, which can be represented by the following equation (1): P(x) = l[P](x) ⊕ c[P] (1) Where P(x) is the input code; l[P] represents the linear part of the input data, which is a matrix; x is the object to be affinely transformed, which can be a data segment; c[P] represents the vector part, which can be a constant; ⊕ is the XOR operation.

[0025] Nonlinear coding information can be added through nonlinear coding. Nonlinear coding is a coding method that does not satisfy the principle of linear superposition. When processing data, there is no linear relationship between the output and input; that is, the output cannot be predicted or described by a simple linear combination. Inverse nonlinear coding is the inverse process of nonlinear coding; that is, inverse nonlinear coding is the reverse mapping relationship of nonlinear coding. For example, Figure 2 A schematic diagram illustrating an example of nonlinear encoding and inverse nonlinear encoding of a data segment provided in an embodiment of this application, as shown below. Figure 2 As shown, 2-bit data 0, 1, 2, 3 can be mapped to another 2-bit data 3, 0, 1, 2 through non-linear encoding. Similarly, 2-bit data 0, 1, 2, 3 can be mapped to 2-bit data 1, 2, 3, 0 through inverse non-linear encoding. There are 2 encoding methods for non-linear encoding of n-bit data in a data segment. nSuch a variety of encoding methods makes data segments containing non-linear encoded information difficult for attackers to crack. For example, to achieve a balance between obfuscation effect, storage size, and computational efficiency, non-linear or inverse non-linear encoding can be applied to every 4 bits of data in the data segment.

[0026] The white-box key ciphertext can be divided into multiple data segments, which are then used as input data for reading and querying the de-white-boxing operation mapping table set. The length of the data segments can be set according to the scenario, requirements, experience, etc., and the key ciphertext can include multiple data segments containing affine transformation information and nonlinear coding information.

[0027] In step S103, based on the key ciphertext, the round key ciphertext containing nonlinear encoding information is obtained by reading and querying a preset key expansion operation mapping table set.

[0028] The key expansion operation mapping table set is a pre-defined collection of multiple mapping tables used to implement key expansion operations. By reading and querying the mapping tables in the key expansion operation mapping table set, the key expansion operation function can be implemented to obtain the round key ciphertext. Each mapping table in the key expansion operation mapping table set is similar in form to a key-value table. Each mapping table can record two sets of data segments with a mapping relationship, where any data segment in one set is mapped to a data segment in the other set.

[0029] The key expansion operation mapping table set hides the specific computations of key expansion operations through multiple mapping tables. By using these tables, the data segments to be output by sub-operations of the key expansion operation can be found, and these data segments are non-plaintext. Reading or querying the key expansion operation mapping table set will not reveal the plaintext of the original key or the plaintext parameters from the key expansion operation. By preserving the computational logic of the key expansion operation through the key expansion operation mapping table set, reading and querying the key expansion operation mapping table set can save a significant amount of computation, thus improving the efficiency of key expansion operations.

[0030] Key expansion operations may include sub-operations such as input encoding processing, XOR processing, and S-box operations. Input encoding processing may include inverse nonlinear encoding, inverse affine transformation, system parameter processing, and nonlinear encoding. S-box operations may include inverse nonlinear encoding, S-box processing, shift processing, and nonlinear encoding. Each sub-operation can be implemented using one or more mapping tables. It should be noted that the mapping tables do not record the computational process of the sub-operations. The data segments obtained as intermediate data by reading and querying the key expansion operation mapping table set are all non-plaintext, posing no risk of plaintext data leakage. Even if an attacker obtains the data segments during the process of reading and querying the key expansion operation mapping table set, it is difficult to decipher them and obtain the plaintext.

[0031] By reading the query key expansion operation mapping table set, the round key ciphertext can be obtained. The round key ciphertext is the ciphertext of the round key obtained after key expansion based on the key ciphertext. The round key ciphertext contains non-linear encoding information, which can be added through non-linear encoding. The specific content of the non-linear encoding can be found in the relevant descriptions in the above embodiments, and will not be repeated here.

[0032] The key ciphertext can be divided into multiple data segments, which are then used as input data for reading the query key expansion operation mapping table set. The specific content of each data segment can be found in the relevant descriptions in the above embodiments, and will not be repeated here. The round key ciphertext may include multiple data segments containing non-linear coding information.

[0033] In step S104, based on the round key ciphertext and traversal parameters, an operation mapping table set is generated by reading and querying a preset key lookup table, resulting in a key lookup table ciphertext containing non-linear encoding.

[0034] The traversal parameter can include multiple traversal values. For example, the traversal parameter can be 0 to 255 (decimal). In actual operation, 0 to 255 can be converted to binary.

[0035] The key lookup table generation operation mapping table set is a pre-set collection of multiple mapping tables used to implement key lookup table generation operations. By reading and querying the mapping tables in this set, the key lookup table generation operation can be performed, resulting in multiple encrypted key lookup tables. These encrypted key lookup tables are the key lookup tables in their encrypted state. Each mapping table in the key lookup table generation operation mapping table set has a similar format to a key-value table; each mapping table can record two sets of data segments with a mapping relationship, where any data segment in one set is mapped to a data segment in the other set.

[0036] The key lookup table generation operation mapping table set hides the specific computations of the key lookup table generation operation through multiple mapping tables. By using these mapping tables, the data segments to be output by the sub-operations of the key lookup table generation operation can be found, and these found data segments are non-plaintext data segments. Reading and querying the key lookup table generation operation mapping table set will not reveal the plaintext of the original key or the plaintext of the parameters used in the key lookup table generation operation. By preserving the computational logic of the key lookup table generation operation through the key lookup table generation operation mapping table set, reading and querying the key lookup table generation operation mapping table set can save a significant amount of computation, improving the efficiency of the key lookup table generation operation.

[0037] The key lookup table generation operation may include sub-operations such as parameter traversal processing, XOR processing, and S-box operations. Parameter traversal processing may include matrix obfuscation and non-linear encoding. S-box operations may include inverse non-linear encoding, S-box processing, matrix processing, constant processing, XOR operations, and non-linear encoding. Each sub-operation can be implemented through one or more mapping tables. It should be noted that the mapping tables do not record the calculation process of the sub-operations. The data segments obtained as intermediate data by reading the mapping tables in the key lookup table generation operation mapping table set are all non-plaintext, and there is no risk of plaintext data leakage. Even if an attacker obtains the data segments during the process of reading the key lookup table generation operation mapping table set, it is difficult to crack them to obtain plaintext.

[0038] By reading the lookup table to generate an operation mapping table set, the ciphertext of the lookup table can be obtained. The ciphertext is the ciphertext of the lookup table generated based on the traversal parameters and round keys. The ciphertext contains non-linear encoding information, which can be added using non-linear encoding. The specific content of the non-linear encoding can be found in the relevant descriptions in the above embodiments, and will not be repeated here.

[0039] The round key ciphertext and traversal parameters can be divided into multiple data segments, which are then used as input data for reading the lookup table to generate the operation mapping table set. The specific content of each data segment can be found in the relevant descriptions in the above embodiments, and will not be repeated here. In some examples, the number of key lookup table ciphertexts can correspond to the number of traversal values ​​in the traversal parameters. For example, if the traversal parameters include 0 to 255, then there can be 256 32-bit key lookup table ciphertexts.

[0040] In step S105, the plaintext data to be encrypted is white-box encrypted based on the key lookup table ciphertext and the preset encryption operation mapping table set to obtain the target ciphertext.

[0041] The encryption operation mapping table set is a pre-defined collection of multiple mapping tables used to implement white-box encryption operations. By reading and querying the mapping tables in the encryption operation mapping table set, the white-box encryption function can be performed to obtain the target ciphertext, which is the ciphertext obtained after white-box encryption of the plaintext data to be encrypted. Each mapping table in the encryption operation mapping table set is similar in form to a key-value table. Each mapping table can record two sets of data segments with a mapping relationship, where any data segment in one set is mapped to a data segment in the other set.

[0042] The encryption operation mapping table set hides the specific computations of white-box encryption operations through multiple mapping tables. By using these tables, the data segments to be output by sub-operations of a white-box encryption operation can be found, and these data segments are non-plaintext. Reading or querying the encryption operation mapping table set will not reveal the plaintext of the original key or the plaintext parameters of the white-box encryption operations. By preserving the computational logic of white-box encryption operations, reading and querying the encryption operation mapping table set can save a significant amount of computation, improving the efficiency of white-box encryption operations.

[0043] White-box encryption operations may include sub-operations such as input encoding, obfuscation, XOR operations, and key lookup table lookups. Input encoding may include affine transformations and non-linear encoding; obfuscation may include inverse non-linear encoding, inverse affine transformations, inverse obfuscation transformations, and non-linear encoding; and XOR operations may include inverse non-linear encoding, XOR operations, and non-linear encoding. Each sub-operation can be implemented using one or more mapping tables. It should be noted that the mapping tables do not record the computational process of the sub-operations. The data segments obtained as intermediate data by reading and querying the encryption operation mapping table set are all non-plaintext, eliminating the risk of plaintext data leakage. Even if an attacker obtains the data segments during the process of reading and querying the encryption operation mapping table set, it is difficult to decipher them and obtain the plaintext.

[0044] The target ciphertext can be generated by reading and querying the encryption operation mapping table set. The plaintext data to be encrypted can be divided into multiple data segments, which are then used as input data for reading and querying the encryption operation mapping table set. The specific content of each data segment can be found in the relevant descriptions in the above embodiments, and will not be repeated here.

[0045] In this embodiment, the client device can receive a white-box key ciphertext obtained by encrypting the original key using the SM algorithm and a root key from the backend system; based on the white-box key ciphertext, a key ciphertext is obtained by reading and querying a set of mapping tables with de-white-boxing functionality; based on the key ciphertext, a round key ciphertext is obtained by reading and querying a set of mapping tables with key expansion functionality; based on the round key ciphertext and traversal parameters, a key lookup table ciphertext is obtained by reading a set of mapping tables with key lookup table generation functionality; by reading and querying the set of mapping tables with white-box encryption functionality and the key lookup table ciphertext, the plaintext data to be encrypted can be white-box encrypted to obtain the target ciphertext. In this white-box SM4 encryption process, operations such as de-whiteboxing, key expansion, key lookup table generation, and white-box encryption are all implemented by reading and querying the mapping table in the mapping table set. The mapping table only stores data segments with mapping relationships and does not contain the computational process of de-whiteboxing, key expansion, key lookup table generation, or white-box encryption. It also does not contain plaintext of important information such as the original key, system parameters required for key expansion, fixed parameters required for key expansion, and round keys. The data association between the original key and the mapping table is severed. Even if an attacker obtains intermediate data in the white-box SM4 encryption process, they cannot reconstruct the original key from the intermediate data, reducing or even eliminating the risk of exposure of the original key, thus providing higher resistance to attacks and improving encryption security.

[0046] In the white-box SM4 encryption process of this application embodiment, each mapping table is pre-set. When the original key is updated, the mapping tables do not need to be recreated. White-box SM4 encryption can be performed based on the updated original key and the original mapping tables, enabling dynamic white-box SM4 key updates and meeting the requirements for high-frequency key updates. The backend system only needs to perform SM4 encryption on the original key, without executing the proprietary obfuscation algorithm. This reduces the CPU utilization of the backend system, avoids business blockage, and improves business stability. The backend system also does not need to be modified to adapt the proprietary obfuscation algorithm to various software and hardware environments, reducing the modification and maintenance costs of the business system.

[0047] In some embodiments, the white-box de-mapping operation mapping table set may include a first input mapping table, a first obfuscation mapping table, a first XOR mapping table, a first S-box operation mapping table, and a second XOR mapping table. Step S102 can be further refined as follows: Read data segments that are mapped to the white-box key ciphertext from the first input mapping table; read data segments that are mapped to the data segments obtained from the first input mapping table from the first obfuscation mapping table; among the data segments obtained from the first obfuscation mapping table, determine the data segments that need to be XORed, and read data segments that are mapped to the data segments that need to be XORed from the first XOR mapping table; read data segments that are mapped to the data segments obtained from the first XOR mapping table from the first S-box operation mapping table; among the data segments obtained from the first obfuscation mapping table, determine the data segments that need to be XORed with the data segments obtained from the first S-box operation mapping table, and read data segments that are mapped to the two data segments undergoing XOR operations from the second XOR mapping table to obtain the key ciphertext.

[0048] The first input mapping table is a preset mapping table used for input encoding processing of data. It essentially hides the specific operations of the input encoding process, storing only the input and output data segments with mapping relationships. It does not contain the plaintext of the original key or the parameters used in the input encoding process. The first input mapping table can be used to look up the data segment corresponding to the data segment divided by the white-box key ciphertext. The retrieved data segment is obtained by affine transformation and nonlinear encoding of the data segment divided by the white-box key ciphertext. Correspondingly, the retrieved data segment contains affine transformation information and nonlinear encoding information, and is non-plaintext data. In some examples, the first input mapping table may include a first traversal data segment and a first result data segment with mapping relationships. The first result data segment is a data segment obtained by pre-processing the first traversal data segment with affine transformation and nonlinear encoding. There can be multiple first traversal data segments, and their values ​​can be set according to the scenario and requirements. The first traversal data segments can accommodate the range of data that may undergo input encoding processing in the business system. Each first traversal data segment can be pre-processed with affine transformation and nonlinear encoding, and the resulting data segment can be used as the first result data segment. A mapping relationship between the first traversal data segment and the first result data segment can be established to generate the first input mapping table.

[0049] The first obfuscation mapping table is a pre-defined mapping table used for data obfuscation. It essentially hides the specific operations of the obfuscation process, storing only the input and output data segments with mapping relationships. The plaintext of the original key and parameters used in the obfuscation process are not present. Data segments retrieved from the first input mapping table can be used as input segments for queries in the first obfuscation mapping table. The retrieved data segment is obtained by applying inverse nonlinear encoding, inverse affine transformation, inverse obfuscation transformation, and nonlinear encoding to the output data segment of the first input mapping table. This retrieved data segment contains obfuscation and nonlinear encoding information and is non-plaintext data. In some examples, the first obfuscation mapping table includes a second traversal data segment and a second result data segment with mapping relationships. The second result data segment is obtained by pre-processing the second traversal data segment with inverse nonlinear encoding, inverse affine transformation, inverse obfuscation transformation, and nonlinear encoding. The inverse nonlinear encoding cancels the nonlinear encoding in the input encoding process represented by the first input mapping table, and the inverse affine transformation cancels the affine transformation in the input encoding process represented by the first input mapping table. The number of second-traversal data segments is multiple, and the values ​​of the second-traversal data segments can be set according to scenarios and requirements. The second-traversal data segments can meet the range of data in the business system that may undergo obfuscation processing. Each second-traversal data segment can be pre-processed with inverse nonlinear encoding, inverse affine transformation, inverse obfuscation transformation, and nonlinear encoding in sequence. The resulting data segment is used as the second-result data segment, and a mapping relationship between the second-traversal data segments and the second-result data segments is established to generate the first obfuscation mapping table.

[0050] A portion of the data segment obtained by querying the first obfuscation mapping table will undergo an XOR operation. For example, to XOR three data segments (segment 1 to segment 3), segment 1 can be XORed with segment 2 to obtain the XOR result, and then the XOR result can be XORed with segment 3 to obtain the final XOR result. This XOR result can be used as the final XOR result for segment 1 to segment 3. The first XOR mapping table is a preset mapping table that can be used to perform XOR operations on data. The first XOR mapping table essentially hides the specific XOR operation, only storing the mapping table of input and output data segments with mapping relationships. The plaintext of the original key and the plaintext of the parameters in the XOR process will not appear in the first XOR mapping table. The data segment corresponding to the data segment that needs to be XORed can be queried in the first XOR mapping table. The queried data segment is the data segment obtained by inverse nonlinear encoding, XOR operation, and nonlinear encoding of the data segment that needs to be XORed. Correspondingly, the queried data segment contains nonlinear encoded information and is non-plaintext data. In some examples, the first XOR mapping table includes a third traversal data segment and a third result data segment with a mapping relationship. The third traversal data segment is formed by concatenating a portion of each of the two data segments. The third result data segment is a data segment obtained by pre-processing the two portions of the third traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. There can be multiple third traversal data segments, and their values ​​can be set according to scenarios and requirements. The third traversal data segments can accommodate the range of data that may undergo XOR operations in the business system. Each third traversal data segment can be pre-processed with inverse nonlinear encoding, XOR operation, and nonlinear encoding sequentially, and the resulting data segment is used as the third result data segment. A mapping relationship between the third traversal data segment and the third result data segment is established to generate the first XOR mapping table. When performing nonlinear encoding or inverse nonlinear encoding on a data segment, each n bits of data in the data segment is nonlinearly encoded or inversely encoded. The XOR operation between two data segments containing nonlinear encoded information can be performed by first splitting the data segment containing nonlinear encoded information into multiple sub-segments of length n bits. Each of the two data segments provides a sub-segment that can be concatenated into a data segment of length 2n bits. The high n bits and low n bits of each 2n bit data segment are then subjected to inverse nonlinear encoding. The two n bits obtained by inverse nonlinear encoding are then XORed to obtain the XOR result. The XOR result is then subjected to nonlinear encoding to obtain a sub-segment of length n bits. The XOR operation between two data segments can yield multiple sub-segments of length n bits.

[0051] For example, when performing nonlinear encoding, each 4 bits of data in the data segment can be sub-linearly encoded to obtain a data segment containing nonlinear encoding information. Figure 3A schematic diagram illustrating an example of the XOR operation provided in an embodiment of this application, as shown below. Figure 3 As shown, when generating the XOR mapping table, if the data segments that need to be XORed are data segment A containing non-linear encoding information and data segment B containing non-linear encoding information, and the length of both data segment A and data segment B containing non-linear encoding information is 32 bits, then the 32-bit data segment A can be split into 8 sub-segments of 4 bits each, and the 32-bit data segment B can be split into 8 sub-segments of 4 bits each. Figure 3 In the diagram, 4 bits + Ai represents the (i+1)th sub-segment obtained by splitting data segment A containing non-linear encoded information, and 4 bits + Bi represents the (i+1)th sub-segment obtained by splitting data segment B containing non-linear encoded information, where i = 0, 1, 2, ..., 7. Every two 4-bit sub-segments from data segments A and B are combined into a new 8-bit data set. The higher 4 bits and lower 4 bits of this new data are then subjected to corresponding inverse non-linear encoding to remove the non-linear encoded information. Figure 3 A0 in -1 B0 represents the inverse nonlinear code corresponding to the first sub-segment obtained by splitting data segment A. -1 This represents the inverse nonlinear code corresponding to the first sub-segment obtained by splitting data segment B. An XOR operation is performed on the sub-segment with the nonlinear code information removed, and the XOR result is then subjected to nonlinear encoding to obtain the sub-segment containing the nonlinear code information (4 bits + Ci). Figure 3 C0 in the code represents the non-linear code corresponding to the first sub-segment. Figure 3 The code only shows the processing performed on the first segment; the processing of the second through eighth segments is the same as that of the first segment. Figure 3 Not all of them are shown in the text. Figure 3 The processing yields an XOR mapping table consisting of an 8-bit input data segment and a 4-bit output data segment, which have mapping relationships. Non-linear encoding of each 4-bit data segment produces approximately 2... 4 = 2.1 × 10 13 With these combinations, it is extremely difficult for an attacker to recover the nonlinear encoded information from the XOR mapping table. The first XOR mapping table can be generated according to the above-mentioned method for generating XOR mapping tables.

[0052] The first S-box operation mapping table is a preset mapping table that can be used to perform S-box operations on data. The first S-box operation mapping table essentially hides the specific operations of the S-box operation; it only stores the mapping table of input and output data segments for S-box operations with mapping relationships. It does not contain the plaintext of the original key, the ciphertext of the root key, or the plaintext of parameters used in the S-box operation process. Data segments retrieved from the first XOR mapping table can be used as input data segments for queries in the first S-box operation mapping table. The retrieved data segments are obtained by processing the data segments output from the first XOR mapping table through inverse nonlinear encoding, obfuscation transformation, S-box processing, shifting, affine transformation, and nonlinear encoding. The retrieved data segments contain affine transformation information and nonlinear encoding information and are non-plaintext data. In some examples, the first S-box operation mapping table includes a fourth traversal data segment and a fourth result data segment with a mapping relationship. The fourth result data segment is a data segment obtained by pre-processing the fourth traversal data with inverse nonlinear encoding, obfuscation transformation, S-box processing, shift processing, affine transformation, and nonlinear encoding. The S-box processing is implemented based on the root key. The inverse nonlinear encoding can cancel the nonlinear encoding in the XOR processing represented by the first XOR mapping table, and the obfuscation transformation can cancel the inverse obfuscation transformation in the obfuscation processing represented by the first obfuscation mapping table. There are multiple fourth traversal data segments, and the values ​​of the fourth traversal data segments can be set according to the scenario, requirements, etc. The fourth traversal data segments can meet the range of data that may be processed by S-box operations in the business system. Each fourth traversal data segment can be pre-processed with inverse nonlinear encoding, obfuscation transformation, S-box processing, shift processing, affine transformation, and nonlinear encoding in sequence. The resulting data segment is used as the fourth result data segment, and a mapping relationship is established between the fourth traversal data segment and the fourth result data segment to generate the first S-box operation mapping table.

[0053] A portion of the data segment obtained by querying the first obfuscation mapping table is XORed with the data segment obtained by querying the first S-box operation mapping table. The second XOR mapping table is a preset mapping table that can be used to perform XOR operations on data. The second XOR mapping table essentially hides the specific XOR operation, only storing the mapping table of input and output data segments of XOR operations with mapping relationships. It does not contain the plaintext of the original key or the plaintext of the parameters in the XOR process. The data segment corresponding to the data segment that needs to be XORed can be queried in the second XOR mapping table. The queried data segment is the data segment obtained by inverse nonlinear encoding, XOR operation, and nonlinear encoding of the data segment that needs to be XORed. Correspondingly, the queried data segment contains affine transformation information and nonlinear encoding information, and is non-plaintext data. The key ciphertext can be obtained from the data segment queried from the second XOR mapping table. In some examples, the second XOR mapping table includes a third traversal data segment and a third result data segment with mapping relationships. The specific contents of the third traversal data segment and the third result data segment can be found in the relevant descriptions in the above embodiments, and will not be repeated here. A mapping relationship is established between the third traversal data segment and the third result data segment to generate a second XOR mapping table. However, it should be noted that the third traversal data segment and the third result data segment in the second XOR mapping table can be different from those in the first XOR mapping table. Furthermore, the nonlinear encoding in the XOR operation represented by the second XOR mapping table can differ from the encoding method in the XOR operation represented by the first XOR mapping table. For details on the XOR operation represented by the second XOR mapping table and the specific content of generating the second XOR mapping table, please refer to the relevant descriptions of the XOR operation and the generation of the XOR mapping table in the above embodiments, which will not be repeated here.

[0054] For example, Figure 4 This is a schematic diagram illustrating an example of obtaining key ciphertext by reading and querying a set of white-box operation mapping tables according to an embodiment of this application. Figure 4 As shown, the 128-bit white-box key ciphertext can be divided into four 32-bit data segments, represented as X0, X1, X2, and X3. These four data segments serve as the input data segments for the first input mapping table 211. Figure 4The contents of the first input mapping table 211 represent the hidden input encoding processing within the first input mapping table 211. P0, P1, P2, and P3 represent affine transformations, and Ni represents nonlinear encoding. The above operations do not actually exist in the first input mapping table 211; they are only used here to illustrate the relationship between the input and output data segments in the first input mapping table 211. By reading and querying the first input mapping table 211, the corresponding output data segments X0'+Ni, X1'+Ni, X2'+Ni, and X3'+Ni can be obtained. These data segments X0'+Ni, X1'+Ni, X2'+Ni, and X3'+Ni are used as the input data segments of the first confusion mapping table 212. i '+Ni、X i+1 '+Ni、X i+2 '+Ni、X i+3 '+Ni is the data segment used as input to the first obfuscation mapping table 212 in the 32 intermediate rounds of the white-box removal algorithm. Figure 4 The contents of the first obfuscation mapping table 212 represent the obfuscation operations hidden in the first obfuscation mapping table 212. The Ni in the first obfuscation mapping table 212... -1 P represents inverse nonlinear encoding. i -1 P i+1 -1 P i+2 -1 P i+3 -1 P represents the inverse affine transformation. i+4 ' represents affine transformation, Ei -1 The expression represents the inverse conflation transformation, and Ni represents the nonlinear encoding. The above operation process does not actually exist in the first conflation mapping table 212; it is only used here to illustrate the relationship between the input and output data segments in the first conflation mapping table 212. The data segment obtained by reading and querying the first conflation mapping table 212 can be used as the input data segment of the first XOR mapping table 213. There can be multiple first XOR mapping tables 213. The data segments obtained by querying the second and third first conflation mapping tables 212 can be used as the input data segment of one first XOR mapping table 213. The output data segment obtained by querying this first XOR mapping table and the data segment obtained by querying the fourth first conflation mapping table 212 can be used as the input data segment of another first XOR mapping table 213. The output data segment obtained by querying the other XOR mapping table 213 can be used as the input data segment of the first S-box operation mapping table 214. Figure 4 The contents of the first S-box operation mapping table 214 represent the hidden S-box operations in the first S-box operation mapping table 214. Ni in the first S-box operation mapping table 214 -1Indicates inverse nonlinear encoding, Ei0, Ei1, Ei2, Ei3 represent confusing transformation, Sbox* represents S-box processing, L represents shift processing, P i+4 * represents affine transformation, Ni represents nonlinear encoding. The above operation process does not actually exist in the first S-box operation mapping table 214; it is only used here to illustrate the relationship between the input and output data segments in the first S-box operation mapping table 214. The S-box operation represented by the first S-box operation mapping table 214 is related to the root key, which is consistent with the root key required by the backend system to generate the white-box key ciphertext. However, the root key does not exist in the first S-box operation mapping table 214. The output data segment obtained by querying the first S-box operation mapping table 214 can be used together with the output data segment of the first obfuscation mapping table 212 as the input data segment of the second XOR mapping table 215. Querying the second XOR mapping table 215 yields the input data segment X. i+4 '+Ni, through 32 rounds of intermediate algorithm rounds, the data segment X can be obtained. 32 '+Ni、X 33 '+Ni、X 34 '+Ni、X 35 +Ni, data segment X 32 '+Ni、X 33 '+Ni、X 34 '+Ni、X 35 '+Ni can form the key ciphertext a', which contains affine transformation information and nonlinear coding information, and can be represented as a'=σ1(a P), σ1 represents nonlinear encoding, P represents affine transformation, and a represents the original key. It should be noted that each of the 32 rounds of the intermediate algorithm requires reading and querying the first confusion map, the first XOR map, the first S-box operation map, and the second XOR map. The maps used in different rounds may be different.

[0055] In some embodiments, the key expansion operation mapping table set includes a second input mapping table, multiple third XOR mapping tables, and a second S-box operation mapping table. Step S103 can be further refined as follows: Read data segments that have a mapping relationship with the key ciphertext from the second input mapping table; among the data segments obtained through the second input mapping table, determine the data segments that need to be XORed; read data segments that have a mapping relationship with the data segments that need to be XORed from the third XOR mapping table; read data segments that have a mapping relationship with the data segments obtained through the third XOR mapping table from the second S-box operation mapping table; among the data segments obtained through the second input mapping table and the data segments obtained through the second S-box operation mapping table, determine the data segments that need to be XORed; read data segments that have a mapping relationship with the data segments that need to be XORed from the third XOR mapping table to obtain the round key ciphertext.

[0056] The second input mapping table is a pre-defined mapping table used for input encoding processing of data. It essentially hides the specific operations of the input encoding process, storing only the input and output data segments with mapping relationships. It does not contain the plaintext of the original key, system parameters, or parameters used in the input encoding process. Users can look up the data segment corresponding to the key-ciphertext segment in the second input mapping table. The retrieved data segment is obtained by performing inverse nonlinear encoding, inverse affine transformation, system parameter processing, and nonlinear encoding on the key-ciphertext segment. Correspondingly, the retrieved data segment contains nonlinear encoding information and is non-plaintext data. In some examples, the second input mapping table includes a fifth traversal data segment and a fifth result data segment with mapping relationships. The fifth result data segment is obtained by pre-processing the fifth traversal data segment with inverse nonlinear encoding, inverse affine transformation, system parameter processing, and nonlinear encoding. The system parameter processing is implemented based on system parameters. The inverse nonlinear encoding cancels out the nonlinear encoding information in the key ciphertext, and the inverse affine transformation cancels out the affine transformation information in the key ciphertext. The system parameter processing utilizes an XOR operation between the system parameters and the vector portion of the inverse affine transformation to implement the system parameter logic in standard key expansion. There are multiple fifth traversal data segments, and their values ​​can be set according to the scenario and requirements. The fifth traversal data segments can accommodate the range of data that may undergo input encoding processing in the business system. Each fifth traversal data segment can be pre-processed with inverse nonlinear encoding, inverse affine transformation, system parameter processing, and nonlinear encoding sequentially. The resulting data segment is used as the fifth result data segment, and a mapping relationship between the fifth traversal data segments and the fifth result data segment is established to generate a second input mapping table.

[0057] A portion of the data segment obtained by querying the second input mapping table is XORed. The specific details of the XOR operation for the three data segments can be found in the relevant descriptions in the above embodiments, and will not be repeated here. The XOR operation for the three data segments can be implemented by querying two XOR mapping tables. XORing the four data segments, i.e., data segments 1 to 4, can be done by XORing data segments 1 and 2, XORing data segments 3 and 4, and then XORing the two XOR results. This XOR result can be used as the final XOR result of the XOR operation for data segments 1 to 4. The XOR operation for the four data segments can be implemented by querying three XOR mapping tables. The third XOR mapping table is a preset mapping table that can be used to perform XOR operations on data. The third XOR mapping table essentially hides the specific XOR operation, storing only the input and output data segments of the XOR process with mapping relationships. It does not contain the plaintext of the original key or the parameters used in the XOR process. The third XOR mapping table can be used to look up and determine the data segment corresponding to the data segment requiring the XOR operation. The retrieved data segment is obtained by inverse nonlinear encoding, XOR operation, and nonlinear encoding of the data segment requiring the XOR operation. Correspondingly, the retrieved data segment contains nonlinear encoding information and is non-plaintext data. In some examples, the third XOR mapping table includes a sixth traversal data segment and a sixth result data segment with mapping relationships. The sixth traversal data segment is formed by concatenating a portion of each of the two data segments, and the sixth result data segment is obtained by pre-processing the two portions of the sixth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. The mapping relationship between the sixth traversal data segment and the sixth result data segment may differ in different third XOR mapping tables. The sixth traversal data segment is formed by concatenating a portion of each of two data segments. The sixth result data segment is a data segment obtained by pre-processing the two portions of the sixth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. There can be multiple sixth traversal data segments, and their values ​​can be set according to scenarios and requirements. The sixth traversal data segments can accommodate the range of data in the business system that may undergo XOR operations. Each sixth traversal data segment can be pre-processed with inverse nonlinear encoding, XOR operation, and nonlinear encoding sequentially, and the resulting data segment can be used as the sixth result data segment. A mapping relationship between the sixth traversal data segments and the sixth result data segments can be established to generate a third XOR mapping table. For details on the XOR operation, please refer to the relevant descriptions in the above embodiments. The third XOR mapping table can be generated according to the generation method of the XOR mapping table in the above embodiments.

[0058] The second S-box operation mapping table is a pre-defined operation table used to perform S-box operations on data. This table essentially hides the specific operations involved in the S-box operations, storing only the input and output data segments of S-box operations with mapping relationships. It does not contain the plaintext of the original key, the ciphertext of fixed parameters, or the plaintext of parameters used in the S-box operation process. Data segments retrieved from the third XOR mapping table can be used as input segments for querying the second S-box operation mapping table. The retrieved data segments are obtained by performing inverse nonlinear encoding, S-box processing, shifting, and nonlinear encoding on a portion of the data segments output from the third XOR mapping table. These retrieved data segments contain nonlinear encoding information and are non-plaintext data. In some examples, the second S-box operation mapping table includes a seventh traversal data segment and a seventh result data segment with mapping relationships. The seventh result data segment is obtained by pre-processing the seventh traversal data with inverse nonlinear encoding, S-box processing, shifting, and nonlinear encoding. The S-box processing is implemented based on fixed parameters, and the shifting processing can be obtained using a key-expanded shift matrix. The inverse nonlinear encoding can cancel the nonlinear encoding in the XOR processing represented by the third XOR mapping table. There are multiple seventh traversal data segments, and their values ​​can be set according to the scenario and requirements. The seventh traversal data segments can accommodate the range of data that may undergo S-box operations in the business system. Each seventh traversal data segment can be pre-processed with inverse nonlinear encoding, S-box processing, shifting, and nonlinear encoding sequentially. The resulting data segment is used as the seventh result data segment, and a mapping relationship is established between the seventh traversal data segments and the seventh result data segment, generating the second S-box operation mapping table.

[0059] The data segment obtained by querying the second S-box operation map table can be XORed and used as input to the third XOR map table. The data segment obtained by querying the third XOR map table, along with a portion of the data segment obtained by querying the second input map table, can be used as input to another third XOR map table. The output data segment obtained by querying the other third XOR map table can be combined to generate the round key ciphertext. The round key ciphertext contains non-linear encoded information and is non-plaintext data.

[0060] For example, Figure 5 This is a schematic diagram illustrating an example of obtaining round key ciphertext by reading a set of query key expansion operation mapping tables provided in an embodiment of this application, as shown below. Figure 5 As shown, the key ciphertext a' is used as the data segment of the input to the second input mapping table 221. Figure 5 The contents of the second input mapping table 221 represent the input encoding processing hidden in the second input mapping table 221. Ni in the second input mapping table 221 -1 P represents inverse nonlinear encoding. 32-1 P 33 -1 P 34 -1 P 35 -1 Let FK0, FK1, FK2, and FK3 represent the system parameters, and Ni represent the nonlinear code. The above calculation process does not actually exist in the second input mapping table 221; it is only used here to illustrate the relationship between the input and output data segments in the second input mapping table 221. By reading and querying the second input mapping table 221, the corresponding output data segments MK0'+Ni, MK1'+Ni, MK2'+Ni, and MK3'+Ni can be obtained. These data segments MK0'+Ni, MK1'+Ni, MK2'+Ni, and MK3'+Ni are used as the input data segments of the third XOR mapping table 222. i '+Ni、MK i+1 '+Ni、MK i+2 '+Ni、MK i+3 '+Ni' is the data segment used as input to the third XOR mapping table 222 in the 32 intermediate rounds of the key expansion operation. Among them, data segment MK... i+1 +Ni and data segment MK i+2 The data segment '+Ni' is used as the input to the first third XOR mapping table 222. The first third XOR mapping table 222 is then queried to obtain the output data segment containing non-linear encoding information. This output data segment is then compared with the data segment MK. i+3 The data segment '+Ni' is used as the input data segment of the second third XOR mapping table 222. The output data segment containing nonlinear encoding information is obtained by querying the second third XOR mapping table 222. The output data segment is used as the input data segment of the second S-box operation mapping table. Figure 5 The contents of the second S-box operation mapping table 223 represent the hidden S-box operations in the second S-box operation mapping table 223. Ni in the second S-box operation mapping table 223 -1 The S-box operations represent inverse nonlinear encoding. Sbox0*, Sbox1*, Sbox2*, and Sbox3* represent S-box processing, L0', L1', L2', and L3' represent shift processing, and Ni represents nonlinear encoding. The above operations do not actually exist in the second S-box operation mapping table 223; they are only used here to illustrate the relationship between the input and output data segments in the second S-box operation mapping table 214. The S-box operations represented by the second S-box operation mapping table 223 are related to the fixed parameter CK. i Related, but the fixed parameter CK does not exist in the second S-box operation mapping table 214. iIf the input data segment of the second S-box operation mapping table includes m data segments of length n bits, then the length of the output data segment is m×n bits. For example, the second S-box operation mapping table can be regarded as a mapping table with four 8-bit data segments as inputs and a 32-bit data segment as output. The 32-bit data segment output by the second S-box operation mapping table 223 can include four 8-bit data segments. In the data segment output by the second S-box operation mapping table 223, the first 8-bit data segment and the second 8-bit data segment can be used as the input data segments of the third XOR mapping table 222, the third 8-bit data segment and the fourth 8-bit data segment can be used as the input data segments of the fourth XOR mapping table 222, the data segments obtained by querying the third XOR mapping table 223 and the data segments obtained by querying the fourth XOR mapping table 223 can be used as the input data segments of the fifth XOR mapping table 223, and the data segments obtained by querying the fifth XOR mapping table 223 and data segment MK... i +Ni can be used as the input data segment of the sixth third XOR mapping table 223, and the data segment obtained by querying the sixth third XOR mapping table 223 is K. i+4 +Ni. Through 32 rounds of computation in the intermediate algorithm, the data segment K4+Ni to X can be obtained. 35 +Ni, data segment K4+Ni to K 35 +Ni can form the round key ciphertext K'. This round key ciphertext K' contains non-linear encoded information and can be represented as K'=σ2(σ1) -1 (a') P -1 ⊕FK i ), σ2 represents nonlinear encoding, σ1 -1 P represents inverse nonlinear encoding. -1 Let FK represent an affine transformation, a' represent the key ciphertext, and FK represent the key ciphertext. i This represents system parameters. Alternatively, the round key can be considered as K, then the round key ciphertext K' = σ3(K), representing the nonlinear encoding σ3. It should be noted that each of the 32 rounds of the intermediate algorithm requires reading and querying the third XOR mapping table and the second S-box operation mapping table, and the mapping tables in different rounds may be different.

[0061] In some embodiments, the key lookup table generation operation mapping table set includes a traversal parameter processing mapping table, a fourth XOR mapping table, and a third S-box operation mapping table. Step S104 can be further refined as follows: Read the data segments in the traversal parameter processing mapping table that have a mapping relationship with the traversal parameters; read the data segments in the fourth XOR mapping table that have a mapping relationship with the round key ciphertext and the data segments obtained by querying the traversal parameter processing mapping table; read the data segments in the third S-box operation mapping table that have a mapping relationship with the data segments obtained by querying the fourth XOR mapping table, to obtain the key lookup table ciphertext.

[0062] The traversal parameter processing mapping table is a pre-defined mapping table used to process traversal parameters. This table essentially hides the specific operations involved in traversal parameter processing, storing only the input and output data segments with mapping relationships. It does not contain the plaintext of the original key or the parameters used in the traversal parameter processing. Users can look up the data segment corresponding to the traversal parameter in the mapping table. The retrieved data segment is the result of matrix obfuscation and non-linear encoding of the traversal parameter; correspondingly, the retrieved data segment contains non-linear encoding information and is non-plaintext data. In some examples, the traversal parameter processing mapping table includes an eighth traversal data segment and an eighth result data segment with mapping relationships. The eighth result data segment is a data segment obtained by pre-processing the eighth traversal data segment with matrix obfuscation and non-linear encoding. There can be multiple eighth traversal data segments, and their values ​​can be set according to the scenario and requirements. The eighth traversal data segments can accommodate the range of data that may be processed by traversal parameters in the business system. Each eighth traversal data segment can be pre-processed with matrix obfuscation and non-linear encoding, and the resulting data segment can be used as the eighth result data segment. A mapping relationship between the eighth traversal data segment and the eighth result data segment can be established to generate a traversal parameter processing mapping table.

[0063] The data segment obtained from the query traversal parameter processing mapping table is XORed with the round key ciphertext. The fourth XOR mapping table is a pre-defined mapping table used for XOR operations on data. The fourth XOR mapping table essentially hides the specific XOR operation, storing only the input and output data segments of the XOR operation with mapping relationships. It does not contain the plaintext of the original key, the round key, or the parameters used in the XOR process. The data segment obtained from the query traversal parameter processing mapping table and the round key ciphertext are used as input data segments to the fourth XOR mapping table. The data obtained by querying the fourth XOR mapping table is a data segment obtained by inverse nonlinear encoding, XOR operation, and nonlinear encoding of the data segment obtained from the query traversal parameter processing mapping table and the round key ciphertext. Correspondingly, the data segment obtained by the query contains nonlinear encoding information and is non-plaintext data. In some examples, the fourth XOR mapping table includes a ninth traversal data segment and a ninth result data segment with a mapping relationship. The ninth traversal data segment is formed by concatenating a portion of each of the two data segments, and the ninth result data segment is a data segment obtained by pre-processing the two portions of the ninth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. The inverse nonlinear encoding cancels out the nonlinear encoding in the traversal parameter processing represented by the traversal parameter processing mapping table, and also cancels out the nonlinear encoding information in the round key ciphertext. The ninth traversal data segment is formed by concatenating a portion of each of the two data segments, and the ninth result data segment is a data segment obtained by pre-processing the two portions of the ninth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. There can be multiple ninth traversal data segments, and their values ​​can be set according to the scenario and requirements. The ninth traversal data segments can accommodate the range of data in the business system that may undergo XOR operations. Each ninth traversal data segment can be pre-processed with inverse nonlinear encoding, XOR operation, and nonlinear encoding sequentially. The resulting data segment is then used as the ninth result data segment. A mapping relationship between the ninth traversal data segment and the ninth result data segment is established to generate a fourth XOR mapping table. For details on the XOR operation, please refer to the relevant descriptions in the above embodiments. The fourth XOR mapping table can be generated according to the generation method of the XOR mapping table in the above embodiments.

[0064] The third S-box operation mapping table is a pre-defined operation table used to perform S-box operations on data. This table essentially hides the specific operations involved in the S-box operations, storing only the input and output data segments of the S-box operations with mapping relationships. It does not contain the plaintext of the original key or the parameters used in the S-box operations. Data segments retrieved from the fourth XOR mapping table can be used as input segments to query the third S-box operation mapping table. The retrieved data segments are obtained by performing inverse nonlinear encoding, S-box processing, matrix processing, constant processing, XOR operation, and nonlinear encoding on the output segments of the fourth XOR mapping table. These retrieved data segments contain nonlinear encoding information and are non-plaintext data. In some examples, the third S-box operation mapping table includes a tenth traversal data segment and a tenth result data segment with mapping relationships. The tenth result data segment is obtained by pre-processing the tenth traversal data segment with inverse nonlinear encoding, S-box processing, matrix processing, constant processing, XOR operation, and nonlinear encoding. The inverse nonlinear encoding cancels out the nonlinear encoding in the XOR processing represented by the fourth XOR mapping table. There are multiple tenth traversal data segments, and their values ​​can be set according to the scenario and requirements. The tenth traversal data segments can accommodate the range of data that may undergo S-box operations in the business system. Each tenth traversal data segment can be pre-processed with inverse nonlinear encoding, S-box processing, shifting, and nonlinear encoding sequentially. The resulting data segment is then used as the tenth result data segment, and a mapping relationship between the tenth traversal data segments and the tenth result data segment is established, generating the third S-box operation mapping table. Querying the data obtained from the third S-box operation mapping table yields multiple key lookup table ciphertexts. Each key lookup table ciphertext corresponds to one key lookup table, and the number of key lookup table ciphertexts can be the same as the number of traversal values ​​in the traversal parameters.

[0065] For example, Figure 6 This is a schematic diagram illustrating an example of obtaining ciphertext from a key lookup table by reading a lookup table and generating an operation mapping table, as provided in an embodiment of this application. Figure 6 As shown, traversing parameter k (0~255) The data segment is processed as the input to the mapping table 231 as a traversal parameter. Figure 6The contents of the traversal parameter processing mapping table 231 represent the traversal parameter processing hidden in the mapping table 231. In the traversal parameter processing mapping table 231, Eij represents matrix obfuscation processing, and Ni represents nonlinear encoding. The above operations do not actually exist in the traversal parameter processing mapping table 231; they are only used here to illustrate the relationship between the input and output data segments in the traversal parameter processing mapping table 231. The traversal parameter processing represented by the traversal parameter processing mapping table 231 can be represented as Table1 = σ4(Eij(x)), where x represents the traversal parameter, Eij represents matrix obfuscation processing, σ4 represents nonlinear encoding, and Table1 represents the output data segment obtained by querying the traversal parameter processing mapping table 231. The data segment obtained by querying the traversal parameter processing mapping table 231 and the round key ciphertext K' are read as the input data segment of the fourth XOR mapping table 232. The XOR operation represented by the fourth XOR mapping table 232 can be represented as Table2 = σ5(σ4) -1 (Table 1) ⊕σ3 -1 (K')), σ5 represents non-linear encoding, σ4 -1 This represents the inverse nonlinear encoding of σ4, σ3 -1 Table 2 represents the inverse nonlinear encoding of σ3, and is the output data segment obtained by querying the fourth XOR mapping table 232. The output data segment obtained by querying the fourth XOR mapping table 232 serves as the input data segment to the third S-box operation mapping table 233. The length of the input data segment to the fourth XOR mapping table 232 can be 8 bits, with 4 bits coming from the data segment obtained by querying the parameter processing mapping table 231, and the other 4 bits coming from the round key ciphertext K. The length of the output data segment of the fourth XOR mapping table 232 can also be 4 bits. Figure 6 The contents of the third S-box operation mapping table 233 represent the hidden S-box operations in the third S-box operation mapping table 233. Ni in the third S-box operation mapping table 233 -1 Indicates inverse nonlinear encoding; Sbox indicates S-box processing; l[L·P (i+4) "] indicates matrix processing, which may include the matrix components of shift transformations and affine transformations. The data obtained after matrix processing is 32 bits in length; c[P (i+4)"] indicates constant processing, which may include the constant processing part of affine transformation. The length of the data obtained after constant processing is 32 bits; Ni indicates non-linear encoding; the data obtained after matrix processing and the data obtained after constant processing are XORed, and the resulting data is then non-linearly encoded to obtain the key lookup table ciphertext. Each traversal value in the traversal parameter corresponds to a key lookup table ciphertext of length 32 bits. Therefore, the traversal value 0 and the value 255 correspond to 256 key lookup table ciphertexts of length 32 bits. The S-box operation represented by the third S-box operation mapping table 233 can be expressed as Table3=σ6(L p (sBox(σ5 -1 (Table 2) represents non-linear encoding, represents inverse non-linear encoding, sBox represents S-box processing, L p Representing L-transformation and affine transformation P'' (i+4) The composite operation, Table 3 represents the data segment of the output obtained by querying the third S-box operation mapping table 233.

[0066] In some embodiments, the encryption operation mapping table set includes a third input mapping table, a second obfuscation mapping table, a fifth XOR mapping table, a sixth XOR mapping table, and an output mapping table. Step S105 can be further refined as follows: Read data segments that have a mapping relationship with the plaintext data to be encrypted in the third input mapping table; read data segments that have a mapping relationship with the data segments obtained through the third input mapping table in the second obfuscation mapping table; among the data segments obtained through the second obfuscation mapping table, determine the data segments that need to be XORed, and read data segments that have a mapping relationship with the data segments that need to be XORed in the fifth XOR mapping table; search for data segments in the ciphertext of the key lookup table that correspond to the data segments obtained through the fifth XOR mapping table; among the data segments obtained through the second obfuscation mapping table, determine the data segments that need to be XORed with the data segments obtained through the key lookup table, and read data segments that have a mapping relationship with the two data segments undergoing XOR operations in the sixth XOR mapping table; read data segments that have a mapping relationship with the data segments obtained through the sixth XOR mapping table in the output mapping table to obtain the target ciphertext.

[0067] The third input mapping table is a pre-defined mapping table used for input encoding processing of data. It essentially hides the specific operations of the input encoding process, storing only the input and output data segments with mapping relationships. It does not contain the plaintext of the original key or the parameters used in the input encoding process. Users can look up the data segment corresponding to the segment of the plaintext data to be encrypted in the third input mapping table. The retrieved data segment is obtained by affine transformation and nonlinear encoding of the plaintext data segment. Correspondingly, the retrieved data segment contains affine transformation information and nonlinear encoding information, and is non-plaintext data. In some examples, the third input mapping table includes an eleventh traversal data segment and an eleventh result data segment with mapping relationships. The eleventh result data segment is obtained by pre-processing the eleventh traversal data segment with affine transformation and nonlinear encoding. There can be multiple eleventh traversal data segments, and their values ​​can be set according to the scenario and requirements. The eleventh traversal data segments can accommodate the range of data that may undergo input encoding processing in the business system. Each eleventh traversal data segment can be pre-processed with affine transformation and nonlinear encoding, and the resulting data segment can be used as the eleventh result data segment. A mapping relationship between the eleventh traversal data segment and the eleventh result data segment can be established to generate the third input mapping table.

[0068] The second obfuscation map is a pre-defined map used for obfuscating data. It essentially hides the specific operations of the obfuscation process, storing only the input and output data segments with mapping relationships. The plaintext of the original key and parameters used in the obfuscation process are not present. Data segments retrieved from the third input map can be used as input segments for queries in the second obfuscation map. The retrieved data segment is obtained by applying inverse nonlinear encoding, inverse affine transformation, inverse obfuscation transformation, and nonlinear encoding to the output data segment of the third input map. This retrieved data segment contains obfuscation and nonlinear encoding information and is non-plaintext data. In some examples, the second obfuscation map includes a twelfth traversal data segment and a twelfth result data segment with mapping relationships. The twelfth result data segment is obtained by pre-processing the twelfth traversal data segment with inverse nonlinear encoding, inverse affine transformation, inverse obfuscation transformation, and nonlinear encoding. The inverse nonlinear encoding cancels out the nonlinear encoding in the input encoding process represented by the third input mapping table, and the inverse affine transformation cancels out the affine transformation in the input encoding process represented by the third input mapping table. There are multiple twelfth traversal data segments, and their values ​​can be set according to the scenario and requirements. The twelfth traversal data segments can accommodate the range of data that may undergo obfuscation processing in the business system. Each twelfth traversal data segment can be pre-processed with inverse nonlinear encoding, inverse affine transformation, inverse obfuscation transformation, and nonlinear encoding sequentially. The resulting data segment is used as the twelfth result data segment, and a mapping relationship between the twelfth traversal data segment and the twelfth result data segment is established to generate a second obfuscation mapping table.

[0069] A portion of the data segment obtained by querying the second obfuscation mapping table will undergo an XOR operation. The fifth XOR mapping table is a pre-defined mapping table that can be used to perform XOR operations on data. The fifth XOR mapping table essentially hides the specific XOR operation, only storing the input and output data segments of the XOR operation with mapping relationships. It does not contain the plaintext of the original key or the parameters during the XOR process. The fifth XOR mapping table can be used to query the data segment corresponding to the data segment that needs to be XORed. The queried data segment is obtained by inverse nonlinear encoding, XOR operation, and nonlinear encoding of the data segment that needs XOR operation. Correspondingly, the queried data segment contains nonlinear encoding information and is non-plaintext data. In some examples, the fifth XOR mapping table includes a thirteenth traversal data segment and a thirteenth result data segment with mapping relationships. The thirteenth traversal data segment is formed by concatenating a portion of each of the two data segments, and the thirteenth result data segment is obtained by pre-processing the two portions of the thirteenth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. There are multiple thirteenth traversal data segments. The values ​​of the thirteenth traversal data segments can be set according to the scenario and requirements. The thirteenth traversal data segments can meet the range of data that may undergo XOR operations in the business system. Each thirteenth traversal data segment can be pre-processed with inverse nonlinear encoding, XOR operation, and nonlinear encoding sequentially. The resulting data segment is used as the thirteenth result data segment, and a mapping relationship between the thirteenth traversal data segments and the thirteenth result data segments is established to generate the fifth XOR mapping table. The specific content of the XOR operation can be found in the relevant descriptions in the above embodiments. The fifth XOR mapping table can be generated according to the generation method of the XOR mapping table in the above embodiments.

[0070] The data segment corresponding to the output data segment obtained from querying the fifth XOR mapping table can be found in the key lookup table ciphertext. A portion of the data segment obtained from the second obfuscation mapping table and the data segment obtained from querying the key lookup table ciphertext are used as the input data segment for the sixth XOR mapping table. The sixth XOR mapping table is a preset mapping table that can be used to perform XOR operations on data. The sixth XOR mapping table essentially hides the specific XOR operation, only storing the input and output data segments of the XOR operation with mapping relationships. It does not contain the plaintext of the original key or the plaintext of the parameters in the XOR process. The data segment corresponding to the data segment that needs to be XORed can be queried in the sixth XOR mapping table. The queried data segment is the data segment obtained by inverse nonlinear encoding, XOR operation, and nonlinear encoding of the data segment that needs to be XORed. Correspondingly, the queried data segment contains nonlinear encoding information and is non-plaintext data. In some examples, the sixth XOR mapping table includes a thirteenth traversal data segment and a thirteenth result data segment with a mapping relationship. The thirteenth traversal data segment is formed by concatenating a portion of each of the two data segments, and the thirteenth result data segment is a data segment obtained by pre-processing the two portions of the thirteenth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. The specific contents of the thirteenth traversal data segment and the thirteenth result data segment can be found in the relevant descriptions above, and will not be repeated here. The specific contents of the XOR operation can be found in the relevant descriptions in the above embodiments, and the sixth XOR mapping table can be generated according to the generation method of the XOR mapping table in the above embodiments.

[0071] The output mapping table is a pre-defined mapping table used for output encoding processing of data. The output mapping table essentially hides the specific operations of the output encoding process, only storing the mapping table of input and output data segments with mapping relationships. It does not contain the plaintext of the original key or the plaintext of parameters during the output encoding process. Data segments retrieved from the sixth XOR mapping table can be used as input data segments for queries in the output mapping table. The corresponding data segments retrieved from the output mapping table are obtained by inverse nonlinear encoding and inverse affine transformation of the data segments output from the sixth XOR mapping table. Combining these data segments yields the target ciphertext. In some examples, the output mapping table includes a fourteenth traversal data segment and a fourteenth result data segment with mapping relationships. The fourteenth result data segment is obtained by pre-processing the fourteenth traversal data segment with inverse nonlinear encoding and inverse affine transformation. The inverse nonlinear encoding cancels the nonlinear encoding in the XOR processing represented by the sixth XOR mapping table, and the inverse affine transformation cancels the affine transformation in the S-box operation hidden in the third S-box operation mapping table. There are multiple fourteenth-round traversal data segments, and their values ​​can be set according to scenarios and requirements. These fourteenth-round traversal data segments can accommodate the range of data that may undergo output encoding processing in the business system. Each fourteenth-round traversal data segment can be pre-processed with inverse nonlinear encoding and inverse affine transformation, and the resulting data segment can be used as the fourteenth-round result data segment. A mapping relationship between the fourteenth-round traversal data segments and the fourteenth-round result data segment can be established to generate an output mapping table. The target ciphertext can be obtained by querying the output mapping table and retrieving the output data segment.

[0072] It should be noted that the thirteenth traversal data segment and the thirteenth result data segment in the fifth XOR mapping table and the sixth XOR mapping table can be different, that is, the mapping relationship in the fifth XOR mapping table and the sixth XOR mapping table can be different.

[0073] For example, Figure 7 This is a schematic diagram illustrating an example of obtaining target ciphertext by reading and querying a set of encryption operation mapping tables, as provided in an embodiment of this application. Figure 7 As shown, the 128-bit plaintext data to be encrypted can be divided into four 32-bit data segments, which can be represented as X0, X1, X2, and X3. These four data segments serve as the input data segments for the third input mapping table 241. Figure 7The contents of the third input mapping table 241 represent the input encoding processing hidden within it. P0, P1, P2, and P3 represent affine transformations, and Ni represents nonlinear encoding. The aforementioned calculation process does not actually exist in the third input mapping table 241; it is only used here to illustrate the relationship between the input and output data segments. By reading and querying the third input mapping table 241, the corresponding output data segments X0'+Ni, X1'+Ni, X2'+Ni, and X3'+Ni can be obtained. These data segments X0'+Ni, X1'+Ni, X2'+Ni, and X3'+Ni are then used as the input data segments of the second confusion mapping table 242. i '+Ni、X i+1 '+Ni、X i+2 '+Ni、X i+3 '+Ni is the data segment used as input to the second obfuscation map 242 in the 32 intermediate rounds of the white-box encryption operation. Figure 7 The contents of the second obfuscation mapping table 242 represent the obfuscation operations hidden in the second obfuscation mapping table 242. Ni in the second obfuscation mapping table 242 -1 P represents inverse nonlinear encoding. i -1 P i+1 -1 P i+2 -1 P i+3 -1 P represents the inverse affine transformation. i+4 ' represents affine transformation, Ei -1 The expression represents the inverse obfuscation transformation, and Ni represents the nonlinear encoding. The above operation does not actually exist in the second obfuscation mapping table 242; it is only used here to illustrate the relationship between the input and output data segments in the second obfuscation mapping table 242. A portion of the data segment obtained by reading and querying the second obfuscation mapping table 242 can be used as the input data segment for the fifth XOR mapping table 243. The Table in the ciphertext set 244 of the key lookup table... i0 To Table i3 All represent the key lookup table ciphertext. The key lookup table ciphertext is used to search for the data segment corresponding to the output data segment obtained from the fifth XOR mapping table 243, and another portion of the data segment obtained from the second obfuscation mapping table 242 is used as the input data segment to the sixth XOR mapping table 245. The sixth XOR mapping table 245 is then searched to obtain data segment X. i+4 '+Ni. Through 32 rounds of computation in the intermediate algorithm, the data segment X can be obtained. 32 '+Ni、X 33 '+Ni、X 34 '+Ni、X 35 +Ni, data segment X32 '+Ni、X 33 '+Ni、X 34 '+Ni、X 35 +Ni can be used as the input data segment of output mapping table 246. Ni in output mapping table 246 -1 P represents inverse nonlinear encoding. 32 -1 P 33 -1 P 34 -1 P 35 -1 This represents the inverse affine transformation. The data segments obtained from querying output mapping table 246 can form the 128-bit target ciphertext X. 35 ,X 34 ,X 33 ,X 32 .

[0074] In some embodiments, the algorithms for nonlinear encoding in at least some of the different mapping tables are different, and the nonlinear encoding in the mapping tables corresponding to different rounds of operation in the intermediate algorithm rounds may also be different. Different algorithms for nonlinear encoding in different mapping tables can further increase the difficulty of cracking the white-box SM4 encryption method in this application embodiment, thereby improving data security. The core concept of the white-box SM4 decryption method is consistent with that of the white-box SM4 encryption method; the difference lies only in the order of calling the round keys. The encryption process of white-box SM4 uses the round keys in a forward order from K0' to K31', while the decryption process calls the round keys in a reverse order from K31' to K0'. Since the nonlinear encoding in the mapping tables corresponding to different rounds of operation can be set to random, the cancellation of its nonlinear encoding information has a strict sequential dependency. Only by following the order of calling the round keys can the nonlinear encoding information be eliminated layer by layer through inverse nonlinear encoding to obtain the correct encryption and decryption results. Therefore, even if an attacker tampers with the order of round key calls, invalid data will be obtained because the non-linear encoded information cannot be canceled out. This blocks the attack path of exchanging plaintext and ciphertext by tampering with the order of round keys, giving it stronger resistance to debugging attacks and further improving the security of data encryption and decryption.

[0075] This application also provides a white-box SM4 encryption device. Figure 8 This is a schematic diagram of the structure of a white-box SM4 encryption device provided in an embodiment of this application, as shown below. Figure 8 As shown, the encryption device 300 of the white box SM4 may include a receiving module 301, a first lookup module 302, a second lookup module 303, a third lookup module 304, and a fourth lookup module 305.

[0076] The receiving module 301 can be used to receive the white-box key ciphertext sent by the back-end system. The white-box key ciphertext is obtained by encrypting the original key based on the SM4 algorithm and the root key.

[0077] The first lookup module 302 can be used to obtain key ciphertext containing affine transformation information and nonlinear coding information by reading and querying a preset set of de-whiteboxing operation mapping tables based on the white-box key ciphertext.

[0078] The second lookup module 303 can be used to obtain the round key ciphertext containing nonlinear encoding information by reading and querying a preset set of key expansion operation mapping tables based on the key ciphertext.

[0079] The third lookup module 304 can be used to generate an operation mapping table set by reading and querying a preset key lookup table based on the round key ciphertext and traversal parameters, and obtain the key lookup table ciphertext containing non-linear encoding.

[0080] The fourth lookup module 305 can be used to perform white-box encryption on the plaintext data to be encrypted based on the key lookup table ciphertext and the preset encryption operation mapping table set, so as to obtain the target ciphertext.

[0081] In some embodiments, the white-box de-mapping operation mapping table set includes a first input mapping table, a first obfuscation mapping table, a first XOR mapping table, a first S-box operation mapping table, and a second XOR mapping table. The first lookup module 302 can be specifically used to: read data segments that have a mapping relationship with the white-box key ciphertext from the first input mapping table; read data segments that have a mapping relationship with the data segments obtained through the first input mapping table from the first obfuscation mapping table; among the data segments obtained through the first obfuscation mapping table, determine the data segments that need to be XORed, and read data segments that have a mapping relationship with the data segments that need to be XORed from the first XOR mapping table; read data segments that have a mapping relationship with the data segments obtained through the first XOR mapping table from the first S-box operation mapping table; among the data segments obtained through the first obfuscation mapping table, determine the data segments that need to be XORed with the data segments obtained through the first S-box operation mapping table, and read data segments that have a mapping relationship with the two data segments undergoing XOR operations from the second XOR mapping table to obtain the key ciphertext.

[0082] In some examples, the first input mapping table includes a first traversal data segment and a first result data segment with a mapping relationship. The first result data segment is a data segment obtained by pre-processing the first traversal data segment with affine transformation and nonlinear encoding. The first confusion mapping table includes a second traversal data segment and a second result data segment with a mapping relationship. The second result data segment is a data segment obtained by pre-processing the second traversal data segment with inverse nonlinear encoding, inverse affine transformation, inverse confusion transformation, and nonlinear encoding. The first XOR mapping table and the second XOR mapping table each include a third traversal data segment and a third result data segment with a mapping relationship. The third traversal data segment is formed by concatenating a portion of each of the two data segments. The third result data segment is a data segment obtained by pre-processing the two portions of the third traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. The first S-box operation mapping table includes a fourth traversal data segment and a fourth result data segment with a mapping relationship. The fourth result data segment is a data segment obtained by pre-processing the fourth traversal data with inverse nonlinear encoding, confusion transformation, S-box processing, shift processing, affine transformation, and nonlinear encoding. The S-box processing is implemented based on the root key.

[0083] In some embodiments, the key expansion operation mapping table set includes a second input mapping table, multiple third XOR mapping tables, and a second S-box operation mapping table. The second lookup module 303 can be specifically used to: read data segments that have a mapping relationship with the key ciphertext from the second input mapping table; determine the data segments that need to be XORed from the data segments obtained through the second input mapping table, and read the data segments that have a mapping relationship with the data segments that need to be XORed from the third XOR mapping table; read the data segments that have a mapping relationship with the data segments obtained through the third XOR mapping table from the second S-box operation mapping table; determine the data segments that need to be XORed from the data segments obtained through the second input mapping table and the data segments obtained through the second S-box operation mapping table, and read the data segments that have a mapping relationship with the data segments that need to be XORed from the third XOR mapping table to obtain the round key ciphertext.

[0084] In some examples, the second input mapping table includes a fifth traversal data segment and a fifth result data segment with a mapping relationship. The fifth result data segment is a data segment obtained by pre-processing the fifth traversal data segment with inverse nonlinear encoding, inverse affine transformation, system parameter processing, and nonlinear encoding. The system parameter processing is implemented based on system parameters. The third XOR mapping table includes a sixth traversal data segment and a sixth result data segment with a mapping relationship. The sixth traversal data segment is formed by concatenating a portion of each of the two data segments. The sixth result data segment is a data segment obtained by pre-processing the two portions of the sixth traversal data with inverse nonlinear encoding, XOR operation, and nonlinear encoding. The second S-box operation mapping table includes a seventh traversal data segment and a seventh result data segment with a mapping relationship. The seventh result data segment is a data segment obtained by pre-processing the seventh traversal data with inverse nonlinear encoding, S-box processing, shift processing, and nonlinear encoding. The S-box processing is implemented based on fixed parameters.

[0085] In some embodiments, the key lookup table generation operation mapping table set includes a traversal parameter processing mapping table, a fourth XOR mapping table, and a third S-box operation mapping table. The third lookup module 304 can be specifically used to: read data segments in the traversal parameter processing mapping table that have a mapping relationship with the traversal parameters; read data segments in the fourth XOR mapping table that have a mapping relationship with the round key ciphertext and the data segments obtained by querying the traversal parameter processing mapping table; and read data segments in the third S-box operation mapping table that have a mapping relationship with the data segments obtained by querying the fourth XOR mapping table, to obtain the key lookup table ciphertext.

[0086] In some examples, the traversal parameter processing mapping table includes an eighth traversal data segment and an eighth result data segment with a mapping relationship. The eighth result data segment is a data segment obtained by pre-processing the eighth traversal data segment with matrix obfuscation and non-linear encoding. The fourth XOR mapping table includes a ninth traversal data segment and a ninth result data segment with a mapping relationship. The ninth traversal data segment is formed by splicing a part of each of the two data segments. The ninth result data segment is a data segment obtained by pre-processing the two parts of the ninth traversal data with inverse non-linear encoding, XOR operation, and non-linear encoding. The third S-box operation mapping table includes a tenth traversal data segment and a tenth result data segment with a mapping relationship. The tenth result data segment is a data segment obtained by pre-processing the tenth traversal data segment with inverse non-linear encoding, S-box processing, matrix processing, constant processing, XOR operation, and non-linear encoding.

[0087] In some embodiments, the encryption operation mapping table set includes a third input mapping table, a second obfuscation mapping table, a fifth XOR mapping table, a sixth XOR mapping table, and an output mapping table. The fourth lookup module 305 can be specifically used to: read data segments that have a mapping relationship with the plaintext data to be encrypted from the third input mapping table; read data segments that have a mapping relationship with the data segments obtained through the third input mapping table from the second obfuscation mapping table; determine the data segments that need to be XORed from the data segments obtained through the second obfuscation mapping table, and read the data segments that have a mapping relationship with the data segments that need to be XORed from the fifth XOR mapping table; query the ciphertext in the key lookup table for data segments corresponding to the data segments obtained through the fifth XOR mapping table; determine the data segments that need to be XORed with the data segments obtained through the key lookup table from the second obfuscation mapping table, and read the data segments that have a mapping relationship with the two data segments undergoing XOR operations from the sixth XOR mapping table; and read the data segments that have a mapping relationship with the data segments obtained through the sixth XOR mapping table from the output mapping table to obtain the target ciphertext.

[0088] In some examples, the third input mapping table includes an eleventh traversal data segment and an eleventh result data segment with a mapping relationship. The eleventh result data segment is a data segment obtained by performing affine transformation and nonlinear encoding on the eleventh traversal data segment in advance. The second scrambling mapping table includes a twelfth traversal data segment and a twelfth result data segment with a mapping relationship. The twelfth result data segment is a data segment obtained by performing inverse nonlinear encoding, inverse affine transformation, inverse scrambling transformation, and nonlinear encoding on the twelfth traversal data segment in advance. The fifth XOR mapping table and the sixth XOR mapping table each include a thirteenth traversal data segment and a thirteenth result data segment with a mapping relationship. The thirteenth traversal data segment is formed by concatenating a portion of each of the two data segments. The thirteenth result data segment is a data segment obtained by performing inverse nonlinear encoding, XOR operation, and nonlinear encoding on the two portions of the thirteenth traversal data segment in advance. The output mapping table includes a fourteenth traversal data segment and a fourteenth result data segment with a mapping relationship. The fourteenth result data segment is a data segment obtained by performing inverse nonlinear encoding and inverse affine transformation on the fourteenth traversal data segment in advance.

[0089] In some embodiments, the algorithms for nonlinear encoding in at least some of the different mapping tables are different.

[0090] It should be noted that the encryption device 300 of the white-box SM4 is a device corresponding to the encryption method of the white-box SM4 described above. All implementation methods in the above method embodiments are applicable to the embodiments of this device and can achieve the same technical effect.

[0091] A third aspect of this application also provides a white-box SM4 encryption device.Figure 9 This is a schematic diagram of the structure of a white-box SM4 encryption device provided in an embodiment of this application, as shown below. Figure 9 As shown, the encryption device 400 of the white box SM4 includes a memory 401, a processor 402, and a computer program stored on the memory 401 and capable of running on the processor 402.

[0092] In some examples, the processor 402 described above may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits that may be configured to implement the embodiments of this application.

[0093] Memory 401 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the encryption method of white-box SM4 according to embodiments of this application.

[0094] The processor 402 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 401, so as to implement the encryption method of the white box SM4 in the above embodiment.

[0095] In some examples, the encryption device 400 of the white-box SM4 may also include a communication interface 403 and a bus 404. For example, Figure 9 As shown, the memory 401, processor 402, and communication interface 403 are connected through bus 404 and complete communication with each other.

[0096] The communication interface 403 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application. Input devices and / or output devices can also be connected through the communication interface 403.

[0097] Bus 404 includes hardware, software, or both, that couples the components of the encryption device 400 of the white-box SM4 together. For example, and not limited to, bus 404 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-E) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, bus 404 may include one or more buses. Although specific buses are described and illustrated in the embodiments of this application, this application considers any suitable bus or interconnection.

[0098] This application also provides a white-box SM4 encryption system, which includes a backend system and the white-box SM4 encryption device described in the above embodiments. The backend system is communicatively connected to the white-box SM4 encryption device and is configured to encrypt the original key based on the SM4 algorithm and the root key to obtain the white-box key ciphertext, and then send it to the white-box SM4 encryption device.

[0099] This application also provides a computer-readable storage medium storing computer program instructions. When executed by a processor, these computer program instructions can implement the white-box SM4 encryption method described in the above embodiments and achieve the same technical effect. To avoid repetition, further details are omitted here. The aforementioned computer-readable storage medium may include non-transitory computer-readable storage media, such as read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, etc., and is not limited thereto.

[0100] This application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the white-box SM4 encryption method in the above embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0101] It should be clarified that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. For the device embodiments, equipment embodiments, system embodiments, computer-readable storage medium embodiments, and computer program product embodiments, the relevant parts can be referred to the description section of the method embodiments. This application is not limited to the specific steps and structures described above and shown in the figures. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application. Furthermore, for the sake of brevity, detailed descriptions of known methods and techniques are omitted here.

[0102] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0103] Those skilled in the art will understand that the above embodiments are exemplary and not restrictive. Different technical features appearing in different embodiments can be combined to achieve beneficial effects. Based on a study of the drawings, specification, and claims, those skilled in the art should be able to understand and implement other variations of the disclosed embodiments. In the claims, the term "comprising" does not exclude other means or steps; the quantifier "a" does not exclude a plurality; the terms "first" and "second" are used to identify names and not to indicate any particular order. Any reference numerals in the claims should not be construed as limiting the scope of protection. The functionality of multiple parts appearing in the claims can be implemented by a single hardware or software module. The appearance of certain technical features in different dependent claims does not mean that these technical features cannot be combined to achieve beneficial effects.

Claims

1. A method of encryption of white-box SM4, characterized in that, The method comprises the following steps: receiving a white-box key ciphertext sent by a background system, the white-box key ciphertext being obtained by encrypting an original key based on an SM4 algorithm and a root key; according to the white-box key ciphertext, reading a preset de-whitening operation mapping table set to obtain a key ciphertext containing affine transformation information and nonlinear encoding information; according to the key ciphertext, reading a preset key expansion operation mapping table set to obtain a round key ciphertext containing nonlinear encoding information; according to the round key ciphertext and a traversal parameter, reading a preset key lookup table generation operation mapping table set to obtain a key lookup table ciphertext containing nonlinear encoding; based on the key lookup table ciphertext and a preset encryption operation mapping table set, performing white-box encryption on to-be-encrypted plaintext data to obtain a target ciphertext.

2. The method of claim 1, wherein, The de-whitening operation mapping table set comprises a first input mapping table, a first confusion mapping table, a first XOR mapping table, a first S-box operation mapping table and a second XOR mapping table; According to the white-box key ciphertext, reading a preset de-whitening operation mapping table set to obtain a key ciphertext containing affine transformation information and nonlinear encoding information, comprising: reading a data segment having a mapping relationship with the white-box key ciphertext in the first input mapping table; reading a data segment having a mapping relationship with the data segment obtained by reading in the first input mapping table in the first confusion mapping table; in the data segment obtained by reading in the first confusion mapping table, determining a data segment that needs to be subjected to an XOR operation, and reading a data segment having a mapping relationship with the data segment that needs to be subjected to an XOR operation in the first XOR mapping table; reading a data segment having a mapping relationship with the data segment obtained by reading in the first XOR mapping table in the first S-box operation mapping table; in the data segment obtained by reading in the first confusion mapping table, determining a data segment that needs to be subjected to an XOR operation with the data segment obtained by reading in the first S-box operation mapping table, and reading a data segment having a mapping relationship with the two data segments subjected to an XOR operation in the second XOR mapping table to obtain the key ciphertext.

3. The method of claim 2, wherein: the first input mapping table comprises first traversal data and first result data having a mapping relationship, the first result data being a data segment obtained by pre- performing affine transformation and nonlinear encoding on the first traversal data; the first confusion mapping table comprises second traversal data and second result data having a mapping relationship, the second result data being a data segment obtained by pre-performing inverse nonlinear encoding, inverse affine transformation, inverse confusion transformation and nonlinear encoding on the second traversal data; the first XOR mapping table and the second XOR mapping table each comprise third traversal data and third result data having a mapping relationship, the third traversal data being a part of two data segments spliced together, and the third result data being a data segment obtained by pre-performing inverse nonlinear encoding, XOR operation and nonlinear encoding on the two parts in the third traversal data; The first S-box operation mapping table includes a fourth traversal data segment and a fourth result data segment having a mapping relationship, the fourth result data segment is a data segment obtained by performing inverse nonlinear encoding, confusion transformation, S-box processing, shift processing, affine transformation and nonlinear encoding on the fourth traversal data in advance, and the S-box processing is based on the root key.

4. The method of claim 1, wherein, The key expansion operation mapping table set includes a second input mapping table, a plurality of third XOR mapping tables and a second S-box operation mapping table; The round key ciphertext containing nonlinear encoding information is obtained by reading and querying the preset key expansion operation mapping table set according to the key ciphertext, and includes: In the second input mapping table, a data segment having a mapping relationship with the key ciphertext is read and queried; In the data segment obtained by querying the second input mapping table, a data segment requiring XOR operation is determined, and a data segment having a mapping relationship with the data segment requiring XOR operation is read and queried in the third XOR mapping table; In the second S-box operation mapping table, a data segment having a mapping relationship with the data segment obtained by querying the third XOR mapping table is read and queried; In the data segment obtained by querying the second input mapping table and the data segment obtained by querying the second S-box operation mapping table, a data segment requiring XOR operation is determined, and a data segment having a mapping relationship with the data segment requiring XOR operation is read and queried in the third XOR mapping table, so as to obtain the round key ciphertext.

5. The method of claim 4, wherein: The second input mapping table includes a fifth traversal data segment and a fifth result data segment having a mapping relationship, the fifth result data segment is a data segment obtained by performing inverse nonlinear encoding, inverse affine transformation, system parameter processing and nonlinear encoding on the fifth traversal data segment in advance, and the system parameter processing is based on system parameters; The third XOR mapping table includes a sixth traversal data segment and a sixth result data segment having a mapping relationship, the sixth traversal data segment is a part of each of two data segments spliced together, and the sixth result data segment is a data segment obtained by performing inverse nonlinear encoding, XOR operation and nonlinear encoding on the two parts of the sixth traversal data in advance; The second S-box operation mapping table includes a seventh traversal data segment and a seventh result data segment having a mapping relationship, the seventh result data segment is a data segment obtained by performing inverse nonlinear encoding, S-box processing, shift processing and nonlinear encoding on the seventh traversal data in advance, and the S-box processing is based on fixed parameters.

6. The method of claim 1, wherein, The key lookup table generation operation mapping table set includes a traversal parameter processing mapping table, a fourth XOR mapping table and a third S-box operation mapping table; The key lookup table ciphertext containing nonlinear encoding is obtained by reading and querying the preset key lookup table generation operation mapping table set according to the round key ciphertext and the traversal parameter, and includes: In the traversal parameter processing mapping table, a data segment having a mapping relationship with the traversal parameter is read and queried; reading, in the fourth exclusive OR mapping table, a data segment that has a mapping relationship with the round key ciphertext and the data segment obtained by processing the mapping table query through the traversal parameter; reading, in the third S-box operation mapping table, a data segment that has a mapping relationship with the data segment obtained by querying the fourth exclusive OR mapping table, to obtain the key lookup table ciphertext.

7. The method of claim 6, wherein, the traversal parameter processing mapping table comprises an eighth traversal data segment and an eighth result data segment that have a mapping relationship, the eighth result data segment being a data segment obtained by previously performing matrix confusion processing and nonlinear encoding on the eighth traversal data segment; the fourth exclusive OR mapping table comprises a ninth traversal data segment and a ninth result data segment that have a mapping relationship, the ninth traversal data segment being a data segment obtained by splicing a part of each of two data segments, and the ninth result data segment being a data segment obtained by previously performing inverse nonlinear encoding, exclusive OR operation, and nonlinear encoding on the two parts in the ninth traversal data; the third S-box operation mapping table comprises a tenth traversal data segment and a tenth result data segment that have a mapping relationship, the tenth result data segment being a data segment obtained by previously performing inverse nonlinear encoding, S-box processing, matrix processing, constant processing, exclusive OR operation, and nonlinear encoding on the tenth traversal data segment.

8. The method of claim 1, wherein, the encryption operation mapping table set comprises a third input mapping table, a second confusion mapping table, a fifth exclusive OR mapping table, a sixth exclusive OR mapping table, and an output mapping table; the white-box encryption of the plaintext data based on the key lookup table ciphertext and the preset encryption operation mapping table set to obtain the target ciphertext comprises: reading, in the third input mapping table, a data segment that has a mapping relationship with the plaintext data to be encrypted; reading, in the second confusion mapping table, a data segment that has a mapping relationship with the data segment obtained by querying the third input mapping table; determining, in the data segment obtained by querying the second confusion mapping table, a data segment that needs to be subjected to exclusive OR operation, reading, in the fifth exclusive OR mapping table, a data segment that has a mapping relationship with the data segment that needs to be subjected to exclusive OR operation; querying, in the key lookup table ciphertext, a data segment corresponding to the data segment obtained by querying the fifth exclusive OR mapping table; determining, in the data segment obtained by querying the second confusion mapping table, a data segment that needs to be subjected to exclusive OR operation with the data segment obtained by querying the key lookup table ciphertext, reading, in the sixth exclusive OR mapping table, a data segment that has a mapping relationship with the two data segments that need to be subjected to exclusive OR operation; reading, in the output mapping table, a data segment that has a mapping relationship with the data segment obtained by querying the sixth exclusive OR mapping table, to obtain the target ciphertext.

9. The method of claim 8, wherein, the third input mapping table comprises an eleventh traversal data segment and an eleventh result data segment that have a mapping relationship, the eleventh result data segment being a data segment obtained by previously performing affine transformation and nonlinear encoding on the eleventh traversal data segment. The second confusion mapping table includes a twelfth traversal data segment and a twelfth result data segment having a mapping relationship, and the twelfth result data segment is a data segment obtained by performing inverse nonlinear encoding, inverse affine transformation, inverse confusion transformation and nonlinear encoding on the twelfth traversal data segment in advance; The fifth and sixth exclusive or mapping tables each include a thirteenth traversal data segment and a thirteenth result data segment having a mapping relationship, the thirteenth traversal data segment is obtained by splicing a part of each of two data segments, and the thirteenth result data segment is a data segment obtained by performing inverse nonlinear encoding, exclusive or operation and nonlinear encoding on the two parts in the thirteenth traversal data in advance; The output mapping table includes a fourteenth traversal data segment and a fourteenth result data segment having a mapping relationship, and the fourteenth result data segment is a data segment obtained by performing inverse nonlinear encoding and inverse affine transformation on the fourteenth traversal data segment in advance.

10. The method according to any one of claims 1 to 9, characterized in that, The algorithms of the nonlinear encodings in the at least partially different mapping tables are different.

11. An encryption apparatus of a white-box SM4, characterized in that, Comprise: The receiving module is used for receiving the white-box key ciphertext sent by the background system, wherein the white-box key ciphertext is obtained by encrypting the original key based on the SM4 algorithm and the root key; The first lookup table module is used for obtaining the key ciphertext containing affine transformation information and nonlinear encoding information by reading and querying the preset de-whitening operation mapping table set according to the white-box key ciphertext; The second lookup table module is used for obtaining the round key ciphertext containing nonlinear encoding information by reading and querying the preset key expansion operation mapping table set according to the key ciphertext; The third lookup table module is used for obtaining the key lookup table ciphertext containing nonlinear encoding by reading and querying the preset key lookup table generation operation mapping table set according to the round key ciphertext and the traversal parameter; The fourth lookup table module is used for white-box encrypting the plaintext data to be encrypted based on the key lookup table ciphertext and the preset encryption operation mapping table set to obtain the target ciphertext.

12. A white-box SM4 encryption device, comprising: Comprise: A processor and a memory storing computer program instructions; The processor executes the computer program instructions to realize the encryption method of the white-box SM4 according to any one of claims 1 to 10.

13. A system for encryption of white-box SM4, characterized in that, Comprise: A background system configured to encrypt the original key based on the SM4 algorithm and the root key to obtain the white-box key ciphertext, and send the white-box key ciphertext to the white-box SM4 encryption device of claim 12; The white-box SM4 encryption device of claim 12.

14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by the processor to realize the encryption method of the white-box SM4 according to any one of claims 1 to 10.

15. A computer program product, characterised in that, The computer program is executed by the processor to realize the encryption method of the white-box SM4 according to any one of claims 1 to 10.