Data processing method, device and electronic equipment
By computing the coordinate point values on the elliptic curve in parallel in the SM2 algorithm to generate a key result, the problem of low computational efficiency of the KDF algorithm in the SM2 algorithm is solved and the data processing efficiency is improved.
Patent Information
- Application Number
- CN202311865436.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2043-12-29
AI Technical Summary
The loop operation of the KDF algorithm in the SM2 algorithm results in low computing efficiency, which in turn makes data encryption and decryption efficiency low.
By obtaining the coordinate point value on the elliptic curve, the universal iteration value is calculated, and the operation is performed in multiple processing modules in parallel to generate the key result, thereby improving the accuracy and efficiency of the key result.
It improves the computing efficiency of the KDF algorithm in the SM2 encryption and decryption algorithm, improves the data processing efficiency, and solves the problem of low data encryption and decryption efficiency.
Smart Images

Figure CN117811737B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data security technology, and in particular to a data processing method, device and electronic device. Background Art
[0002] With the development of informatization and computer technology, network security issues have become a common challenge faced by mankind in the information age. The SM2 elliptic curve public key cryptography algorithm (or SM2 algorithm) is a common public key cryptography algorithm. In cloud computing, network data transmission and other scenarios, data processing equipment can encrypt and decrypt data through the SM2 algorithm, thereby improving the security of data transmission. Among them, the SM2 algorithm includes a key derivation function (KDF) (or KDF algorithm). During the execution of the KDF algorithm used by the SM2 algorithm, the following loop operations need to be implemented through counter control: determine the iteration value, and perform operations based on the parameters corresponding to the iteration value and the counter. Obviously, the computational efficiency under the loop operation in the KDF algorithm is low, which leads to low efficiency in encrypting and decrypting data through the SM2 algorithm. Summary of the invention
[0003] The present application provides a data processing method, device and electronic device for improving the operational efficiency of the KDF algorithm in the SM2 encryption and decryption algorithm, thereby improving data processing efficiency.
[0004] In the first aspect, the present application provides a data processing method, which includes: a first device obtains the horizontal coordinate value and the vertical coordinate value of any coordinate point on an elliptic curve; the first device includes p processing modules; p is greater than or equal to 2 and p is a positive integer; the first device determines a universal iteration value based on the horizontal coordinate value and the vertical coordinate value, and inputs the universal iteration value into the p processing modules; the first device generates a parameter set, and inputs the p first parameters contained in the parameter set into the p processing modules; the first device calls p processing modules, and performs the following steps in each processing module: operates on the input first parameter and the universal iteration value, and outputs a first sub-result; wherein the p processing modules perform operations in parallel and each processing module performs different operations; the first device determines the key result corresponding to the elliptic curve based on the p first sub-results; the first device can also encrypt the first plaintext data according to the key result to obtain the first ciphertext data; or, the first device can also decrypt the second ciphertext data according to the key result to obtain the second plaintext data.
[0005] Based on the above method, the first device can first calculate the general iteration value, and then perform parallel operations based on the general iteration value and different parameters in the parameter set to obtain multiple first sub-results, thereby determining the key result; there is no need to repeatedly determine the general iteration value, and multiple first sub-results can be obtained through parallel operations, thereby improving the operational efficiency of the KDF algorithm in the SM2 encryption and decryption algorithm, thereby improving data processing efficiency, thereby solving the problem of low efficiency in encrypting and decrypting data using the SM2 algorithm.
[0006] In a possible design, the parameter set further includes q second parameters, q is less than or equal to p and q is a positive integer; the process of determining the key result includes: the first device inputs the q second parameters into q processing modules; the first device calls the q processing modules and performs the following steps in each processing module: operates on the input second parameters and the universal iteration value, and outputs a second sub-result; wherein the q processing modules operate in parallel and each processing module performs a different operation; the first device determines the key result according to The key result is determined by using q first sub-results and q second sub-results output by q processing modules; m is the number of parameters included in the parameter set.
[0007] With this design, the first device can determine the key result by combining the second parallel results corresponding to the q second parameters, thereby improving the accuracy of the key result.
[0008] In one possible design, the process of determining the key result in the aforementioned design includes: the first device obtains a preset key length; the first device concatenates p first sub-results and q second sub-results to obtain a temporary key; the first device intercepts the leftmost part of the bit value of the temporary key according to the preset key length to obtain the key result; the length of the key result is the preset key length.
[0009] With this design, the first device can determine that the length of the key result is a preset key length, thereby making encryption and decryption operations more efficient.
[0010] In one possible design, the length of the concatenated horizontal and vertical coordinate values is 512 bits.
[0011] In one possible design, the first device can also receive single instruction multiple data (SIMD) instructions; the SIMD instructions are used to instruct p processing modules to perform operations in parallel; and / or, the first device can also schedule the p processing modules to p parallel execution threads for processing; and / or, the first device can also perform parallel operations on the p processing modules through a graphics processor (GPU).
[0012] With this design, the first device can implement parallel computing in a variety of different ways, thereby improving flexibility.
[0013] In a second aspect, the present application further provides a data processing device, which includes a communication module and a processing module, wherein the communication module is used to receive and send data, and the processing module is used to execute the method shown in the first aspect.
[0014] In a possible example, the communication module is specifically used to: obtain the horizontal coordinate value and the vertical coordinate value of any coordinate point on the elliptic curve; the data processing device includes p processing modules; p is greater than or equal to 2 and p is a positive integer; the processing module is specifically used to: determine the universal iteration value according to the horizontal coordinate value and the vertical coordinate value, and input the universal iteration value into the p processing modules; the processing module is also used to: generate a parameter set, and input the p first parameters contained in the parameter set into the p processing modules; the processing module is also used to: call p processing modules, and perform the following steps in each of the processing modules: operate on the input first parameter and the universal iteration value, and output a first sub-result; wherein the p processing modules operate in parallel and each processing module performs different operations; the processing module is also used to: determine the key result corresponding to the elliptic curve according to the p first sub-results; the processing module is also used to: encrypt the first plaintext data according to the key result to obtain the first ciphertext data; or, decrypt the second ciphertext data according to the key result to obtain the second plaintext data.
[0015] In a possible design, the parameter set further includes q second parameters, q is less than or equal to p and q is a positive integer; the processing module is specifically used to: input the q second parameters into the q processing modules; call the q processing modules, and perform the following steps in each of the processing modules: operate on the input second parameters and the universal iteration value, and output a second sub-result; wherein the q processing modules operate in parallel and each processing module performs a different operation; according to The key result is determined by using q first sub-results and q second sub-results output by q processing modules; m is the number of parameters included in the parameter set.
[0016] In one possible design, the processing module is specifically used to: obtain a preset key length through the communication module; concatenate p first sub-results and q second sub-results to obtain a temporary key; according to the preset key length, intercept the leftmost part of the bit value of the temporary key to obtain a key result; the length of the key result is the preset key length.
[0017] In one possible design, the length of the concatenated horizontal and vertical coordinate values is 512 bits.
[0018] In one possible design, the processing module is also used to: receive single instruction multiple data (SIMD) instructions through the communication module; the SIMD instructions are used to instruct p processing modules to perform operations in parallel; and / or, schedule the p processing modules to p parallel execution threads for processing; and / or, perform parallel operations on the p processing modules through a graphics processor (GPU).
[0019] In a third aspect, the present application further provides an electronic device comprising a processor and a memory, wherein the processor is used to implement the steps of the data processing method as described in the first aspect above and any possible design thereof when executing a computer program stored in the memory.
[0020] In a fourth aspect, the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the data processing method as described in the first aspect and any possible design thereof.
[0021] In a fifth aspect, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the data processing method as described in the first aspect and any possible design thereof.
[0022] In addition, the technical effects brought about by the second to fifth aspects can be found in the description of the first aspect above and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0024] Figure 1 A schematic diagram of a data encryption method provided in an embodiment of the present application;
[0025] Figure 2 A flowchart of a data decryption method provided in an embodiment of the present application;
[0026] Figure 3 A flowchart of a data processing method provided in an embodiment of the present application;
[0027] Figure 4a An example diagram of a data processing flow provided in an embodiment of the present application;
[0028] Figure 4b Another example diagram of a data processing flow provided in an embodiment of the present application;
[0029] Figure 4c Another example diagram of a data processing flow provided in an embodiment of the present application;
[0030] Figure 4d Another example diagram of a data processing flow provided in an embodiment of the present application;
[0031] Figure 5a An example diagram of parallel processing provided in an embodiment of the present application;
[0032] Figure 5b Another example diagram of parallel processing provided in an embodiment of the present application;
[0033] Figure 6 A schematic diagram of a modular structure of a data processing device provided in an embodiment of the present application;
[0034] Figure 7 A schematic diagram of the structure of another data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solutions and advantages of this application clearer, this application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. The acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of national laws and regulations.
[0036] The following are some explanations of the symbols designed in this application:
[0037] (1) “||” indicates character concatenation. For example, “A||B” means concatenating “A” and “B”; assuming A = “123” and B = “456”, then A||B = “123456”.
[0038] (2) Indicates that C is rounded up. For example, Indicates 8; Means 3.
[0039] (3) Indicates that D is rounded down. For example, Indicates 7; Means 2.
[0040] In the embodiments of the present application, the number of nouns, unless otherwise specified, means "singular noun or plural noun", that is, "one or more". "At least one" means one or more, and "plural" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. For example, A / B means: A or B. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c means: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0041] The ordinal numbers such as "first" and "second" mentioned in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the size, content, order, timing, application scenario, priority or importance of the multiple objects. For example, the first cell and the second cell can be the same cell or different cells, and such a name does not indicate the difference in priority, application scenario or importance of the two cells.
[0042] In the embodiments of the present application, "when...", "under the circumstances...", and "if...", "then" may represent the same meaning and may be replaced with each other.
[0043] The embodiment of the present application provides a possible data processing architecture, which includes a KDF computing device (or computing device), an encryption device, and a decryption device. Among them, the encryption device and the decryption device can be the same device in some scenarios. It should be understood that in a data processing architecture, the computing device, the encryption device, and the decryption device can be integrated into the same device, which is not limited in this application.
[0044] In order to improve the operational efficiency of the KDF algorithm and thus improve the data processing efficiency, the embodiment of the present application provides a data processing method, which is applied to a first device. The data processing method in the present application can be applied in the aforementioned data processing architecture, wherein the first device can be a computing device in the aforementioned data processing architecture.
[0045] In combination with the aforementioned data processing architecture, taking the SM2 encryption algorithm as an example, the present application embodiment provides a data processing method, which is applied to an encryption device, and the method is used to encrypt plaintext data to be encrypted. Figure 1 As shown, the method specifically comprises the following steps:
[0046] Step A1: The encryption device generates a random number k through a random number generator, where k is an integer between 1 and n-1, and n is the order of the base point G. The value of n can refer to GB / T 32918.5-2017 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 5: Parameter Definition", which is not elaborated in this application.
[0047] Step A2: The encryption device calculates the coordinates of the elliptic curve point C1: C1 = [k] G = (x1, y1). The encryption device can also refer to the methods given in 4.2.9 and 4.2.5 of GB / T 32918.1-2016 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 1: General Principles" to convert the data type of C1 into a bit string.
[0048] Step A3: Assume that the user corresponding to the decryption device (or receiver, decryptor) is user B, and the public key of user B is P B , the encryption device calculates the value of the elliptic curve point S based on the public key of the user B: S = [h]P B If S is a point at infinity, an error is reported and the program exits; otherwise, the program continues to execute step A4; where h is the cofactor. The value of h can be found in GB / T 32918.5-2017 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 5: Parameter Definition", which is not described in detail in this application.
[0049] Step A4: The encryption device calculates the elliptic curve point [k]P B Value: [k]P B =(x2, y2). The encryption device may also refer to the methods given in 4.2.6 and 4.2.5 of GB / T 32918.1-2016 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 1: General Principles" to convert the data types of coordinates x2 and y2 into bit strings.
[0050] Step A5: The encryption device calls the computing device to calculate the value of the key stream t: t = KDF(x2||y2, klen); where klen represents the bit length of the plaintext data to be encrypted. If t is a string of all 0 bits, the encryption device returns to step A1; otherwise, the encryption device continues to execute step A6. The KDF function is a key derivation function. The calculation process of the KDF function can refer to the method given in Section 5.4.3 of GB / T 32918.4-2016 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 4: Public Key Cryptography Algorithm".
[0051] The processing actions of the computing device will be described in detail later in the text and will not be repeated here.
[0052] Step A6: The encryption device calculates the bit string C2 according to the plaintext data M to be encrypted: C2 = M⊕t.
[0053] Step A7: The encryption device calculates the bit string C3: C3 = SM3 (x2||M||y2).
[0054] Step A8: The encryption device confirms and outputs the ciphertext C: C=C1||C3||C2, wherein the ciphertext C is the ciphertext corresponding to the plaintext data M mentioned above.
[0055] In combination with the aforementioned data processing architecture, taking the SM2 decryption algorithm as an example, the present application embodiment provides a data processing method, which is applied to a decryption device, and the method is used to decrypt the ciphertext data to be decrypted. Figure 2 As shown, the method specifically comprises the following steps:
[0056] Step B1: The decryption device determines the bit string C1 according to the ciphertext C. Referring to the methods given in 4.2.4 and 4.2.10 of GB / T 32918.1-2016 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 1: General Principles", the decryption device converts the data type of C1 into a coordinate point on the elliptic curve. The decryption device verifies whether C1 satisfies the elliptic curve equation; if not, the decryption device reports an error and exits; otherwise, the decryption device continues to execute step B2.
[0057] Step B2: The decryption device calculates the value of the elliptic curve point S: S = [h] C1. If S is a point at infinity, the decryption device reports an error and exits; otherwise, the decryption device continues to execute step B3.
[0058] Step B3: Assume that the user corresponding to the decryption device is user B, and user B’s private key is d B , the decryption device calculates [d B ]C1 value: [d B ]C1=(x2, y2). The decryption device can also refer to the methods given in 4.2.6 and 4.2.5 of GB / T32918.1-2016 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 1: General Principles" to convert the data types of coordinates x2 and y2 into bit strings.
[0059] Among them, user B’s public key P B and private key d B Corresponding.
[0060] Step B4: The decryption device calls the calculation device to calculate the value of the key stream t: t = KDF (x2||y2, klen). If t is a string of all 0 bits, the decryption device reports an error and exits; otherwise, the decryption device continues to execute step B5.
[0061] The processing actions of the computing device will be described in detail later in the text and will not be repeated here.
[0062] Step B5: The decryption device determines the bit string C2 according to the ciphertext C. The decryption device calculates the decrypted plaintext data M': M'=C2⊕t.
[0063] Step B6: The decryption device calculates the value of u: u=SM3(x2||M'||y2). The decryption device can also determine the bit string C3 based on the ciphertext C. The decryption device verifies whether the value of u is the same as the value of C3; if u≠C3, the decryption device reports an error and exits; otherwise, the decryption device continues to execute step B7.
[0064] Step B7: The decryption device outputs the decrypted plaintext data M'.
[0065] In combination with the aforementioned data processing architecture, an embodiment of the present application provides a data processing method for executing a KDF algorithm in an encryption operation or a decryption operation, thereby improving the calculation rate of the encryption operation or the decryption operation.
[0066] The data processing method provided in the embodiment of the present application is described below in conjunction with the accompanying drawings. Figure 3 A data processing method provided in an embodiment of the present application is applied to a first device (for example, a computing device), and the method may include the following steps:
[0067] S301: The first device obtains the horizontal coordinate value and the vertical coordinate value of any coordinate point on the elliptic curve; the first device includes p processing modules; p is greater than or equal to 2 and p is a positive integer.
[0068] It is worth mentioning that, in actual application, when p=1, this solution can still be executed, that is, when the first device includes only one processing module, data processing can be achieved by cyclically executing the steps in this method.
[0069] Optionally, the length of the bit message block Z obtained by concatenating the horizontal axis value and the vertical axis value is 512 bits.
[0070] For example, x2 in the aforementioned step A5 and step B4 is the horizontal coordinate value, and y2 in the aforementioned step A5 and step B4 is the vertical coordinate value. The length of the bit data string x2||y2 is 512 bits.
[0071] S302: The first device determines a common iteration value according to the abscissa value and the ordinate value, and inputs the common iteration value into p processing modules.
[0072] Optionally, assume that the common iteration value is denoted by V (1) ; The first device can be based on the first preset value V (0), the horizontal coordinate value and the vertical coordinate value, determine the general iteration value V (1) .
[0073] For example, the first device expands the 512-bit bit message block Z to obtain 68 32-bit words, and the expanded bit word set is recorded as E(Z)=(W0, W1, ..., W 67 ), see Section 5.3.2 of GB / T32905-2016; the first device obtains the first preset value V (0) , V (0) The 256-bit initial value "7380166F4914B2B9172442D7DA8A0600A96F30BC163138AAE38DEE4DB0FB0E4E" (in hexadecimal) defined in Section 4.1 of GB / T32905-2016 is obtained by performing 64 rounds of iterative compression to obtain a universal iterative value, which is recorded as V (1) =F(V (0) , (W0, W1, …, W 67 )), see Section 5.3.3 of GB / T32905-2016; i.e. V (1) =F(V (0) , E(Z))=CF(V (0) , Z). Among them, CF function is the compression function described in Section 5.3.1 of GB / T 32905-2016 "Information Security Technology SM3 Cryptographic Hash Algorithm", V (1) It is the output value of the CF function.
[0074] S303: The first device generates a parameter set, and inputs p first parameters included in the parameter set into p processing modules.
[0075] Optionally, the first device calls a counter, and the counter generates m positive integers (1 to m); the first device concatenates each of the m positive integers with the second preset value pad to determine m parameters, thereby generating a parameter set, wherein pad = 0x80||0x00||blen.
[0076] Optionally, assuming that the bit length value output by the SM3 hash algorithm is represented by hlen, the first device may determine the value of m according to the preset key lengths klen and hlen, for example,
[0077] Among them, the first device can determine hlen by referring to the bit length of the SM3 hash algorithm output in Section 5.4.3 of GB / T 32918.4-2016 "Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 4: Public Key Encryption Algorithm", for example, hlen is 512.
[0078] For example, the first device takes m 64-byte parameters (byte strings): Y i =ct i ||0x80||0x00 (51) ||blen, i=1, 2, ..., m; where the 64-byte byte string Y1= 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00
[0082] 00 00 00 00 00 00 00 80 00 00 00 00 00 00 02 20.
[0083] The first device generates a parameter set based on the m parameters determined above. i Indicates that i is represented as a 4-byte byte string in big endian. For example, when i is 1, the byte string ct i The hexadecimal representation is "00000001"; 0x80 represents a specific value of 1 byte; 0x00 (51) Indicates a byte string of 51 bytes with all 0x00. blen indicates an 8-byte byte string with a specific value, and its hexadecimal representation is "0000000000000220".
[0084] Further, the first device inputs the p first parameters included in the parameter set into p processing modules, that is, stores (Y1, Y2, ..., Y p ) in order to save some computing resources for the next round of calculations.
[0085] S304: The first device calls p processing modules, and executes the following steps in each processing module: operates on the input first parameter and the common iteration value, and outputs a first sub-result; wherein the p processing modules operate in parallel and each processing module performs different operations.
[0086] Here, p is also called a parallel index, and the maximum number of times the first device can execute operations (eg, CF functions) in parallel is p.
[0087] S305: The first device determines the key result corresponding to the elliptic curve according to the p first sub-results.
[0088] It should be understood that when p is greater than or equal to m, operations corresponding to the m parameters in the parameter set can be completed in one round of parallel processing, that is, the p first sub-results include the first sub-results corresponding to the m parameters respectively.
[0089] Optionally, the process of the first device obtaining the key result in step S305 may include: the first device obtains a preset key length; the first device concatenates p first sub-results to obtain a temporary key; the first device intercepts the leftmost bit value of the temporary key according to the preset key length to obtain the key result; the length of the key result is the preset key length. The preset key length is represented by klen, for example, the value is less than (2 32 -1)hlen (where hlen=256 bits represents the hash value length of SM3).
[0090] For example, the first device sends m first sub-results V (2) 1. V (2) 2. ……, V (2) m Splice together to get the temporary key: K'=V (2) 1||V (2) 2||…||V (2) m ; The first device intercepts the leftmost klen bits of K' as the key result K, that is, K = MSB klen (K'). The first device may also output the aforementioned key result K. The most significant bit (MSB) function represents taking the bit representing the highest value in binary.
[0091] In a possible design, when p is less than m, the first device may repeatedly perform the actions in step S303 and step S304, thereby performing multiple rounds ( round) to obtain m first sub-results; further, when executing step S305, the first device can determine the key result corresponding to the elliptic curve according to the m first sub-results.
[0092] Optionally, when p is not divisible by m, in the last round of parallel operation, assuming that the number of first parameters to be processed is less than p, the first device fills the insufficient message blocks with 0s. For example, multiple rounds of parallel operation are expressed as: (V (2) 1+j , V (2) 2+j , …, V (2) p+j )=CF (p) (V (1) , (Y 1+j , Y 2+j , …, Y p+j)), where if j+p>m, then take Y j+p =0.
[0093] Optionally, when p is not divisible by m, in the last round of parallel computing, assuming that the number of first parameters to be processed is less than p, the first device calculates the first parameters to be processed one by one in a traditional manner, that is, parallel processing is not performed. Execute the common non-parallel CF compression function in sequence: V (2) j+1 =CF(V (1) , Y j ).
[0094] In another possible design, when p is not divisible by m, After step S303 and step S304, the first device obtains The parameter set also includes q second parameters. q is less than p and q is a positive integer; then step S305 includes the following steps:
[0095] Step 1: The first device inputs q second parameters into q processing modules.
[0096] Step 2: The first device calls q processing modules, and executes the following steps in each processing module: operates on the input second parameter and the common iteration value, and outputs a second sub-result; wherein the q processing modules operate in parallel and each processing module performs different operations.
[0097] Step 3: First device based The key result is determined based on the q first sub-results and the q second sub-results output by the q processing modules.
[0098] Optionally, the process of the first device determining the key result in step 3 may include: the first device obtains a preset key length; the first device The first sub-results and q second sub-results are concatenated to obtain a temporary key; the first device intercepts the leftmost bit value of the temporary key according to the preset key length to obtain a key result; the length of the key result is the preset key length.
[0099] Optionally, after executing step S305, the first device may also encrypt the first plaintext data according to the key result to obtain the first ciphertext data. For example, the first device may serve as an encryption device to execute the process of confirming and outputting the ciphertext C in the aforementioned step A8.
[0100] Optionally, after executing step S305, the first device may also decrypt the second ciphertext data according to the key result to obtain the second plaintext data. For example, the first device may serve as a decryption device to execute the process of outputting the decrypted plaintext data in the aforementioned step B7.
[0101] In the encryption and decryption calculation process of the traditional SM2 algorithm, the calculations in the aforementioned steps A5 and B4 are the operations of the KDF algorithm, which need to be executed in sequence in a loop in the encryption device (or decryption device), that is, m calculations are performed. The method specifically includes the following steps:
[0102] Step C1: The encryption device (or decryption device) initializes the 32-bit counter ct=0x00000001;
[0103] C2: for i from 1 to implement:
[0104] C2-1: Calculate H i =SM3(Z||ct);
[0105] C2-2: add 1 to the 32-bit counter ct, that is, ct = ct + 1;
[0106] C3: Concatenate m hash strings into K'=H1||H2||…||H m ;
[0107] C4: intercept the leftmost klen bits of K' as K output, that is, output K = MSB klen (K').
[0108] Figure 4a An example diagram of an SM2 data processing flow provided in an embodiment of the present application. Among them, the first device calculates the first parameter to be processed one by one, that is, no parallel processing is performed. It should be understood that the data processing flow can be understood as the data processing flow when p=1, that is, the traditional processing method of the SM2 encryption and decryption algorithm. The aforementioned data processing flow includes the following steps:
[0109] Step 4a-1: Obtain parameter 1 (i.e., bit message block Z) and parameter 2 (i.e., any parameter in the parameter set), wherein parameter 1 is the horizontal coordinate value and the vertical coordinate value of any coordinate point on the elliptic curve in the aforementioned step S301; parameter 2 is the first parameter in the parameter set in the aforementioned step S303.
[0110] Step 4a-2: Execute operations A1 and A2 according to parameter 1 to obtain an iterative value.
[0111] Step 4a-3: Perform operations B1 and B2 according to parameter 2 and the aforementioned iteration value to obtain the subkey.
[0112] Step 4a-4: After repeatedly executing multiple rounds of the aforementioned steps 4a-1 to 4a-3, a key result K is determined based on multiple subkeys.
[0113] Obviously, in the encryption and decryption calculation process of the traditional SM2 algorithm, multiple rounds of steps C1 to C2-2 (or steps 4a-1 to 4a-3) need to be repeated, and step C2-1 (or step 4a-2) needs to be repeated multiple times without distinction, resulting in a waste of computing resources and increasing the time cost of the calculation.
[0114] Figure 4b This is an example diagram of an SM2 data processing flow provided in an embodiment of the present application. Figure 4b As shown, in combination with the method and design shown in the aforementioned steps S301 to S305, the process of the data processing method may include the following steps:
[0115] Step 4b-1: For i (1 to m), take a 64-byte byte string Yi respectively.
[0116] Step 4b-2: Calculate the general iteration value v (1) =F(v (0) , E(Z))=CF(v (0) , Z); the step 4b-2 can refer to the aforementioned step S302 and will not be described in detail here.
[0117] Step 4b-3: for j(0, p, 2p, ...), respectively perform the function calculation of p processing modules in parallel; this step 4b-3 can refer to the aforementioned steps S303 to S304, which will not be described in detail here; it should be understood that the m data are divided into group, and to the front The group data executes the aforementioned step 4b-3.
[0118] Step 4b-4: When p is not divisible by m, The last group (eg, m') of data to be processed in the group is subjected to function calculation; for example, m' function calculations are performed in parallel; or for another example, function calculations are performed one by one.
[0119] Step 4b-5: concatenate the above results obtained by function calculation to obtain a temporary key K'.
[0120] Step 4b-6: intercept the leftmost klen bits of K' as the key result K; Step 4b-5 and Step 4b-6 can refer to the aforementioned step S305 and will not be described in detail here.
[0121] Figure 4c This is an example diagram of an SM2 data processing flow provided in an embodiment of the present application. Figure 4cAs shown, in combination with the method and design shown in the aforementioned steps S301 to S305, the process of the data processing method may include the following steps:
[0122] Step 4c-1: Obtain parameter 1 (ie, bit message block Z); parameter 1 is the horizontal coordinate value and the vertical coordinate value of any coordinate point on the elliptic curve in the aforementioned step S301.
[0123] Step 4c-2: In the first SM3 processing module, according to parameter 1 and the first preset value V (0) , execute operations A1 and A2 to obtain the universal iteration value V (1) The step 4c-2 may refer to the aforementioned step S302 and will not be described in detail here.
[0124] Step 4c-3: Obtain parameter 2 (ie, parameter set); parameter 2 is any parameter in the parameter set in the aforementioned step S303.
[0125] Step 4c-4: For each parameter in the parameter set (i 32 , for example: 1 32 , 2 32 , 3 32 …m 32 ), splicing the second preset value pad, and the splicing result (i 32 ||pad) is used for subsequent operations. Step 4c-3 and step 4c-4 can refer to the aforementioned step S303, and will not be described in detail here.
[0126] Step 4c-5: In the subsequent SM3 block processing module, perform operation B1 and operation B2 to obtain the operation result (for example: V (2) 1. V (2) 2……V (2) m ). The steps 4c-5 may refer to the aforementioned step S304 and will not be described in detail here.
[0127] When executing operation B1, due to the 64-byte byte string i 32 ||pad is predictable data, so operation B1 can be pre-calculated; that is, operation B1 is performed in advance for each parameter in the parameter set, and its result is stored. The result consists of 68 4-byte data, so storing the result of one operation B1 only requires 68*4=272 bytes. Based on this, when executing operation B2, multiple operations B2 are processed in parallel.
[0128] Step 4c-6: concatenate the above operation results to obtain a temporary key K', and intercept the leftmost klen bits of K' as the key result K. This step 4c-6 can refer to the above step S305, and will not be described in detail here.
[0129] Figure 4d This is an example diagram of a data processing flow provided in an embodiment of the present application. Figure 4d As shown, in combination with the method and design shown in the aforementioned steps S301 to S305, the process of the data processing method may include the following steps:
[0130] Step 4d-1: Obtain parameter 1 (ie, bit message block Z); parameter 1 is the horizontal coordinate value and the vertical coordinate value of any coordinate point on the elliptic curve in the aforementioned step S301.
[0131] Step 4d-2: According to parameter 1 and the first preset value V (0) , execute operations A1 and A2 to obtain the universal iteration value V (1) The step 4d-2 may refer to the aforementioned step S302 and will not be described in detail here.
[0132] Step 4d-3: Obtain parameter 2 (ie, parameter set); parameter 2 is any parameter in the parameter set in the aforementioned step S303.
[0133] Step 4d-4: For each parameter in the parameter set (i 32 , for example: 1 32 , 2 32 , 3 32 …m 32 ), splicing the second preset value pad, and the splicing result (i 32 ||pad) input multiple modules for performing operation B1; perform multiple operations B2 according to the result of operation A2 and the results of multiple operations B1. This step 4c-4 can refer to the aforementioned step S304 and will not be described in detail here.
[0134] It should be understood that Figure 4d Only one set of parallel solutions is shown. In actual application, multiple other sets of parallel solutions may be included, and the number of parallel solutions in each set is less than or equal to p.
[0135] Step 4d-5: Determine the key result corresponding to the elliptic curve according to the results of the aforementioned multiple operations B2. Step 4c-5 can refer to the aforementioned step S305 and will not be described in detail here.
[0136] In a possible design, the first device may satisfy the data processing method of parallel processing (i.e., parallel operation of the CF compression function) in the following manner:
[0137] Mode 1: The first device receives a single instruction multiple data (SIMD) instruction; the SIMD instruction is used to instruct p processing modules to perform operations in parallel;
[0138] Method 2: The first device schedules p processing modules to p parallel execution threads for processing;
[0139] Method three: The first device performs parallel calculations of p processing modules through a graphics processor GPU.
[0140] It should be understood that the above three methods can be selected any one or combined, and this application does not limit them.
[0141] Figure 5a This is an example diagram of a parallel processing (CF compression function) provided in an embodiment of the present application, denoted by (V (i+1) 1. V (i +1) 2,…,V (i+1) p )=CF (p) (V (i) , (Y1, Y2, ..., Y p )) is to execute p CF compression functions in parallel, that is, V (i+1) j =CF(V (i) , Y j ), j = 1, 2, ..., p. Among them, (Y1, Y2, ..., Y p ) is a p-bit message block Z (512 bits), (V (i+1) 1. V (i+1) 2,…,V (i +1) p ) are p calculation results, i.e., p first sub-results.
[0142] like Figure 5b As shown, the first device may pre-store a universal iteration value, that is, store a set of bit words after the 512-bit bit message block Z is expanded: E(Z)=(W0, W1, ..., W 67 ); Thus, the first device subsequently executes the following p CF compression functions simultaneously: (V (2) 1+j , V (2) 2+j , …, V (2) p+j )=CF (p) (V (1) , (Y 1+j , Y 2+j , …, Y p+j )) process, there is no need to recalculate (Y 1+j , Y 2+j , …, Y p+j ) can save computing resources.
[0143] Based on the aforementioned Figure 3The data processing method shown in the present application provides the following embodiments: Assuming that the first device (or workstation) uses an Intel processor that supports the AVX512 instruction set, the SM3 CF compression function implemented in parallel by the AVX512 instruction is selected, and one CPU core can process 16 CF compression functions in parallel, that is, p=16; the test is performed with megabyte (MB) to gigabyte (GB) level data, using Figure 3 The execution efficiency of the data processing method shown is about 10-16 times that of the traditional implementation method. Obviously, the data processing method shown in this application can greatly improve the operation efficiency of the KDF algorithm, thereby improving the data processing efficiency.
[0144] Based on the same concept as the above-mentioned data processing method, an embodiment of the present application also provides a data processing device for implementing the above-mentioned method performed by the data processing device.
[0145] Figure 6 The figure shows a schematic diagram of a modular structure of a data processing device provided by an embodiment of the present application. Among them, the communication module 601 can be used to receive and send data, and the processing module 602 can be used to execute the data processing method shown in steps S301 to S305. The specific actions and functions performed are not further elaborated here, and the description of the aforementioned method embodiment can be referred to.
[0146] Figure 7 A structural schematic diagram of a data processing device provided in an embodiment of the present application is shown.
[0147] The electronic device in the embodiment of the present application may include a processor 701. The processor 701 is the control center of the data processing device, and various interfaces and lines can be used to connect various parts of the data processing device, by running or executing instructions stored in the memory 702 and calling data stored in the memory 702. Optionally, the processor 701 may include one or more processing units, and the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes operating systems and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701. In some embodiments, the processor 701 and the memory 702 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0148] Processor 701 may be a general purpose processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and may implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor, etc. The steps performed by the first device or the second device disclosed in the embodiments of the present application may be performed directly by a hardware processor, or performed by a combination of hardware and software modules in the processor.
[0149] In an embodiment of the present application, the memory 702 stores instructions that can be executed by at least one processor 701. The at least one processor 701 can be used to execute the aforementioned steps performed by the first device or the second device by executing the instructions stored in the memory 702.
[0150] The memory 702 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 702 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 702 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 702 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0151] In the embodiment of the present application, the network device may further include a communication interface 703, and the data processing device may transmit data through the communication interface 703. For example, if the data processing device is a server, the communication interface 703 may be used to obtain information of multiple container network interface CNI plug-ins configured by the user.
[0152] Optional, can be Figure 7 The processor 701 (or the processor 701 and the memory 702) is implemented Figure 6The processing module 602 shown, and / or, is implemented by the communication interface 703 Figure 6 The communication module 601 is shown.
[0153] Based on the same inventive concept, the embodiment of the present application also provides a computer-readable storage medium, which may store instructions. When the instructions are executed on a computer, the computer executes the operation steps provided in the above method embodiment. The computer-readable storage medium may be Figure 7 Memory 702 is shown.
[0154] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0155] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, 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, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0156] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0157] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1A step that specifies a function in one or more boxes.
[0158] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data processing method, characterized in that: The method comprises: The first device obtains the abscissa value and the ordinate value of any coordinate point on the elliptic curve; the first device includes p processing modules; p is greater than or equal to 2 and p is a positive integer; The first device determines a common iteration value according to the abscissa value and the ordinate value, and inputs the common iteration value into the p processing modules; The first device generates a parameter set, and inputs p first parameters included in the parameter set into the p processing modules; The first device calls the p processing modules, and performs the following steps in each of the processing modules: performing operations on the input first parameter and the universal iteration value, and outputting a first sub-result; wherein the p processing modules perform operations in parallel and each processing module performs different operations; The first device determines a key result corresponding to the elliptic curve according to the p first sub-results; The first plaintext data is encrypted according to the key result to obtain the first ciphertext data; or the second ciphertext data is decrypted according to the key result to obtain the second plaintext data.
2. The method according to claim 1, characterized in that The parameter set further includes q second parameters, q is less than or equal to p and q is a positive integer; The first device determines the key result corresponding to the elliptic curve according to the p first sub-results, including: The first device inputs the q second parameters into q processing modules; The first device calls the q processing modules, and performs the following steps in each of the processing modules: performing operations on the input second parameter and the universal iteration value, and outputting a second sub-result; wherein the q processing modules perform operations in parallel and each processing module performs different operations; The first device is based on the The key result is determined by the q first sub-results and the q second sub-results output by the q processing modules; m is the number of parameters included in the parameter set.
3. The method according to claim 2, characterized in that The first device determines the key result according to the p first sub-results and the q second sub-results output by the q processing modules, including: The first device obtains a preset key length; The first device concatenates the p first sub-results and the q second sub-results to obtain a temporary key; The first device intercepts the leftmost bit value of the temporary key according to the preset key length to obtain the key result; the length of the key result is the preset key length.
4. The method according to claim 1, characterized in that The length of the concatenated horizontal coordinate value and the vertical coordinate value is 512 bits.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: The first device receives a single instruction multiple data (SIMD) instruction; the SIMD instruction is used to instruct the p processing modules to perform operations in parallel; and / or, The first device schedules the p processing modules to p parallel execution threads for processing; and / or, The first device performs parallel operations on the p processing modules through a graphics processor (GPU).
6. A data processing device, characterized in that: The device comprises: A communication module, used to obtain the abscissa value and the ordinate value of any coordinate point on the elliptic curve; the data processing device includes p processing modules; p is greater than or equal to 2 and p is a positive integer; a processing module, configured to determine a common iteration value according to the abscissa value and the ordinate value, and input the common iteration value into the p processing modules; The processing module is further used to: generate a parameter set, and input the p first parameters included in the parameter set into the p processing modules; The processing module is further used to: call the p processing modules, and perform the following steps in each of the processing modules: operate on the input first parameter and the universal iteration value, and output a first sub-result; wherein the p processing modules operate in parallel and each processing module performs a different operation; The processing module is further used to: determine the key result corresponding to the elliptic curve according to the p first sub-results; The processing module is further used to: encrypt the first plaintext data according to the key result to obtain the first ciphertext data; or decrypt the second ciphertext data according to the key result to obtain the second plaintext data.
7. The device according to claim 6, characterized in that The parameter set further includes q second parameters, q is less than or equal to p and q is a positive integer; the processing module is specifically used for: Inputting the q second parameters into q processing modules; Calling the q processing modules, and executing the following steps in each of the processing modules: performing operations on the input second parameter and the universal iteration value, and outputting a second sub-result; wherein the q processing modules perform operations in parallel and each processing module performs different operations; According to the The key result is determined by the q first sub-results and the q second sub-results output by the q processing modules; m is the number of parameters included in the parameter set.
8. The device according to claim 7, characterized in that The processing module is specifically used for: Acquiring a preset key length through the communication module; Concatenate the p first sub-results and the q second sub-results to obtain a temporary key; According to the preset key length, the leftmost part of the bit value of the temporary key is intercepted to obtain the key result; the length of the key result is the preset key length.
9. The device according to claim 6, characterized in that The length of the concatenated horizontal coordinate value and the vertical coordinate value is 512 bits.
10. The device according to any one of claims 6 to 9, characterized in that: The processing module is also used for: Receiving a single instruction multiple data (SIMD) instruction through the communication module; the SIMD instruction is used to instruct the p processing modules to perform operations in parallel; and / or, Scheduling the p processing modules to p parallel execution threads for processing; and / or, The p processing modules are operated in parallel by a graphics processing unit (GPU).
11. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods of claims 1-5 according to the obtained program instructions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 5.
