Decryption method and key decapsulation method based on SM9 cryptographic algorithm
By introducing random number replacement bilinear pairing operation into the SM9 algorithm, the number of participation times of the user's private key is reduced, the problem of the risk of private key leakage is solved, and the security and confidentiality of the SM9 decapsulation and decryption algorithm are improved.
Patent Information
- Application Number
- CN202211717992.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In the SM9 algorithm, the user's private key frequently participates in bilinear pairing operations, increasing the risk of leakage and affecting the security of the decapsulation and decryption algorithm.
By introducing a random number R in the decapsulation and decryption algorithm, calculating C' and D', replacing the original bilinear pairing operation, reducing the number of private key operations at the bottom, using the characteristics of bilinear pairing for replacement, reducing the number of private keys Risk of leakage.
Effectively protect the user's private key, reduce the risk of private key leakage, increase system confidentiality, improve the difficulty of protecting data in the algorithm process, and enhance the resistance to side channel attacks.
Smart Images

Figure CN116132047B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a key decapsulation method based on an SM9 cryptographic algorithm, and also relates to a decryption method based on the SM9 cryptographic algorithm, belonging to the technical field of information security. Background Art
[0002] At present, digital signature and encryption and decryption technologies based on public key cryptography have been widely used in e-commerce, identity authentication and other applications, providing a set of mature and secure technologies and specifications for online transactions and communications. The security of private keys is one of the basic conditions for ensuring the security of these applications.
[0003] The SM9 identity cryptographic algorithm is a commercial cryptographic algorithm based on the identity cryptographic system independently designed by my country. It is an identity-based cryptographic algorithm constructed using bilinear pairings on elliptic curves in a finite field. In the SM9 algorithm, the user's private key is calculated by the key generation center based on the master key and the user's identity. The user's public key is uniquely determined by the user's identity and the authenticity of the identity is guaranteed by the user's device manager. The SM9 algorithm includes a signature / verification algorithm, an encryption / decryption algorithm, an encapsulation / decapsulation algorithm, and a key exchange algorithm.
[0004] According to the decapsulation algorithm process and decryption algorithm process disclosed in Sections 8.5 and 9.5 of the Chinese national standard GB / T 38635.2-2020 "Information Security Technology SM9 Identification Cryptographic Algorithm Part 2: Algorithm", it can be seen that the user's private key is mainly involved in the operation of bilinear pairings. If the user's private key is leaked, it will directly affect the security of the SM9 decapsulation algorithm and decryption algorithm. In the bilinear pairing calculation, the user's private key will be frequently used to participate in some underlying operations. Frequent use of the user's private key in the operation will increase the risk of leakage of the user's private key. Therefore, it is necessary to study a method to effectively protect the user's private key during the operation of the decryption algorithm and the decapsulation algorithm. Summary of the invention
[0005] The primary technical problem to be solved by the present invention is to provide a key decapsulation method based on the SM9 cryptographic algorithm.
[0006] Another technical problem to be solved by the present invention is to provide a decryption method based on the SM9 cryptographic algorithm.
[0007] In order to achieve the above technical objectives, the present invention adopts the following technical solutions:
[0008] According to a first aspect of an embodiment of the present invention, a key decapsulation method based on an SM9 cryptographic algorithm is provided, comprising the following steps:
[0009] M1: Verify whether the ciphertext C∈G1 is true. If not, exit. If yes, proceed to the next step. Group G1 represents an additive cyclic group with an order of prime number N.
[0010] M2: Computation group G T The bilinear pairing of elements in w1′=e(C′, D′) is converted into a bit string, where the group G T represents a multiplicative cyclic group of prime order N, C' is obtained based on the temporary public key C1 used for each encryption of the encapsulated ciphertext received by the decryption device;
[0011] D' is based on the encrypted private key of the decryption device B obtained;
[0012] M3: Convert the data type of the ciphertext C to a bit string and calculate the encapsulation key K'=KDF(C||w'||ID B , klen), if K' is a string of all 0 bits, an error is reported and the process exits, otherwise it proceeds to the next step;
[0013] M4: Output key K'.
[0014] Preferably, in step M1, the ciphertext C received by the decryption device is C=C1||C2||C3, wherein C1 is an encapsulation of a symmetric key, C2 is an encapsulation of a message, and C3 is used for message authentication.
[0015] Preferably, the step M2 includes the following sub-steps:
[0016] Step 1: Get a random number R through a secure random number generator;
[0017] Step 2: Use the base domain dot multiplication unit to calculate C'=[R]C1;
[0018] Step 3: Calculate R' = R by modular inverse operation unit -1 mod N;
[0019] Step 4: Calculate D'=[R']de through the extended domain point multiplication unit B ;
[0020] Step 5: Calculate the bilinear pair w1'=e(C', D').
[0021] Preferably, the random number R is between [1, N-1], and R is smaller than N.
[0022] Preferably, e is a bilinear mapping, which means from G1×G2 to G T The bilinear pairing of w1' is a temporary variable belonging to the multiplicative group G T The elements in .
[0023] According to a second aspect of an embodiment of the present invention, a decryption method based on the SM9 cryptographic algorithm is provided, comprising the following steps:
[0024] N1: Extract the bit string C1 from the ciphertext C, convert the data type of C1 into a point on the elliptic curve, and verify whether C1∈G1 holds. If not, report an error and exit, otherwise proceed to the next step, where group G1 represents an additive cyclic group with an order of prime number N;
[0025] N2: Computation group G T The element w'=e(C1, de B ), convert the data type of w' to a bit string; B Represents the encrypted private key for decrypting the device,
[0026] N3: Based on the key K', calculate according to the method of encrypting plaintext to obtain the plaintext M';
[0027] N4: Calculate u=MAC(K2', C2), and extract the bit string C3 from C: If u≠C3, report an error and exit, otherwise proceed to the next step;
[0028] N5: Output plain text M'.
[0029] Preferably, the key K' is obtained according to the aforementioned key decapsulation method based on the SM9 cryptographic algorithm.
[0030] Preferably, the classification by the method of encrypting plain text refers to the classification based on a sequence cipher of a key derivation function or a block cipher combined with a key derivation function.
[0031] Compared with the prior art, the decryption method and key decapsulation method based on the SM9 cryptographic algorithm provided by the present invention can not only rely on the advantages of the SM9 algorithm to effectively overcome the problems of weak key distribution security in traditional cryptographic algorithms, but also greatly increase the difficulty of obtaining key information by side channel attack methods such as timing attacks and power consumption analysis from the algorithm implementation level. The application of the present invention in the IoT security platform can not only solve the problem of mutual trust between the current IoT devices and servers, and between IoT devices and IoT devices, but also effectively disrupt the correlation between important intermediate data and energy consumption in the SM9 algorithm, and realize the protection of important data in the algorithm process. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a flowchart of the SM9 decryption algorithm in the prior art;
[0033] Figure 2 This is a flow chart of a private key protection method for the SM9 decryption and decapsulation algorithm in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] The technical content of the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0035] In order to enable those skilled in the art to better understand the present invention, the relevant background of the present invention is further described below. First of all, it should be noted that the present invention is an improvement on the SM9 decapsulation and decryption method in the Chinese national standard GB / T 38635.2-2020 "Information Security Technology SM9 Identification Cryptographic Algorithm Part 2: Algorithm" (hereinafter referred to as: this standard), focusing on the differences between the technical solution provided by the present invention and the standard. Therefore, some of the contents in the standard that are the same as the technical solution provided by the present invention can be cited here, and will not be repeated here.
[0036] The decapsulation algorithm is described in Section 8.4 of the standard. After user B (decryption device) receives the encapsulated ciphertext C, in order to decapsulate the key with a bit length of klen, the following key decapsulation steps need to be performed:
[0037] A1: Verify whether the encapsulated ciphertext C∈G1 is valid. If not, report an error and exit. Otherwise, proceed to the next step. Group G1 is an additive cyclic group with an order of prime number N.
[0038] A2: Calculate group G T The element w'=e(C, de B ), convert the data type of w' to a bit string, where de B is the SM9 private key, w' is the private key de B The bilinear pair value, e represents the bilinear pair mapping: G1 (the group where C is located) * G2 (de B The group where it is located) → GT, GT is a multiplicative cyclic group of order prime number N.
[0039] A3: Convert the data type of the encapsulated ciphertext C to a bit string and calculate the encapsulated key K'=KDF(C||w'||ID B , klen), if K' is a string of all 0 bits, an error is reported and the program exits. KDF is the key derivation function, ID B Indicates the user ID.
[0040] A4: Output the key K'.
[0041] The decryption algorithm is described in Section 9.4 of the standard. Let the ciphertext C = C1||C3||C2, where mlen is the bit length of C2, K 1— len is the bit length of key K1 in the block cipher algorithm, and K2_len is the bit length of key K2 in the authentication message code function MAC(K2, Z).
[0042] In order to decrypt ciphertext C, user B, as the decryptor, needs to perform the following steps:
[0043] B1: Extract the bit string C1 from the ciphertext C, convert the data type of C1 into a point on the elliptic curve, and verify whether C1∈G1 holds. If not, report an error and exit, otherwise proceed to the next step.
[0044] B2: Calculation group G T The element w'=e(C1, de B ), convert the data type of w' to a bit string.
[0045] B3: Based on the key K', the plaintext M' is obtained by performing calculations according to the method of encrypting the plaintext (a sequence cipher based on a key derivation function or a block cipher combined with a key derivation function).
[0046] If the method used to encrypt the plaintext is a stream cipher of a key derivation function, then K1' is the leftmost mlen bits of the key K', and K2' is the remaining K2_len bits of the key K'. If K1' is a string of all 0 bits, an error is reported and the function exits. If not, the plaintext M' is calculated.
[0047] If the method of encrypting the plaintext is a block cipher algorithm combined with a key derivation function, then K1' is the leftmost K1_len bits of the key K', and K2' is the remaining K2_len bits. If K1' is a string of all 0 bits, an error is reported and the program exits. If not, the plaintext M'=Dec(K1', C2) is calculated. Where Dec is the block cipher decryption algorithm.
[0048] B4: Calculate u=MAC(K2', C2), and extract the bit string C3 from C: If u≠C3, report an error and exit, otherwise go to the next step. The authentication message code function MAC(K2', C2) inputs the bit string K2' and the bit string C2, and outputs a message authentication code data bit string of length υ. K2' is the right K2_len bits of the key K' obtained in step B3.
[0049] B5: Output plain text M'.
[0050] like Figure 1 As shown, the embodiment of the present invention first discloses a private key protection method based on the SM9 decryption and decapsulation algorithm, which decrypts the user's private key. B The bilinear pairing operation involved is replaced, that is, the operation w'=e(C1, de B ) steps to replace it.
[0051] Therefore, the key decapsulation method provided by the embodiment of the present invention comprises the following steps:
[0052] M1: Verify whether the ciphertext C∈G1 is valid. If not, report an error and exit. If valid, proceed to the next step.
[0053] Among them, user B (decryption device) receives the ciphertext C = C1||C2||C3, where C1 is the encapsulation of the symmetric key (the symmetric key and the private key de B C2 is the encapsulation of the message, and C3 is used for message authentication. Group G1 represents an additive cyclic group with an order of prime number N.
[0054] M2: Computation group G T The bilinear pairing of elements in w1'=e(C',D') converts the data type of w' into a bit string.
[0055] The step of calculating bilinear pairings in step M2 includes the following sub-steps:
[0056] Step 1: Get a random number R through a secure random number generator.
[0057] Specifically, the random number R must be between [1, N-1]. If the generated random number R is greater than or equal to N, a new random number R is generated until R is less than N. Wherein, N is the order of the SM9 elliptic curve. Specifically, N represents the cyclic group G1, G2, G T The order of N is greater than 2 191 The group G1 represents an additive cyclic group whose order is a prime number N, G2 represents another additive cyclic group (different from G1) whose order is a prime number N, and the group G T represents the multiplicative cyclic group of prime order N. G1 is the additive group of the base field, and G2 is the additive group of the quadratic extension field.
[0058] Step 2: Use the base field dot multiplication unit to calculate C'=[R]C1.
[0059] Where C1 is the temporary public key for each encryption of the encapsulated ciphertext received by user B (decryption device), [R]C1 represents R times the element C1, and the obtained C' is used to replace the bilinear pairing operation w'=e(C1, de B ) in C1.
[0060] Step 3: Calculate R' = R by modular inverse operation unit -1 mod N.
[0061] Among them, mod represents the modulo operation, and it can be seen from this formula that R*R'=1.
[0062] Step 4: Calculate D'=[R']de through the extended domain point multiplication unitB .
[0063] Among them, B is the encrypted private key of user B, [R']de B Represents an element B Because R is a random number, and from step S3 we know that R' is also a random number, so D' is also a random number. The obtained D' is used to replace the original bilinear pairing operation w'=e(C1, de B ) B .
[0064] It can be seen from this that by using a randomized private key calculation process, the number and intensity of operations involving the original private key can be reduced, the risk of private key leakage can be reduced, the private key can be protected, and confidentiality can be improved.
[0065] Point multiplication operation is multiple point operation, which meets the description of Chapter B.2 of Part 1 of GB / T38635.1-2020.
[0066] Step 5: Calculate the bilinear pair w1'=e(C', D').
[0067] Among them, e is a bilinear mapping, which means from G1×G2 to G T The bilinear pairing of w1' is a temporary variable belonging to the multiplicative group G T Elements in. From Section 6.1 of GB / T38635.1-2020 "Information Security Technology SM9 Identity Cryptographic Algorithm Part 1: General Principles", it can be seen that the bilinear pairing has bilinearity, that is: for any P∈G1, Q∈G2, a, b∈Z N , we can get e([a]P,[b]Q)=e(P,Q) ab .
[0068] Through the above process, the user's private key can be B It does not participate in the final bilinear pairing operation, but uses the randomized D' to participate in the operation. This can reduce the user's private key B The number of times it is used in the underlying operation reduces the user's private key B The risk of leakage is reduced while increasing the confidentiality of the system.
[0069] M3: Convert the data type of C to a bit string and calculate the encapsulated key K'=KDF(C||w'||ID B , klen), if K' is a string of all 0 bits, report an error and exit, otherwise go to the next step.
[0070] M4: Output key K'.
[0071] In one embodiment of the present invention, the corresponding decryption process includes the following sub-steps:
[0072] N1: Take the bit string C1 from C, convert the data type of C1 to a point on the elliptic curve, and verify whether C1∈G1 holds. If not, report an error and exit, otherwise proceed to the next step.
[0073] N2: Computation group G T The element w'=e(C1, de B ), convert the data type of w' to a bit string.
[0074] The bilinear pairing w' is obtained according to the algorithm in step M2, which will not be described in detail here.
[0075] N3: Based on the key K' obtained in step M4, calculation is performed according to the method of encrypting plaintext (sequential cipher based on key derivation function or block cipher combined with key derivation function) to obtain plaintext M'.
[0076] N4: Calculate u=MAC(K2', C2), and extract the bit string C3 from C: If u≠C3, report an error and exit, otherwise proceed to the next step.
[0077] N5: Output plain text M'.
[0078] In summary, the private key protection method of the SM9 decryption and decapsulation algorithm provided by the embodiment of the present invention first obtains a random number R between [1, N-1] through a secure random number generator, then calculates C'=[R]C1 using a base field point multiplication operation unit, and then calculates R'=R by a modular inverse operation unit. -1 mod N, and then calculate D'=[R'] through the extended domain point multiplication unit B Finally, the bilinear pairing w1'=e(C', D') is calculated. The above steps utilize the characteristics of the bilinear pairing and convert the operation w'=e(C1, de B ) is replaced by w1'=e(C', D'), and the randomized D' is used to replace the user's private key de B Perform underlying operations, which can reduce the user's private key B The use of 256-bit data reduces the risk of user private key leakage. In addition, due to the randomization of 256-bit data, it is more difficult to obtain key information through side channel attacks such as timing attacks and power consumption analysis from the algorithm implementation level.
[0079] In order to illustrate the feasibility of the decryption method and key decapsulation method based on the SM9 cryptographic algorithm provided by the present invention, further demonstration is as follows:
[0080] The calculation formula w1'=e(C', D') in the above step S5 is expanded as follows:
[0081] 1) Replace C', we can get w1'=e([R]C1, D')
[0082] 2) Substituting D', we can get w1'=e([R]C1, [R']de B )
[0083] 3) According to the bilinearity of bilinear pairing, we have: w1' = e(C1, de B ) R*R'
[0084] 4) From R' = R -1 mod N, we know that R*R'=1, so w1'=e(C1, de B )
[0085] It can be seen that w1' obtained by the decryption method and key decapsulation method based on the SM9 cryptographic algorithm provided by the present invention is exactly the same as w1' in the original process. This shows that replacing the decapsulation algorithm step A2 and the decryption algorithm step B2 in Sections 8.4 and 9.4 of GB / T 38635.2-2020 "Information Security Technology SM9 Identification Cryptographic Algorithm Part 2: Algorithm" with the decryption method and key decapsulation method provided by the present invention will not affect the final bilinear pairing operation results, that is, the decryption method and key decapsulation method provided by the present invention are feasible in principle.
[0086] It can be understood that the decryption method and key decapsulation method provided by the present invention can be used in the field of mobile communication technology as well as in various technical fields such as computer communication and the Internet of Things.
[0087] Compared with the prior art, the decryption method and key decapsulation method based on the SM9 cryptographic algorithm provided by the present invention can not only rely on the advantages of the SM9 algorithm to effectively overcome the problems of weak key distribution security in traditional cryptographic algorithms, but also greatly increase the difficulty of obtaining key information by side channel attack methods such as timing attacks and power consumption analysis from the algorithm implementation level. The application of the present invention in the Internet of Things security platform can not only solve the problem of mutual trust between current Internet of Things devices and servers, and between Internet of Things devices and Internet of Things devices, but also effectively disrupt the correlation between important intermediate data and energy power consumption in the SM9 algorithm, and realize the protection of important data in the algorithm process.
[0088] The above is a detailed description of the decryption method and key decapsulation method based on the SM9 cryptographic algorithm provided by the present invention. For those skilled in the art, any obvious changes made to it without departing from the essence of the present invention will constitute an infringement of the patent right of the present invention and will bear corresponding legal responsibilities.
Claims
1. A key decapsulation method based on the SM9 cryptographic algorithm, characterized in that The following steps are involved: M1: Verify whether the ciphertext C∈G1 is valid. If not, report an error and exit. If valid, proceed to the next step. Group G1 represents an additive cyclic group with an order of prime number N. M2: Computation group G T The bilinear pair of elements in w1'=e(C',D'), convert the data type of w1' to a bit string, where the group G T represents a multiplication cyclic group of prime order N, C' is obtained based on the encapsulation C1 of the symmetric key received by the decryption device; D' is based on the encrypted private key de of the decryption device B obtained; M3: Convert the data type of the ciphertext C to a bit string and calculate the encapsulation key K'=KDF(C||w1'||ID B , klen), if K' is a string of all 0 bits, report an error and exit, otherwise proceed to the next step; Among them, ID B is the user identifier of the decryption device, which can uniquely identify the public key of the user of the decryption device; klen is the bit length of the key data to be obtained; KDF is the key derivation function; M4: output key K'; The step M2 includes the following sub-steps: Step 1: Get a random number R through a secure random number generator; Step 2: Use the base domain dot multiplication unit to calculate C' = [R] C1; Step 3: Calculate R' = R by modular inverse operation unit -1 mod N; Step 4: Calculate D'=[R']de through the extended domain point multiplication unit B ; Step 5: Calculate the bilinear pairing w1'=e(C',D').
2. The key decapsulation method based on the SM9 cryptographic algorithm as claimed in claim 1, characterized in that: In the step M1, the ciphertext C received by the decryption device is C=C1||C2||C3, wherein C1 is the encapsulation of the symmetric key, C2 is the encapsulation of the message, and C3 is used for message authentication.
3. The key decapsulation method based on the SM9 cryptographic algorithm as claimed in claim 1, characterized in that: The random number R is between [1, N-1], and R is less than N.
4. The key decapsulation method based on the SM9 cryptographic algorithm as claimed in claim 1, characterized in that: e is a bilinear mapping from G1×G2 to G T The bilinear pairing of w1' is a temporary variable belonging to the multiplicative group G T Elements in Among them, G2 is the additive group of the quadratic extension field.
5. A decryption method based on the SM9 cryptographic algorithm, characterized in that The following steps are involved: N1: Take the bit string C1 from the ciphertext C, convert the data type of C1 into a point on the elliptic curve, and verify whether C1∈G1 holds. If not, report an error and exit, otherwise proceed to the next step, where group G1 represents an additive cyclic group with an order of prime number N; N2: Computation group G T The element w'=e(C1, de B ), convert the data type of w' to a bit string; B Represents the encrypted private key for decrypting the device; Among them, C1 is the encapsulation of the symmetric key; N3: Based on the key K', calculate according to the method of encrypting plaintext to obtain the plaintext M'; N4: Calculate u=MAC(K2', C2), and extract the bit string C3 from C: If u≠C3, report an error and exit, otherwise proceed to the next step; Wherein, K2' is the remaining K2_len bits except the leftmost K1_len bits of the key K'; C2 is the encapsulation of the message; C3 is the message authentication; N5: output plain text M'; The key K' is obtained according to any one of claims 1-4.
6. The decryption method based on the SM9 cryptographic algorithm as claimed in claim 5, characterized in that: Classification by the method of encrypting plain text refers to classification based on KDF-based sequence ciphers or block ciphers combined with KDF.
