Encrypted communication method, system, electronic device and storage medium

By adding extended parameters to the handshake information, hybrid key exchange between post-quantum algorithm and SM2 algorithm is realized, which solves the problem that SM2 algorithm is easily cracked and improves communication security.

CN118972059BActive Publication Date: 2025-01-10BEIJING INFOSEC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411442312.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2025-01-10
Estimated Expiration
2044-10-15

AI Technical Summary

Technical Problem

In practical applications, SM2 algorithms are easily cracked and lead to private key leakage, which is low in security, and it is difficult for the existing technology to effectively solve this problem.

Method used

By adding the first and second extended parameters to the handshake information of the client and the server, key exchange based on the post-quantum algorithm is realized, and the second premaster key component containing the SM2 algorithm is generated, combined with pseudo-random function generation Target pre-master key realizes hybrid key exchange between post-quantum algorithm and SM2 algorithm.

Benefits of technology

Even if one of the post-quantum algorithm or SM2 algorithm is cracked, the other algorithm can still ensure high security of data transmission and improve communication security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118972059B_ABST
    Figure CN118972059B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides an encrypted communication method, system, electronic device and storage medium. The method includes: sending a first handshake message to a server, the first handshake message includes a first extended parameter and a second extended parameter, the second extended parameter includes a plurality of post-quantum cryptographic algorithm public keys corresponding to the post-quantum algorithm; receiving a second handshake message sent by the server, the second handshake message includes a first pre-master key component, the first pre-master key component is obtained by the server based on the first extended parameter and the second extended parameter; sending a third handshake message to the server, so that the client and the server respectively generate the second pre-master key component corresponding to the SM2 algorithm; according to the first pre-master key component and the second pre-master key component, determining the target pre-master key, so as to perform encrypted communication based on the target pre-master key. The present application has high security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information security technology, and in particular to an encryption communication method, system, electronic device and storage medium. Background Art

[0002] In the Transport Layer Cryptographic Protocol (TLCP)

[0003] In the field of encryption, the SM2 algorithm is often used in key links such as key exchange and digital signature to ensure the security and credibility of both parties in communication. However, in actual applications, if the SM2 algorithm is forcibly cracked, it will cause the private key to be leaked, and the security is low. Summary of the invention

[0004] Multiple aspects of the present application provide an encrypted communication method, system, electronic device and storage medium with high security.

[0005] In a first aspect, an embodiment of the present application provides an encrypted communication method, which is applied to a client, and the method includes:

[0006] Sending a first handshake message to the server, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm public key corresponding to the plurality of post-quantum algorithms;

[0007] receiving a second handshake message sent by the server, where the second handshake message includes a first pre-master key component obtained after key encapsulation by the server, where the first pre-master key component is obtained by the server based on the first extended parameter and the second extended parameter;

[0008] Sending a third handshake message to the server, where the third handshake message includes a second pre-master key component corresponding to the SM2 algorithm, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message;

[0009] A target pre-master key is determined according to the first pre-master key component and the second pre-master key component to perform encrypted communication based on the target pre-master key.

[0010] Optionally, sending the first handshake information to the server includes:

[0011] Determining security priorities of multiple post-quantum algorithms supported by the client and the server during a handshake phase;

[0012] Based on the security priority, a first handshake message is sent to the server.

[0013] Optionally, after sending the first handshake information to the server, the method further includes:

[0014] If a target message sent by the server is received, the handshake action with the server is terminated, wherein the target message is a message other than the second handshake information.

[0015] Optionally, determining a target pre-master key according to the first pre-master key component and the second pre-master key component includes:

[0016] Based on a pseudo-random function, a mathematical operation is performed on the first pre-master key component and the second pre-master key component to obtain a target pre-master key.

[0017] In a second aspect, an embodiment of the present application provides an encrypted communication method, which is applied to a server, and the method includes:

[0018] Receive a first handshake message sent by a client, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm public key corresponding to the plurality of post-quantum algorithms;

[0019] Sending a second handshake message and an SM2 algorithm public key to the client, where the second handshake message includes a first pre-master key component obtained after key encapsulation by the server, where the first pre-master key component is obtained based on the first extended parameter and the second extended parameter;

[0020] Receive the third handshake information sent by the client, and obtain the second pre-master key component corresponding to the SM2 algorithm according to the third handshake information, wherein the third handshake information includes the second pre-master key component corresponding to the SM2 algorithm;

[0021] A target pre-master key is determined according to the first pre-master key component and the second pre-master key component to perform encrypted communication based on the target pre-master key.

[0022] Optionally, the sending the second handshake information to the client includes:

[0023] Based on the security line priorities of the multiple algorithm curves supported by the server, performing algorithm curve matching according to the multiple post-quantum algorithms to obtain a target curve among the multiple algorithm curves corresponding to the multiple post-quantum algorithms;

[0024] Based on the second extended parameter, determining a public key corresponding to the target curve;

[0025] Performing key encapsulation on the public key corresponding to the target curve to obtain a first pre-master key component;

[0026] Sending a second handshake message including the first pre-master key component to the client.

[0027] In a third aspect, an embodiment of the present application further provides an encrypted communication system, which is applied to a client, and the system includes:

[0028] A sending module, configured to send a first handshake message to a server, wherein the first handshake message includes a first extended parameter and a second extended parameter, wherein the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm public key corresponding to the plurality of post-quantum algorithms;

[0029] a receiving module, configured to receive second handshake information sent by the server, wherein the second handshake information includes a first pre-master key component obtained after key encapsulation by the server, and the first pre-master key component is obtained by the server based on the first extended parameter and the second extended parameter;

[0030] an acquisition module, configured to send a third handshake message to the server, wherein the third handshake message includes a second pre-master key component corresponding to the SM2 algorithm, so that the server acquires the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message;

[0031] A determination module is configured to determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key.

[0032] In a fourth aspect, an embodiment of the present application further provides an encrypted communication system, which is applied to a server, and the system includes:

[0033] A receiving module, configured to receive first handshake information sent by a client, wherein the first handshake information includes a first extended parameter and a second extended parameter, wherein the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm public key corresponding to the plurality of post-quantum algorithms;

[0034] a sending module, configured to send second handshake information and an SM2 algorithm public key to the client, wherein the second handshake information includes a first pre-master key component obtained after key encapsulation by the server, and the first pre-master key component is obtained based on the first extended parameter and the second extended parameter;

[0035] an acquisition module, configured to receive the third handshake information sent by the client, and acquire the second pre-master key component corresponding to the SM2 algorithm according to the third handshake information, wherein the third handshake information includes the second pre-master key component corresponding to the SM2 algorithm;

[0036] A determination module is configured to determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key.

[0037] In the fifth aspect, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a communication interface; wherein an executable code is stored on the memory, and when the executable code is executed by the processor, the processor executes the method described in the first aspect or the second aspect above.

[0038] In the sixth aspect, an embodiment of the present application also provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first or second aspect above.

[0039] In a seventh aspect, an embodiment of the present application further provides a computer program product, comprising: a computer program, which, when executed by a processor of an electronic device, enables the processor to execute the method described in the first or second aspect above.

[0040] In an embodiment of the present application, by adding the first extended parameter and the second extended parameter to the first handshake information and the second handshake information respectively, and obtaining the first pre-master key component in the handshake process between the client and the server, a key exchange based on the post-quantum algorithm is realized. Afterwards, a third handshake message containing the second pre-master key component corresponding to the SM2 algorithm is generated, and the third handshake message is sent to the server, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message, thereby realizing a key exchange based on the SM2 algorithm. Finally, according to the first pre-master key component and the second pre-master key component, the target pre-master key is determined, and a hybrid key exchange of the post-quantum algorithm and the SM2 algorithm is realized. Even if one of the post-quantum algorithm and the SM2 algorithm is cracked, the other algorithm can still ensure the security of data transmission, and the security is relatively high. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0042] Figure 1 A flowchart of an encrypted communication method provided for an exemplary embodiment of the present application;

[0043] Figure 2 A flowchart of sending a first handshake message to a server provided by an exemplary embodiment of the present application;

[0044] Figure 3 A flowchart of an encrypted communication method provided for an exemplary embodiment of the present application;

[0045] Figure 4 A flowchart of another encryption communication method provided for an exemplary embodiment of the present application;

[0046] Figure 5 A schematic diagram of the structure of an encrypted communication system provided for an exemplary embodiment of the present application;

[0047] Figure 6 A schematic diagram of the structure of another encrypted communication system provided for an exemplary embodiment of the present application;

[0048] Figure 7 A schematic diagram of the structure of an electronic device provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0050] The following is an explanation of the terms involved in the embodiments of the present application:

[0051] ML-KEM algorithm: refers to a Post-Quantum Cryptography (PQC) algorithm, specifically a Key Encapsulation Mechanism (KEM), which is specifically used to resist attacks from quantum computers and ensure that encrypted communications remain secure even after quantum computing becomes a reality.

[0052] The core components and processes of the ML-KEM algorithm include:

[0053] Key generation: Generate a public and private key pair. This process involves randomly selecting some polynomials and performing specific linear transformations to ensure that the public key can be shared publicly, while the private key needs to be kept secret.

[0054] Key wrapping: Allows a user who does not have a pre-shared key to wrap (encrypt) a symmetric key with the recipient's public key. This typically involves creating a ciphertext and a key-associated wrapping data so that only the recipient with the corresponding private key can decapsulate and recover the original symmetric key.

[0055] Key decapsulation: Use the private key to decrypt the previously encapsulated ciphertext and recover the symmetric key originally encapsulated by the sender. This process ensures that only the intended recipient can obtain the key used for subsequent data encryption.

[0056] In the Transport Layer Cryptographic Protocol (TLCP)

[0057] In the encryption and decryption of encrypted communications, the SM2 algorithm is often used in key links such as key exchange and digital signature to ensure the security and credibility of both parties in communication. However, in practical applications, if the SM2 algorithm is forcibly cracked, it will cause the private key to be leaked, and the security is low. In view of this, an embodiment of the present application provides an encrypted communication method.

[0058] Figure 1 A flowchart of an encrypted communication method provided in an embodiment of the present application, the method is applied to a client, such as Figure 1 As shown, the method includes:

[0059] 101. Send a first handshake message to the server, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate multiple post-quantum algorithms supported by the client, and the second extended parameter includes post-quantum cryptographic algorithm public keys corresponding to the multiple post-quantum algorithms.

[0060] 102. Receive second handshake information sent by the server, where the second handshake information includes a first pre-master key component obtained after key encapsulation by the server, where the first pre-master key component is obtained by the server based on a first extended parameter and a second extended parameter.

[0061] 103. Send a third handshake message to the server, where the third handshake message includes the second pre-master key component corresponding to the SM2 algorithm, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message.

[0062] 104. Determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key.

[0063] It should be noted that the embodiment of the present application is improved based on TLCP. The specific key exchange and encryption communication process is described below:

[0064] The client sends a first handshake message ClientHello to the server. Compared with the traditional TLCP, the ClientHello adds a first extended parameter and a second extended parameter.

[0065] Among them, the first extended parameter can be supported_groups, which is used to indicate multiple post-quantum algorithms supported by the client, that is, the first extended parameter contains a name list (also called an ID list) of multiple post-quantum algorithms supported by the client. For example, assuming that the post-quantum algorithm is the MLKEM algorithm, then the ID list can include the IDs corresponding to the post-quantum algorithms such as MLKEM512, MLKEM768 and MLKEM1024, such as the ID corresponding to MLKEM512 is "0x024A", the ID corresponding to MLKEM768 is "0x0768", and the ID corresponding to MLKEM1024 is "0x1024", which are not listed here one by one. Among them, MLKEM512, MLKEM768 and MLKEM1024 correspond to different security levels respectively. The larger the number after MLKEM, the higher the security.

[0066] The second extended parameter may be key_share, which includes multiple post-quantum cryptographic algorithm public keys corresponding to the post-quantum algorithms. The public key is used to be sent to the server, and the private key corresponding to the public key is stored locally on the client for subsequent decryption.

[0067] After receiving the first handshake message ClientHello sent by the client, the server will feedback the second handshake message ServerHello to the client. It should be noted that the first extended parameter supported_groups and the second extended parameter key_share are also added to ServerHello.

[0068] In specific implementation, the server will parse the supported_groups and key_share in the first handshake information ClientHello based on the added supported_groups and key_share to obtain the ID list of multiple post-quantum algorithms and the post-quantum cryptographic algorithm public keys corresponding to the multiple post-quantum algorithms.

[0069] Perform key encapsulation on the post-quantum cryptographic algorithm public keys corresponding to multiple post-quantum algorithms to obtain a first pre-master key component PreMasterKeyMLKEM. Send the first pre-master key component to the client via key_share in ServerHello.

[0070] After receiving the first pre-master key component, the client uses the pre-stored private key to decapsulate it to obtain the first pre-master key component.

[0071] After the handshake process based on the first handshake information and the second handshake information is completed, as an implementation method, the client generates a random number as the second pre-master key component PreMasterKeySM2 corresponding to the SM2 algorithm, and encrypts the random number using the SM2 algorithm public key sent by the server. The encrypted random number is sent to the server (that is, the third handshake information is sent to the server), so that the server decrypts the random number based on the SM2 algorithm private key corresponding to the SM2 algorithm public key to obtain the decrypted random number, that is, the second pre-master key component PreMasterKeySM2. At this time, both the client and the server have obtained the second pre-master key component PreMasterKeySM2.

[0072] As another implementation method, the key exchange is performed based on the key exchange protocol ECDH (Elliptic CurveDiffie-Hellman Key Exchange) of elliptic curve encryption. Specifically, the second handshake information includes the SM2 server key exchange parameter. After the client generates the SM2 client key exchange parameter, it sends the SM2 client key exchange parameter to the server through the third handshake information. At this time, the client and the server can determine the second pre-master key component PreMasterKeySM2 according to the "SM2 server key exchange parameter" and "SM2 client key exchange parameter" obtained by themselves.

[0073] It should be noted that in the SM2 algorithm, the pre-master key is a randomly generated large integer within a certain range. Based on this, the specific steps for generating the second pre-master key component are as follows:

[0074] S1. Select elliptic curve and base point: First, select a 256-bit elliptic curve and its base point according to the standards specified by the National Cryptography Administration.

[0075] S2. Generate private key: Randomly select a 256-bit random number as the private key to ensure the randomness and security of the private key.

[0076] S3. Calculate the public key: Use point multiplication on the elliptic curve to multiply the private key by the base point to get the public key. The public key is a point on the elliptic curve and can be expressed as (x, y) coordinates.

[0077] S4. An additional key derivation function (KDF) or hash operation may be performed based on the private key or the public key to obtain a second pre-master key component. It should be noted that the concept of the pre-master key may vary depending on specific application scenarios and requirements, and is not limited here.

[0078] Afterwards, the client and the server determine the target pre-master key PreMasterKey according to the first pre-master key component PreMasterKeyMLKEM and the second pre-master key component PreMasterKeySM2 respectively. In practical applications, the first pre-master key component can be understood as a 32-byte random number, and the second pre-master key component can be understood as a 48-byte random number. In order to obtain the final target pre-master key according to the first pre-master key component and the second pre-master key component, the first pre-master key component and the second pre-master key component can be mathematically operated based on a pseudo-random function to obtain the target pre-master key. The specific formula is as follows:

[0079] MLPreKEMMasterKey=PRF(PreMasterKeyMLKEM, "PreMasterKey", ClientHello.random+ ServerHello.random)[0..47]; the hash algorithm in the pseudo-random function PRF is the hash algorithm in the selected cipher suite.

[0080] PreMasterKey= PreMasterKeySM2 xor PreMasterKeyMLKEM.

[0081] After obtaining the target pre-master key, a working key can be generated based on the target pre-master key to perform subsequent encrypted communication work. This process is a common process for generating a working key based on a pre-master key and will not be repeated here.

[0082] It should be noted that in the above-mentioned handshake process between the client and the server, the client can request the corresponding extended function of the server through the first extended parameter. When the client requests a function unexpected to the first extended parameter and the server does not support the function, the client may disconnect the handshake. The server must receive the first handshake information with or without the first extended parameter / second extended parameter, and parse the first handshake information with the first extended parameter / second extended parameter. If it finds any content that cannot be parsed, it does not need to be processed.

[0083] The encryption communication method provided in the embodiment of the present application realizes the key exchange based on the post-quantum algorithm by respectively adding the first extended parameter and the second extended parameter to the first handshake information and the second handshake information, and obtaining the first pre-master key component in the handshake process between the client and the server. Afterwards, a third handshake information containing the second pre-master key component corresponding to the SM2 algorithm is generated, and the third handshake information is sent to the server, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake information, thereby realizing the key exchange based on the SM2 algorithm. Finally, according to the first pre-master key component and the second pre-master key component, the target pre-master key is determined, and the hybrid key exchange of the post-quantum algorithm and the SM2 algorithm is realized. Even if one of the post-quantum algorithm and the SM2 algorithm is cracked, the other algorithm can still ensure the security of data transmission, and the security is relatively high.

[0084] Figure 2 The flowchart of sending the first handshake information to the server provided in the embodiment of the present application is as follows: Figure 2 As shown, the method includes:

[0085] 201. Determine the security priorities of multiple post-quantum algorithms supported by the client and server during the handshake phase.

[0086] 202. Based on the security priority, send first handshake information to the server.

[0087] In practical applications, the first handshake information includes multiple post-quantum algorithms. In order to ensure the security of information transmission, the embodiment of the present application sends the first handshake information to the server based on the security priorities of the multiple post-quantum algorithms.

[0088] For ease of understanding, let's take a look at the following code as an example:

[0089] enum {

[0090] / * MLKEM* /

[0091] mlkem1024(0x1024), mlkem768(0x0768), mlkem512(0x024A)

[0092] } NamedGroup;

[0093] struct {

[0094] NamedGroup named_group_list<2..2^16-1>;

[0095] } NamedGroupList;

[0096] Among them, NamedGroup represents the IDs of multiple post-quantum algorithms, and NamedGroupList represents the ID list of multiple post-quantum algorithms. In the above example, the ID list includes the IDs corresponding to MLKEM512, MLKEM768 and MLKEM1024, such as the ID corresponding to MLKEM512 is "0x024A", the ID corresponding to MLKEM768 is "0x0768", and the ID corresponding to MLKEM1024 is "0x1024". Among them, MLKEM512, MLKEM768 and MLKEM1024 correspond to different security levels respectively. The larger the number after MLKEM, the higher the security. When sending data to the server, according to the above security priority, it is sent in the following order: MLKEM1024, MLKEM768, MLKEM512.

[0097] In addition, in the first handshake message ClientHello, the second extended parameter key_share contains a KeyShareClientHello value:

[0098] struct {

[0099] KeyShareEntry client_shares<0..2^16-1>;

[0100] }KeyShareClientHello;

[0101] Furthermore, in the second extended parameter key_share, it specifically includes: the IDs of the above-mentioned multiple post-quantum algorithms, and the public keys of the MLKEM algorithms corresponding to the IDs of the multiple post-quantum algorithms. The specific examples are as follows:

[0102] struct {

[0103] NamedGroup group;

[0104] opaque key_exchange<1..2^16-1>;

[0105] }KeyShareEntry;

[0106] Among them, opaque key_exchang indicates that this is binary key exchange data.

[0107] In actual applications, the public key of the corresponding MLKEM algorithm (such as MLKEM768) can be obtained through "NamedGroup". In specific implementation, the client can send all the public keys of the post-quantum algorithms it supports to the server at one time. "NamedGroup" must be defined in supported_groups. For example, assuming that the following IDs are defined in supported_groups: "0x024A" and "0x0768", which correspond to the MLKEM512 and MLKEM768 post-quantum algorithms respectively, then if "0x1024" is defined in key_share at this time, which corresponds to the MLKEM1024 post-quantum algorithm, the definition of "0x1024" will not be supported in actual applications.

[0108] Figure 3 A flowchart of an encrypted communication method provided in an embodiment of the present application, such as Figure 3 As shown, the method includes:

[0109] 301. Send first handshake information to the server.

[0110] 302. If a target message sent by the server is received, the handshake action with the server is terminated, wherein the target message is a message other than the second handshake information.

[0111] In actual applications, after the client sends the first handshake message to the server, it will wait for the server to return the second handshake message based on the first handshake message. However, the server does not necessarily return the second handshake message corresponding to the first handshake message. If the client receives the target message sent by the server, that is, a message other than the second handshake message, in order to avoid errors in the current handshake process, the client will end the current handshake action with the server.

[0112] Figure 4 A flowchart of another encryption communication method provided in an embodiment of the present application, the method is applied to a server, such as Figure 4 As shown, the method includes:

[0113] 401. Receive a first handshake message sent by a client, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate multiple post-quantum algorithms supported by the client, and the second extended parameter includes post-quantum cryptographic algorithm public keys corresponding to the multiple post-quantum algorithms.

[0114] 402. Send a second handshake message and an SM2 algorithm public key to the client, where the second handshake message includes a first pre-master key component obtained after key encapsulation by the server, where the first pre-master key component is obtained based on the first extended parameter and the second extended parameter.

[0115] 403. Receive the third handshake information sent by the client, and obtain the second pre-master key component corresponding to the SM2 algorithm according to the third handshake information, wherein the third handshake information includes the second pre-master key component corresponding to the SM2 algorithm.

[0116] 404. Determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key.

[0117] Figure 4 The method shown can execute the steps in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.

[0118] In an embodiment of the present application, sending the second handshake information to the client includes:

[0119] Based on the security line priorities of multiple algorithm curves supported by the server, algorithm curve matching is performed according to multiple post-quantum algorithms to obtain target curves corresponding to multiple post-quantum algorithms in the multiple algorithm curves;

[0120] Based on the second extended parameter, determining a public key corresponding to the target curve;

[0121] Perform key encapsulation on the public key corresponding to the target curve to obtain a first pre-master key component;

[0122] A second handshake message including the first pre-master key component is sent to the client.

[0123] In actual applications, after parsing the first extended parameter supported_groups and the second extended parameter key_share sent by the client, the server can obtain the ID list of multiple post-quantum algorithms in the first extended parameter supported_groups and the public key list of the post-quantum algorithm in the second extended parameter key_share (the list records the public keys corresponding to the MLKEM512, MLKEM768 post-quantum algorithms, etc.).

[0124] In the process of the server processing the first extended parameter supported_groups and the second extended parameter key_share sent by the server to the client, the order of processing multiple post-quantum algorithms can be determined according to the security line priority of multiple algorithm curves supported by the server. Specifically, each algorithm curve supported by the server is compared with multiple post-quantum algorithms respectively, and it is checked whether there is a post-quantum algorithm corresponding to the algorithm curve of the server in the ID list of multiple post-quantum algorithms. If so, the curve is selected, otherwise, the next algorithm curve of the server is compared until all the algorithm curves of the server are compared with the multiple post-quantum algorithms sent by the client.

[0125] According to the target curve IDs corresponding to the multiple post-quantum algorithms in the multiple algorithm curves, the corresponding post-quantum algorithm public key is searched in the second extended parameter key_share. For unmatched algorithm curves, this process is skipped.

[0126] For ease of understanding, for distance, assume that the multiple post-quantum algorithms sent by the client are B, C, and D in descending order of security priority, and the security line priorities of the multiple algorithm curves supported by the server are A, B, C, D, and E. Then, "B, C, D" is matched with "A, B, C, D, E", and finally "B, C, D" is determined as the target curve corresponding to the multiple post-quantum algorithms in the multiple algorithm curves. It should be understood that for ease of description, "A, B, C, D, E" is assumed to be the algorithm curve ID. According to the final matched "B, C, D", the corresponding post-quantum algorithm public key is searched in the second extended parameter key_share.

[0127] The found post-quantum algorithm public key is used for key encapsulation to obtain the first pre-master key component PreMasterKeyMLKEM, and the encapsulated first pre-master key component PreMasterKeyMLKEM is placed in the second extended parameter key_share in the second handshake message ServerHello and sent to the client. After receiving the second handshake message ServerHello, the client uses its pre-saved private key to decapsulate and obtain the first pre-master key component PreMasterKeyMLKEM.

[0128] Based on the above, the encryption communication method provided by the embodiment of the present application realizes the key exchange based on the post-quantum algorithm by adding the first extended parameter and the second extended parameter to the first handshake information and the second handshake information respectively, and obtaining the first pre-master key component in the handshake process between the client and the server. Afterwards, a third handshake message containing the second pre-master key component corresponding to the SM2 algorithm is generated, and the third handshake message is sent to the server, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message. At this time, both the client and the server obtain the second pre-master key component corresponding to the SM2 algorithm, and the key exchange based on the SM2 algorithm is realized. Finally, according to the first pre-master key component and the second pre-master key component, the target pre-master key is determined, and the hybrid key exchange of the post-quantum algorithm and the SM2 algorithm is realized. Even if one of the post-quantum algorithm and the SM2 algorithm is cracked, the other algorithm can still ensure the security of data transmission, and the security is relatively high.

[0129] Figure 5 A schematic diagram of the structure of an encrypted communication system provided in an embodiment of the present application, the system is applied to a client, such as Figure 5 As shown, the system includes: a sending module 51, a receiving module 52, an acquiring module 53, and a determining module 54.

[0130] The sending module 51 is used to send a first handshake message to the server. The first handshake message includes a first extended parameter and a second extended parameter. The first extended parameter is used to indicate multiple post-quantum algorithms supported by the client, and the second extended parameter includes post-quantum cryptographic algorithm public keys corresponding to multiple post-quantum algorithms.

[0131] The receiving module 52 is used to receive the second handshake information sent by the server, where the second handshake information includes the first pre-master key component obtained after key encapsulation by the server, and the first pre-master key component is obtained by the server based on the first extended parameter and the second extended parameter.

[0132] The acquisition module 53 is used to send third handshake information to the server, where the third handshake information includes the second pre-master key component corresponding to the SM2 algorithm, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake information.

[0133] The determination module 54 is configured to determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key.

[0134] Optionally, the sending module 51 is specifically used to: determine the security priorities of multiple post-quantum algorithms supported by the client and the server in the handshake phase; and send first handshake information to the server based on the security priority.

[0135] Optionally, the system further includes: a processing module, configured to terminate the handshake action with the server if a target message sent by the server is received, wherein the target message is not a message of the second handshake information.

[0136] Optionally, the determining module 54 is specifically configured to: perform a mathematical operation on the first pre-master key component and the second pre-master key component based on a pseudo-random function to obtain a target pre-master key.

[0137] Figure 5 The system shown can execute the steps in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.

[0138] Figure 6 A schematic diagram of the structure of another encrypted communication system provided in an embodiment of the present application, the system is applied to a server, such as Figure 6 As shown, the system includes: a receiving module 61, a sending module 62, an acquiring module 63, and a determining module 64.

[0139] The receiving module 61 is used to receive a first handshake message sent by the client, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate multiple post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm key pair corresponding to the multiple post-quantum algorithms, where the key pair includes a public key and a private key.

[0140] The sending module 62 is used to send a second handshake message and an SM2 algorithm public key to the client, wherein the second handshake message includes a first pre-master key component obtained after key encapsulation by the server, and the first pre-master key component is obtained based on the first extended parameter and the second extended parameter.

[0141] The acquisition module 63 is configured to receive the third handshake information sent by the client, and acquire the second pre-master key component corresponding to the SM2 algorithm according to the third handshake information, wherein the third handshake information includes the second pre-master key component corresponding to the SM2 algorithm.

[0142] The determination module 64 is configured to determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key.

[0143] Optionally, the sending module 62 is specifically configured to:

[0144] Based on the security line priorities of the multiple algorithm curves supported by the server, performing algorithm curve matching according to the multiple post-quantum algorithms to obtain a target curve among the multiple algorithm curves corresponding to the multiple post-quantum algorithms;

[0145] Based on the second extended parameter, determining a public key corresponding to the target curve;

[0146] Performing key encapsulation on the public key corresponding to the target curve to obtain a first pre-master key component;

[0147] Sending a second handshake message including the first pre-master key component to the client.

[0148] Figure 6 The system shown can execute the steps in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.

[0149] The present application also provides an electronic device, such as Figure 7 As shown, the electronic device may include: a processor 71, a memory 72, and a communication interface 73. The memory 72 stores executable codes, and when the executable codes are executed by the processor 71, the processor 71 implements the encryption communication method in the above-mentioned embodiment.

[0150] In addition, an embodiment of the present application provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the encryption communication method provided in the aforementioned embodiment.

[0151] An embodiment of the present application provides a computer program product, which includes: a computer program, when the computer program is executed by a processor of an electronic device, the processor executes the encryption communication method provided in the above-mentioned embodiment.

[0152] 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 combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0153] 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 embodiments of 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 generate 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.

[0154] 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 comprising 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.

[0155] 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 1 The steps for the functions specified in one or more boxes.

[0156] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0157] Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0158] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0159] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0160] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. An encrypted communication method, characterized in that: Applied to a client, the method comprises: Sending a first handshake message to the server, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm public key corresponding to the plurality of post-quantum algorithms; receiving a second handshake message sent by the server, where the second handshake message includes a first pre-master key component obtained after key encapsulation by the server, where the first pre-master key component is obtained by the server based on the first extended parameter and the second extended parameter; Sending a third handshake message to the server, where the third handshake message includes a second pre-master key component corresponding to the SM2 algorithm, so that the server obtains the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message; determining a target pre-master key based on the first pre-master key component and the second pre-master key component to perform encrypted communication based on the target pre-master key; The sending of the first handshake information to the server includes: determining the security priorities of multiple post-quantum algorithms supported by the client and the server in the handshake phase; and sending the first handshake information to the server based on the security priorities.

2. The method according to claim 1, characterized in that After sending the first handshake information to the server, the method further includes: If a target message sent by the server is received, the handshake action with the server is terminated, wherein the target message is a message other than the second handshake information.

3. The method according to claim 1, characterized in that The determining a target pre-master key according to the first pre-master key component and the second pre-master key component includes: Based on a pseudo-random function, a mathematical operation is performed on the first pre-master key component and the second pre-master key component to obtain a target pre-master key.

4. An encrypted communication method, characterized in that: Applied to a server, the method comprises: Receive a first handshake message sent by a client, where the first handshake message includes a first extended parameter and a second extended parameter, where the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm public key corresponding to the plurality of post-quantum algorithms; Sending a second handshake message and an SM2 algorithm public key to the client, where the second handshake message includes a first pre-master key component obtained after key encapsulation by the server, where the first pre-master key component is obtained based on the first extended parameter and the second extended parameter; receiving a third handshake message sent by the client, and acquiring a second pre-master key component corresponding to the SM2 algorithm according to the third handshake message, wherein the third handshake message includes the second pre-master key component corresponding to the SM2 algorithm; determining a target pre-master key based on the first pre-master key component and the second pre-master key component to perform encrypted communication based on the target pre-master key; The sending of the second handshake information to the client includes: based on the security line priorities of the multiple algorithm curves supported by the server, performing algorithm curve matching according to the multiple post-quantum algorithms to obtain target curves corresponding to the multiple post-quantum algorithms among the multiple algorithm curves; based on the second extended parameter, determining a public key corresponding to the target curve; performing key encapsulation on the public key corresponding to the target curve to obtain a first pre-master key component; and sending the second handshake information including the first pre-master key component to the client.

5. An encrypted communication system, characterized in that: Applied to a client, the system comprises: A sending module, configured to send a first handshake message to a server, wherein the first handshake message includes a first extended parameter and a second extended parameter, wherein the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm key pair corresponding to the plurality of post-quantum algorithms, wherein the key pair includes a public key and a private key; a receiving module, configured to receive second handshake information sent by the server, wherein the second handshake information includes a first pre-master key component obtained after key encapsulation by the server, and the first pre-master key component is obtained by the server based on the first extended parameter and the second extended parameter; an acquisition module, configured to send a third handshake message to the server, wherein the third handshake message includes a second pre-master key component corresponding to the SM2 algorithm, so that the server acquires the second pre-master key component corresponding to the SM2 algorithm based on the third handshake message; a determination module, configured to determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key; The sending module is specifically used to: determine the security priorities of multiple post-quantum algorithms supported by the client and the server in the handshake phase; and send first handshake information to the server based on the security priority.

6. An encrypted communication system, characterized in that: Applied to a server, the system comprises: A receiving module, configured to receive a first handshake message sent by a client, wherein the first handshake message includes a first extended parameter and a second extended parameter, wherein the first extended parameter is used to indicate a plurality of post-quantum algorithms supported by the client, and the second extended parameter includes a post-quantum cryptographic algorithm key pair corresponding to the plurality of post-quantum algorithms, wherein the key pair includes a public key and a private key; a sending module, configured to send second handshake information and an SM2 algorithm public key to the client, wherein the second handshake information includes a first pre-master key component obtained after key encapsulation by the server, and the first pre-master key component is obtained based on the first extended parameter and the second extended parameter; an acquisition module, configured to receive the third handshake information sent by the client, and acquire the second pre-master key component corresponding to the SM2 algorithm according to the third handshake information, wherein the third handshake information includes the second pre-master key component corresponding to the SM2 algorithm; a determination module, configured to determine a target pre-master key according to the first pre-master key component and the second pre-master key component, so as to perform encrypted communication based on the target pre-master key; The sending module is specifically used to: based on the security line priorities of multiple algorithm curves supported by the server, perform algorithm curve matching according to the multiple post-quantum algorithms to obtain a target curve corresponding to the multiple post-quantum algorithms among the multiple algorithm curves; based on the second extended parameter, determine a public key corresponding to the target curve; perform key encapsulation on the public key corresponding to the target curve to obtain a first pre-master key component; and send a second handshake information containing the first pre-master key component to the client.

7. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the encryption communication method as described in any one of claims 1 to 3 or claim 4.

8. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the encryption communication method as described in any one of claims 1 to 3 or claim 4.

9. A computer program product, characterized in that include: A computer program, when executed by a processor of an electronic device, causes the processor to execute the encryption communication method according to any one of claims 1 to 3 or claim 4.

Citation Information

Patent Citations

  • Ciphertext sending method, device and system, storage medium and electronic equipment

    CN114826637A

  • Key exchange method and system, electronic equipment and storage medium

    CN115695003A