A two-party encryption and decryption method and system based on SM9 and electronic equipment

By using a two-way encryption and decryption method based on the SM9 algorithm and employing user identifiers for message encryption and decryption, the problem of key negotiation and management difficulties in instant messaging is solved, enabling secure data transmission and storage that can be decrypted by both communicating parties.

CN116132032BActive Publication Date: 2025-12-05YANTAI JIAGANG ELECTRONIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310065949.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-16
Publication Date
2025-12-05
Estimated Expiration
2043-01-16

AI Technical Summary

Technical Problem

Existing instant messaging encryption technologies suffer from complex key negotiation processes and difficulties in key management, making it impossible for both communicating parties to decrypt the data.

Method used

A two-way encryption and decryption method based on the SM9 algorithm is adopted. The message encryption and decryption are performed using user identifiers, eliminating the key negotiation process. The intermediate parameters are calculated by using the identifiers of user A and user B and the system public key to realize a public key encryption algorithm that can be decrypted by both parties.

Benefits of technology

It enables secure data transmission and storage in instant messaging scenarios, eliminates the problem of only one party being able to decrypt data in the key negotiation process and traditional public key encryption, and ensures the privacy of data transmission and storage in the end-to-end encryption scheme.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116132032B_ABST
    Figure CN116132032B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on SM9's two parties encryption decryption method, system and electronic equipment, first user A uses the identification ID of message receiving two parties and system public key encrypts message M and sends to user B;Then the encrypted message ciphertext C contains the identification of user A and user B and key information;Finally, user A can use the private key of itself and the C1 and C contained in message ciphertext'C1 Calculate intermediate parameter, and decrypt message plaintext;User B can use the private key of itself and the C contained in message ciphertext'C1 Calculate intermediate parameter, and decrypt message plaintext.The application uses the extension implementation of public key encryption algorithm based on SM9, and message encryption and decryption using the user identification of message receiving two parties can save the process of digital certificate exchange and certificate management in message communication process, and is suitable for data security guarantee in instant messaging scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of information security technology and relates to a two-way encryption and decryption method, system and electronic device, specifically a two-way encryption and decryption method, system and electronic device based on the SM9 algorithm. Background Technology

[0002] In the field of information security, protecting data security and privacy has always been a key concern. In secure communication scenarios, server-side encryption stores encrypted data during transmission to prevent unauthorized access, but this method cannot protect the privacy of the entire data transmission process. End-to-end encryption provides a better solution. This method involves encryption and decryption occurring on the terminal device; only the sender and designated receiver can access the data, and no third-party organization can access the encrypted data on the server. Instant messaging is a widely used communication technology on current information networks, allowing two or more people to transmit text, voice, and images in real time over the internet. Unlike traditional secure communication tasks such as email, secure instant messaging requires not only ensuring the secure transmission of user information but also the secure storage of user privacy data.

[0003] Cryptographic techniques are a crucial means of addressing data privacy protection during communication. Current instant messaging encryption technologies, to meet the decryption needs of both users in this scenario, require key negotiation to generate a shared session key. This method not only complicates achieving the one-time pad security requirement for the session key but also poses significant challenges to key management in instant messaging systems. The SM9 public-key encryption and decryption algorithm, an identifier-based asymmetric cryptographic algorithm, allows the message sender to encrypt the message using the recipient's identifier, and only the recipient can decrypt the ciphertext using the corresponding private key to retrieve the message. Compared to traditional public-key encryption algorithms, SM9 uses the user identifier as the public key, thus eliminating the need for digital certificate exchange and management, making it suitable for security in various emerging internet applications. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of existing secure instant messaging encryption methods. It proposes a two-way encryption and decryption method, system, and electronic device based on the SM9 algorithm. This invention addresses the problems of complex key negotiation processes and difficult key management in existing technologies. By eliminating the key negotiation process, it achieves a public-key encryption algorithm that satisfies one-time pad encryption and can be decrypted by both communicating parties. It also solves the problems of secure data transmission and secure storage.

[0005] The technical solution adopted by the method of the present invention is: a two-way encryption and decryption method based on the SM9 algorithm, comprising the following steps:

[0006] Step 1: User A uses the identifiers of both the sender and receiver and the system public key to encrypt message M and send it to user B; the encrypted message ciphertext C contains the identifiers and key information of user A and user B;

[0007] Where: C = C1||C′1||C3||C2;

[0008] C′1=[r]Q B ;

[0009] C1=[r·t -1 Q A ;

[0010] C3 = MAC(K2, C2);

[0011] Q A =[H1(ID) A ||hid,N)]P1+P pub-e ;

[0012] Q B =[H1(ID) B ||hid,N)]P1+P pub-e ;

[0013] t = H1(de) A ||C′1);

[0014] Among them, ID A and ID B These are the identifiers for users A and B, respectively; H1() is the cryptographic function derived from the cryptographic hash function; hid is the private key generation function identifier represented by one byte, selected and published by the key generation center KGG; P1 is the generator of group G1, where G1 is an additive cyclic group of order N prime numbers; P pub-e To encrypt the master public key, P pub-e = [ke]P1, where ke is the master private key; random number r∈[1,N-1]; de A Use user A's private key; use the key derivation function KDF() to generate an encryption key, encrypt message M to obtain C2; MAC() is the message authentication code function, and K2 is the key;

[0015] Step 2: User A uses their private key and C1 and C′1 contained in the ciphertext of the message to calculate intermediate parameters and decrypt the plaintext of the message;

[0016] Step 3: User B uses their private key and C′1 contained in the ciphertext of the message to calculate intermediate parameters and decrypt the plaintext of the message.

[0017] The technical solution adopted by the system of this invention is: a two-way encryption and decryption system based on the SM9 algorithm, comprising the following modules:

[0018] Module 1 is used by user A to encrypt message M using the identifiers of both the sender and receiver and the system public key, and send it to user B; the encrypted message ciphertext C contains the identifiers and key information of user A and user B.

[0019] Where: C = C1||C′1||C3||C2;

[0020] C′1=[r]Q B ;

[0021] C1=[r·t -1 Q A ;

[0022] C3 = MAC(K2, C2);

[0023] Q A =[H1(ID) A ||hid,N)]P1+P pub-e ;

[0024] Q B =[H1(ID) B ||hid,N)]P1+P pub-e ;

[0025] t = H1(de) A ||C′1);

[0026] Among them, ID A and ID B These are the identifiers for users A and B, respectively; H1() is the cryptographic function derived from the cryptographic hash function; hid is the private key generation function identifier represented by one byte, selected and published by the key generation center KGC; P1 is the generator of group G1, where G1 is an additive cyclic group of order N prime numbers; P pub-e To encrypt the master public key, P pub-e = [ke]P1, where ke is the master private key; random number r∈[1,N-1]; de A Use user A's private key; use the key derivation function KDF() to generate an encryption key, encrypt message M to obtain C2; MAC() is the message authentication code function, and K2 is the key;

[0027] Module 2 is used by user A to use their private key and C1 and C1 contained in the ciphertext of the message. ′ Calculate intermediate parameters and decrypt the plaintext message;

[0028] Module 3 is used by user B to use their own private key and the C1 contained in the ciphertext of the message.′ Calculate the intermediate parameters and decrypt the plaintext message.

[0029] The technical solution adopted by the electronic device of the present invention is: an electronic device comprising:

[0030] One or more processors;

[0031] A storage device for storing one or more programs, which, when executed by one or more processors, enable the one or more processors to implement the two-way encryption and decryption method based on the SM9 algorithm.

[0032] Compared to existing technologies, the advantages of this invention are as follows: It utilizes an extended implementation of the SM9-based public-key encryption algorithm, employing the user identifiers of both the sender and receiver for message encryption and decryption. This eliminates the need for digital certificate exchange and management during message communication, making it suitable for data security in instant messaging scenarios. Introducing the user identifiers into the message encryption process allows both the sender and receiver to decrypt their messages, eliminating the key negotiation process in current instant messaging symmetric encryption methods and the problem of only one party being able to decrypt in traditional public-key encryption algorithms. Furthermore, it effectively integrates the end-to-end encryption scheme's protection of privacy data transmission throughout the entire process with the end-to-server encryption scheme's secure storage of privacy data, completing both secure transmission and secure storage of privacy data in one step. Attached Figure Description

[0033] Figure 1 This is a flowchart illustrating the encryption implementation of an embodiment of the present invention;

[0034] Figure 2 This is a flowchart illustrating the decryption process for User A in an embodiment of the present invention.

[0035] Figure 3 The flowchart illustrates the decryption process for User B in this embodiment of the invention. Detailed Implementation

[0036] To facilitate understanding and implementation of the present invention by those skilled in the art, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0037] This invention proposes a two-way encryption and decryption method based on SM9 to solve the problems of complex key negotiation process and difficult key management in existing secure instant communication methods. By eliminating the key negotiation process, it implements a public key encryption algorithm that satisfies one-time pad and can be decrypted by both communicating parties.

[0038] Let the message to be sent be a bit string M, mlen be the bit length of M, K1_ be the bit length of the key K1 in the block cipher algorithm, and K2_ be the bit length of the key K2 in the function MAC(K2,). See below. Figure 1 , Figure 2 and Figure 3 The present invention provides a two-way encryption and decryption method based on the SM9 algorithm, comprising the following steps:

[0039] Step 1: User A uses the identifiers of both the sender and receiver and the system public key to encrypt message M and send it to user B; the encrypted message ciphertext C contains the identifiers and key information of user A and user B;

[0040] Please see Figure 1 In this embodiment, step 1 is specifically implemented by including the following sub-steps:

[0041] Step 1.1: User A uses the identifiers of both the message sender and receiver. A and ID B and the system public key P pub-e Calculate the intermediate parameter Q respectively A and Q B ;

[0042] Q A =[H1(ID) A ||hid,N)]P1+P pub-e ;

[0043] Q B =[H1(ID) B ||hid,N)]P1+P pub-e ;

[0044] Among them, ID A and ID B These are the identifiers for users A and B, respectively; H1() is the cryptographic function derived from the cryptographic hash function; hid is the private key generation function identifier represented by one byte, selected and published by the key generation center KGC; P1 is the generator of group G1, where G1 is an additive cyclic group of order N prime numbers; P pub-e To encrypt the master public key, P pub-e = [ke]P1, where ke is the master private key for encryption;

[0045] Step 1.2: Generate random numbers r∈[1,N-1];

[0046] Step 1.3: Use random number r and intermediate parameter Q B Calculate C′1=[r]Q B Convert the data type of C′1 to a bit string;

[0047] Step 1.4: Using user A's private key, random number r, and C′1, calculate element C1 = [r·t] in G1. -1 Q A Where t = H1(de) A ||C′1), de A For user A's private key, de A =[ke·(H1(ID)] A ||hid,N)+ke) -1 P2; P2 is a generator of group G2, which is an additive cyclic group of order N.

[0048] Step 1.5: Calculate group G T The element g = e(P) pub-e ,P2); where P2 is a generator of group G2; G2 is an additive cyclic group of order N; G T It is a multiplicative cyclic group of order N; e is a number from G1×G2 to G T Bilinear pairs;

[0049] Step 1.6: Calculate group G T The element w = g r This converts the data type of w into a bit string;

[0050] Step 1.7: Use the key derivation function KDF() to generate the encryption key, and encrypt message M to obtain C2;

[0051] If the method for encrypting plaintext is a stream cipher algorithm based on key derivation functions, then:

[0052] (1) Calculate the integer klen = mlen + K2_len, and then calculate K = KDF(C1||C′1||w||ID) A ||ID B Let K1 be the leftmost mlen bit of K, and K2 be the remaining K2_ bits. If K1 is a string of all 0 bits, then go back to step 1.2.

[0053] (2) Calculate C2 = M⊕K1;

[0054] If the method used to encrypt plaintext is a block cipher algorithm that combines a key derivation function, then:

[0055] (1) Calculate the integer klen = K1_len + K2_len, and then calculate K = KDF(C1||C′1||w||ID) A ||ID B Let K1 be the leftmost K1_len bit of K, and K2 be the remaining K2_len bits. If K1 is a string of all 0 bits, then go back to step 1.2.

[0056] (2) Calculate C2 = Enc(K1,M); where Enc() is the block cipher algorithm;

[0057] Step 1.8: Calculate C3 = MAC(K2, C2); where MAC() is the message authentication code function;

[0058] Step 1.9: Output the ciphertext C = C1||C′1||C3||C2.

[0059] Step 2: User A uses their private key and C1 and C′1 contained in the ciphertext of the message to calculate intermediate parameters and decrypt the plaintext of the message;

[0060] Please see Figure 2 In this embodiment, step 2 is specifically implemented by including the following sub-steps:

[0061] Step 2.1: Extract bit strings C1 and C′1 from C, convert the data type of C1 to a point on an elliptic curve, verify whether C1∈G1 is true, and calculate the intermediate variable t. If it is not true, report an error and exit.

[0062] Step 2.2: Calculate group G T The element w′ in the string is converted to a bit string;

[0063] w′=e(C1,de A ) t ;

[0064] Step 2.3: Use the key derivation function KDF() to generate the encryption key, and decrypt the ciphertext C2 to obtain M;

[0065] If the method for encrypting plaintext is a stream cipher algorithm based on key derivation functions, then:

[0066] (1) Calculate the integer klen = mlen + K2_len, and then calculate K′ = KDF(C1||C′1||w′||ID) A ||ID B Let K′1 be the leftmost mlen bits of K′, and K′2 be the remaining K2_len bits. If K′1 is a string of all 0 bits, then report an error and exit.

[0067] (2) Calculate M′=C2⊕K′1;

[0068] If the method used to encrypt plaintext is a block cipher algorithm that combines a key derivation function, then:

[0069] (1) Calculate the integer klen = K1_len + K2_len, and then calculate K′ = KDF(C1||C′). w||w′||ID A ||ID B Let K′1 be the leftmost K1_len bits of K′, and K′2 be the remaining K2_len bits. If K′1 is a string of all 0 bits, then report an error and exit.

[0070] (2) Calculate M′=Dec(k′1,C2); where Dec() is the block decryption algorithm;

[0071] Step 2.4: Calculate u = MAC(K′2, C2), extract bit string C3 from C. If u ≠ C3, report an error and exit.

[0072] Step 2.5: Output plaintext M′.

[0073] Step 3: User B uses their private key and C′1 contained in the ciphertext of the message to calculate intermediate parameters and decrypt the plaintext of the message.

[0074] Please see Figure 3 In this embodiment, step 3 is specifically implemented by including the following sub-steps:

[0075] Step 3.1: Extract the bit string C′1 from C, convert the data type of C′1 to a point on an elliptic curve, and verify whether C′1∈G1 is true. If not, report an error and exit.

[0076] Step 3.2: Calculate group G T The element w′ in the string is converted to a bit string;

[0077] w′=e(C′1,de B );

[0078] Among them, de B For user B's private key, de B =[ke·(H1(ID)] B ||id,N)+ke) -1 P2;

[0079] Step 3.3: Use the key derivation function KDF() to generate the encryption key, and decrypt the ciphertext C2 to obtain M;

[0080] If the method for encrypting plaintext is a stream cipher algorithm based on key derivation functions, then:

[0081] (1) Calculate the integer klen = mlen + K2_len, and then calculate K′ = KDF(C1||C′1||w′||ID) A ||ID BLet K′1 be the leftmost mlen bits of K′, and K′2 be the remaining K2_len bits. If K′1 is a string of all 0 bits, then report an error and exit.

[0082] (2) Calculate M′=C2⊕K′1;

[0083] If the method used to encrypt plaintext is a block cipher algorithm that combines a key derivation function, then:

[0084] (1) Calculate the integer klen = K1_len + K2_len, and then calculate K′ = KDF(C1||C′1||w′||ID) A ||ID B Let K′1 be the leftmost K1_len bits of K′, and K′2 be the remaining K2_len bits. If K′1 is a string of all 0 bits, then report an error and exit.

[0085] (2) Calculate M′=Dec(k′1,C2); where Dec() is the block decryption algorithm;

[0086] Step 3.4: Calculate u = MAC(K′2, C2), extract the bit string C3 from C. If u ≠ C3, report an error and exit.

[0087] Step 3.5: Output plaintext M′.

[0088] This invention utilizes an extended implementation of the SM9-based public-key encryption algorithm. By employing the user identifiers of both the sender and receiver for message encryption and decryption, it eliminates the need for digital certificate exchange and management during message communication, making it suitable for data security in instant messaging scenarios. By introducing the user identifiers into the message encryption process, both parties can decrypt each other's messages, eliminating the key negotiation process in current instant messaging symmetric encryption methods and the problem of only one party being able to decrypt in traditional public-key encryption algorithms. It effectively integrates the protection of privacy data transmission throughout the end-to-end encryption scheme in secure communication with the secure storage of privacy data in the end-to-server encryption scheme, completing the secure transmission and storage of privacy data in one step.

[0089] It should be understood that the above description of the preferred embodiments is quite detailed, but it should not be considered as a limitation on the scope of protection of this invention. Those skilled in the art, under the guidance of this invention, can make substitutions or modifications without departing from the scope of protection of the claims of this invention, and all such substitutions or modifications fall within the scope of protection of this invention. The scope of protection of this invention should be determined by the appended claims.

Claims

1. A two-party encryption and decryption method based on SM9, characterized in that, The method comprises the following steps: Step 1: User A encrypts a message M with a system public key using the identities ID of the two parties in the message transmission, and sends the message to user B; the encrypted message ciphertext C contains the identities and key information of user A and user B; Wherein: C=C1||C'1||C3||C2; C'1 = [r] Q B ; C1 = [r · t -1 ]Q A ; C3=MAC(K2, C2); Q A = [H1(ID A ||hid, N)]P1+P pub-e ; Q B = [H1(ID B ||hid, N)]P1+P pub-e ; t = H1(de A ||C′1); ID A and ID B are the identities of user A and user B respectively; H1() is a password function derived from a password hash function; hid is a private key generation function identifier represented by a byte, selected and disclosed by a key generation center KGC; P1 is a generator of group G1, G1 is an additive cyclic group with a prime number N as order; P pub-e is an encryption master public key, P pub-e = [ke] P1, ke is an encryption master private key; a random number r ∈ [1, N-1]; de A is a private key of user A; a secret key is generated by using a key derivation function KDF(), and a message M is encrypted to obtain C2; MAC() is a message authentication code function, and K2 is a key; Step 2: User A calculates an intermediate parameter using the private key of itself and C1 and C'1 contained in the message ciphertext, and decrypts the message plaintext; Step 3: User B calculates an intermediate parameter using the private key of itself and C'1 contained in the message ciphertext, and decrypts the message plaintext.

2. The SM9-based two-party encryption and decryption method according to claim 1, characterized in that, The specific implementation of step 1 comprises the following sub-steps: Step 1.1: User A uses the identities ID of the messaging parties A and ID B and the system public key P pub-e to compute the intermediate parameters Q A and Q B respectively; Q A = [H1(ID A ||hid, N)]P1+P pub-e ; Q B = [H1(ID B ||hid, N)]P1+P pub-e ; ID A and ID B are the identities of user A and user B respectively; H1() is a password function derived from a password hash function; hid is a private key generation function identifier expressed in one byte, selected and disclosed by a key generation center KGC; P1 is a generator of group G1, G1 is an additive cyclic group of prime number N; P pub-e is an encryption master public key, P pub-e = [ke] P1, ke is an encryption master private key; Step 1.2: Generate a random number r∈[1, N-1]; Step 1.3: Use of random number r with intermediate parameter Q B Compute C'1 = [r]Q B Convert data type of C'1 to bit string; Step 1.4: Compute an element C1= [r-t in G1 using the private key of user A, the random number r and C'1 -1 ]Q A ; where t = H1(de A || C'1), de A is the private key of user A, de A = [ke- (H1(ID A || hid, N) + ke) -1 ]P2; P2 is a generator of group G2, G2 is an additive cyclic group of prime order N. Step 1.5: Compute the element g = e(P T , P2) in the group G pub-e ; where G T is a multiplicative cyclic group of order prime N; e is a bilinear pair from G1 x G2 to G T ; Step 1.6: Compute the group G T of elements w = g r Convert the data type of w to a bit string; Step 1.7: Generate a cipher key using a key derivation function KDF(), and encrypt the message M to obtain C2; If the method of encrypting plaintext is a sequence cipher algorithm based on a key derivation function, then: (1) Compute the integer klen = ml en + K 2_ len, then compute K = KDF(C1||C'1||w||ID A ||ID B , klen); let K1 be the mlen leftmost bits of K, and K2 be the remaining K 2_ len bits, and if K1 is a string of all 0 bits, then go back to step 1.2: (2) Compute If the method of encrypting plaintext is a block cipher algorithm combined with a key derivation function, then: (1) Compute integer klen = K 1- len+K 2_ len, then compute K = KDF(C1||C'1||w||ID A ||ID B , klen); let K1 be the leftmost K 1_ len bits of K, K2 be the remaining K 2_ len bits, and if K1 is the all-zero bit string, then go back to step 1.2; (2) Calculate C2=Enc(K1, M); wherein, Enc() is a block encryption algorithm; Step 1.8: Calculate C3=MAC(K2, C2); wherein, MAC() is a message authentication code function; Step 1.9: Output the ciphertext C=C1||C'1||C3||C2.

3. The SM9-based two-party encryption and decryption method according to claim 1, characterized in that, The specific implementation of step 2 comprises the following sub-steps: Step 2.1: Take out the bit strings C1 and C'1 from C, convert the data type of C1 into a point on an elliptic curve, verify whether C1∈G1 is true, and calculate an intermediate variable t, if not, report an error and exit; Step 2.2: Compute the element w' of the group G T and convert the data type of w' to a bit string; w' = e(C1, de A ) t ; Step 2.3: Generate a cipher key using a key derivation function KDF(), and decrypt the ciphertext C2 to obtain M; If the method of encrypting plaintext is a sequence cipher algorithm based on a key derivation function, then: (1) Compute integer klen = mlen + K 2_ len, then compute K' = KDF(C1||C'1||w'||ID A ||ID B , klen); let K'1 be the mlen leftmost bits of K', and K'2 be the remaining K 2_ len bits, if K'1 is a string of all 0 bits, then report an error and exit. (2) Compute If the method of encrypting plaintext is a block cipher algorithm combined with a key derivation function, then: (1) compute integer klen = K 1_ len+K 2_ len, then compute K' = KDF(C1||C'1||w'||ID A ||ID B , klen); let K'1 be the leftmost K 1_ len bits of K', and K'2 be the remaining K 2_ len bits, if K'1 is a string of all 0 bits, then report an error and exit; (2) Calculate M'=Dec(k'1, C2); wherein, Dec() is a block decryption algorithm; Step 2.4: Calculate u=MAC(K'2, C2), take out the bit string C3 from C, if u≠C3, then report an error and exit; Step 2.5: Output the plaintext M'.

4. The SM9-based two-party encryption and decryption method according to claim 1, characterized in that, The specific implementation of step 3 comprises the following sub-steps: Step 3.1: Take out the bit string C'1 from C, convert the data type of C'1 into a point on an elliptic curve, verify whether C'1∈G1 is true, if not, report an error and exit; Step 3.2: Compute the element w' of the group G T and convert the data type of w' to a bit string; w' = e(C'1, de B ); where de B is the private key of the user B, de B = [ke·(H1(ID B || id, N) + ke) -1 ]P2; Step 3.3: Generate a cipher key using a key derivation function KDF(), and decrypt the ciphertext C2 to obtain M; If the method of encrypting plaintext is a sequence cipher algorithm based on a key derivation function, then: (1) Compute integer klen = mlen + K 2_ len, then compute K' = KDF(C1||C'1||w'||ID A ||ID B , klen); let K'1 be the mlen leftmost bits of K', K'2 be the remaining K 2_ len bits, if K'1 is a string of all 0 bits, then report an error and exit. (2) Calculate If the method of encrypting plaintext is a block cipher algorithm combined with a key derivation function, then: (1) Compute integer klen = K 1_ len + K 2_ len, then compute K' = KDF(C1||C'1||w'||ID A ||ID B , klen); let K'1 be the leftmost K 1_ len bits of K', and K'2 be the remaining K 2_ len bits, and if K'1 is a string of all 0 bits, then report an error and exit. (2) Calculate M'=Dec(k'1, C2); wherein, Dec() is a block decryption algorithm; Step 3.4: Calculate u=MAC(K'2, C2), take out the bit string C3 from C, if u≠C3, then report an error and exit; Step 3.5: Output the plaintext M'.

5. A double encryption and decryption system based on SM9, characterized in that, The method comprises the following modules: Module 1, for user A to send a message M to user B using the identification ID of the message receiving party and the system public key to encrypt the message; the encrypted message ciphertext C contains the identification and key information of user A and user B; Wherein: C=C1||C'1||C3||C2; C1= [r] Q B ; C1 = [r · t -1 ]Q A ; C3=MAC(K2, C2); Q A = [H1(ID A ||hid, N)]P1+P bub-e ; Q B = [H1(ID B || hid, N)]P1+ P pub-e ; t = H1(de A ||C′1); ID A and ID B are the identities of user A and user B respectively; H1() is a password function derived from a password hash function; hid is a private key generation function identifier represented by a byte, selected and disclosed by a key generation center KGC; P1 is a generator of group G1, G1 is an additive cyclic group of prime order N; P pub-e is an encryption master public key, P pub-e = [ke] P1, ke is an encryption master private key; a random number r ∈ [1, N-1]; de A is a private key of user A; a secret key is generated using a key derivation function KDF(), and a message M is encrypted to obtain C2; MAC() is a message authentication code function, and K2 is a key; Module 2, for user A to calculate an intermediate parameter using the private key of itself and C1 and C'1 contained in the message ciphertext, and to decrypt the message plaintext; Module 3, for user B to calculate an intermediate parameter using the private key of itself and C'1 contained in the message ciphertext, and to decrypt the message plaintext.

6. An electronic device, comprising: Comprise: One or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the SM9-based two-party encryption and decryption method as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Short message encryption method based on SM9 algorithm

    CN109600725A

  • Software and hardware collaborative design SM9 digital signature communication method and system

    CN112202568A