Collaborative key management methods, systems, storage media and electronic devices
By using the secure device to generate encrypted SM2 key pairs and the encrypted certificate private keys in the collaborative key system, the private keys can be decrypted only in the secure device, solving the risk of private key leakage and improving the key security.
Patent Information
- Application Number
- CN202311659414.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-05
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2043-12-05
AI Technical Summary
In a collaborative key system, the risk of private keys being easily leaked is higher because there is a complete private key plaintext in memory. The attacker can obtain the private key plaintext after successfully attacking the system, resulting in insufficient key security.
The encrypted SM2 key pair is generated through the functional interface of the security device, and key operations are performed only in the security device to ensure the private key encryption, prevent the private key from leaking plain text, use the encryption certificate private key to split the key, and generate a collaborative decryption secret Key components and public keys ensure that the private key can only be decrypted by the security device.
Effectively prevent private keys from being leaked in plain text, improve the security of collaborative keys, and ensure that even if the system is attacked, the private key cannot be decrypted unauthorized.
Smart Images

Figure CN117749360B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a collaborative key management method, system, storage medium and electronic device. Background Art
[0002] The national secret collaborative key signature and collaborative key decryption are implemented based on the national secret SM2 algorithm. It is a key calculation method launched to address the problem that soft certificate keys are easily copied or the scenario where collaboration between two parties or multiple users is required to sign or decrypt. It ensures that the collaborative key is distributed between two or more parties, thereby improving the security of collaborative key calculations. Therefore, it has a wide range of application scenarios.
[0003] However, when performing collaborative key splitting, the complete private key plaintext and the key component private key plaintext will be generated in the collaborative key system memory, which leads to the risk of private key leakage. Once an attacker successfully attacks the system, the attacker can obtain the complete private key plaintext from the system memory, resulting in the possibility of private key plaintext leakage.
[0004] Based on this, there is an urgent need for a collaborative key management solution to protect the collaborative keys in the collaborative key system and prevent them from existing completely in the system memory in plain text, thereby improving the security of the collaborative keys. Summary of the invention
[0005] The purpose of this application is to provide a collaborative key management method, system, storage medium and electronic device for encrypting the plaintext of the private key during the generation, key splitting and use of collaborative key component keys to prevent the plaintext leakage of the private key.
[0006] The present application provides a collaborative key management method, including:
[0007] Based on the SM2 key pair with the private key part encrypted generated by the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; based on the second functional interface of the security device, the encryption certificate private key is key split to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein, the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data.
[0008] Optionally, after the encryption certificate private key is split based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component, the method also includes: decrypting the user encrypted data based on the third functional interface of the security device and the private key ciphertext of the encryption certificate second device collaborative decryption key component; wherein the user encrypted data is the encrypted data obtained by encrypting using the encryption certificate public key.
[0009] Optionally, the decryption of user encrypted data based on the third functional interface of the security device and the private key ciphertext of the collaborative decryption key component of the second device of the encryption certificate includes: the first device parses the user encrypted data to obtain the C1 value of the SM2 asymmetric encryption result, and sends the C1 value to the second device; the second device calls the third functional interface of the security device with the C1 value and the private key ciphertext of the collaborative decryption key component of the second device of the encryption certificate as input parameters to obtain the collaborative decryption component, and sends the collaborative decryption component to the first device; the first device decrypts the user encrypted data based on the collaborative decryption key component of the first device of the encryption certificate and the collaborative decryption component to obtain the original user data.
[0010] Optionally, the SM2 key pair with the encrypted private key part generated based on the first functional interface of the security device is used by the first device and the second device to jointly complete the certificate application and generate a signed SM2 certificate application, including: the first device uses the generated SM2 key component as the collaboratively signed first key component; the second device calls the first functional interface of the security device to obtain the first SM2 key pair as the collaboratively signed second key component; the first device sends the collaboratively signed first key component public key to the second device, and the second device sends the collaboratively signed second key component public key to the first device; the first device synthesizes the collaboratively signed certificate complete public key based on the collaboratively signed first key component private key and the collaboratively signed second key component public key; the second device calls the fourth functional interface of the security device with the collaboratively signed first key component public key and the key component private key ciphertext of the collaboratively signed second key component as input parameters to synthesize them into the collaboratively signed certificate complete public key.
[0011] Optionally, the SM2 key pair with the encrypted private key portion generated based on the first functional interface of the security device is used by the first device and the second device to jointly complete the certificate application and generate a signed SM2 certificate application, including: the first device generates an unsigned certificate application based on the complete public key of the collaborative signature certificate; the second device calls the first functional interface of the security device to obtain a collaborative signature SM2 random key pair, and sends the key public key of the collaborative signature SM2 random key pair to the first device; the first device calculates the first device collaborative signature component based on the key component private key of the SM2 key component and the key public key of the collaborative signature SM2 random key pair, and sends the first device collaborative signature component to the second device; the second device calls the fifth functional interface of the security device with the first device collaborative signature component, the private key ciphertext of the second device collaborative signature key component and the private key ciphertext of the collaborative signature SM2 random key pair as input parameters to obtain the second device collaborative signature component, and send the second device collaborative signature component to the first device; the first device generates the signed SM2 certificate application based on the first device collaborative signature component, the second device collaborative signature component and the certificate application without a signature.
[0012] Optionally, the encryption certificate private key is key split based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key, including: the first device uses the signed SM2 certificate application to apply for and obtain the encryption certificate private key ciphertext from the certificate authority; the first device uses the collaboratively signed first key component to collaboratively decrypt the first device part of the encryption certificate private key ciphertext to generate a first device decryption component; the first device generates an SM2 temporary key, and sends the first device decryption component, the encryption certificate private key ciphertext and the SM2 temporary key public key to the second device; the second device calls the second functional interface of the security device with the first device decryption component, the encryption certificate private key ciphertext, the SM2 temporary key public key and the collaboratively signed second key component as input parameters to obtain the encryption certificate first device collaborative decryption key component with the encrypted private key, the encryption certificate second device collaborative decryption key component with the encrypted private key and the encryption certificate public key, and sends the encryption certificate first device collaborative decryption key component to the first device.
[0013] Optionally, after the encryption certificate private key is split based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component, the method also includes: the second device calls the first functional interface of the security device to obtain a third SM2 key pair, and sends the key public key of the third SM2 key pair to the first device; the first device calculates the collaborative signature first device component based on the key component private key of the collaborative signature first key component and the key public key of the third SM2 key pair, and sends the collaborative signature first device component to the second device; the second device calls the fifth functional interface of the security device with the collaborative signature first device component, the private key ciphertext of the collaborative signature second key component and the key private key ciphertext of the third SM2 key pair as input parameters to obtain the collaborative signature second device component, and sends the collaborative signature second device component to the first device; the first device generates a signature result of the user data based on the collaborative signature first device component and the collaborative signature second device component.
[0014] The present application also provides a collaborative key management system, comprising: a first device, a second device and a security device communicatively connected to the second device; the collaborative key management system is used to implement the steps of the collaborative key management method as described in any one of the above items.
[0015] The present application also provides a computer program product, including a computer program / instruction, which implements the steps of any of the collaborative key management methods described above when executed by a processor.
[0016] The present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-mentioned collaborative key management methods when executing the program.
[0017] The present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the collaborative key management methods described above are implemented.
[0018] The collaborative key management method, system, storage medium and electronic device provided by the present application, first, based on the SM2 key pair with the encrypted private key part generated by the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; then, based on the second functional interface of the security device, the encryption certificate private key is split to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein, the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data. In this way, the security device can encrypt the private key plaintext during the collaborative key component key generation, key splitting and use process, and the private key plaintext can only be decrypted by the security device to prevent the leakage of the private key plaintext. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 This is a schematic diagram of the structure of the collaborative key management system provided by this application
[0021] Figure 2 It is a flowchart of the collaborative key management method provided by this application;
[0022] Figure 3 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0025] The following is a description of the professional terms involved in the embodiments of the present application:
[0026] Collaborative Key Management System (CKMS) is a system for centralized management and distribution of encryption keys. It can achieve secure, efficient and controllable management of keys in encryption scenarios involving multiple parties. CKMS can handle multiple key types such as symmetric keys, asymmetric keys, certificates, and proxy re-encryption.
[0027] In order to solve the technical problem that the private key is stored in plain text in the memory in the related art, which may cause the private key plain text to be leaked, the embodiment of the present application provides a collaborative key management system, such as Figure 1 As shown, the system includes a first device, a second device and a security device communicatively connected to the second device. In this system, all calculations involving plaintext of a private key are performed in a closed security device, and the encrypted private key can only be decrypted by the security device, thereby avoiding the possibility of plaintext leakage of the private key.
[0028] The collaborative key management method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0029] like Figure 2 As shown, an embodiment of the present application provides a collaborative key management method, which may include the following steps 201 and 202:
[0030] Step 201: Based on the SM2 key pair whose private key part is encrypted generated by the first functional interface of the security device, the first device and the second device cooperate to complete the certificate application and generate a signed SM2 certificate application.
[0031] The SM2 certificate application with signature is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key. The encrypted private key in the SM2 key pair can only be used for key calculation through the security device.
[0032] Exemplarily, the certificate application is generated based on the PKCS#10 standard. In the embodiment of the present application, the signed SM2 certificate application can be collaboratively generated by the first device and the second device based on the first functional interface of the security device and the encrypted SM2 key pair of the private key part.
[0033] Exemplarily, the first functional interface is one of the multiple functional interfaces provided by the security device, and the first functional interface is used to generate an encrypted SM2 key pair. The collaborative key management system can obtain the key pair encrypted by the private key through the interface. The encrypted private key can only be decrypted by the security device when performing collaborative key calculations using the relevant key in the security device. In this way, it can be ensured that even if the user key is copied, it cannot be used when the system is attacked.
[0034] Specifically, the above step 201 may include the following steps 201a1 to 201a5:
[0035] Step 201a1: The first device uses the generated SM2 key component as the first key component for collaborative signature.
[0036] Step 201a2: The second device calls the first functional interface of the security device to obtain a first SM2 key pair as a second key component for collaborative signature.
[0037] Step 201a3: The first device sends the collaboratively signed first key component public key to the second device, and the second device sends the collaboratively signed second key component public key to the first device.
[0038] Step 201a4: The first device synthesizes a complete public key of the collaborative signature certificate based on the collaborative signature first key component private key and the collaborative signature second key component public key.
[0039] Step 201a5: The second device uses the public key of the collaborative signature first key component and the key component private key ciphertext of the collaborative signature second key component as input parameters to call the fourth function interface of the security device to synthesize the collaborative signature certificate complete public key.
[0040] Exemplarily, in order to generate a signed SM2 certificate application, it is first necessary to generate a complete public key of the co-signed certificate of the first device and the second device.
[0041] The specific steps are as follows:
[0042] S1.1.1. The first device generates an SM2 key component.
[0043] S1.1.2, the second device calls the first functional interface of the security device to generate a first SM2 key pair with an encrypted private key, and uses it as the key component of the second device, that is, the second device key component. The key component private key ciphertext in the key component can only be used by the security device for key calculation.
[0044] S1.1.3. The first device sends the key component public key in the SM2 key component to the second device.
[0045] S1.1.4. The second device sends the public key of the key component in the second device key component to the first device.
[0046] S1.1.5. The first device uses the key component in the SM2 key component and the key component public key in the second device key component to synthesize the complete public key of the system signature certificate.
[0047] S1.1.6. The second device uses the key component public key of the SM2 key component and the key component private key ciphertext of the second device key component as input parameters to call the fourth function interface of the security device to synthesize the complete public key of the collaborative signature certificate.
[0048] Exemplarily, the fourth functional interface is an interface used by the security device to synthesize a collaborative key public key, which takes the collaboratively signed first key component public key and the key component private key ciphertext of the collaboratively signed second key component as input to synthesize a complete collaborative key certificate public key and output it.
[0049] Exemplarily, after obtaining the complete public key of the collaborative signature certificate, the first device and the second device may interactively complete the generation of the certificate application PKCS#10.
[0050] Specifically, after the above step 201a5, the above step 201 may further include the following steps 201b1 to 201b5:
[0051] Step 201b1: The first device generates an unsigned certificate application based on the complete public key of the co-signed certificate.
[0052] Step 201b2: The second device calls the first functional interface of the security device to obtain a random key pair for collaborative signature SM2, and sends the public key of the random key pair for collaborative signature SM2 to the first device.
[0053] Step 201b3: The first device calculates the first device collaborative signature component based on the key component private key of the SM2 key component and the key public key of the collaborative signature SM2 random key pair, and sends the first device collaborative signature component to the second device.
[0054] Exemplarily, in the actual calculation process of the collaborative signature component, in addition to the key component private key of the above-mentioned SM2 key component and the key public key of the collaborative signature SM2 random key pair, the signed data summary value is also required, that is, in the above-mentioned step 201b3, the first device can calculate the first device collaborative signature component based on the key component private key of the SM2 key component, the key public key of the collaborative signature SM2 random key pair and the signed data summary value.
[0055] Step 201b4: The second device calls the fifth function interface of the security device using the collaborative signature component of the first device, the private key ciphertext of the collaborative signature key component of the second device, and the private key ciphertext of the collaborative signature SM2 random key pair as input parameters to obtain the collaborative signature component of the second device, and sends the collaborative signature component of the second device to the first device.
[0056] Exemplarily, the fifth functional interface is an interface for the security device to calculate the collaborative signature, which takes the second device collaborative key component private key ciphertext, random key private key ciphertext, first device signature component and other parameters as input to complete the calculation and output of the second device collaborative signature component.
[0057] Step 201b5: The first device generates the signed SM2 certificate application based on the first device collaborative signature component, the second device collaborative signature component and the unsigned certificate application.
[0058] The specific steps are as follows:
[0059] S1.2.1. The first device uses the complete public key of the collaborative signature certificate obtained in S1.5 as one of the parameters of the certificate application PKCS#10 to encapsulate a certificate application without a signature.
[0060] S1.2.2, the second device calls the first functional interface of the security device to obtain the second SM2 key pair, and sends the public key of the second SM2 key pair to the first device. The private key ciphertext in the key pair can only be used for key calculation by the security device.
[0061] S1.2.3. The first device uses the key component private key in the SM2 key component generated in the above S1.1.1 and the key public key of the second SM2 key pair sent by the second device to calculate the collaborative signature component of the first device, that is, the above-mentioned collaborative signature first device component, and sends the collaborative signature first device component to the second device.
[0062] S1.2.4. The second device uses the received collaborative signature first device component, the private key ciphertext of the second device key component in the above S1.1.2, and the key private key ciphertext of the second SM2 key pair in the above S1.2.2 as input parameters to call the fifth functional interface of the security device. The security device completes the calculation of the collaborative signature component of the second device, obtains the above collaborative signature second device component, and sends it to the second device, and the second device sends it to the first device.
[0063] S1.2.5. The first device encapsulates a signed SM2 certificate application based on the collaboratively signed first device component, the collaboratively signed second device component, and the unsigned certificate application, that is, the above-mentioned signed SM2 certificate application.
[0064] For example, after obtaining the above-mentioned signed SM2 certificate application, you can apply for and obtain the national secret signature certificate, national secret encryption certificate and encryption certificate private key ciphertext from the certificate authority.
[0065] Step 202: Split the encryption certificate private key based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key.
[0066] Among them, the first device collaborative decryption key component of the encryption certificate and the second device collaborative decryption key component of the encryption certificate are used to decrypt user encrypted data; the functional interface of the security device is called by the second device; and the encryption certificate public key is used to encrypt user data.
[0067] Exemplarily, in the above step 202, the encryption certificate private key is key-splitting based on the second functional interface of the security device, specifically, the ciphertext of the encryption certificate private key is key-splitting.
[0068] Specifically, the above step 202 may include the following steps 202a1 to 202a4:
[0069] Step 202a1: The first device uses the signed SM2 certificate application to apply for and obtain the encrypted certificate private key ciphertext from a certificate authority.
[0070] Step 202a2: The first device uses the collaboratively signed first key component to collaboratively decrypt the first device portion of the encryption certificate private key ciphertext to generate a first device decryption component.
[0071] Step 202a3: The first device generates an SM2 temporary key, and sends the first device decryption component, the encryption certificate private key ciphertext and the SM2 temporary key public key to the second device.
[0072] Step 202a4, the second device calls the second functional interface of the security device using the first device decryption component, the encryption certificate private key ciphertext, the SM2 temporary key public key and the collaborative signature second key component as input parameters, obtains the encryption certificate first device collaborative decryption key component with the private key encrypted, the encryption certificate second device collaborative decryption key component with the private key encrypted and the encryption certificate public key, and sends the encryption certificate first device collaborative decryption key component to the first device.
[0073] Exemplarily, the private key of the first device collaborative decryption key component involved in the above step 202a4 is encrypted by a temporary public key generated by the first device.
[0074] Exemplarily, when using the signed SM2 certificate application, after applying for and obtaining the national secret signature certificate, national secret encryption certificate and encryption certificate private key ciphertext from the certificate authority, the key of the encryption certificate can be split.
[0075] Exemplarily, the above-mentioned second functional interface is a collaborative key splitting interface provided by the security device, which takes the encryption certificate private key ciphertext returned by the CA organization, the temporary public key of the first device, the second device collaborative signature key component private key ciphertext and the first device collaborative decryption component as input, completes the splitting of the encryption certificate private key and outputs it. The output parameters include the encryption certificate second device collaborative decryption key component encrypted by the private key, the encryption certificate first device collaborative decryption key component and the encryption certificate public key. Among them, the encryption certificate second device collaborative decryption key component private key ciphertext can only be decrypted by this cryptographic device; the encryption certificate first device collaborative decryption key component private key is encrypted by this security device using the first device temporary public key of S1.3.1 above, and only the first device can decrypt it through the first device temporary key private key.
[0076] The specific steps are as follows:
[0077] S1.3.1. The first device uses the signed SM2 certificate application generated in S1.2.5 to obtain the national secret signature certificate, national secret encryption certificate and encryption certificate private key ciphertext from the certificate authority (CA).
[0078] S1.3.2. The first device uses the collaboratively signed first device component to collaboratively decrypt the first device portion of the encryption certificate private key ciphertext to generate a first device decryption component.
[0079] S1.3.3. The first device generates an SM2 temporary key.
[0080] S1.3.4. The first device sends the national secret encryption certificate obtained in S1.3.1, the ciphertext of the encryption certificate private key, the first device decryption component in S1.3.2, and the SM2 temporary key public key in S1.3.3 to the second device.
[0081] S1.3.5. The second device uses the encryption certificate private key ciphertext in S1.3.1, the first device decryption component in S1.3.2, the SM2 temporary key public key in S1.3.3 and the private key ciphertext of the collaboratively signed second device component as input parameters to call the second functional interface of the security device, and the security device completes the final encryption certificate private key ciphertext decryption and key splitting, and obtains the encryption certificate first device collaborative decryption key component with the encrypted private key, the encryption certificate second device collaborative decryption key component with the encrypted private key and the encryption certificate public key, and sends them to the second device.
[0082] S1.3.6. The second device sends the encryption certificate and the first device collaborative decryption key component to the first device.
[0083] Exemplarily, after obtaining the first device collaborative decryption key component of the encryption certificate, the second device collaborative decryption key component of the encryption certificate and the encryption certificate public key, the first device and the second device can collaboratively complete the signing of user data and the decryption of user encrypted data.
[0084] Optionally, in an embodiment of the present application, the first device and the second device may collaborate to complete decryption of user data, and during the decryption process, operations on the private key of the second device are performed in the security device.
[0085] Exemplarily, after the above step 202, the collaborative key management method provided in the embodiment of the present application may further include the following step 203:
[0086] Step 203: Decrypt the user encrypted data based on the third functional interface of the security device and the private key ciphertext of the second device collaborative decryption key component of the encryption certificate.
[0087] The user encrypted data is encrypted data obtained by using the encryption certificate public key.
[0088] Exemplarily, since the operations of the second device private key are all performed in the security device, the user data decryption process relies on the third functional interface of the security device. The third functional interface is a collaborative decryption interface provided by the security device, which takes the encryption certificate, the second device collaborative decryption key component private key ciphertext and SM2 ciphertext data as input, completes the operation of the second device collaborative decryption component and outputs the second device collaborative decryption component.
[0089] Specifically, the above step 203 may further include the following steps 203a1 to 203a3:
[0090] Step 203a1: The first device parses the user encrypted data to obtain the C1 value of the SM2 asymmetric encryption result, and sends the C1 value to the second device.
[0091] Step 203a2: The second device uses the C1 value and the private key ciphertext of the collaborative decryption key component of the second device of the encryption certificate as input parameters to call the third functional interface of the security device, obtain the collaborative decryption component, and send the collaborative decryption component to the first device.
[0092] Step 203a3: The first device decrypts the user encrypted data based on the encryption certificate, the first device collaborative decryption key component and the collaborative decryption component to obtain the original user data.
[0093] Exemplarily, after encrypting the user data based on the public key of the encryption certificate, the user device sends the encrypted data to the first device. After receiving the user encrypted data, the first device can decrypt it.
[0094] The specific steps are as follows:
[0095] S2.1.1. The first device receives the user data SM2 ciphertext encrypted by the user device using the encryption certificate public key, i.e., the above-mentioned user encrypted data, and then parses the SM2 ciphertext to obtain the C1 value, and sends it to the second device.
[0096] S2.1.2. The second device uses the received C1 value and the private key ciphertext of the collaborative decryption key component of the encryption certificate split out in the above S1.3.4 as input parameters to call the third functional interface of the security device. The security device decrypts the user encrypted data to obtain the collaborative decryption component, and the second device sends the collaborative decryption component to the first device.
[0097] S2.1.3. The first device decrypts the user encrypted data based on the encryption certificate, the first device collaborative decryption key component and the collaborative decryption component to obtain the original user data.
[0098] In this way, during the collaborative decryption process between the first device and the second device, the security device can calculate the private key to avoid leakage of the plain text of the private key during the decryption process.
[0099] Optionally, in an embodiment of the present application, the first device and the second device may collaborate to complete the signing process for user data, and during the signing process, operations on the private key of the second device are all performed within the security device.
[0100] Exemplarily, after the above step 202, the collaborative key management method provided in the embodiment of the present application may further include the following steps 204 to 207:
[0101] Step 204: The second device calls the first functional interface of the security device to obtain a third SM2 key pair, and sends the public key of the third SM2 key pair to the first device.
[0102] Step 205: The first device calculates the collaboratively signed first device component based on the key component private key of the collaboratively signed first key component and the key public key of the third SM2 key pair, and sends the collaboratively signed first device component to the second device.
[0103] Step 206: The second device calls the fifth functional interface of the security device using the collaboratively signed first device component, the private key ciphertext of the collaboratively signed second key component, and the key private key ciphertext of the third SM2 key pair as input parameters to obtain the collaboratively signed second device component, and sends the collaboratively signed second device component to the first device.
[0104] It should be noted that the third SM2 key pair mentioned above is the same key as the collaborative signature SM2 random key pair generated in the above step 201b2.
[0105] Step 207: The first device generates a signature result of the user data based on the collaboratively signed first device component and the collaboratively signed second device component.
[0106] Exemplarily, each time the second device calls the first functional interface of the security device, a different SM2 key pair is randomly generated.
[0107] The specific steps are as follows:
[0108] S3.1.1. The second device calls the first functional interface of the security device to generate a random key pair encrypted by the private key of the collaborative signature process, namely the third SM2 key pair mentioned above, and sends the public key of the third SM2 key pair to the first device.
[0109] S3.1.2, the first device uses the key component private key of the SM2 key component generated in S1.1.1, the key public key of the third SM2 cryptographic pair in S3.1.1, and the signed data digest value to calculate the collaborative signature first device component, and then sends the collaborative signature first device component to the second device.
[0110] S3.1.3. The second device uses the received collaborative signature first device component, the key component private key ciphertext of the second device key component in S1.1.2, and the private key ciphertext of the third SM2 key pair in the above S3.1.1 as input parameters to call the fifth functional interface of the security device. The security device completes the calculation of the collaborative signature component of the second device, obtains the collaborative signature second device component, and sends it to the first device.
[0111] S3.1.4. After receiving the collaboratively signed second device component, the first device generates a signature result of the user data by combining the collaboratively signed first device component.
[0112] It should be noted that when the first device sends data containing a key and a collaborative key operation component (such as a collaborative signature component or a collaborative decryption component calculated by the first device) to the second device, a verification code can be calculated based on the sent data, and the second device can verify the received data based on the verification code to determine whether the received data is complete and whether it has been tampered with.
[0113] It should be noted that in the embodiment of the present application, the steps executed by the first device can also be executed by a security device that is communicatively connected to the first device, and the steps that the security device that is communicatively connected to the first device can specifically execute can refer to the steps executed by the security device that is communicatively connected to the second device.
[0114] The collaborative key management method provided by the embodiment of the present application, first, based on the SM2 key pair with the encrypted private key part generated by the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; then, based on the second functional interface of the security device, the encryption certificate private key is split to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein, the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data. In this way, the security device can encrypt the private key plaintext during the collaborative key component key generation, key splitting and use process, and the private key plaintext can only be decrypted by the security device to prevent the leakage of the private key plaintext.
[0115] It should be noted that the collaborative key management method provided in the embodiment of the present application can be executed by a collaborative key management system or a control module in the collaborative key management system for executing the collaborative key management method. In the embodiment of the present application, the collaborative key management system provided in the embodiment of the present application is explained by taking the collaborative key management system executing the collaborative key management method as an example.
[0116] It should be noted that, in the embodiments of the present application, the collaborative key management methods shown in the above-mentioned method drawings are all illustrated by taking one of the drawings in the embodiments of the present application as an example. In specific implementation, the collaborative key management methods shown in the above-mentioned method drawings can also be implemented in combination with any other drawings that can be combined as shown in the above-mentioned embodiments, which will not be repeated here.
[0117] The collaborative key management system provided by the present application, first, based on the SM2 key pair with the encrypted private key part generated by the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; then, based on the second functional interface of the security device, the encryption certificate private key is split to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein, the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data. In this way, the security device can be used to encrypt the private key plaintext during the collaborative key component key generation, key splitting and use process, and the private key plaintext can only be decrypted by the security device to prevent the leakage of the private key plaintext.
[0118] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3As shown, the electronic device may include: a processor (processor) 310, a communication interface (Communications Interface) 320, a memory (memory) 330 and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 can call the logic instructions in the memory 330 to execute a collaborative key management method, which includes: based on the SM2 key pair whose private key part is encrypted generated by the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; based on the second functional interface of the security device, the encryption certificate private key is key split to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data.
[0119] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0120] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the collaborative key management method provided by the above methods, the method including: an SM2 key pair with a private key part encrypted based on the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; based on the second functional interface of the security device, the encryption certificate private key is key-splitting to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data.
[0121] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the collaborative key management methods provided above, the method comprising: an SM2 key pair whose private key part is encrypted based on the first functional interface of the security device, the first device and the second device collaboratively completing a certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; based on the second functional interface of the security device, the encryption certificate private key is key-splitting to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; wherein the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data.
[0122] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0123] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application 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 embodiments of the present application.
Claims
1. A collaborative key management method, characterized in that: Applied to a collaborative key management system, the collaborative key management system comprises: a first device, a second device and a security device connected to the second device for communication; Based on the SM2 key pair with the private key portion encrypted generated by the first functional interface of the security device, the first device and the second device jointly complete the certificate application to generate a signed SM2 certificate application; the signed SM2 certificate application is used to obtain the ciphertext of the national secret signature certificate, the national secret encryption certificate and the encryption certificate private key; Based on the second functional interface of the security device, the encryption certificate private key is split to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key; Among them, the encrypted private key in the SM2 key pair can only be used for key calculation through the security device; the functional interface of the security device is called by the second device; the encryption certificate public key is used to encrypt user data; the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component are used to decrypt user encrypted data; The SM2 key pair whose private key part is encrypted based on the first functional interface of the security device, the first device and the second device jointly complete the certificate application, and generate a signed SM2 certificate application, including: The first device generates an SM2 key component, and uses the generated SM2 key component as a collaborative signature first key component; The second device uses the SM2 key pair obtained by calling the first functional interface of the security device as the collaborative signature second key component; The first device sends the co-signed first key component public key to the second device, and the second device sends the co-signed second key component public key to the first device; The first device synthesizes a collaborative signature certificate complete public key based on the collaborative signature first key component private key and the collaborative signature second key component public key; The SM2 key pair whose private key part is encrypted based on the first functional interface of the security device, the first device and the second device jointly complete the certificate application, and generate a signed SM2 certificate application, including: The first device generates a certificate application without a signature based on the complete public key of the collaborative signature certificate; The second device calls the first functional interface of the security device to obtain a random key pair for collaborative signature SM2, and sends a public key of the random key pair for collaborative signature SM2 to the first device; The first device calculates a first device collaborative signature component based on a key component private key of the SM2 key component and a key public key of the collaborative signature SM2 random key pair, and sends the first device collaborative signature component to the second device; The second device uses the first device collaborative signature component, the private key ciphertext of the collaborative signature second key component, and the private key ciphertext of the collaborative signature SM2 random key pair as input parameters to call the fifth function interface of the security device to obtain the second device collaborative signature component, and send the second device collaborative signature component to the first device; The first device generates the signed SM2 certificate application based on the first device collaborative signature component, the second device collaborative signature component, and the unsigned certificate application; The key splitting of the encryption certificate private key based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component, the encryption certificate second device collaborative decryption key component and the encryption certificate public key includes: The first device uses the signed SM2 certificate application to apply for and obtain the encrypted certificate private key ciphertext from a certificate authority; The first device uses the collaborative signature first key component to collaboratively decrypt the first device portion of the encryption certificate private key ciphertext to generate a first device decryption component; The first device generates an SM2 temporary key, and sends the first device decryption component, the encryption certificate private key ciphertext, and the SM2 temporary key public key to the second device; The second device calls the second functional interface of the security device using the decryption component of the first device, the ciphertext of the encryption certificate private key, the SM2 temporary key public key and the collaborative signature second key component as input parameters, obtains the collaborative decryption key component of the encryption certificate first device with the private key encrypted, the collaborative decryption key component of the encryption certificate second device with the private key encrypted and the encryption certificate public key, and sends the collaborative decryption key component of the encryption certificate first device to the first device.
2. The method according to claim 1, characterized in that After the encryption certificate private key is split based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component, the method further includes: Decrypting the user encrypted data based on the third functional interface of the security device and the private key ciphertext of the second device collaborative decryption key component of the encryption certificate; The user encrypted data is encrypted data obtained by using the encryption certificate public key.
3. The method according to claim 2, characterized in that The decrypting the user encrypted data based on the third functional interface of the security device and the private key ciphertext of the second device collaborative decryption key component of the encryption certificate includes: The first device parses the user encrypted data to obtain a C1 value of the SM2 asymmetric encryption result, and sends the C1 value to the second device; The second device uses the C1 value and the private key ciphertext of the collaborative decryption key component of the second device of the encryption certificate as input parameters to call the third functional interface of the security device to obtain the collaborative decryption component, and sends the collaborative decryption component to the first device; The first device decrypts the user encrypted data based on the encryption certificate, the first device collaborative decryption key component and the collaborative decryption component to obtain the original user data.
4. The method according to claim 1, characterized in that: After the encryption certificate private key is split based on the second functional interface of the security device to obtain the encryption certificate first device collaborative decryption key component and the encryption certificate second device collaborative decryption key component, the method further includes: The second device calls the first functional interface of the security device to obtain a third SM2 key pair, and sends the public key of the third SM2 key pair to the first device; The first device calculates the collaboratively signed first device component based on the key component private key of the collaboratively signed first key component and the key public key of the third SM2 key pair, and sends the collaboratively signed first device component to the second device; The second device uses the collaborative signature first device component, the private key ciphertext of the collaborative signature second key component, and the key private key ciphertext of the third SM2 key pair as input parameters to call the fifth function interface of the security device to obtain the collaborative signature second device component, and sends the collaborative signature second device component to the first device; The first device generates a signature result of the user data based on the collaboratively signed first device component and the collaboratively signed second device component.
5. A collaborative key management system, characterized in that: The system includes: a first device, a second device and a security device in communication with the second device; the collaborative key management system is used to implement the steps of the collaborative key management method as described in any one of claims 1 to 4.
6. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the collaborative key management method as claimed in any one of claims 1 to 4 when executing the program.
7. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the collaborative key management method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Method and system for protecting, using and decrypting collaborative key of collaborative key system
CN116668011A