End-to-end encryption key distribution method and system based on national secret key
Through the end-to-end encryption method based on national secrets, using the SM4 algorithm and WebSocket TLS channel, the security and flexibility of key distribution are achieved, solving the problems of insufficient security and flexibility of key distribution in existing technologies, and is suitable for large-scale distributed systems.
Patent Information
- Application Number
- CN202511254877.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-09-04
AI Technical Summary
Existing key distribution mechanisms lack security and flexibility, making it difficult to meet specific security and compliance requirements, especially in large-scale distributed systems where there is a risk of single point failure.
An end-to-end encryption method based on national encryption is adopted, and the SM4 algorithm is used to generate derived temporary key pairs. Authentication and key distribution are performed through the WebSocket TLS end-to-end encrypted channel to generate derived session key pairs and content keys, realizing one-master-multiple-derivative key family management.
It improves the security and flexibility of key distribution, meets specific security and compliance requirements, solves single point failure problems, and is suitable for large-scale distributed systems.
Smart Images

Figure CN120729656A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of key distribution technology, and in particular to a key distribution method and system based on end-to-end encryption of national secrets. Background Art
[0002] With the acceleration of digital transformation, data security has become a major challenge for organizations. Key management, at the core of data security, plays a crucial role in protecting the confidentiality, integrity, and availability of encryption keys. An effective key management strategy not only reduces the risk of data leakage and misuse but is also crucial for meeting compliance requirements, building user trust, and adapting to emerging technological challenges.
[0003] Key management plays a critical role in ensuring data security, maintaining system integrity, supporting regulatory compliance, mitigating risk, building trust, serving as the foundation for encryption, adapting to technological developments, rapidly responding to security incidents, and covering the entire key lifecycle. Key distribution is a critical step in key management, involving the secure transfer of keys between communicating parties.
[0004] Among related technologies, current key distribution mechanisms mainly include Diffie-Hellman key exchange, public key infrastructure, and key distribution centers. Each method has its own specific application scenarios and advantages, but they also face some limitations in practical applications: Diffie-Hellman key exchange itself does not provide key authentication and is vulnerable to man-in-the-middle attacks. Public key infrastructure relies on trusted third-party certificate authorities and has high management costs. Key distribution centers may become single points of failure and may not be flexible enough for large-scale distributed systems. In terms of hierarchical key management, existing key management strategies often lack sufficient refinement to meet the needs of different security levels and application scenarios, limiting their application under specific security needs and compliance requirements. This leads to insufficient flexibility and targeting of key management, which may affect overall security and efficiency. Summary of the Invention
[0005] In response to the shortcomings of the existing technology, this application provides a key distribution method and system based on end-to-end encryption of national secrets, which solves the problems of insufficient security and flexibility in current key distribution and difficulty in meeting specific security requirements.
[0006] To achieve the above objectives, this application is implemented through the following technical solutions: In the first aspect, an embodiment of the present application provides a key distribution method based on end-to-end encryption of national encryption, which is used for a key server. The key distribution method based on end-to-end encryption of national encryption includes: generating a derived temporary key pair based on the SM4 algorithm, and after receiving the first session request sent by the client and authenticating the client, sending the public key and WebSocket address of the derived temporary key pair to the client, so that the client can encrypt the identity information to obtain identity ciphertext information; receiving the identity ciphertext information sent by the client, decrypting it and generating a derived session key pair, and encrypting it based on the private key of the derived temporary key pair to obtain the session public key ciphertext information and sending it to the client, so that the client can decrypt it to obtain the public key of the derived session key pair to encrypt the encryption request; receiving the encryption request ciphertext information sent by the client and decrypting it to obtain the encryption request, generating the target content key and encrypting it by the private key of the derived session key pair to obtain the target content key ciphertext information and sending it to the client.
[0007] According to the first aspect of the embodiment of the present application, the aforementioned derived temporary key pair is generated based on the SM4 algorithm. After receiving the first session request sent by the client and authenticating the client, the public key and WebSocket address of the derived temporary key pair are sent to the client, so that the client can encrypt the identity information to obtain identity ciphertext information, including: generating a master key based on the SM4 algorithm, and generating a derived temporary key pair based on the master key; after receiving the first session request sent by the client, authenticating the client and verifying the TLS certificate; after the verification is passed, the public key and WebSocket address of the derived temporary key pair are sent to the client, and a WebSocket TLS end-to-end encryption channel is established, so that the client can encrypt the identity information to obtain identity ciphertext information.
[0008] According to the first aspect of the embodiment of the present application, identity ciphertext information sent by the client is received, decrypted and a derived session key pair is generated, and the session public key ciphertext information is obtained by encrypting it based on the private key of the derived temporary key pair and sending it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request, including: receiving the identity ciphertext information sent by the client; decrypting the identity ciphertext information by the private key of the derived temporary key pair to obtain the identity information; obtaining a random number, and generating a derived session key pair based on the master key and the random number and binding the identity information; encrypting the public key of the derived session key pair using the private key of the derived temporary key pair to obtain the session public key ciphertext information and sending it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request.
[0009] According to a first aspect of an embodiment of the present application, receiving encryption request ciphertext information sent by a client and decrypting it to obtain an encryption request, generating a target content key and encrypting it using a private key of a derived session key pair, obtaining target content key ciphertext information and sending it to the client, including: receiving encryption request ciphertext information sent by the client; Decrypt the encrypted request ciphertext information using the private key of the derived session key pair to obtain the encrypted request and verify the request parameters of the encrypted request; generate a derived content key based on the master key, and bind the identity information and the derived content key to obtain the target content key; encrypt the target content key using the private key of the derived session key pair to obtain the target content key ciphertext information; and send the target content key ciphertext information to the client.
[0010] On the second aspect, an embodiment of the present application provides a key distribution method based on end-to-end encryption of national encryption, which is used for the client. The key distribution method based on end-to-end encryption of national encryption includes: sending a first session request to the key server for the key server to authenticate the client; receiving the public key and WebSocket address of the derived temporary key pair, encrypting the client's identity information to obtain identity ciphertext information, and sending it to the key server; receiving the session public key ciphertext information sent by the key server and decrypting it to obtain the public key of the derived session key pair to encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server for the key server to decrypt it to obtain the encryption request; receiving the target content key ciphertext information sent by the key server, and decrypting it to obtain the target content key.
[0011] According to the second aspect of the embodiment of the present application, the public key and WebSocket address of the derived temporary key pair are received, the identity information of the client is encrypted to obtain identity ciphertext information, and sent to the key server, including: receiving the public key and WebSocket address of the derived temporary key pair sent by the key server; determining the identity information of the client including ID information and IP information, encrypting the identity information by the public key of the derived temporary key pair to obtain identity ciphertext information; and sending the identity ciphertext information to the key server.
[0012] According to the second aspect of the embodiment of the present application, the session public key ciphertext information sent by the key server is received and decrypted to obtain the public key of the derived session key pair, so as to encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server for the key server to decrypt and obtain the encryption request, including: receiving the session public key ciphertext information sent by the key server; decrypting the session public key ciphertext information by using the public key of the derived temporary key pair to obtain the public key of the derived session key pair; triggering the encryption request for the derived content key, and encrypting the encryption request based on the public key of the derived session key pair to obtain the encryption request ciphertext information; sending the encryption request ciphertext information to the key server through the WebSocket TLS end-to-end encrypted channel, so as to be decrypted by the key server to obtain the encryption request.
[0013] According to the second aspect of the embodiment of the present application, the target content key ciphertext information sent by the key server is received and decrypted to obtain the target content key, including: receiving the target content key ciphertext information sent by the key server; decrypting the target content key ciphertext information by deriving the public key of the session key pair to obtain the target content key.
[0014] In the third aspect, an embodiment of the present application provides a key distribution system based on end-to-end encryption of national secrets, which is used for a key service end. The key distribution system based on end-to-end encryption of national secrets includes: a first temporary key processing module, a first session key processing module and a first content key processing module; specifically, the first temporary key processing module is used to generate a derived temporary key pair based on the SM4 algorithm. After receiving the first session request sent by the client and authenticating the client, the public key and WebSocket address of the derived temporary key pair are sent to the client, so that the client can encrypt the identity information to obtain identity ciphertext information; the first session key processing module is used to receive the identity ciphertext information sent by the client, decrypt it and generate a derived session key pair, and encrypt it based on the private key of the derived temporary key pair to obtain the session public key ciphertext information and send it to the client, so that the client can decrypt it to obtain the public key of the derived session key pair to encrypt the encryption request; the first content key processing module is used to receive the encryption request ciphertext information sent by the client and decrypt it to obtain the encryption request, generate the target content key and encrypt it by the private key of the derived session key pair to obtain the target content key ciphertext information and send it to the client.
[0015] In the fourth aspect, an embodiment of the present application provides a key distribution system based on end-to-end encryption of national encryption, which is used for the client. The key distribution system based on end-to-end encryption of national encryption includes: a session request sending module, a second temporary key processing module, a second session key processing module and a second content key processing module; specifically, the session request sending module is used to send the first session request to the key server for the key server to authenticate the client; the second temporary key processing module is used to receive the public key and WebSocket address of the derived temporary key pair, encrypt the identity information of the client to obtain identity ciphertext information, and send it to the key server; the second session key processing module is used to receive the session public key ciphertext information sent by the key server and decrypt it to obtain the public key of the derived session key pair, so as to encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server, so that the key server can decrypt it to obtain the encryption request; the second content key processing module is used to receive the target content key ciphertext information sent by the key server, and decrypt it to obtain the target content key.
[0016] This application provides a key distribution method and system based on end-to-end encryption of national secrets. Compared with the existing technology, it has the following advantages: After receiving the first session request sent by the client, this application authenticates the client and sends the public key and WebSocket address of the derived temporary key pair generated based on the SM4 algorithm to the client to encrypt the client's identity information to obtain identity ciphertext information, and send it to the key server; the key server decrypts and generates a derived session key pair based on the identity ciphertext information, encrypts the derived temporary key pair with the private key to obtain the session public key ciphertext information and sends it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server. After decrypting and obtaining the encryption request, the key server generates the target content key and encrypts it with the private key of the derived session key pair and sends it to the client. After receiving it, the client performs corresponding decryption to obtain the target content key. This application adopts the national secret algorithm to protect the key distribution process, meeting the application under specific security needs and compliance requirements; and can comply with most scenarios of secure key distribution. By refining the hierarchical types of keys, a one-master-multiple-derived key family is realized, and the cancellation of the main family can quickly cancel its sub-family keys; it solves the problem of system unusability caused by single point failure, and is more flexible for large-scale distributed systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 This is a flow chart of a key distribution method based on end-to-end encryption of national secrets provided in an embodiment of the present application; Figure 2 This is a flow chart of another key distribution method based on end-to-end encryption of national secrets provided in an embodiment of the present application; Figure 3 This is a schematic diagram of the interaction between the key server and the client provided in an embodiment of the present application; Figure 4 This is a structural diagram of a key distribution system based on end-to-end encryption of national secrets provided in an embodiment of the present application; Figure 5 This is a structural diagram of another key distribution system based on end-to-end encryption of national secrets provided in an embodiment of the present application. DETAILED DESCRIPTION To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0019] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0020] The embodiments of the present application solve the problems of insufficient security and flexibility in current key distribution and difficulty in meeting specific security requirements by providing a key distribution method and system based on national encryption end-to-end encryption.
[0021] The technical solution in the embodiments of the present application is to solve the above technical problems, and the overall idea is as follows: With the acceleration of digital transformation, data security has become a major challenge for organizations. Key management, at the core of data security, plays a crucial role in protecting the confidentiality, integrity, and availability of encryption keys. An effective key management strategy not only reduces the risk of data leakage and misuse but is also crucial for meeting compliance requirements, building user trust, and adapting to emerging technological challenges.
[0022] Key management plays a critical role in ensuring data security, maintaining system integrity, supporting regulatory compliance, mitigating risk, building trust, serving as the foundation for encryption, adapting to technological developments, rapidly responding to security incidents, and covering the entire key lifecycle. Key distribution is a critical step in key management, involving the secure transfer of keys between communicating parties.
[0023] Defects and shortcomings of existing technology: 1. Current key distribution mechanisms mainly include Diffie-Hellman key exchange, public key infrastructure (PKI), and key distribution center (KDC). Each method has its specific application scenarios and advantages, but they also face some limitations in practical applications: (1) Diffie-Hellman key exchange: Although it allows two parties to exchange keys securely over an insecure channel, it does not provide key authentication itself and is vulnerable to man-in-the-middle attacks.
[0024] (2) Public Key Infrastructure (PKI): provides a comprehensive solution for authentication and key management, but it relies on trusted third-party certificate authorities and has high management costs.
[0025] (3) Key Distribution Center (KDC): Such as the KDC in the Kerberos protocol, it provides an effective key distribution and management method for network services, but it may become a single point of failure and may not be flexible enough for large-scale distributed systems.
[0026] In addition, the current market lacks a key distribution mechanism based on national encryption algorithms, which limits its application under specific security needs and compliance requirements.
[0027] 2. Key management currently has some shortcomings, particularly in hierarchical key management. Existing key management strategies often lack sufficient detail to meet the needs of different security levels and application scenarios. This results in insufficient flexibility and targeted key management, potentially impacting overall security and efficiency.
[0028] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0029] The following first introduces a key distribution method based on end-to-end encryption of national secrets provided in an embodiment of the present application.
[0030] The embodiment of the present application provides a flow chart of a key distribution method based on end-to-end encryption of national secrets, such as Figure 1 As shown, the key distribution method based on end-to-end encryption of national secrets is used for the key service end and may include the following steps S110-S130.
[0031] S110. Generate a derived temporary key pair based on the SM4 algorithm. After receiving the first session request sent by the client and authenticating the client, send the public key and WebSocket address of the derived temporary key pair to the client so that the client can encrypt the identity information to obtain the identity ciphertext information.
[0032] S120. Receive the identity ciphertext information sent by the client, decrypt it and generate a derived session key pair, and encrypt the session public key ciphertext information based on the private key of the derived temporary key pair and send it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request.
[0033] S130: Receive the encryption request ciphertext information sent by the client and decrypt it to obtain the encryption request, generate the target content key and encrypt it using the private key of the derived session key pair to obtain the target content key ciphertext information and send it to the client.
[0034] In some embodiments, the present application provides a key distribution method based on end-to-end encryption of national secrets, such as Figure 2 As shown, the method is used on the client and may include the following steps: S210: Send a first session request to the key server so that the key server can authenticate the client.
[0035] S220: Receive the public key and WebSocket address of the derived temporary key pair, encrypt the client's identity information to obtain identity ciphertext information, and send it to the key server.
[0036] S230. Receive the session public key ciphertext information sent by the key server and decrypt it to obtain the public key of the derived session key pair, encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server for the key server to decrypt and obtain the encryption request.
[0037] S240: Receive the target content key ciphertext information sent by the key server, and decrypt it to obtain the target content key.
[0038] The above is a specific implementation of a key distribution method based on national secret end-to-end encryption provided in the embodiment of this application. It is understandable that please refer to Figure 1-Figure 3 After receiving the first session request sent by the client, this application authenticates the client and sends the public key and WebSocket address of the derived temporary key pair generated based on the SM4 algorithm to the client to encrypt the client's identity information to obtain identity ciphertext information, and send it to the key server; the key server decrypts and generates a derived session key pair based on the identity ciphertext information, encrypts the derived temporary key pair with the private key to obtain the session public key ciphertext information and sends it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server. After decrypting and obtaining the encryption request, the key server generates the target content key and encrypts it with the private key of the derived session key pair and sends it to the client. After receiving it, the client performs corresponding decryption to obtain the target content key.
[0039] Based on this, this application uses a national secret algorithm to protect the key distribution process, meeting specific security and compliance requirements. It also meets most scenarios for secure key distribution. By refining the hierarchical types of keys, a single-master, multi-derived key family is implemented. Deregistration of a master family can quickly deregister its sub-family keys. This solves the problem of single-point failures rendering the system unusable, and provides greater flexibility for large-scale distributed systems. This application addresses the current issues of insufficient security and flexibility in key distribution, making it difficult to meet specific security requirements.
[0040] It's important to note that WebSocket itself is a standalone protocol designed to establish persistent connections between web clients and servers. However, to ensure secure communication, WebSocket can also utilize TLS encryption via the wss: / / (WebSocket Secure) protocol scheme. When using wss: / / , the WebSocket connection uses TLS (Transport Layer Security) to encrypt data at the transport layer, similar to how HTTPS encrypts HTTP.
[0041] In some embodiments, the aforementioned temporary key pair is generated based on the SM4 algorithm. After receiving the first session request sent by the client and authenticating the client, the public key and WebSocket address of the temporary key pair are sent to the client for the client to encrypt the identity information to obtain the identity ciphertext information. That is, the aforementioned S110 may specifically include the following steps: S111. Generate a master key based on the SM4 algorithm, and generate a derived temporary key pair based on the master key.
[0042] S112. After receiving the first session request sent by the client, authenticate the client and verify the TLS certificate.
[0043] S113. After the verification is passed, the public key and WebSocket address of the derived temporary key pair are sent to the client, and a WebSocket TLS end-to-end encrypted channel is established for the client to encrypt the identity information to obtain the identity ciphertext information.
[0044] In some embodiments, the aforementioned receiving of the public key and WebSocket address for deriving the temporary key pair, encrypting the identity information of the client to obtain identity ciphertext information, and sending it to the key server, that is, the aforementioned S220 may specifically include the following steps: S221. Receive the public key and WebSocket address of the derived temporary key pair sent by the key server.
[0045] S222: Determine the identity information of the client including the ID information and the IP information, encrypt the identity information by deriving the public key of the temporary key pair, and obtain the identity ciphertext information.
[0046] S223. Send the identity ciphertext information to the key server.
[0047] In the embodiments of this application, it is understood that the master key is the top layer of the key system and is managed by the user administrator or system administrator after generation. Other derived keys are generated based on the master key. When the master key is revoked, the other derived keys are also revoked accordingly. The master key is generated using the SM4 algorithm, that is, the master key is an SM4 key. A derived temporary key pair is associated with the master key and is used to encrypt the first interaction between the key server and the client. One master key can generate multiple derived temporary key pairs.
[0048] It should also be noted that in a distributed architecture, considering the distributed deployment, this application has also made corresponding design optimizations for how the client can quickly obtain the target content key. The client will pre-register an identity ID in the key system. The identity ID will be bound to the master key and stored in the nearest key system and its database. At the same time, the master key will be synchronized to the farthest key system and its database as a backup. When a client triggers a key distribution request, a WebSocket address will be allocated based on its identity ID and IP address to establish an end-to-end encrypted channel. If a client triggers a key distribution request in place A, its master key is also stored in place A, and the key system will allocate the WebSocket address in place A to the user; conversely, if the master key corresponding to a client is in place B and the backup is in place C, the key system will allocate the WebSocket address in place C to the user.
[0049] In some embodiments, the aforementioned receiving of the identity ciphertext information sent by the client, performing decryption processing and generating a derived session key pair, encrypting the obtained session public key ciphertext information based on the private key of the derived temporary key pair, and sending the obtained session public key ciphertext information to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request, that is, the aforementioned S120 may specifically include the following steps: S121. Receive the encrypted identity information sent by the client.
[0050] S122. Decrypt the identity ciphertext information using the private key of the derived temporary key pair to obtain the identity information.
[0051] S123. Obtain a random number, and generate a derived session key pair based on the master key and the random number and bound to the identity information.
[0052] S124. Use the private key of the derived temporary key pair to encrypt the public key of the derived session key pair, obtain the session public key ciphertext information and send it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request.
[0053] In some embodiments, the aforementioned receiving the session public key ciphertext information sent by the key server and decrypting it to obtain the public key of the derived session key pair, encrypting the encryption request, obtaining the encryption request ciphertext information and sending it to the key server for the key server to decrypt to obtain the encryption request, that is, the aforementioned S230 may specifically include: S231. Receive the session public key ciphertext information sent by the key server.
[0054] S232. Decrypt the session public key ciphertext information using the public key of the derived temporary key pair to obtain the public key of the derived session key pair.
[0055] S233: trigger an encryption request for deriving a content key, and encrypt the encryption request based on the public key of the derived session key pair to obtain encryption request ciphertext information.
[0056] S234. Send the encrypted request ciphertext information to the key server through the WebSocket TLS end-to-end encrypted channel, so that the key server decrypts it to obtain the encrypted request.
[0057] In the embodiment of the present application, it can be understood that the derived session key pair is an SM2 key pair generated in combination with a random number, and the derived session key pair is used to encrypt and decrypt encryption requests between the client and the key server, ensuring the privacy of the process of the client sending encryption requests to the key server.
[0058] In some embodiments, the aforementioned receiving and decrypting the encrypted request ciphertext information sent by the client to obtain the encrypted request, generating a target content key, and encrypting the target content key ciphertext information using the private key of the derived session key pair to obtain the target content key ciphertext information and send it to the client, that is, the aforementioned S130 may specifically include the following steps: S131. Receive the encrypted request ciphertext information sent by the client.
[0059] S132. Decrypt the encrypted request ciphertext information using the private key derived from the session key pair to obtain the encrypted request and verify the request parameters of the encrypted request.
[0060] S133. Generate a derived content key based on the master key, and bind the identity information and the derived content key to obtain a target content key.
[0061] S134. Encrypt the target content key using the private key of the derived session key pair to obtain ciphertext information of the target content key.
[0062] S135. Send the target content key ciphertext information to the client.
[0063] In some embodiments, the aforementioned receiving the target content key ciphertext information sent by the key server and decrypting it to obtain the target content key, that is, the aforementioned S240 may specifically include: S241. Receive the target content key ciphertext information sent by the key server.
[0064] S242. Decrypt the target content key ciphertext information using the public key of the derived session key pair to obtain the target content key.
[0065] In the embodiments of this application, it is understood that the derived content key is an SM4 key generated based on the master key. The derived content key is used to encrypt privacy-sensitive and confidential information required for the service, such as user information and core service information stored in the database. It can also be used in other scenarios using symmetric encryption. The derived content key is associated with the master key, and one master key can generate multiple derived content keys.
[0066] In some embodiments, the present application provides a key distribution system 300 based on end-to-end encryption of national secrets, such as Figure 4 As shown, the system 300 is used for a key server and may include the following modules: The first temporary key processing module 310 is used to generate a derived temporary key pair based on the SM4 algorithm. After receiving the first session request sent by the client and authenticating the client, the public key and WebSocket address of the derived temporary key pair are sent to the client so that the client can encrypt the identity information to obtain the identity ciphertext information.
[0067] The first session key processing module 320 is used to receive the identity ciphertext information sent by the client, perform decryption processing and generate a derived session key pair, and encrypt the session public key ciphertext information based on the private key of the derived temporary key pair and send it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request.
[0068] The first content key processing module 330 is used to receive the encryption request ciphertext information sent by the client and decrypt it to obtain the encryption request, generate the target content key and encrypt it through the private key of the derived session key pair to obtain the target content key ciphertext information and send it to the client.
[0069] According to an embodiment of the present application, any multiple modules among the first temporary key processing module 310, the first session key processing module 320, and the first content key processing module 330 can be combined into a single module, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in a single module.
[0070] In some embodiments, the first temporary key processing module 310 may be specifically configured to: Generate a master key based on the SM4 algorithm, and generate a derived temporary key pair based on the master key; After receiving the first session request from the client, authenticate the client and verify the TLS certificate; After verification, the public key and WebSocket address of the derived temporary key pair are sent to the client, and a WebSocket TLS end-to-end encrypted channel is established for the client to encrypt the identity information and obtain the identity ciphertext information.
[0071] In some embodiments, the first session key processing module 320 may be specifically configured to: Receive the encrypted identity information sent by the client; Decrypt the identity ciphertext information by deriving the private key of the temporary key pair to obtain the identity information; Obtain a random number, and generate a derived session key pair based on the master key and the random number and bound to the identity information; The public key of the derived session key pair is encrypted using the private key of the derived temporary key pair to obtain the ciphertext of the session public key and send it to the client for decryption to obtain the public key of the derived session key pair to encrypt the encryption request.
[0072] In some embodiments, the first content key processing module 330 may be specifically configured to: Receive the encrypted request ciphertext information sent by the client; Decrypt the encrypted request ciphertext information using the private key derived from the session key pair to obtain the encrypted request and verify the request parameters of the encrypted request; Generate a derived content key based on the master key, and bind the identity information and the derived content key to obtain the target content key; Encrypt the target content key by deriving the private key of the session key pair to obtain the target content key ciphertext information; Send the target content key ciphertext information to the client.
[0073] In some embodiments, the present application provides a key distribution system 400 based on end-to-end encryption of national secrets, such as Figure 5 As shown, the system 400 is used for a client and may include the following modules: A session request sending module 410 is configured to send a first session request to the key server for the key server to authenticate the client; The second temporary key processing module 420 is configured to receive the public key and WebSocket address of the derived temporary key pair, encrypt the client's identity information to obtain identity ciphertext information, and send the ciphertext information to the key server; The second session key processing module 430 is configured to receive the ciphertext of the session public key sent by the key server and decrypt it to obtain the public key of the derived session key pair, encrypt the encryption request, obtain the encrypted request ciphertext, and send it to the key server for the key server to decrypt and obtain the encrypted request; The second content key processing module 440 is configured to receive the target content key ciphertext information sent by the key server and decrypt it to obtain the target content key.
[0074] According to an embodiment of the present application, any multiple modules among the session request sending module 410, the second temporary key processing module 420, the second session key processing module 430, and the second content key processing module 440 can be combined into a single module, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in a single module.
[0075] In some embodiments, the second temporary key processing module 420 may be specifically configured to: Receive the public key and WebSocket address of the derived temporary key pair sent by the key server; Determine the client's identity information, including ID information and IP information, and encrypt the identity information using the public key of the derived temporary key pair to obtain the identity ciphertext information; Send identity ciphertext information to the key server.
[0076] In some embodiments, the second session key processing module 430 may be specifically configured to: Receive the session public key ciphertext information sent by the key server; Decrypt the session public key ciphertext information using the public key of the derived temporary key pair to obtain the public key of the derived session key pair; Triggering an encryption request for deriving a content key, and encrypting the encryption request based on the public key of the derived session key pair to obtain encryption request ciphertext information; The encrypted request ciphertext is sent to the key server through the WebSocket TLS end-to-end encrypted channel, so that the key server can decrypt it and obtain the encrypted request.
[0077] In some embodiments, the second content key processing module 440 may be specifically configured to: Receive the target content key ciphertext information sent by the key server; The target content key is decrypted by deriving the public key of the session key pair to obtain the target content key.
[0078] Figure 4 and Figure 5 Each module in the system shown has the function of implementing each step in the aforementioned end-to-end encryption key distribution method based on national secrets, and can achieve its corresponding technical effects. For the sake of concise description, it will not be repeated here.
[0079] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.
[0080] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0081] In summary, compared with the prior art, this application has the following beneficial effects: 1. This application uses the national secret algorithm to protect the key distribution process, meeting the application under specific security needs and compliance requirements.
[0082] 2. This application can meet most scenarios of secure key distribution. By refining the hierarchical types of keys, a one-master-multiple-derived key family can be implemented. The cancellation of the master family can quickly cancel the keys of its sub-family.
[0083] 3. This application solves the problem of system unavailability caused by single point failure and is more flexible and applicable to large-scale distributed systems.
[0084] 4. This application solves the problem of insufficient security and flexibility in current key distribution, which makes it difficult to meet specific security requirements.
[0085] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A key distribution method based on end-to-end encryption of national secrets, characterized in that: For the key server, the key distribution method based on the national secret end-to-end encryption includes: Generate a derived temporary key pair based on the SM4 algorithm. After receiving the first session request from the client and authenticating the client, send the public key and WebSocket address of the derived temporary key pair to the client, so that the client can encrypt the identity information to obtain the identity ciphertext information. Receive the identity ciphertext information sent by the client, decrypt it and generate a derived session key pair, and encrypt the obtained session public key ciphertext information based on the private key of the derived temporary key pair and send it to the client for the client to decrypt it to obtain the public key of the derived session key pair to encrypt the encryption request; Receive the encryption request ciphertext information sent by the client and decrypt it to obtain the encryption request, generate the target content key and encrypt it with the private key of the derived session key pair to obtain the target content key ciphertext information and send it to the client.
2. The key distribution method based on end-to-end encryption of national secrets according to claim 1, characterized in that: The derived temporary key pair is generated based on the SM4 algorithm. After receiving the first session request sent by the client and authenticating the client, the public key and WebSocket address of the derived temporary key pair are sent to the client for the client to encrypt the identity information to obtain the identity ciphertext information, including: Generate a master key based on the SM4 algorithm, and generate a derived temporary key pair based on the master key; After receiving the first session request from the client, authenticate the client and verify the TLS certificate; After verification, the public key and WebSocket address of the derived temporary key pair are sent to the client, and a WebSocket TLS end-to-end encrypted channel is established for the client to encrypt the identity information to obtain identity ciphertext information.
3. The key distribution method based on end-to-end encryption of national secrets according to claim 2, characterized in that: The receiving of the identity ciphertext information sent by the client, performing decryption processing and generating a derived session key pair, and encrypting the obtained session public key ciphertext information based on the private key of the derived temporary key pair and sending the ciphertext information to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request, including: Receiving the encrypted identity information sent by the client; Decrypting the identity ciphertext information using the private key of the derived temporary key pair to obtain identity information; Obtain a random number, and generate a derived session key pair based on the master key and the random number and bound to the identity information; The public key of the derived session key pair is encrypted using the private key of the derived temporary key pair to obtain the session public key ciphertext information and send it to the client for the client to decrypt and obtain the public key of the derived session key pair to encrypt the encryption request.
4. The key distribution method based on end-to-end encryption of national secrets according to claim 2, characterized in that: The receiving and decrypting the encrypted request ciphertext information sent by the client to obtain the encrypted request, generating a target content key and encrypting the target content key ciphertext information by using the private key of the derived session key pair to obtain the target content key ciphertext information and sending the ciphertext information to the client, including: Receiving the encrypted request ciphertext information sent by the client; Decrypting the encrypted request ciphertext information using the private key of the derived session key pair to obtain the encrypted request and verifying the request parameters of the encrypted request; generating a derived content key based on the master key, and binding the identity information and the derived content key to obtain a target content key; Encrypting the target content key using the private key of the derived session key pair to obtain ciphertext information of the target content key; Sending target content key ciphertext information to the client.
5. A key distribution method based on end-to-end encryption of national secrets, characterized in that: For the client, the key distribution method based on end-to-end encryption of national secrets includes: Sending a first session request to the key server for the key server to authenticate the client; Receive the public key and WebSocket address of the derived temporary key pair, encrypt the client's identity information to obtain identity ciphertext information, and send it to the key server; Receive the session public key ciphertext information sent by the key server and decrypt it to obtain the public key of the derived session key pair, encrypt the encryption request, obtain the encryption request ciphertext information and send it to the key server, so that the key server can decrypt it to obtain the encryption request; Receive the target content key ciphertext information sent by the key server and decrypt it to obtain the target content key.
6. The key distribution method based on end-to-end encryption of national secrets according to claim 5, characterized in that: The receiving of the public key and WebSocket address of the derived temporary key pair, encrypting the identity information of the client to obtain identity ciphertext information, and sending the identity ciphertext information to the key server includes: Receive the public key and WebSocket address of the derived temporary key pair sent by the key server; Determine the identity information of the client including ID information and IP information, and encrypt the identity information using the public key of the derived temporary key pair to obtain identity ciphertext information; Send the identity ciphertext information to the key service end.
7. The key distribution method based on end-to-end encryption of national secrets according to claim 5, characterized in that: The receiving the session public key ciphertext information sent by the key server and decrypting it to obtain the public key of the derived session key pair, encrypting the encryption request, obtaining the encryption request ciphertext information and sending it to the key server for the key server to decrypt and obtain the encryption request, including: Receiving the session public key ciphertext information sent by the key server; Decrypting the session public key ciphertext information using the public key of the derived temporary key pair to obtain the public key of the derived session key pair; triggering an encryption request for a derived content key, and encrypting the encryption request based on the public key of the derived session key pair to obtain encryption request ciphertext information; The encrypted request ciphertext information is sent to the key server through the WebSocket TLS end-to-end encrypted channel, so that the key server decrypts it to obtain the encrypted request.
8. The key distribution method based on end-to-end encryption of national secrets according to claim 5 is characterized in that: The receiving the target content key ciphertext information sent by the key server and decrypting it to obtain the target content key includes: Receiving target content key ciphertext information sent by the key server; The target content key ciphertext information is decrypted using the public key of the derived session key pair to obtain the target content key.
9. A key distribution system based on end-to-end encryption of national secrets, characterized in that: For the key server, the key distribution system based on the national secret end-to-end encryption includes: A first temporary key processing module is configured to generate a derived temporary key pair based on the SM4 algorithm. After receiving the first session request from the client and authenticating the client, the module sends the public key and WebSocket address of the derived temporary key pair to the client, so that the client can encrypt the identity information to obtain ciphertext identity information. a first session key processing module, configured to receive the identity ciphertext information sent by the client, decrypt it and generate a derived session key pair, encrypt it using the private key of the derived temporary key pair to obtain the session public key ciphertext information, and send it to the client for the client to decrypt it to obtain the public key of the derived session key pair for encrypting the encryption request; The first content key processing module is used to receive the encryption request ciphertext information sent by the client and decrypt it to obtain the encryption request, generate the target content key and encrypt it with the private key of the derived session key pair to obtain the target content key ciphertext information and send it to the client.
10. A key distribution system based on end-to-end encryption of national secrets, characterized in that: For the client, the key distribution system based on the national secret end-to-end encryption includes: A session request sending module, configured to send a first session request to a key server for the key server to authenticate the client; A second temporary key processing module is configured to receive the public key and WebSocket address of the derived temporary key pair, encrypt the identity information of the client to obtain identity ciphertext information, and send the ciphertext information to the key server; a second session key processing module, configured to receive the ciphertext of the session public key sent by the key server and decrypt the ciphertext to obtain the public key of the derived session key pair, encrypt the encryption request, obtain the ciphertext of the encryption request, and send the ciphertext of the encryption request to the key server for the key server to decrypt the ciphertext to obtain the encryption request; The second content key processing module is used to receive the target content key ciphertext information sent by the key server and decrypt it to obtain the target content key.
Citation Information
Patent Citations
Session security processing system, equipment, device, and method
CN107404469A
TLS key exchange method and system based on national cryptographic algorithm
CN115664725A
Secret key negotiation method based on SM2 encryption certificate and communication system
CN119483917A
National key identification cryptographic algorithm-based private key distribution system
WO2022143030A1
Chinese national cryptographic algorithm-based identity authentication and data encryption method for coap
WO2025000590A1