Session key generation method and device, electronic equipment and storage medium

By integrating national cryptographic key encapsulation and post-quantum key encapsulation algorithms to generate session keys, the security problem of post-quantum cryptography algorithms in a quantum computing environment is solved, and high-security communication in a quantum computing environment is achieved.

CN120856331BActive Publication Date: 2025-11-25SHANGHAI TURING INTELLIGENT COMPUTING QUANTUM TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511325887.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-17
Publication Date
2025-11-25
Estimated Expiration
2045-09-17

AI Technical Summary

Technical Problem

Post-quantum cryptography algorithms face problems such as insufficient security proofs and inability to meet existing security evaluation standards in practical applications, resulting in insufficient communication security, especially posing a threat in quantum computing environments.

Method used

The session key is generated by combining the national cryptographic key encapsulation algorithm and the post-quantum key encapsulation algorithm. Through dual key encapsulation and decapsulation between the client and the server, it is ensured that even if one algorithm is compromised, the other algorithm can still guarantee communication security.

Benefits of technology

It improves communication security in the post-quantum migration stage. By integrating dual-key encapsulation algorithms, it ensures that even if one algorithm is compromised, the other algorithm can still maintain communication security, thus enhancing the system's resistance to quantum computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120856331B_ABST
    Figure CN120856331B_ABST
Patent Text Reader

Abstract

The application provides a session key generation method and device, electronic equipment and storage medium, and relates to the technical field of data security. In the method, the client and the server each generate a post-quantum key pair and a national secret key pair, the client and the server perform post-quantum key encapsulation and national secret key encapsulation based on the post-quantum public key and the national secret public key of the other party, respectively, generate corresponding ciphertexts and shared keys, then encapsulate the ciphertext generated by the other party through the post-quantum private key and the national secret private key of the self, and obtain the shared key generated by the other party, and finally, the two parties generate a unified session key based on the four shared keys, which is used for encryption and decryption and authentication in subsequent communication. The session key between the client and the server is generated by fusing the national secret key encapsulation algorithm and the post-quantum key encapsulation algorithm, so that even if one algorithm is broken, the other algorithm can still guarantee the communication security, and the communication security in the post-quantum migration stage is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data security technology, and more specifically, to a session key generation method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the increasing demands for internet security, Transport Layer Security (TLS) protocols are widely used as a core technology for ensuring network communication security. Traditional TLS protocols rely on classical cryptographic algorithms for authentication and key exchange. However, with the development of quantum computing technology, cryptographic systems based on classical mathematical problems face potential threats. Post-quantum cryptography has emerged to address this need, aiming to design novel cryptographic algorithms that can resist quantum computing attacks.

[0003] The KEMTLS protocol, as a post-quantum alternative to the TLS protocol, is optimized to address the key and ciphertext inflation problem inherent in post-quantum cryptography algorithms. This protocol employs a Key Encapsulation Mechanism (KEM) instead of traditional signature authentication, merging the authentication and key exchange processes. This significantly reduces the number of handshake rounds and message size, thereby improving protocol efficiency.

[0004] While post-quantum cryptography algorithms are theoretically resistant to quantum computing attacks, they face numerous challenges in practical applications, such as a lack of effective security proofs and inability to meet existing security evaluation standards. Furthermore, their standardization process is still under development. Therefore, improving communication security in the post-quantum transition phase is an urgent problem to be solved. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a session key generation method, apparatus, electronic device and storage medium, which generates a session key between the client and the server by integrating the national cryptographic key encapsulation algorithm and the post-quantum key encapsulation algorithm. Even if one algorithm is compromised, the other algorithm can still ensure communication security, which greatly improves the communication security in the post-quantum migration stage.

[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:

[0007] In a first aspect, the present invention provides a session key generation method, applied to a server, the method comprising:

[0008] The client receives a first post-quantum ciphertext, a first national cryptographic ciphertext, a public key from a first post-quantum key pair, and a public key from a first national cryptographic key pair. The first post-quantum key pair and the first national cryptographic key pair are generated by the client. The client performs post-quantum key encapsulation based on the public key from the server's second post-quantum key pair to obtain the first post-quantum ciphertext and the first post-quantum shared key. The client also performs national cryptographic key encapsulation based on the public key from the server's second national cryptographic key pair to obtain the first national cryptographic ciphertext and the first national cryptographic shared key.

[0009] Based on the private key in the second post-quantum key pair and the first post-quantum ciphertext, post-quantum key decapsulation is performed to obtain the first post-quantum shared key; based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext, national cryptographic key decapsulation is performed to obtain the first national cryptographic shared key;

[0010] Based on the public key in the first post-quantum key pair, post-quantum key encapsulation is performed to obtain the second post-quantum ciphertext and the second post-quantum shared key; based on the public key in the first national cryptographic key pair, national cryptographic key encapsulation is performed to obtain the second national cryptographic ciphertext and the second national cryptographic shared key.

[0011] A session key is generated based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key;

[0012] The second post-quantum ciphertext and the second national cryptographic ciphertext are sent to the client, so that the client performs post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; and generates the session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0013] In an optional implementation, the step of decapsulating the first national cryptographic shared key based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext includes:

[0014] Based on the private key in the second national cryptographic key pair and the preset national cryptographic decryption algorithm, the first national cryptographic ciphertext is decrypted to obtain the first plaintext corresponding to the first national cryptographic ciphertext.

[0015] Based on the first plaintext, the public key in the second national cryptographic key pair, and the preset first hash function, the first hash value and the second hash value are obtained;

[0016] Based on the second hash value, the public key in the second national cryptographic key pair, and the preset national cryptographic encryption algorithm, the first plaintext is encrypted to obtain the ciphertext corresponding to the first plaintext;

[0017] If the first national cryptographic ciphertext is the same as the ciphertext corresponding to the first plaintext, then the first national cryptographic shared key is obtained based on the first hash value, the first national cryptographic ciphertext, and a preset key derivation function; if the first national cryptographic ciphertext is different from the ciphertext corresponding to the first plaintext, then the third national cryptographic shared key is obtained based on the first random number, the first national cryptographic ciphertext, and a preset key derivation function; the third national cryptographic shared key is different from the first national cryptographic shared key; the first random number is obtained during the generation of the second national cryptographic key pair.

[0018] In an optional implementation, obtaining the first hash value and the second hash value based on the first plaintext, the public key in the second national cryptographic key pair, and a preset first hash function includes:

[0019] Input the public key from the second national cryptographic key pair into a preset second hash function to obtain the hash value corresponding to the public key of the second national cryptographic key pair;

[0020] The first plaintext is concatenated with the hash value corresponding to the public key in the second national cryptographic key pair, and then input into a preset first hash function to obtain the first hash value and the second hash value.

[0021] In an optional implementation, obtaining the first national cryptographic shared key based on the first hash value, the first national cryptographic ciphertext, and a preset key derivation function includes:

[0022] The first national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with the first hash value and then input into a preset key derivation function to obtain the first national cryptographic shared key;

[0023] The process of obtaining the third national cryptographic shared key based on the first random number, the first national cryptographic ciphertext, and a preset key derivation function includes:

[0024] The first national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with the first random number and then input into a preset key derivation function to obtain the third national cryptographic shared key.

[0025] In an optional implementation, the step of encapsulating the public key in the first national cryptographic key pair with a national cryptographic key to obtain the second national cryptographic ciphertext and the second national cryptographic shared key includes:

[0026] Generate a second random number;

[0027] Based on the second random number, the public key in the first national cryptographic key pair, and the preset first hash function, the third hash value and the fourth hash value are obtained;

[0028] Based on the fourth hash value, the public key in the first national cryptographic key pair, and the preset national cryptographic encryption algorithm, the second random number is encrypted to obtain the second national cryptographic ciphertext;

[0029] Based on the second national cryptographic ciphertext, the third hash value, and the preset key derivation function, the second national cryptographic shared key is obtained.

[0030] In an optional implementation, obtaining the third hash value and the fourth hash value based on the second random number, the public key in the first national cryptographic key pair, and a preset first hash function includes:

[0031] Input the public key from the first national cryptographic key pair into a preset second hash function to obtain the hash value corresponding to the public key from the first national cryptographic key pair;

[0032] The second random number is concatenated with the hash value corresponding to the public key in the first national cryptographic key pair, and then input into a preset first hash function to obtain the third hash value and the fourth hash value.

[0033] In an optional implementation, obtaining the second national cryptographic shared key based on the second national cryptographic ciphertext, the third hash value, and a preset key derivation function includes:

[0034] The second national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the second national cryptographic ciphertext;

[0035] The hash value corresponding to the second national cryptographic ciphertext is concatenated with the third hash value and then input into a preset key derivation function to obtain the second national cryptographic shared key.

[0036] In an optional implementation, the second national cryptographic key pair of the server is generated through the following steps:

[0037] An initial national cryptographic key pair is generated based on a preset national cryptographic key generation algorithm;

[0038] Generate the first random number;

[0039] The second national cryptographic key pair is obtained based on the initial national cryptographic key pair and the first random number; wherein the public key in the second national cryptographic key pair is the same as the public key in the initial national cryptographic key pair, and the private key in the second national cryptographic key pair is obtained by concatenating the private key in the initial national cryptographic key pair with the first random number.

[0040] Secondly, the present invention provides a session key generation method, applied to a client, the method comprising:

[0041] The first post-quantum key pair is generated according to the preset post-quantum key generation algorithm, and the first national cryptographic key pair is generated according to the preset national cryptographic key generation algorithm.

[0042] Based on the public key in the second post-quantum key pair on the server, post-quantum key encapsulation is performed to obtain the first post-quantum ciphertext and the first post-quantum shared key; based on the public key in the second national cryptographic key pair on the server, national cryptographic key encapsulation is performed to obtain the first national cryptographic ciphertext and the first national cryptographic shared key;

[0043] The first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair are sent to the server. The server then performs post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key; performs post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; performs national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key; and generates a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0044] Receive the second post-quantum ciphertext and the second national cryptographic ciphertext sent by the server;

[0045] Based on the private key in the first post-quantum key pair and the second post-quantum ciphertext, post-quantum key decapsulation is performed to obtain the second post-quantum shared key; based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext, national cryptographic key decapsulation is performed to obtain the second national cryptographic shared key;

[0046] The session key is generated based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0047] Thirdly, the present invention provides a session key generation device for use on a server, the device comprising:

[0048] The first receiving module is configured to receive a first post-quantum ciphertext, a first national cryptographic ciphertext, a public key in a first post-quantum key pair, and a public key in a first national cryptographic key pair sent by a client; wherein, the first post-quantum key pair and the first national cryptographic key pair are generated by the client, and the client performs post-quantum key encapsulation based on the public key in the second post-quantum key pair of the server to obtain the first post-quantum ciphertext and the first post-quantum shared key, and performs national cryptographic key encapsulation based on the public key in the second national cryptographic key pair of the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key;

[0049] The first key decapsulation module is used to perform post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; and to perform national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key.

[0050] The first key encapsulation module is used to perform post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; and to perform national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key.

[0051] The first session key generation module is used to generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key;

[0052] The first sending module is configured to send the second post-quantum ciphertext and the second national cryptographic ciphertext to the client, so that the client performs post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; and generates the session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0053] Fourthly, the present invention provides a session key generation apparatus for use on a client, the apparatus comprising:

[0054] The key generation module is used to generate a first post-quantum key pair according to a preset post-quantum key generation algorithm, and to generate a first national cryptographic key pair according to a preset national cryptographic key generation algorithm.

[0055] The second key encapsulation module is used to perform post-quantum key encapsulation based on the public key in the second post-quantum key pair on the server to obtain the first post-quantum ciphertext and the first post-quantum shared key; and to perform national cryptographic key encapsulation based on the public key in the second national cryptographic key pair on the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key.

[0056] The second sending module is configured to send the first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair to the server, so that the server performs post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key; performs post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; performs national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key; and generates a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0057] The second receiving module is used to receive the second post-quantum ciphertext and the second national cryptographic ciphertext sent by the server;

[0058] The second key decapsulation module is used to perform post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; and to perform national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key.

[0059] The second session key generation module is used to generate the session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0060] Fifthly, the present invention provides an electronic device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the session key generation method as described in any of the foregoing embodiments.

[0061] In a sixth aspect, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the session key generation method as described in any of the foregoing embodiments.

[0062] The session key generation method, apparatus, electronic device, and storage medium provided in this invention involve a server receiving a first post-quantum ciphertext, a first national cryptographic ciphertext, a public key from a first post-quantum key pair, and a public key from a first national cryptographic key pair sent by a client. The first post-quantum key pair and the first national cryptographic key pair are generated by the client. The client performs post-quantum key encapsulation based on the public key from the server's second post-quantum key pair to obtain the first post-quantum ciphertext and the first post-quantum shared key. The client also performs national cryptographic key encapsulation based on the public key from the server's second national cryptographic key pair to obtain the first national cryptographic ciphertext and the first national cryptographic shared key. Finally, the client performs post-quantum key decapsulation based on the private key from the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key. Finally, the client performs national cryptographic key decapsulation based on the private key from the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key. The process involves: encapsulating the public key in the first post-quantum key pair with a post-quantum key to obtain a second post-quantum ciphertext and a second post-quantum shared key; encapsulating the public key in the first national cryptographic key pair with a national cryptographic key to obtain a second national cryptographic ciphertext and a second national cryptographic shared key; generating a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key; sending the second post-quantum ciphertext and the second national cryptographic ciphertext to the client, enabling the client to decapsulate the post-quantum key using the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; decapsulating the national cryptographic key using the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; and generating a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key. By integrating the national cryptographic key encapsulation algorithm and the post-quantum key encapsulation algorithm to generate the session key between the client and the server, even if one algorithm is compromised, the other algorithm can still ensure communication security, greatly improving the communication security during the post-quantum migration phase.

[0063] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0064] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0065] Figure 1 A schematic diagram of an application environment applicable to an embodiment of the present invention is shown;

[0066] Figure 2 This illustration shows a flowchart of a session key generation method applied to a server according to an embodiment of the present invention;

[0067] Figure 3 This illustration shows a flowchart of a session key generation method for a client provided by an embodiment of the present invention;

[0068] Figure 4 A schematic diagram illustrating the interaction between the server and the client is shown.

[0069] Figure 5 This diagram illustrates a functional block diagram of a session key generation device applied to a server, as provided in an embodiment of the present invention.

[0070] Figure 6 This invention illustrates a functional block diagram of a session key generation device applied to a client, according to an embodiment of the present invention.

[0071] Figure 7 A block diagram of an electronic device provided in an embodiment of the present invention is shown.

[0072] Icons: 100 - Server; 200 - Client; 700 - Electronic device; 510 - First receiving module; 520 - First key decapsulation module; 530 - First key encapsulation module; 540 - First session key generation module; 550 - First sending module; 610 - Key generation module; 620 - Second key encapsulation module; 630 - Second sending module; 640 - Second receiving module; 650 - Second key decapsulation module; 660 - Second session key generation module; 710 - Memory; 720 - Processor; 730 - Communication module. Detailed Implementation

[0073] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0074] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0075] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0076] Please refer to Figure 1 This is a schematic diagram of an application environment applicable to an embodiment of the present invention. The server 100 and client 200 are communicatively connected, and data communication or interaction between the server 100 and client 200 occurs via a network. The client 200 can be understood as the party initiating the communication request, such as a browser, mobile application, or terminal device (e.g., smartphone, tablet, laptop, desktop computer, etc.); the server 100 can be understood as the party responding to the communication request, typically a server providing services, such as a web server or cloud service platform.

[0077] In this embodiment, before communicating, the server 100 and the client 200 can negotiate a session key through protocols such as KEMTLS and TLS, which will be used for encryption, decryption and authentication in subsequent communications.

[0078] Please refer to Figure 2 This is a flowchart illustrating a session key generation method applied to the aforementioned server 100 according to an embodiment of the present invention. It should be noted that the session key generation method of this embodiment is not based on... Figure 2 The specific order described below is a limitation. It should be understood that in other embodiments, the order of some steps in the session key generation method of this invention can be interchanged according to actual needs, or some steps can be omitted or deleted. The following will describe... Figure 2 The specific process shown will be explained in detail.

[0079] Step S201: Receive the first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair sent by the client; wherein, the first post-quantum key pair and the first national cryptographic key pair are generated by the client, the client performs post-quantum key encapsulation based on the public key in the second post-quantum key pair of the server to obtain the first post-quantum ciphertext and the first post-quantum shared key, and performs national cryptographic key encapsulation based on the public key in the second national cryptographic key pair of the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key.

[0080] In this embodiment, the second post-quantum key pair and the second national cryptographic key pair of the server 100 can be generated on the server 100, or generated on other devices and configured on the server 100. The public keys in the second post-quantum key pair and the second national cryptographic key pair of the server 100 can be pre-stored on the client 200, or the client 200 can obtain them from the server 100 before the handshake begins, so that the client 200 can use the public keys in the second post-quantum key pair and the second national cryptographic key pair to perform corresponding key encapsulation operations during the handshake process. After the handshake begins, the client 200 first needs to generate the first post-quantum key pair and the first national cryptographic key pair. Then, based on the public key in the second post-quantum key pair of the server 100, it uses the key encapsulation algorithm in the existing post-quantum KEM algorithm to perform post-quantum key encapsulation, obtaining the first post-quantum ciphertext and the first post-quantum shared key. Based on the public key in the second national cryptographic key pair of the server 100, it uses the key encapsulation algorithm in the KEM algorithm based on the national cryptographic algorithm designed in this embodiment to perform national cryptographic key encapsulation, obtaining the first national cryptographic ciphertext and the first national cryptographic shared key. Next, the client 200 sends the generated first post-quantum ciphertext, the first national cryptographic ciphertext, and the public key in its own first post-quantum key pair and the public key in its first national cryptographic key pair to the server 100, so that the server 100 can perform the corresponding key decapsulation and key encapsulation operations.

[0081] It should be noted that in this embodiment, the first and second post-quantum key pairs can be generated using the key generation algorithm in the existing post-quantum KEM algorithm, and the first and second national cryptographic key pairs can be generated using the key generation algorithm in the KEM algorithm based on the national cryptographic algorithm designed in this embodiment. Here, the national cryptographic algorithm refers to domestically developed cryptographic algorithms, mainly including SM1, SM2, SM3, and SM4. This embodiment mainly uses the SM2 algorithm as an example for explanation.

[0082] Step S202: Decapsulate the post-quantum key based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; decapsulate the national cryptographic key based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key.

[0083] In this embodiment, since the first post-quantum ciphertext is obtained by the client 200 using the public key in the second post-quantum key pair of the server 100 for post-quantum key encapsulation, the server 100 can recover the first post-quantum shared key generated by the client 200 during the post-quantum key encapsulation process by decapsulating the private key in the second post-quantum key pair with the first post-quantum ciphertext. Similarly, since the first national cryptographic ciphertext is obtained by the client 200 using the public key in the second national cryptographic key pair of the server 100 for national cryptographic key encapsulation, the server 100 can recover the first national cryptographic shared key generated by the client 200 during the national cryptographic key encapsulation process by decapsulating the private key in the second national cryptographic key pair with the first national cryptographic ciphertext.

[0084] Specifically, the server 100 can use the key decapsulation algorithm in the existing post-quantum KEM algorithm to decapsulate the post-quantum key to obtain the first post-quantum shared key, and use the key decapsulation algorithm in the KEM algorithm based on the national cryptographic algorithm designed in this embodiment to decapsulate the national cryptographic key to obtain the first national cryptographic shared key.

[0085] It is understandable that, regardless of whether it is post-quantum key decapsulation or national cryptographic key decapsulation, if the ciphertext is tampered with or if the correct public and private keys are not used, the shared key recovered by the server may be incorrect, and ultimately a unified session key cannot be generated, thus effectively ensuring communication security.

[0086] Step S203: Perform post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; perform national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key.

[0087] In this embodiment, the server 100 uses the public key in the first post-quantum key pair of the client 200 to perform post-quantum key encapsulation using the key encapsulation algorithm in the existing post-quantum KEM algorithm to obtain the second post-quantum ciphertext and the second post-quantum shared key; based on the public key in the first national cryptographic key pair, the server uses the key encapsulation algorithm in the KEM algorithm based on the national cryptographic algorithm designed in this embodiment to perform national cryptographic key encapsulation to obtain the second national cryptographic ciphertext and the second national cryptographic shared key.

[0088] Step S204: Generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0089] In this embodiment, the server 100 can derive a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key, which is used for encryption, decryption, and authentication in subsequent communications. For example, the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key can be concatenated and input into a preset key derivation function. The output of the key derivation function is the session key.

[0090] Step S205: Send the second post-quantum ciphertext and the second national cryptographic ciphertext to the client, so that the client can perform post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; perform national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key and the second national cryptographic shared key.

[0091] In this embodiment, server 100 sends the generated second post-quantum ciphertext and second national cryptographic ciphertext to client 200. After receiving the second post-quantum ciphertext and the second national cryptographic ciphertext, client 200 performs a key decapsulation operation similar to that performed by server 100 after receiving the first post-quantum ciphertext and the first national cryptographic ciphertext sent by client 200, in order to recover the second post-quantum shared key generated by server 100 during the post-quantum key encapsulation process and the second national cryptographic shared key generated during the national cryptographic key encapsulation process.

[0092] In other words, since the second post-quantum ciphertext is obtained by the server 100 using the public key from the client 200's first post-quantum key pair for post-quantum key encapsulation, the client 200 can recover the second post-quantum shared key generated by the server 100 during the post-quantum key encapsulation process by decapsulating the private key from the first post-quantum key pair and the second post-quantum ciphertext. Similarly, since the second national cryptographic ciphertext is obtained by the server 100 using the public key from the client 200's first national cryptographic key pair for national cryptographic key encapsulation, the client 200 can recover the second national cryptographic shared key generated by the server 100 during the national cryptographic key encapsulation process by decapsulating the private key from the first national cryptographic key pair and the second national cryptographic ciphertext.

[0093] In this embodiment, the client 200 can use the key decapsulation algorithm in the existing post-quantum KEM algorithm to decapsulate the post-quantum key to obtain the second post-quantum shared key, and use the key decapsulation algorithm in the KEM algorithm based on the national cryptographic algorithm designed in this embodiment to decapsulate the national cryptographic key to obtain the second national cryptographic shared key.

[0094] After obtaining the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key, client 200 can also derive a session key through key derivation, which is used for encryption, decryption, and authentication in subsequent communications. For example, the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key can be concatenated and input into a preset key derivation function. The output of the key derivation function is the session key.

[0095] It is understandable that the unified session key generated by the server 100 and client 200 through key derivation is the final key exchange result of the KEMTLS protocol, which is part of the standard protocol and is used for encryption, decryption and authentication in subsequent communications.

[0096] As can be seen, the session key generation method provided in this embodiment of the invention generates a session key between the client and the server by integrating the national cryptographic key encapsulation algorithm and the post-quantum key encapsulation algorithm. Even if one algorithm is compromised, the other algorithm can still ensure communication security, which greatly improves the communication security in the post-quantum migration stage.

[0097] In one implementation, the second national cryptographic key pair of the server 100 is generated through the following steps:

[0098] An initial national cryptographic key pair is generated based on a preset national cryptographic key generation algorithm; a first random number is generated; a second national cryptographic key pair is obtained based on the initial national cryptographic key pair and the first random number; wherein the public key in the second national cryptographic key pair is the same as the public key in the initial national cryptographic key pair, and the private key in the second national cryptographic key pair is obtained by concatenating the private key in the initial national cryptographic key pair with the first random number.

[0099] For example, first use the national cryptographic key generation algorithm to generate an initial national cryptographic key pair, which contains a public key and a private key; use the public key in the initial national cryptographic key pair as the public key in the second national cryptographic key pair; concatenate the generated first random number (which can be a 256-bit binary string) with the private key in the initial national cryptographic key pair, and use the concatenated result as the private key in the second national cryptographic key pair. In this way, the second national cryptographic key pair of server 100 can be obtained.

[0100] In one implementation, step S202 above, which involves decapsulating the national cryptographic key based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key, may include:

[0101] The first national cryptographic ciphertext is decrypted using the private key in the second national cryptographic key pair and a preset national cryptographic decryption algorithm to obtain the first plaintext corresponding to the first national cryptographic ciphertext. A first hash value and a second hash value are obtained using the first plaintext, the public key in the second national cryptographic key pair, and a preset first hash function. The first plaintext is then encrypted using the second hash value, the public key in the second national cryptographic key pair, and a preset national cryptographic encryption algorithm to obtain the ciphertext corresponding to the first plaintext. If the first national cryptographic ciphertext is the same as the ciphertext corresponding to the first plaintext, a first national cryptographic shared key is obtained based on the first hash value, the first national cryptographic ciphertext, and a preset key derivation function. If the first national cryptographic ciphertext is different from the ciphertext corresponding to the first plaintext, a third national cryptographic shared key is obtained based on a first random number, the first national cryptographic ciphertext, and a preset key derivation function. The third national cryptographic shared key is different from the first national cryptographic shared key. The first random number is obtained during the generation of the second national cryptographic key pair.

[0102] In this embodiment, the private key in the second national cryptographic key pair and the first national cryptographic ciphertext are used as inputs to a preset national cryptographic decryption algorithm, and the output of the national cryptographic decryption algorithm is the first plaintext corresponding to the first national cryptographic ciphertext.

[0103] In this embodiment, a preset first hash function can map a binary string of arbitrary length into two hash values ​​of fixed length (e.g., 256 bits). In one implementation, the public key of the second national cryptographic key pair can be input into the preset second hash function to obtain the hash value corresponding to the public key in the second national cryptographic key pair; the first plaintext and the hash value corresponding to the public key in the second national cryptographic key pair are concatenated and then input into the preset first hash function to obtain the first hash value and the second hash value.

[0104] In this embodiment, a preset second hash function can map a binary string of arbitrary length to a hash value of fixed length (e.g., 256 bits). Therefore, after inputting the public key from the second national cryptographic key pair into the preset second hash function, a 256-bit hash value (the hash value corresponding to the public key in the second national cryptographic key pair) will be obtained. Then, the first plaintext and the hash value corresponding to the public key in the second national cryptographic key pair are concatenated, and the concatenated binary string will be mapped by the first hash function into two 256-bit hash values ​​(i.e., the first hash value and the second hash value).

[0105] In this embodiment, the public key, the first plaintext, and the second hash value in the second national cryptographic key pair are used as inputs to a preset national cryptographic encryption algorithm. The second hash value is used as a random number variable in the national cryptographic encryption algorithm process, and the output of the national cryptographic encryption algorithm is the ciphertext corresponding to the first plaintext.

[0106] In this embodiment, after obtaining the ciphertext corresponding to the first plaintext, it is compared with the first national cryptographic ciphertext. If the two are the same, the correct shared key (i.e., the first national cryptographic shared key generated by the client 200 during the national cryptographic key encapsulation process) will be returned; if the two are different, an incorrect shared key (i.e., the third national cryptographic shared key) will be returned.

[0107] In one implementation, if the first national cryptographic ciphertext is the same as the ciphertext corresponding to the first plaintext, the first national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with the first hash value and then input into a preset key derivation function to obtain the first national cryptographic shared key.

[0108] In other words, the first national cryptographic ciphertext is input into the second hash function, the hash value corresponding to the first national cryptographic ciphertext output by the second hash function is concatenated with the first hash value, and the concatenated result is input into the preset key derivation function to obtain the first national cryptographic shared key.

[0109] In one implementation, if the first national cryptographic ciphertext is different from the ciphertext corresponding to the first plaintext, the first national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with a first random number and then input into a preset key derivation function to obtain the third national cryptographic shared key.

[0110] In other words, the first national cryptographic ciphertext is input into the second hash function. The hash value corresponding to the first national cryptographic ciphertext output by the second hash function is concatenated with the first random number. The concatenated result is input into a preset key derivation function to obtain the third national cryptographic shared key. Since the third national cryptographic shared key is different from the first national cryptographic shared key, it indicates that the ciphertext has been tampered with, or that the correct public and private keys have not been used, or other abnormal situations.

[0111] In one implementation, step S203 above, which involves encapsulating the public key in the first national cryptographic key pair with a national cryptographic key to obtain a second national cryptographic ciphertext and a second national cryptographic shared key, may include: generating a second random number; obtaining a third hash value and a fourth hash value based on the second random number, the public key in the first national cryptographic key pair, and a preset first hash function; encrypting the second random number based on the fourth hash value, the public key in the first national cryptographic key pair, and a preset national cryptographic encryption algorithm to obtain a second national cryptographic ciphertext; and obtaining the second national cryptographic shared key based on the second national cryptographic ciphertext, the third hash value, and a preset key derivation function.

[0112] In this embodiment, the second random number can be a 256-bit binary string.

[0113] In one implementation, the public key of the first national cryptographic key pair is input into a preset second hash function to obtain the hash value corresponding to the public key of the first national cryptographic key pair; the second random number is concatenated with the hash value corresponding to the public key of the first national cryptographic key pair and then input into a preset first hash function to obtain the third hash value and the fourth hash value.

[0114] Taking the example that the first hash function can map a binary string of any length into two 256-bit hash values, and the second hash function can map a binary string of any length into a single 256-bit hash value, after inputting the public key from the first national cryptographic key pair into the preset second hash function, a 256-bit hash value (the hash value corresponding to the public key in the first national cryptographic key pair) will be obtained. Then, after concatenating the second random number with the hash value corresponding to the public key in the first national cryptographic key pair, the concatenated binary string will be mapped by the first hash function into two 256-bit hash values ​​(i.e., the third hash value and the fourth hash value).

[0115] In this embodiment, after obtaining the third hash value and the fourth hash value, the public key, the second random number and the fourth hash value in the first national cryptographic key pair are used as inputs to the preset national cryptographic encryption algorithm. The fourth hash value is used as a random number variable in the national cryptographic encryption algorithm process, and the output of the national cryptographic encryption algorithm is the second national cryptographic ciphertext.

[0116] In one implementation, the second national cryptographic ciphertext can be input into a preset second hash function to obtain the hash value corresponding to the second national cryptographic ciphertext; the hash value corresponding to the second national cryptographic ciphertext can be concatenated with a third hash value and then input into a preset key derivation function to obtain the second national cryptographic shared key.

[0117] In other words, the second national cryptographic ciphertext is input into the second hash function, the hash value corresponding to the second national cryptographic ciphertext output by the second hash function is concatenated with the third hash value, and the concatenated result is input into the key derivation function to finally obtain the second national cryptographic shared key.

[0118] Please refer to Figure 3 This is a flowchart illustrating a session key generation method applied to the aforementioned client 200, as provided in an embodiment of the present invention. It should be noted that the session key generation method in this embodiment is not based on... Figure 3 The specific order described below is a limitation. It should be understood that in other embodiments, the order of some steps in the session key generation method of this invention can be interchanged according to actual needs, or some steps can be omitted or deleted. The following will describe... Figure 3 The specific process shown will be explained in detail.

[0119] Step S301: Generate a first post-quantum key pair according to a preset post-quantum key generation algorithm, and generate a first national cryptographic key pair according to a preset national cryptographic key generation algorithm.

[0120] In this embodiment, the preset post-quantum key generation algorithm is the key generation algorithm in the aforementioned existing post-quantum KEM algorithm; the preset national cryptographic key generation algorithm is the key generation algorithm in the aforementioned KEM algorithm based on the national cryptographic algorithm.

[0121] The generation process of the first national cryptographic key pair can refer to the generation steps of the second national cryptographic key pair in the aforementioned server 100. For example, a reference national cryptographic key pair is generated based on a preset national cryptographic key generation algorithm; the first national cryptographic key pair is obtained based on the reference national cryptographic key pair and the generated third random number; wherein the public key in the first national cryptographic key pair is the same as the public key in the reference national cryptographic key pair, and the private key in the first national cryptographic key pair is obtained by concatenating the private key in the reference national cryptographic key pair with the third random number.

[0122] Step S302: Perform post-quantum key encapsulation based on the public key in the second post-quantum key pair on the server to obtain the first post-quantum ciphertext and the first post-quantum shared key; perform national cryptographic key encapsulation based on the public key in the second national cryptographic key pair on the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key.

[0123] In this embodiment, based on the public key in the second post-quantum key pair of the server 100, the key encapsulation algorithm in the existing post-quantum KEM algorithm is used to encapsulate the post-quantum key, resulting in the first post-quantum ciphertext and the first post-quantum shared key. Based on the public key in the second national cryptographic key pair of the server 100, the key encapsulation algorithm in the KEM algorithm based on the national cryptographic algorithm designed in this embodiment is used to encapsulate the national cryptographic key, resulting in the first national cryptographic ciphertext and the first national cryptographic shared key.

[0124] Step S303: Send the first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair to the server. The server will then perform post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; perform national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key; perform post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; perform national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key; and generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0125] In this embodiment, the client 200 sends the generated first post-quantum ciphertext, the first national cryptographic ciphertext, and the public key in its own first post-quantum key pair and the public key in its first national cryptographic key pair to the server 100, so that the server 100 can subsequently perform corresponding key decapsulation and key encapsulation operations to finally generate a session key.

[0126] Step S304: Receive the second post-quantum ciphertext and the second national ciphertext sent by the server.

[0127] Step S305: Decapsulate the post-quantum key based on the private key and the second post-quantum ciphertext in the first post-quantum key pair to obtain the second post-quantum shared key; decapsulate the national cryptographic key based on the private key and the second national cryptographic ciphertext in the first national cryptographic key pair to obtain the second national cryptographic shared key.

[0128] In this embodiment, since the second post-quantum ciphertext is obtained by the server 100 through post-quantum key encapsulation based on the public key in the first post-quantum key pair of the client 200, the client 200 can recover the second post-quantum shared key generated by the server 100 during the post-quantum key encapsulation process by decapsulating the second post-quantum ciphertext based on the private key in the first post-quantum key pair. Similarly, since the second national cryptographic ciphertext is obtained by the server 100 through national cryptographic key encapsulation based on the public key in the first national cryptographic key pair of the client 200, the client 200 can recover the second national cryptographic shared key generated by the server 100 during the national cryptographic key encapsulation process by decapsulating the second national cryptographic ciphertext based on the private key in the first national cryptographic key pair.

[0129] Step S306: Generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0130] In this embodiment, after obtaining the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key, the client 200 can concatenate the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key, and then input them into a preset key derivation function. The output of the key derivation function is the session key.

[0131] In one implementation, step S302 above, which involves encapsulating the public key in the second national cryptographic key pair on the server with a national cryptographic key to obtain the first national cryptographic ciphertext and the first national cryptographic shared key, may include:

[0132] Generate a fourth random number; based on the fourth random number, the public key in the second national cryptographic key pair, and the preset first hash function, obtain a fifth hash value and a sixth hash value; based on the sixth hash value, the public key in the second national cryptographic key pair, and the preset national cryptographic encryption algorithm, encrypt the fourth random number to obtain the first national cryptographic ciphertext; based on the first national cryptographic ciphertext, the fifth hash value, and the preset key derivation function, obtain the first national cryptographic shared key.

[0133] In one implementation, the public key of the second national cryptographic key pair can be input into a preset second hash function to obtain the hash value corresponding to the public key in the second national cryptographic key pair; the fourth random number is concatenated with the hash value corresponding to the public key in the second national cryptographic key pair and then input into a preset first hash function to obtain a fifth hash value and a sixth hash value. The first national cryptographic ciphertext is input into the preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with the fifth hash value and then input into a preset key derivation function to obtain the first national cryptographic shared key.

[0134] In one implementation, step S305 above, which involves decapsulating the national cryptographic key based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key, may include:

[0135] The second national cryptographic ciphertext is decrypted using the private key from the first national cryptographic key pair and a preset national cryptographic decryption algorithm to obtain the second plaintext corresponding to the second national cryptographic ciphertext. The seventh and eighth hash values ​​are obtained using the second plaintext, the public key from the first national cryptographic key pair, and a preset first hash function. The second plaintext is then encrypted using the eighth hash value, the public key from the first national cryptographic key pair, and a preset national cryptographic encryption algorithm to obtain the corresponding ciphertext. If the second national cryptographic ciphertext is the same as the ciphertext corresponding to the second plaintext, a second national cryptographic shared key is obtained using the seventh hash value, the second national cryptographic ciphertext, and a preset key derivation function. If the second national cryptographic ciphertext is different from the ciphertext corresponding to the second plaintext, a fourth national cryptographic shared key is obtained using a third random number, the second national cryptographic ciphertext, and a preset key derivation function. The fourth national cryptographic shared key is different from the second national cryptographic shared key. The third random number is obtained during the generation of the first national cryptographic key pair.

[0136] In one implementation, the public key in the first national cryptographic key pair can be input into a preset second hash function to obtain the hash value corresponding to the public key in the first national cryptographic key pair; the second plaintext is concatenated with the hash value corresponding to the public key in the first national cryptographic key pair and then input into a preset first hash function to obtain the seventh hash value and the eighth hash value.

[0137] If the ciphertext corresponding to the second national cryptographic standard is the same as the ciphertext corresponding to the second plaintext, the second national cryptographic standard ciphertext is input into the preset second hash function to obtain the hash value corresponding to the second national cryptographic standard ciphertext; the hash value corresponding to the second national cryptographic standard ciphertext is concatenated with the seventh hash value and then input into the preset key derivation function to obtain the second national cryptographic standard shared key.

[0138] If the ciphertext corresponding to the second national cryptographic ciphertext is different from the ciphertext corresponding to the second plaintext, the second national cryptographic ciphertext is input into the preset second hash function to obtain the hash value corresponding to the second national cryptographic ciphertext; the hash value corresponding to the second national cryptographic ciphertext is concatenated with the third random number and input into the preset key derivation function to obtain the fourth national cryptographic shared key.

[0139] Below, in conjunction with Figure 4 This invention provides an exemplary description of the interaction process between server 100 and client 200. KEM is a key encapsulation algorithm, comprising three parts: key generation, key encapsulation, and key decapsulation. This embodiment of the invention involves two KEM algorithms: a post-quantum KEM algorithm and a KEM algorithm based on the SM2 algorithm. The key generation algorithm has no input and outputs a key pair (pk, sk), where pk represents the public key and sk represents the private key. Since the post-quantum KEM algorithm is existing technology, this embodiment of the invention will not elaborate on this part, but will mainly introduce the implementation of the three parts of the SM2-based KEM algorithm: the key generation algorithm, the key encapsulation algorithm, and the key decapsulation algorithm.

[0140] The implementation process of the key generation algorithm in the KEM algorithm based on the SM2 algorithm (denoted as SM2.KEM.Keygen in this embodiment, with no input parameters) is as follows: First, the key generation algorithm of the SM2 algorithm is used to obtain the SM2 key pair (pk1, sk1), and then based on... Obtain a 256-bit random number z, and finally output the key pair. , Indicates splicing.

[0141] The implementation process of the key encapsulation algorithm (denoted as SM2.KEM.Encapsulate(pk) in this embodiment, with pk as the input parameter) in the KEM algorithm based on the SM2 algorithm is as follows:

[0142] The first step, based on Generate a 256-bit random number;

[0143] The second step, based on Generate two hash values r and H are hash functions whose output is a 256-bit hash function, i.e., the second hash function mentioned above; G is a hash function whose output is two 256-bit hash functions, i.e., the first hash function mentioned above;

[0144] The third step, based on To obtain the ciphertext c, we use the SM2 encryption algorithm, pk as the public key, m as the plaintext, and r as k, where k is a random number variable in the SM2 encryption process.

[0145] Fourth step, based on Obtain the shared key K, where KDF represents the key derivation function;

[0146] Step 5, return to (c, K).

[0147] The implementation process of the key decapsulation algorithm (SM2.KEM.Decapsulate(c,sk), with input parameters c and sk) in the KEM algorithm based on the SM2 algorithm is as follows:

[0148] The first step, based on Once the decrypted plaintext m is obtained, the SM2 decryption algorithm is used to extract the SM2 algorithm private key sk1 from sk as the private key, and c is used as the ciphertext for decryption.

[0149] The second step, based on Generate two hash values and r;

[0150] The third step, based on Obtain the ciphertext ;

[0151] Fourth step, if Then return ;

[0152] Fifth step, if Then return .

[0153] like Figure 4 As shown, the second post-quantum key pair of server 100 ( ) and the second national cryptographic key pair ( The second quantum key pair has been generated, and client 200 has obtained the public key from server 100. The public key in the second national cryptographic key pair The client 200 and server 100 can generate the session key through the following process:

[0154] Step S401, the client uses KEM.Keygen (the key generation algorithm in the post-quantum KEM algorithm) to generate the first post-quantum key pair. ), use SM2.KEM.Keygen to generate the first national cryptographic key pair ( ),Right now , .

[0155] Step S402, the client uses the public key from the server's second post-quantum key pair. Post-quantum key encapsulation is performed to obtain the first post-quantum ciphertext. Shared key with the first post-quantum ,Right now Use the public key from the second national cryptographic key pair on the server. Encapsulating the data with the national cryptographic key yields the first national cryptographic ciphertext. Shared key with the first national cryptographic standard ,Right now .

[0156] In step S403, the client generates the first post-quantum ciphertext. First State Secret Confidential Documents The public key in the first post-quantum key pair The public key in the first national cryptographic key pair Send to the server.

[0157] Step S404, the server uses the private key from the second post-quantum key pair. and the first post-quantum cipher Perform post-quantum key decapsulation to obtain the first post-quantum shared key. ,Right now Based on the private key in the second national cryptographic key pair and the First State Secret Code Decapsulating the national cryptographic key yields the first national cryptographic shared key. ,Right now .

[0158] Step S405, the server uses the public key from the first post-quantum key pair. Post-quantum key encapsulation is performed to obtain the second post-quantum ciphertext. Second post-quantum shared key ,Right now Use the public key from the first national cryptographic key pair. Encapsulating the data with the national cryptographic key yields the second national cryptographic ciphertext. Second national cryptographic shared key ,Right now .

[0159] Step S406, the server will send the second post-quantum ciphertext and second country cipher text Send to the client.

[0160] Step S407, the client uses the private key from the first post-quantum key pair. Second post-quantum cipher Perform post-quantum key decapsulation to obtain the second post-quantum shared key. ,Right now Use the private key from the first national cryptographic key pair. and second country cipher text Decapsulate the national cryptographic key to obtain the second national cryptographic shared key. ,Right now .

[0161] Step S408, the client uses the first post-quantum shared key. First National Cryptographic Shared Key Second post-quantum shared key Second national cryptographic shared key Key derivation is performed to obtain the session key, which is used for message encryption / decryption and authentication. .

[0162] Step S409, the server uses the first post-quantum shared key. First National Cryptographic Shared Key Second post-quantum shared key Second national cryptographic shared key Key derivation is performed to obtain the session key, which is used for message encryption / decryption and authentication. It is understandable that after executing step S405, the server can execute step S409.

[0163] It should be noted that in this embodiment, the output value of the KDF function is the session key, which includes... , The output values ​​of the KDF function can be divided according to the same or different lengths. The final key exchange result of the KEMTLS protocol is part of the standard protocol and is used for message encryption and verification in subsequent communications.

[0164] In order to perform the corresponding steps in the above embodiments and various possible methods, the following provides an implementation method for a session key generation device applied to a server 100 and a session key generation device applied to a client 200.

[0165] Please see Figure 5This is a functional block diagram of a session key generation device applied to a server 100 according to an embodiment of the present invention. It should be noted that the basic principle and technical effects of the session key generation device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The session key generation device includes: a first receiving module 510, a first key decapsulation module 520, a first key encapsulation module 530, a first session key generation module 540, and a first sending module 550.

[0166] The first receiving module 510 is used to receive the first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair sent by the client; wherein, the first post-quantum key pair and the first national cryptographic key pair are generated by the client, the client performs post-quantum key encapsulation based on the public key in the second post-quantum key pair of the server to obtain the first post-quantum ciphertext and the first post-quantum shared key, and performs national cryptographic key encapsulation based on the public key in the second national cryptographic key pair of the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key.

[0167] It is understandable that the first receiving module 510 can perform the above step S201.

[0168] The first key decapsulation module 520 is used to decapsulate the first post-quantum key based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; and to decapsulate the second national cryptographic key based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key.

[0169] It is understandable that the first key decapsulation module 520 can perform the above step S202.

[0170] The first key encapsulation module 530 is used to perform post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; and to perform national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key.

[0171] It is understandable that the first key encapsulation module 530 can perform the above step S203.

[0172] The first session key generation module 540 is used to generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0173] It is understandable that the first session key generation module 540 can perform the above step S204.

[0174] The first sending module 550 is used to send the second post-quantum ciphertext and the second national cryptographic ciphertext to the client, so that the client can perform post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; perform national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; and generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key and the second national cryptographic shared key.

[0175] It is understandable that the first sending module 550 can perform the above step S205.

[0176] Please see Figure 6 This is a functional block diagram of a session key generation device applied to a client 200 according to an embodiment of the present invention. It should be noted that the basic principle and technical effects of the session key generation device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The session key generation device includes: a key generation module 610, a second key encapsulation module 620, a second sending module 630, a second receiving module 640, a second key decapsulation module 650, and a second session key generation module 660.

[0177] The key generation module 610 is used to generate a first post-quantum key pair according to a preset post-quantum key generation algorithm and to generate a first national cryptographic key pair according to a preset national cryptographic key generation algorithm.

[0178] It is understood that the key generation module 610 can perform the above step S301.

[0179] The second key encapsulation module 620 is used to perform post-quantum key encapsulation based on the public key in the second post-quantum key pair on the server to obtain the first post-quantum ciphertext and the first post-quantum shared key; and to perform national cryptographic key encapsulation based on the public key in the second national cryptographic key pair on the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key.

[0180] It is understandable that the second key encapsulation module 620 can perform the above step S302.

[0181] The second sending module 630 is used to send the first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair to the server, so that the server performs post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key; performs post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; performs national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key; and generates a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0182] It is understandable that the second sending module 630 can perform the above step S303.

[0183] The second receiving module 640 is used to receive the second post-quantum ciphertext and the second national cryptographic ciphertext sent by the server.

[0184] It is understandable that the second receiving module 640 can perform the above step S304.

[0185] The second key decapsulation module 650 is used to decapsulate the second post-quantum key based on the private key and the second post-quantum ciphertext in the first post-quantum key pair to obtain the second post-quantum shared key; and to decapsulate the second national cryptographic key based on the private key and the second national cryptographic ciphertext in the first national cryptographic key pair to obtain the second national cryptographic shared key.

[0186] It is understood that the second key decapsulation module 650 can perform the above step S305.

[0187] The second session key generation module 660 is used to generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

[0188] It is understood that the second session key generation module 660 can perform the above step S306.

[0189] Please refer to Figure 7 This is a block diagram of an electronic device 700 provided in an embodiment of the present invention. The electronic device 700 can implement the aforementioned server 100 and client 200. The electronic device 700 includes a memory 710, a processor 720, and a communication module 730. The memory 710, processor 720, and communication module 730 are electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0190] The memory 710 is used to store programs or data. The memory 710 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0191] The processor 720 is used to read / write data or programs stored in the memory 710 and perform corresponding functions. For example, when a computer program stored in the memory 710 is executed by the processor 720, the session key generation method disclosed in the above embodiments can be implemented.

[0192] The communication module 730 is used to establish a communication connection between the electronic device 700 and other devices via a network, and to send and receive data via the network.

[0193] It should be understood that, Figure 7 The structure shown is only a schematic diagram of the electronic device 700. The electronic device 700 may also include components that are larger than those shown. Figure 7 The more or fewer components shown, or having the same Figure 7 The different configurations shown. Figure 7 The components shown can be implemented using hardware, software, or a combination thereof.

[0194] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor 720, implements the session key generation method disclosed in the above embodiments.

[0195] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0196] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0197] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0198] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for generating a session key, characterized in that, Applied to the server side, the method includes: The client receives a first post-quantum ciphertext, a first national cryptographic ciphertext, a public key from a first post-quantum key pair, and a public key from a first national cryptographic key pair. The first post-quantum key pair and the first national cryptographic key pair are generated by the client. The client performs post-quantum key encapsulation based on the public key from the server's second post-quantum key pair to obtain the first post-quantum ciphertext and the first post-quantum shared key. The client also performs national cryptographic key encapsulation based on the public key from the server's second national cryptographic key pair to obtain the first national cryptographic ciphertext and the first national cryptographic shared key. Based on the private key in the second post-quantum key pair and the first post-quantum ciphertext, post-quantum key decapsulation is performed to obtain the first post-quantum shared key; based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext, national cryptographic key decapsulation is performed to obtain the first national cryptographic shared key; Based on the public key in the first post-quantum key pair, post-quantum key encapsulation is performed to obtain the second post-quantum ciphertext and the second post-quantum shared key; based on the public key in the first national cryptographic key pair, national cryptographic key encapsulation is performed to obtain the second national cryptographic ciphertext and the second national cryptographic shared key. A session key is generated based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key; The second post-quantum ciphertext and the second national cryptographic ciphertext are sent to the client, so that the client performs post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; and generates the session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

2. The session key generation method according to claim 1, characterized in that, The step of decapsulating the first national cryptographic shared key based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext includes: Based on the private key in the second national cryptographic key pair and the preset national cryptographic decryption algorithm, the first national cryptographic ciphertext is decrypted to obtain the first plaintext corresponding to the first national cryptographic ciphertext. Based on the first plaintext, the public key in the second national cryptographic key pair, and the preset first hash function, the first hash value and the second hash value are obtained; Based on the second hash value, the public key in the second national cryptographic key pair, and the preset national cryptographic encryption algorithm, the first plaintext is encrypted to obtain the ciphertext corresponding to the first plaintext; If the first national cryptographic ciphertext is the same as the ciphertext corresponding to the first plaintext, then the first national cryptographic shared key is obtained based on the first hash value, the first national cryptographic ciphertext, and a preset key derivation function; if the first national cryptographic ciphertext is different from the ciphertext corresponding to the first plaintext, then the third national cryptographic shared key is obtained based on the first random number, the first national cryptographic ciphertext, and a preset key derivation function; the third national cryptographic shared key is different from the first national cryptographic shared key; the first random number is obtained during the generation of the second national cryptographic key pair.

3. The session key generation method according to claim 2, characterized in that, The step of obtaining the first hash value and the second hash value based on the first plaintext, the public key in the second national cryptographic key pair, and a preset first hash function includes: Input the public key from the second national cryptographic key pair into a preset second hash function to obtain the hash value corresponding to the public key of the second national cryptographic key pair; The first plaintext is concatenated with the hash value corresponding to the public key in the second national cryptographic key pair, and then input into a preset first hash function to obtain the first hash value and the second hash value.

4. The session key generation method according to claim 2, characterized in that, The process of obtaining the first national cryptographic shared key based on the first hash value, the first national cryptographic ciphertext, and a preset key derivation function includes: The first national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with the first hash value and then input into a preset key derivation function to obtain the first national cryptographic shared key; The process of obtaining the third national cryptographic shared key based on the first random number, the first national cryptographic ciphertext, and a preset key derivation function includes: The first national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the first national cryptographic ciphertext; the hash value corresponding to the first national cryptographic ciphertext is concatenated with the first random number and then input into a preset key derivation function to obtain the third national cryptographic shared key.

5. The session key generation method according to claim 1, characterized in that, The step of encapsulating the public key in the first national cryptographic key pair with a national cryptographic key to obtain the second national cryptographic ciphertext and the second national cryptographic shared key includes: Generate a second random number; Based on the second random number, the public key in the first national cryptographic key pair, and the preset first hash function, the third hash value and the fourth hash value are obtained; Based on the fourth hash value, the public key in the first national cryptographic key pair, and the preset national cryptographic encryption algorithm, the second random number is encrypted to obtain the second national cryptographic ciphertext; Based on the second national cryptographic ciphertext, the third hash value, and the preset key derivation function, the second national cryptographic shared key is obtained.

6. The session key generation method according to claim 5, characterized in that, The process of obtaining the third and fourth hash values ​​based on the second random number, the public key in the first national cryptographic key pair, and a preset first hash function includes: Input the public key from the first national cryptographic key pair into a preset second hash function to obtain the hash value corresponding to the public key from the first national cryptographic key pair; The second random number is concatenated with the hash value corresponding to the public key in the first national cryptographic key pair, and then input into a preset first hash function to obtain the third hash value and the fourth hash value.

7. The session key generation method according to claim 5, characterized in that, The process of obtaining the second national cryptographic shared key based on the second national cryptographic ciphertext, the third hash value, and a preset key derivation function includes: The second national cryptographic ciphertext is input into a preset second hash function to obtain the hash value corresponding to the second national cryptographic ciphertext; The hash value corresponding to the second national cryptographic ciphertext is concatenated with the third hash value and then input into a preset key derivation function to obtain the second national cryptographic shared key.

8. The session key generation method according to any one of claims 1-7, characterized in that, The second national cryptographic key pair on the server is generated through the following steps: An initial national cryptographic key pair is generated based on a preset national cryptographic key generation algorithm; Generate the first random number; The second national cryptographic key pair is obtained based on the initial national cryptographic key pair and the first random number; wherein the public key in the second national cryptographic key pair is the same as the public key in the initial national cryptographic key pair, and the private key in the second national cryptographic key pair is obtained by concatenating the private key in the initial national cryptographic key pair with the first random number.

9. A method for generating a session key, characterized in that, Applied to a client, the method includes: The first post-quantum key pair is generated according to the preset post-quantum key generation algorithm, and the first national cryptographic key pair is generated according to the preset national cryptographic key generation algorithm. Based on the public key in the second post-quantum key pair on the server, post-quantum key encapsulation is performed to obtain the first post-quantum ciphertext and the first post-quantum shared key; based on the public key in the second national cryptographic key pair on the server, national cryptographic key encapsulation is performed to obtain the first national cryptographic ciphertext and the first national cryptographic shared key; The first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair are sent to the server. The server then performs post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key; performs post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; performs national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key; and generates a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key. Receive the second post-quantum ciphertext and the second national cryptographic ciphertext sent by the server; Based on the private key in the first post-quantum key pair and the second post-quantum ciphertext, post-quantum key decapsulation is performed to obtain the second post-quantum shared key; based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext, national cryptographic key decapsulation is performed to obtain the second national cryptographic shared key; The session key is generated based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

10. A session key generation device, characterized in that, Applied to the server side, the device includes: The first receiving module is configured to receive a first post-quantum ciphertext, a first national cryptographic ciphertext, a public key in a first post-quantum key pair, and a public key in a first national cryptographic key pair sent by a client; wherein, the first post-quantum key pair and the first national cryptographic key pair are generated by the client, and the client performs post-quantum key encapsulation based on the public key in the second post-quantum key pair of the server to obtain the first post-quantum ciphertext and the first post-quantum shared key, and performs national cryptographic key encapsulation based on the public key in the second national cryptographic key pair of the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key; The first key decapsulation module is used to perform post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; and to perform national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key. The first key encapsulation module is used to perform post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; and to perform national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key. The first session key generation module is used to generate a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key; The first sending module is configured to send the second post-quantum ciphertext and the second national cryptographic ciphertext to the client, so that the client performs post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key; and generates the session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

11. A session key generation device, characterized in that, Applied to a client, the device includes: The key generation module is used to generate a first post-quantum key pair according to a preset post-quantum key generation algorithm, and to generate a first national cryptographic key pair according to a preset national cryptographic key generation algorithm. The second key encapsulation module is used to perform post-quantum key encapsulation based on the public key in the second post-quantum key pair on the server to obtain the first post-quantum ciphertext and the first post-quantum shared key; and to perform national cryptographic key encapsulation based on the public key in the second national cryptographic key pair on the server to obtain the first national cryptographic ciphertext and the first national cryptographic shared key. The second sending module is configured to send the first post-quantum ciphertext, the first national cryptographic ciphertext, the public key in the first post-quantum key pair, and the public key in the first national cryptographic key pair to the server, so that the server performs post-quantum key decapsulation based on the private key in the second post-quantum key pair and the first post-quantum ciphertext to obtain the first post-quantum shared key; performs national cryptographic key decapsulation based on the private key in the second national cryptographic key pair and the first national cryptographic ciphertext to obtain the first national cryptographic shared key; performs post-quantum key encapsulation based on the public key in the first post-quantum key pair to obtain the second post-quantum ciphertext and the second post-quantum shared key; performs national cryptographic key encapsulation based on the public key in the first national cryptographic key pair to obtain the second national cryptographic ciphertext and the second national cryptographic shared key; and generates a session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key. The second receiving module is used to receive the second post-quantum ciphertext and the second national cryptographic ciphertext sent by the server; The second key decapsulation module is used to perform post-quantum key decapsulation based on the private key in the first post-quantum key pair and the second post-quantum ciphertext to obtain the second post-quantum shared key; and to perform national cryptographic key decapsulation based on the private key in the first national cryptographic key pair and the second national cryptographic ciphertext to obtain the second national cryptographic shared key. The second session key generation module is used to generate the session key based on the first post-quantum shared key, the first national cryptographic shared key, the second post-quantum shared key, and the second national cryptographic shared key.

12. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the session key generation method as described in any one of claims 1-9.

13. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the session key generation method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Session key generation method and related device

    CN119276494A

  • Short message secure transmission method and system based on post-quantum algorithm, and electronic equipment

    CN119766502A