Key distribution method and system for end-to-end encryption based on national secret
By using a national cryptographic end-to-end encryption method and the SM4 algorithm and WebSocket TLS channel for key distribution, the problem of insufficient security and flexibility in key distribution in existing technologies is solved, which meets specific security and compliance requirements and is suitable for large-scale distributed systems.
Patent Information
- Application Number
- CN202511254877.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-09-04
AI Technical Summary
Existing key distribution mechanisms are insufficient in terms of security and flexibility, making it difficult to meet specific security needs and compliance requirements, especially in large-scale distributed systems where there is a risk of single point of failure.
An end-to-end encryption method based on Chinese national cryptography is adopted. 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 session and content keys, ensuring the security and flexibility of the encryption process.
It enables applications under specific security and compliance requirements, supports large-scale distributed systems, solves the single point of failure problem, and improves the flexibility and security of key distribution.
Smart Images

Figure CN120729656B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of key distribution, in particular to a key distribution method and system based on end-to-end encryption of a national secret. BACKGROUND
[0002] With the acceleration of digital transformation, data security has become one of the main challenges faced by organizations. As the core of data security, key management plays a key role in protecting the confidentiality, integrity and availability of encryption keys. Effective key management strategies not only reduce the risk of data leakage and misuse, but also are essential to meet compliance requirements, establish user trust, and adapt to emerging technology challenges.
[0003] Key management plays a key role in ensuring data security, maintaining system integrity, supporting compliance, reducing risk, establishing trust, serving as the basis for encryption, adapting to technology development, responding quickly to security incidents, and covering the entire life cycle of keys. Key distribution is a key link in key management, which involves how to securely transfer keys between communicating parties.
[0004] In related technologies, current key distribution mechanisms mainly include Diffie-Hellman key exchange, public key infrastructure, and key distribution center. Each method has its specific application scenarios and advantages, but they also face some limitations in practical applications: Diffie-Hellman key exchange does not provide authentication of keys itself 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 center can become a single point of failure and may not be flexible enough for large-scale distributed systems. In terms of key hierarchical management, existing key management strategies often lack sufficient refinement and cannot meet the needs of different security levels and application scenarios, limiting their application in specific security requirements and compliance requirements. This leads to insufficient flexibility and targeting of key management, which may affect overall security and efficiency. SUMMARY
[0005] To overcome the deficiencies of the prior art, the application provides a key distribution method and system based on end-to-end encryption of a national secret, 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 purpose, the application is implemented by the following technical solutions:
[0007] In a first aspect, the embodiments of the present application provide a key distribution method based on a national secret end-to-end encryption, which is used for a key server and includes the following steps: generating a derived temporary key pair based on an SM4 algorithm; after receiving a first session request sent by a client and verifying the identity of the client, sending a public key of the derived temporary key pair and a WebSocket address to the client, so that the client encrypts identity information to obtain identity ciphertext information; receiving the identity ciphertext information sent by the client, performing decryption processing and generating a derived session key pair, encrypting a session public key ciphertext information based on a private key of the derived temporary key pair and sending the session public key ciphertext information to the client, so that the client decrypts the session public key ciphertext information to obtain a public key of the derived session key pair and encrypts an encryption request; receiving encryption request ciphertext information sent by the client and performing decryption to obtain the encryption request, generating a target content key and encrypting the target content key through the private key of the derived session key pair to obtain target content key ciphertext information and sending the target content key ciphertext information to the client.
[0008] According to the first aspect of the embodiments of the present application, the foregoing generating a derived temporary key pair based on an SM4 algorithm, after receiving a first session request sent by a client and verifying the identity of the client, sending a public key of the derived temporary key pair and a WebSocket address to the client, so that the client encrypts identity information to obtain identity ciphertext information, includes: generating a master key based on an SM4 algorithm, and generating a derived temporary key pair based on the master key; after receiving a first session request sent by a client, verifying the identity of the client and verifying a TLS certificate; after verification, sending the public key of the derived temporary key pair and the WebSocket address to the client, and establishing a WebSocket TLS end-to-end encryption channel, so that the client encrypts identity information to obtain identity ciphertext information.
[0009] According to the first aspect of the embodiments of the present application, the foregoing receiving identity ciphertext information sent by a client, performing decryption processing and generating a derived session key pair, encrypting session public key ciphertext information based on a private key of the derived temporary key pair and sending the session public key ciphertext information to the client, so that the client decrypts the session public key ciphertext information to obtain a public key of the derived session key pair and encrypts an encryption request, includes: receiving identity ciphertext information sent by a client; decrypting the identity ciphertext information through a private key of a derived temporary key pair to obtain identity information; obtaining a random number, generating a derived session key pair based on a master key and the random number and binding the identity information; encrypting a public key of the derived session key pair using the private key of the derived temporary key pair to obtain session public key ciphertext information and sending the session public key ciphertext information to the client, so that the client decrypts the session public key ciphertext information to obtain the public key of the derived session key pair and encrypts an encryption request.
[0010] According to a first aspect of the embodiments of the present application, the encrypted request ciphertext information sent by the client is received and decrypted to obtain an encrypted request, a target content key is generated and encrypted by the private key of the derived session key pair to obtain target content key ciphertext information and sent to the client, including: receiving the encrypted request ciphertext information sent by the client;
[0011] The encrypted request ciphertext information is decrypted by the private key of the derived session key pair to obtain the encrypted request and verify the request parameters of the encrypted request; the derived content key is generated based on the master key, and the identity information and the derived content key are bound to obtain the target content key; the target content key is encrypted by the private key of the derived session key pair to obtain the target content key ciphertext information; and the target content key ciphertext information is sent to the client.
[0012] In a second aspect, the embodiments of the present application provide a key distribution method based on end-to-end encryption of national secret, for a client, the key distribution method based on end-to-end encryption of national secret includes: sending a first session request to a key server for the key server to authenticate the client; receiving the public key of a derived temporary key pair and a WebSocket address, encrypting the identity information of the client to obtain identity ciphertext information, and sending the identity ciphertext information to the key server; receiving the session public key ciphertext information sent by the key server and decrypting the session public key ciphertext information to obtain the public key of the derived session key pair, encrypting the encrypted request to obtain encrypted request ciphertext information, and sending the encrypted request ciphertext information to the key server to decrypt the encrypted request; receiving the target content key ciphertext information sent by the key server and decrypting the target content key ciphertext information to obtain the target content key.
[0013] According to a second aspect of the embodiments of the present application, the public key of the derived temporary key pair and the WebSocket address are received, the identity information of the client is encrypted to obtain identity ciphertext information, and the identity ciphertext information is sent to the key server, including: receiving the public key of the derived temporary key pair and the WebSocket address 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 the identity ciphertext information; and sending the identity ciphertext information to the key server.
[0014] According to a second aspect of the embodiments 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, so as to decrypt the encryption request by the key server, comprising: receiving the session public key ciphertext information sent by the key server; decrypting the session public key ciphertext information by the public key of the derived temporary key pair to obtain the public key of the derived session key pair; triggering the encryption request of 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 encryption channel, so that the key server decrypts the encryption request.
[0015] According to a second aspect of the embodiments 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, comprising: receiving the target content key ciphertext information sent by the key server; decrypting the target content key ciphertext information by the public key of the derived session key pair to obtain the target content key.
[0016] In a third aspect, the embodiments of the present application provide a key distribution system based on end-to-end encryption of national secret, for a key server, comprising: 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, and after receiving the first session request sent by the client and verifying the identity of the client, the public key of the derived temporary key pair and the WebSocket address are sent to the client, so that the client encrypts the identity information to obtain the identity ciphertext information; the first session key processing module is used to receive the identity ciphertext information sent by the client, decrypt and generate the 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, so that the client decrypts to obtain the public key of the derived session key pair, so as 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, obtain the target content key ciphertext information and send it to the client.
[0017] In a fourth aspect, the embodiments of the present application provide a key distribution system based on end-to-end encryption of national secret, for a client, the key distribution system based on end-to-end encryption of national secret comprising: 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 configured to send a first session request to a key server for the key server to authenticate the client; the second temporary key processing module is configured to receive a public key of a derived temporary key pair and a WebSocket address, encrypt identity information of the client to obtain identity ciphertext information, and send the identity ciphertext information to the key server; the second session key processing module is configured to receive session public key ciphertext information sent by the key server and decrypt the session public key ciphertext information to obtain a public key of a derived session key pair, encrypt an encryption request to obtain encryption request ciphertext information, and send the encryption request ciphertext information to the key server, so that the key server decrypts the encryption request; and the second content key processing module is configured to receive target content key ciphertext information sent by the key server, and decrypt the target content key ciphertext information to obtain a target content key.
[0018] The present application provides a key distribution method and system based on end-to-end encryption of national secret. Compared with the prior art, the following beneficial effects are achieved:
[0019] After receiving the first session request sent by the client, the present application authenticates the client, sends a public key of a derived temporary key pair and a WebSocket address generated based on an SM4 algorithm to the client, encrypts identity information of the client to obtain identity ciphertext information, and sends the identity ciphertext information to the key server; the key server decrypts the identity ciphertext information and generates a derived session key pair, encrypts a private key of the derived temporary key pair to obtain session public key ciphertext information and sends the session public key ciphertext information to the client, so that the client decrypts the session public key ciphertext information to obtain a public key of the derived session key pair, encrypts an encryption request to obtain encryption request ciphertext information, and sends the encryption request ciphertext information to the key server; after decrypting the encryption request, the key server generates a target content key, encrypts the target content key by using a private key of the derived session key pair, and sends the target content key to the client; and the client decrypts the target content key after receiving the target content key. The present application protects the process of distributing the key by using a national secret algorithm, meets the application under specific security requirements and compliance requirements, and can meet most scenarios of securely distributing the key, realizes a master key family and a plurality of derived key families by refining the hierarchical types of the key, the master key family can be quickly unregistered, solves the problem that a single point failure causes the system to be unable to be used, and is more flexible for large-scale distributed systems. BRIEF DESCRIPTION OF DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without any creative effort.
[0021] Figure 1 is a flowchart of a key distribution method based on end-to-end encryption of a national secret provided by an embodiment of the present application;
[0022] Figure 2 is a flowchart of another key distribution method based on end-to-end encryption of a national secret provided by an embodiment of the present application;
[0023] Figure 3 is an interaction diagram between a key server and a client provided by an embodiment of the present application;
[0024] Figure 4 is a structural diagram of a key distribution system based on end-to-end encryption of a national secret provided by an embodiment of the present application;
[0025] Figure 5 is a structural diagram of another key distribution system based on end-to-end encryption of a national secret provided by an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application are described clearly and completely. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort belong to the protection scope of the present application.
[0027] It should be noted that in this document, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another same element in the process, method, article or equipment including the element.
[0028] The embodiments of the present application provide a key distribution method and system based on end-to-end encryption of national cryptography, and solve the problems of insufficient security and flexibility in current key distribution, and difficulty in meeting specific security requirements.
[0029] The technical solutions in the embodiments of the present application are to solve the above technical problems, and the general idea is as follows:
[0030] With the acceleration of digital transformation, data security has become one of the main challenges faced by organizations. As the core of data security, key management plays a key role in protecting the confidentiality, integrity and availability of encryption keys. Effective key management strategies not only reduce the risk of data leakage and misuse, but also are crucial for meeting compliance requirements, establishing user trust, and adapting to emerging technology challenges.
[0031] Key management plays a key role in ensuring data security, maintaining system integrity, supporting compliance, reducing risk, establishing trust, serving as the basis for encryption, adapting to technology development, responding quickly to security incidents, and covering the entire life cycle of keys. Key distribution is a key link in key management, which involves how to securely transfer keys between communicating parties.
[0032] Defects and deficiencies of the prior art:
[0033] 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:
[0034] (1) Diffie-Hellman key exchange: Although it allows both parties to securely exchange keys over an insecure channel, it does not provide key authentication itself and is vulnerable to man-in-the-middle attacks.
[0035] (2) Public Key Infrastructure (PKI): provides a comprehensive solution for identity verification and key management, but it relies on trusted third-party certificate authorities and has high management costs.
[0036] (3) Key Distribution Center (KDC): such as the KDC in the Kerberos protocol, provides an effective key distribution and management method for network services, but it can become a single point of failure and may not be flexible enough for large-scale distributed systems.
[0037] In addition, there is a lack of key distribution mechanisms based on national cryptographic algorithms in the current market, which limits their application in specific security requirements and compliance requirements.
[0038] 2、There are also some deficiencies in key management, especially in key hierarchical management. The existing key management strategy often lacks sufficient refinement and cannot meet the needs of different security levels and application scenarios. This leads to insufficient flexibility and relevance of key management, which may affect the overall security and efficiency.
[0039] In order to better understand the above technical solutions, the above technical solutions will be described in detail in conjunction with the drawings in the specification and specific embodiments.
[0040] First, a key distribution method based on end-to-end encryption of national secret provided by the embodiment of the application will be introduced.
[0041] The flowchart of the key distribution method based on end-to-end encryption of national secret provided by the embodiment of the application is shown in Figure 1 The key distribution method based on end-to-end encryption of national secret is used for the key server and can include the following steps S110-S130.
[0042] S110, generate a pair of derived temporary keys based on the SM4 algorithm, after receiving the first session request sent by the client and verifying the identity of the client, send the public key of the derived temporary key pair and the WebSocket address to the client, for the client to encrypt the identity information to obtain the identity ciphertext information.
[0043] S120, receive the identity ciphertext information sent by the client, perform decryption processing and generate a pair of derived session keys, 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 the public key of the derived session key pair to encrypt the encryption request.
[0044] S130, receive the encrypted request ciphertext information sent by the client and perform decryption to obtain the encryption request, generate the target content key and encrypt it through the private key of the derived session key pair, obtain the target content key ciphertext information and send it to the client.
[0045] In some embodiments, the application provides a key distribution method based on end-to-end encryption of national secret, as shown in Figure 2 The method is used for the client and can include the following steps:
[0046] S210, send a first session request to the key server for the key server to verify the identity of the client.
[0047] S220, receive the public key of the derived temporary key pair and the WebSocket address, encrypt the identity information of the client to obtain the identity ciphertext information, and send it to the key server.
[0048] S230, receiving the session public key ciphertext information sent by the key server and decrypting to obtain the public key of the derived session key pair, to encrypt the encrypted request, obtain the encrypted request ciphertext information and send to the key server, for the key server to decrypt to obtain the encrypted request.
[0049] S240, receiving the target content key ciphertext information sent by the key server, and decrypting to obtain the target content key.
[0050] The above is a specific implementation of a key distribution method based on the end-to-end encryption of the national secret provided by the embodiment of the application, and it can be understood that please refer to Figures 1-3 After receiving the first session request sent by the client, the application verifies the identity of the client, sends the public key of the derived temporary key pair and the WebSocket address based on the SM4 algorithm to the client, encrypts the identity information of the client to obtain the identity ciphertext information, and sends it to the key server; the key server decrypts and generates a derived session key pair based on the identity ciphertext information, encrypts the private key of the derived temporary key pair to obtain the session public key ciphertext information and sends it to the client, for the client to decrypt to obtain the public key of the derived session key pair, to encrypt the encrypted request, obtain the encrypted request ciphertext information and send to the key server, the key server decrypts to obtain the encrypted request, generates the target content key and encrypts it through the private key of the derived session key pair and sends it to the client, the client decrypts after receiving to obtain the target content key.
[0051] Based on this, the application adopts the national secret algorithm to protect the process of distributing the key, meets the application under the specific security demand and compliance requirement; and can meet most of the security key distribution scene, through the refinement of the hierarchical category of the key, realizes a main multi-derived key family, the main family can quickly cancel its child key; solves the problem that single point failure causes the system to be unable to use, and is more flexible for large-scale distributed system. The application solves the problems of insufficient security and flexibility in current key distribution, and is difficult to meet the specific security requirements.
[0052] It should be noted that WebSocket itself is an independent protocol designed to establish a persistent connection between a web client and a server. However, in order to ensure the security of communication, WebSocket can also use TLS encryption through the wss: / / (WebSocket Secure) protocol scheme. When using wss: / / , the WebSocket connection uses TLS (Transport Layer Security) on the transport layer to encrypt data, similar to the encryption of HTTPS to HTTP.
[0053] In some embodiments, the foregoing generation of the derived temporary key pair based on the SM4 algorithm, after receiving the first session request sent by the client and authenticating the client, sends the public key of the derived temporary key pair and the WebSocket address to the client for the client to encrypt the identity information to obtain the identity ciphertext information, that is, the foregoing S110 can specifically include the following steps:
[0054] S111, generating a master key based on the SM4 algorithm, and generating a derived temporary key pair based on the master key.
[0055] S112, after receiving the first session request sent by the client, authenticating the client and verifying the TLS certificate.
[0056] S113, after verification, sending the public key of the derived temporary key pair and the WebSocket address to the client, and establishing a WebSocket TLS end-to-end encryption channel for the client to encrypt the identity information to obtain the identity ciphertext information.
[0057] In some embodiments, the foregoing receiving the public key of the derived temporary key pair and the WebSocket address, encrypting the identity information of the client to obtain the identity ciphertext information, and sending to the key service end, that is, the foregoing S220 can specifically include the following steps:
[0058] S221, receiving the public key of the derived temporary key pair and the WebSocket address sent by the key service end.
[0059] S222, determining the identity information of the client including the ID information and the IP information, encrypting the identity information by the public key of the derived temporary key pair to obtain the identity ciphertext information.
[0060] S223, sending the identity ciphertext information to the key service end.
[0061] In the embodiments of the present application, it can be understood that the master key is the uppermost layer of the key system, and the master key is managed by a user administrator or a system administrator after being generated; other derived keys are generated based on the master key, and after the master key is revoked, other derived keys will also be revoked accordingly; the master key generation method is the SM4 algorithm, that is, the master key is an SM4 key. The derived temporary key pair is associated with the master key and is used to encrypt the first interaction between the key service end and the client, and one master key can generate multiple derived temporary key pairs.
[0062] It also needs to be explained that in the distributed architecture, considering the distributed deployment, the application also makes corresponding design optimization for how the client quickly obtains the target content key. The client will pre-register an identity ID in the key system, and the identity ID will be bound with the master key and stored in the nearest key system and its database, and at the same time, the master key will be synchronized to the key system and its database at the farthest end as a backup. When a certain client triggers a distribution key request, a WebSocket address will be allocated according to its identity ID and IP address, which is used to establish an end-to-end encrypted channel. If a certain client triggers a distribution key request in A, and its master key is also stored in A, the key system will allocate the address of the WebSocket in A to the user; in contrast, if the master key corresponding to a certain client is in B, and the backup is in C, the key system will allocate the address of the WebSocket in C to the user.
[0063] In some embodiments, the aforementioned receiving the identity ciphertext information sent by the client, performing decryption processing and generating a derived session key pair, and encrypting the session public key ciphertext information based on the private key of the derived temporary key pair and sending it to the client, so that the client decrypts the derived session key pair to obtain the public key, and encrypts the encryption request, that is, the aforementioned S120 can specifically include the following steps:
[0064] S121, receiving the identity ciphertext information sent by the client.
[0065] S122, decrypting the identity ciphertext information by using the private key of the derived temporary key pair to obtain the identity information.
[0066] S123, obtaining a random number, generating a derived session key pair based on the master key and the random number and binding the identity information.
[0067] S124, encrypting the public key of the derived session key pair by using 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 decrypts the derived session key pair to obtain the public key, and encrypts the encryption request.
[0068] In some embodiments, the aforementioned receiving the session public key ciphertext information sent by the key service end and decrypting the public key of the derived session key pair to encrypt the encryption request, obtaining the encryption request ciphertext information and sending it to the key service end, so that the key service end decrypts the encryption request, that is, the aforementioned S230 can specifically include:
[0069] S231, receiving the session public key ciphertext information sent by the key service end.
[0070] S232, decrypt 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.
[0071] S233, trigger an encryption request of the derived content key, and encrypt the encryption request based on the public key of the derived session key pair to obtain encryption request ciphertext information.
[0072] S234, send the encryption request ciphertext information to the key server through the WebSocket TLS end-to-end encryption channel, so that the key server decrypts the encryption request.
[0073] In the embodiments 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 for encrypting and decrypting the encryption request between the client and the key server, to ensure the privacy of the process of sending the encryption request from the client to the key server.
[0074] In some embodiments, the foregoing receiving the encryption request ciphertext information sent by the client and decrypting the encryption request ciphertext information to obtain the encryption request, generating the target content key and encrypting the target content key by using the private key of the derived session key pair to obtain the target content key ciphertext information and sending the target content key ciphertext information to the client, that is, the foregoing S130 can specifically include the following steps:
[0075] S131, receiving the encryption request ciphertext information sent by the client.
[0076] S132, decrypting the encryption request ciphertext information by using the private key of the derived session key pair to obtain the encryption request and verifying the request parameters of the encryption request.
[0077] S133, generating the derived content key based on the master key, and binding the identity information and the derived content key to obtain the target content key.
[0078] S134, encrypting the target content key by using the private key of the derived session key pair to obtain the target content key ciphertext information.
[0079] S135, sending the target content key ciphertext information to the client.
[0080] In some embodiments, the foregoing receiving the target content key ciphertext information sent by the key server and decrypting the target content key ciphertext information to obtain the target content key, that is, the foregoing S240 can specifically include:
[0081] S241, receiving the target content key ciphertext information sent by the key server.
[0082] S242, decrypting the target content key ciphertext information by using the public key of the derived session key pair to obtain the target content key.
[0083] In the embodiments of the present application, it can be understood that the derived content key is an SM4 key generated based on the master key, and the derived content key is used to encrypt privacy-sensitive confidential information required to be encrypted in the service, such as user information stored in the database, service core information, and the like; and 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.
[0084] In some embodiments, the present application provides a key distribution system 300 based on end-to-end encryption of national secret, as shown in Figure 4 The system 300 is used for a key service end and can include the following modules:
[0085] The first temporary key processing module 310 is configured to generate a derived temporary key pair based on the SM4 algorithm, and send the public key of the derived temporary key pair and a WebSocket address to the client after receiving the first session request sent by the client and verifying the identity of the client, so as to be used by the client to encrypt the identity information to obtain identity ciphertext information.
[0086] The first session key processing module 320 is configured 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, so as to be used by the client to decrypt the public key of the derived session key pair to encrypt the encryption request.
[0087] The first content key processing module 330 is configured to receive the encryption request ciphertext information sent by the client and perform decryption to obtain the encryption request, generate a target content key and encrypt it through the private key of the derived session key pair to obtain target content key ciphertext information and send it to the client.
[0088] According to the embodiments of the present application, any multiple modules in 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 in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of the modules can be combined with at least part of the functions of other modules, and implemented in one module.
[0089] In some embodiments, the first temporary key processing module 310 can be specifically configured to:
[0090] Generate a master key based on the SM4 algorithm, and generate a derived temporary key pair based on the master key;
[0091] After receiving the first session request sent by the client, verify the identity of the client and verify the TLS certificate;
[0092] After the verification passes, the public key of the derived temporary key pair and the WebSocket address are sent to the client, and a WebSocket TLS end-to-end encryption channel is established for the client to encrypt the identity information to obtain identity ciphertext information.
[0093] In some embodiments, the first session key processing module 320 can be specifically configured to:
[0094] receive the identity ciphertext information sent by the client;
[0095] decrypt the identity ciphertext information by using the private key of the derived temporary key pair to obtain the identity information;
[0096] obtain a random number, generate a derived session key pair based on the master key and the random number and binding the identity information;
[0097] encrypt the public key of the derived session key pair by using the private key of the derived temporary key pair to obtain session public key ciphertext information and send the session public key ciphertext information to the client, so that the client decrypts the session public key ciphertext information to obtain the public key of the derived session key pair, and encrypts the encryption request by using the public key of the derived session key pair.
[0098] In some embodiments, the first content key processing module 330 can be specifically configured to:
[0099] receive the encryption request ciphertext information sent by the client;
[0100] decrypt the encryption request ciphertext information by using the private key of the derived session key pair to obtain the encryption request and verify the request parameters of the encryption request;
[0101] 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;
[0102] encrypt the target content key by using the private key of the derived session key pair to obtain target content key ciphertext information;
[0103] send the target content key ciphertext information to the client.
[0104] In some embodiments, the present application provides a key distribution system 400 based on end-to-end encryption of national secret, as shown in Figure 5 The system 400 is used for the client and can include the following modules:
[0105] The session request sending module 410 is configured to send a first session request to the key server for the key server to perform identity verification on the client.
[0106] The second temporary key processing module 420 is configured to receive the public key of the derived temporary key pair and the WebSocket address, encrypt identity information of the client to obtain identity ciphertext information, and send the identity ciphertext information to the key server.
[0107] The second session key processing module 430 is configured to receive the session public key ciphertext information sent by the key server, decrypt the session public key ciphertext information to obtain the public key of the derived session key pair, encrypt an encryption request based on the public key of the derived session key pair to obtain encryption request ciphertext information, and send the encryption request ciphertext information to the key server, so that the key server decrypts the encryption request to obtain the encryption request.
[0108] The second content key processing module 440 is configured to receive the target content key ciphertext information sent by the key server, and decrypt the target content key ciphertext information to obtain the target content key.
[0109] According to embodiments of the present application, any one or more of 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 in one module, or any one of them can be split into multiple modules. Alternatively, at least part of the function of one or more of these modules can be combined with at least part of the function of other modules, and implemented in one module.
[0110] In some embodiments, the second temporary key processing module 420 can be specifically configured to:
[0111] receive the public key of the derived temporary key pair and the WebSocket address sent by the key server;
[0112] determine identity information of the client including ID information and IP information, encrypt the identity information by using the public key of the derived temporary key pair to obtain identity ciphertext information;
[0113] send the identity ciphertext information to the key server.
[0114] In some embodiments, the second session key processing module 430 can be specifically configured to:
[0115] receive the session public key ciphertext information sent by the key server;
[0116] decrypt 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;
[0117] trigger an encryption request of a derived content key, and encrypt the encryption request based on the public key of the derived session key pair to obtain encryption request ciphertext information;
[0118] The encrypted request ciphertext information is sent to the key service end through the WebSocket TLS end-to-end encryption channel, so that the key service end decrypts the encrypted request.
[0119] In some embodiments, the second content key processing module 440 can be specifically configured to:
[0120] receive the target content key ciphertext information sent by the key service end;
[0121] decrypt the target content key ciphertext information through the public key of the derived session key pair to obtain the target content key.
[0122] Figure 4 and Figure 5 Each module in the system shown in the figure has the function of implementing each step in the foregoing key distribution method based on the national secret end-to-end encryption, and can achieve the corresponding technical effects. For the sake of brevity, no further description is given here.
[0123] It should be noted that the present application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after understanding the spirit of the present application.
[0124] It should also be noted that the exemplary embodiments mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in an order different from the embodiments, or several steps can be performed simultaneously.
[0125] In summary, compared with the prior art, the present application has the following beneficial effects:
[0126] 1. The present application protects the process of distributing keys by using national secret algorithm, which meets the application under specific security requirements and compliance requirements.
[0127] 2. The present application can meet most of the scenarios of secure key distribution, and through the refinement of the hierarchical types of keys, a master key family is realized, and the master key family can quickly cancel its child key family.
[0128] 3. The present application solves the problem that single point failure causes the system to be unable to use, and is more flexible for large-scale distributed systems.
[0129] 4. The application solves the problem of insufficient security and flexibility in current key distribution, which is difficult to meet specific security requirements.
[0130] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalent features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A key distribution method for end-to-end encryption based on national cryptographic standards, characterized in that, For use in a key server, the end-to-end encryption key distribution method based on national cryptographic standards includes: A derived temporary key pair is generated based on the SM4 algorithm. After receiving the first session request from 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 ciphertext identity information. The system receives the encrypted identity information sent by the client, decrypts it, generates a derived session key pair, and encrypts the session public key encrypted information based on the private key of the derived temporary key pair and sends it to the client. The client then decrypts the encrypted information to obtain the public key of the derived session key pair, which is used to encrypt the encryption request. The system receives and decrypts the encrypted request ciphertext information sent by the client to obtain the encrypted request, generates a target content key and encrypts it using the private key of the derived session key pair to obtain the target content key ciphertext information and sends it to the client. The method of generating a derived temporary key pair based on the SM4 algorithm, after receiving the first session request from the client and authenticating the client, sends the public key and WebSocket address of the derived temporary key pair to the client for the client to encrypt identity information to obtain ciphertext identity information, including: A master key is generated based on the SM4 algorithm, and a derived temporary key pair is generated based on the master key. After receiving the first session request from the client, the client is authenticated and its TLS certificate is verified. After successful verification, the public key of the derived temporary key pair and the WebSocket address 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 ciphertext identity information. One master key can generate multiple derived temporary key pairs; The process of receiving encrypted identity information sent by the client, decrypting it to generate a derived session key pair, encrypting it with the private key of the derived temporary key pair to obtain encrypted session public key information, and sending it to the client for the client to decrypt to obtain the public key of the derived session key pair, and then encrypting the encryption request, includes: Receive the encrypted identity information sent by the client; The identity information is obtained by decrypting the encrypted identity information using the private key of the derived temporary key pair. Obtain a random number, and based on the master key and the random number, bind the identity information to generate a derived session key pair; The private key of the derived temporary key pair is used to encrypt the public key of the derived session key pair to obtain the ciphertext information of the session public key, which is then sent to the client for the client to decrypt and obtain the public key of the derived session key pair, so as to encrypt the encryption request.
2. The key distribution method for end-to-end encryption based on national cryptographic standards as described in claim 1, characterized in that, The process of receiving and decrypting the encrypted request ciphertext information sent by the client to obtain the encrypted request, generating a target content key and encrypting it using the private key of the derived session key pair to obtain the target content key ciphertext information, and sending it to the client includes: Receive encrypted request ciphertext information sent by the client; The encrypted request ciphertext is decrypted using the private key of the derived session key pair to obtain the encrypted request and verify the request parameters of the encrypted request. A derived content key is generated based on the master key, and the identity information and the derived content key are bound together to obtain the target content key; The target content key is encrypted using the private key of the derived session key pair to obtain the ciphertext information of the target content key; Send the target content key encrypted information to the client.
3. A key distribution method for end-to-end encryption based on national cryptographic standards, characterized in that, For the client, the end-to-end encryption key distribution method based on Chinese national cryptographic standards includes: Send an initial 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 ciphertext identity information, and send it to the key server; The system receives the session public key ciphertext information sent by the key server and decrypts it to obtain the public key of the derived session key pair, which is used to encrypt the encryption request. The encrypted request ciphertext information is then sent to the key server for the key server to decrypt and 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; The process of receiving the public key and WebSocket address of the derived temporary key pair, encrypting the client's identity information to obtain encrypted identity information, and sending it to the key server includes: Receive the public key and WebSocket address of the derived temporary key pair sent by the key server; The client's identity information, including ID and IP information, is determined, and the identity information is encrypted using the public key of the derived temporary key pair to obtain the encrypted identity information. Send the encrypted identity information to the key server; The process of 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, includes: Receive the session public key ciphertext information sent by the key server; The public key of the derived session key pair is obtained by decrypting the ciphertext information of the session public key using the public key of the derived temporary key pair. Trigger an encryption request for the derived content key, and encrypt the encryption request based on the public key of the derived session key pair to obtain the encrypted request ciphertext information; The encrypted request ciphertext is sent to the key server via a WebSocket TLS end-to-end encrypted channel, so that the key server can decrypt it to obtain the encrypted request.
4. The key distribution method for end-to-end encryption based on national cryptographic standards as described in claim 3, characterized in that, The step of receiving the target content key ciphertext information sent by the key server and decrypting it to obtain the target content key includes: Receive the target content key ciphertext information sent by the key server; The target content key is obtained by decrypting the ciphertext information of the target content key using the public key of the derived session key pair.
5. A key distribution system based on national cryptographic standards for end-to-end encryption, characterized in that, For use as a key server, the end-to-end encryption key distribution system based on national cryptographic standards includes: 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, it 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 the ciphertext identity 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 the session public key ciphertext information based on the private key of the derived temporary key pair and send it to the client, so that the client can decrypt it to obtain the public key of the derived session key pair, and encrypt the encryption request. The first content key processing module is used to receive the encrypted 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. The method of generating a derived temporary key pair based on the SM4 algorithm, after receiving the first session request from the client and authenticating the client, sends the public key and WebSocket address of the derived temporary key pair to the client for the client to encrypt identity information to obtain ciphertext identity information, including: A master key is generated based on the SM4 algorithm, and a derived temporary key pair is generated based on the master key. After receiving the first session request from the client, the client is authenticated and its TLS certificate is verified. After successful verification, the public key of the derived temporary key pair and the WebSocket address 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 ciphertext identity information. One master key can generate multiple derived temporary key pairs; The process of receiving encrypted identity information sent by the client, decrypting it to generate a derived session key pair, encrypting it with the private key of the derived temporary key pair to obtain encrypted session public key information, and sending it to the client for the client to decrypt to obtain the public key of the derived session key pair, and then encrypting the encryption request, includes: Receive the encrypted identity information sent by the client; The identity information is obtained by decrypting the encrypted identity information using the private key of the derived temporary key pair. Obtain a random number, and based on the master key and the random number, bind the identity information to generate a derived session key pair; The private key of the derived temporary key pair is used to encrypt the public key of the derived session key pair to obtain the ciphertext information of the session public key, which is then sent to the client for the client to decrypt and obtain the public key of the derived session key pair, so as to encrypt the encryption request.
6. A key distribution system based on national cryptographic standards for end-to-end encryption, characterized in that, For the client, the end-to-end encryption key distribution system based on Chinese national cryptographic standards includes: The session request sending module is used to send a 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 client's identity information to obtain the 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 for the key server to decrypt 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. The process of receiving the public key and WebSocket address of the derived temporary key pair, encrypting the client's identity information to obtain encrypted identity information, and sending it to the key server includes: Receive the public key and WebSocket address of the derived temporary key pair sent by the key server; The client's identity information, including ID and IP information, is determined, and the identity information is encrypted using the public key of the derived temporary key pair to obtain the encrypted identity information. Send the encrypted identity information to the key server; The process of 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, includes: Receive the session public key ciphertext information sent by the key server; The public key of the derived session key pair is obtained by decrypting the ciphertext information of the session public key using the public key of the derived temporary key pair. Trigger an encryption request for the derived content key, and encrypt the encryption request based on the public key of the derived session key pair to obtain the encrypted request ciphertext information; The encrypted request ciphertext is sent to the key server via a WebSocket TLS end-to-end encrypted channel, so that the key server can decrypt it to obtain the encrypted request.
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