Encryption service providing method, electronic device and storage medium
By generating collaborative key components and performing encryption service operations on the client and server respectively, the problems of private key leakage and illegal signature decryption in traditional encryption service provision methods are solved, improving security and ensuring collaborative participation in operations.
Patent Information
- Application Number
- CN202311733317.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-12-15
AI Technical Summary
In traditional encryption service provision methods, there is a risk of private keys being leaked, or there may be situations where the server performs signing or decryption privately without the client's knowledge.
By calling the CSP encryption interface, the client collaborative key component and the server collaborative key component are generated on the client and server respectively. The server collaborative key component is stored on the server, and the client collaborative key component is stored on the client. And perform encryption service operations based on these key components, using the collaborative key split storage feature to improve the security of private key storage and ensure that the complete private key plaintext does not appear in the memory or network of either the client or the server.
It effectively improves the storage security of the private key, prevents the leakage of the private key, and prevents the server from performing signature or decryption privately without the client's knowledge, ensuring that the operation requires the collaborative participation of the client and the server.
Smart Images

Figure CN117749465B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data security technology, and in particular to an encryption service providing method, electronic equipment and storage medium. Background Art
[0002] The CSP (Cryptographic Service Provider) interface is a component of encryption algorithm-related functions provided by Microsoft Windows operating system. Applications can call the CSP interface through the CryptoAPI series of functions to implement cryptographic operations such as data encryption, decryption, digital signature, signature verification and data summary. The certificates and private keys required for encryption services are generally stored in hardware USBKey media. The purpose is to use the USBKey's secure storage function to protect the private key from being illegally read and used. However, this method limits the user's usage scenarios. For example, in cloud desktops, cloud operating systems and other environments, physical USBKeys cannot be used as storage media for certificates and private keys; on the other hand, it is limited by the USBKey storage space and more certificates cannot be stored in the same USBKey. In the related art, certificates and private keys are stored in a remote device, or certificates and private keys are centrally stored in an access device. When placed in a remote device, once the security of the remote device is at risk, or there are security risks in the network communication with the remote device, the private key will face the risk of leakage; when stored in an access device, since the access device has a complete private key, signing and decryption operations can be performed without the client's participation. It is possible that the server will privately perform signing or decryption without the client's knowledge. Summary of the invention
[0003] The present invention provides an encryption service providing method, an electronic device and a storage medium, which are used to solve the defects in the traditional encryption service providing method that there is a risk of leakage of private keys, or there is a situation where the server performs signing or decryption privately without the knowledge of the client.
[0004] The present invention provides a method for providing an encryption service, comprising:
[0005] Calling the CSP encryption interface, generating a client collaborative key component and a server collaborative key component on the client and the server, respectively, wherein the server collaborative key component is stored on the server, and the client collaborative key component is stored on the client;
[0006] The CSP service interface is called to perform corresponding encryption service operations according to the client collaborative key component and the server collaborative key component.
[0007] According to a method for providing encryption services provided by the present invention, the encryption service operation includes downloading a security certificate, calling a CSP service interface, and performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component, including:
[0008] Synthesize a signature public key based on the client collaborative key component and the server collaborative key component;
[0009] Call the CSP to obtain the key parameter interface and export the signature public key from the client;
[0010] Construct an application form according to the signature public key, call the CSP hash signature interface, sign the application form, and obtain an application form including the signature value;
[0011] Sending the application including the signature value to a security certification center to obtain a signature certificate;
[0012] Call the CSP key parameter setting interface to import the signing certificate into the client, parse the signing certificate on the client, and verify whether the public key of the signing certificate is the same as the signing public key;
[0013] If they are the same, the signature certificate is stored on the client, and the signature certificate is associated with the signature public key.
[0014] According to a method for providing encryption services provided by the present invention, the client collaborative key component includes a client signature public key component and a client signature private key component; the server collaborative key component includes a server signature public key component and a server signature private key component; the method of synthesizing a signature public key according to the client collaborative key component and the server collaborative key component includes:
[0015] Establishing a secure network channel between the client and the server;
[0016] The client signature public key component is sent to the server through the secure network channel, and the server uses the client signature public key component and the server signature public key component to synthesize a complete signature public key;
[0017] And, the server-side signature public key component is sent to the client through the secure network channel; and the client-side signature private key component and the server-side signature public key component are used to synthesize a complete signature public key on the client.
[0018] According to a method for providing encryption services provided by the present invention, the encryption service operation includes downloading a security certificate, calling a CSP service interface, performing a corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, and further comprising:
[0019] After synthesizing the signature public key, calling the CSP encryption interface to generate an encryption key pair, the encryption key pair includes an encryption public key and an encryption private key;
[0020] Call the CSP key import interface to import the encryption key pair to the client;
[0021] Construct an application form according to the temporary public key, and send the application form to a security certification center to obtain an encryption certificate and an encryption key pair, wherein the encryption key pair includes an encryption public key and an encryption private key ciphertext;
[0022] Call the CSP key import interface to import the encryption key pair to the client;
[0023] Call the CSP key parameter setting interface to import the encryption certificate to the client;
[0024] Parse the encryption certificate on the client to verify whether the public key of the encryption certificate is the same as the encryption public key;
[0025] If they are the same, the encryption certificate is stored on the client, and the encryption certificate is associated with the encryption public key.
[0026] According to a method for providing encryption services provided by the present invention, the calling of a CSP import key interface to import the encryption key pair into a client comprises:
[0027] The encrypted private key ciphertext is transmitted to the server, and the encrypted private key ciphertext is decrypted by the temporary private key at the server to obtain the encrypted private key plaintext;
[0028] Perform collaborative key splitting on the encrypted private key plaintext to obtain a client encryption public key component, a client encryption private key component, a server encryption public key component, and a server encryption private key component, store the client encryption public key component, the server encryption public key component, and the server encryption private key component on the server, and send the client encryption public key component, the client encryption private key component, and the server encryption public key component to the client, wherein the client encryption private key component is encrypted using the client signature public key component;
[0029] On the client side, the client-side encrypted private key component and the server-side encrypted public key component are used to synthesize the encrypted public key.
[0030] According to a method for providing encryption services provided by the present invention, the encryption service operation includes a signature operation, and the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, including:
[0031] Call the CSP create hash interface and calculate hash interface to pass in the original text to be signed and the client calculates the message digest of the original text to be signed, or directly call the CSP set hash interface to pass in the message digest of the original text to be signed and generate a first random number;
[0032] Calculate a first intermediate result according to the message digest and the random number, and send the first intermediate result and the message digest to the server;
[0033] Generate a second random number on the server, calculate the server signature value component through the message digest, the second random number, and the first intermediate result, calculate the second intermediate result according to the server signature private key component, the signature value component, and the second random number; send the server signature value component and the second intermediate result to the client;
[0034] The client calculates the client signature value component based on the client signature private key component, the first random number, the second intermediate result and the server signature value component, and concatenates the server signature value component and the client signature value component as the signature value.
[0035] According to a method for providing encryption services provided by the present invention, the encryption service operation includes collaborative encryption, and the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, including:
[0036] The external program calls CSP to obtain the context and user key interface to obtain the key handle;
[0037] The external program calls the CSP encryption interface and takes the key handle and the plaintext to be encrypted as input parameters;
[0038] After the client obtains the key handle and the plaintext to be encrypted, a third random number is generated;
[0039] Calculate a key point according to a third random number and an encryption and decryption public key, where the encryption and decryption public key is a signature public key or an encryption public key;
[0040] The key point is used to encrypt the plaintext to be encrypted to obtain an encrypted ciphertext.
[0041] According to a method for providing encryption services provided by the present invention, the calling of the CSP service interface and the execution of corresponding encryption service operations according to the client collaborative key component and the server collaborative key component include:
[0042] When the encryption and decryption public key is a signature public key, a partial ciphertext of the encrypted ciphertext is sent to the server, and the server calculates a third intermediate result by using the encrypted ciphertext and the server signature private key component, and sends the result to the client;
[0043] Calculating a fourth intermediate result on the client through the client signature private key component, the third intermediate result and the encrypted ciphertext, using the fourth intermediate result as a key point, and using the key point to decrypt the encrypted ciphertext;
[0044] When the encryption and decryption public key is an encryption public key, the encrypted ciphertext is sent to the server, and the server calculates a fifth intermediate result using the encrypted ciphertext and the server encryption private key component, and sends the result to the client;
[0045] The sixth intermediate result is calculated on the client side by using the client signature private key component, the fifth intermediate result and the encrypted ciphertext, the sixth intermediate result is used as a key point, and the encrypted ciphertext is decrypted using the key point.
[0046] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the encryption service providing methods described above is implemented.
[0047] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any of the above-mentioned encryption service providing methods.
[0048] The present invention provides an encryption service providing method, electronic device and storage medium. By calling a CSP encryption interface, a client collaborative key component and a server collaborative key component are generated on the client and the server respectively. The server collaborative key component is stored on the server, and the client collaborative key component is stored on the client. The CSP service interface is called to perform corresponding encryption service operations according to the client collaborative key component and the server collaborative key component. The collaborative key splitting storage feature is used to improve the security of private key storage. The complete private key plaintext does not appear in the memory or network of either the client or the server. Even if there is a risk in the client environment, the private key cannot be restored. Moreover, the functional operation requires the collaborative participation of the client and the server to complete the operation. In principle, it is prevented from happening that the server performs signing or decryption privately without the knowledge of the client. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 It is a flowchart of the encryption service providing method provided by the present invention;
[0051] Figure 2 It is a structural schematic diagram of the encryption service providing device provided by the present invention;
[0052] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] Figure 1 A flowchart of a method for providing an encryption service provided by an embodiment of the present invention, such as Figure 1 As shown, the encryption service providing method provided by the embodiment of the present invention includes:
[0055] Step 101, calling the CSP encryption interface, generating a client collaborative key component and a server collaborative key component on the client and the server, respectively, wherein the server collaborative key component is stored on the server, and the client collaborative key component is stored on the client;
[0056] Step 102: Call the CSP service interface and perform corresponding encryption service operations according to the client collaborative key component and the server collaborative key component.
[0057] In the traditional encryption service provision method, the certificates and private keys required for encryption services are generally stored in the hardware USBKey medium. The purpose is to use the USBKey's secure storage function to protect the private key from being illegally read and used. However, this method limits the user's usage scenarios. For example, in cloud desktops, cloud operating systems and other environments, physical USBKeys cannot be used as storage media for certificates and private keys; on the other hand, due to the USBKey storage space limitation, more certificates cannot be stored in the same USBKey. In the related technology, certificates and private keys are stored in the remote device, or certificates and private keys are centrally stored in the access device. When placed in the remote device, once the remote device security is at risk, or there are security risks in the network communication with the remote device, the private key will face the risk of leakage; when stored in the access device, since the access device has a complete private key, it can perform signing and decryption operations without the client's participation at all. It may happen that the server performs signing or decryption privately without the client's knowledge.
[0058] The present invention provides a method for providing encryption services. By calling a CSP encryption interface, a client collaborative key component and a server collaborative key component are generated on the client and the server respectively. The server collaborative key component is stored on the server, and the client collaborative key component is stored on the client. The CSP service interface is called to perform corresponding encryption service operations according to the client collaborative key component and the server collaborative key component. The collaborative key split storage feature is used to improve the security of private key storage. The complete private key plaintext does not appear in the memory or network of either the client or the server. Even if there is a risk in the client environment, the private key cannot be restored. Moreover, the functional operation requires the collaborative participation of the client and the server to complete the operation. In principle, it is prevented that the server performs signing or decryption privately without the knowledge of the client.
[0059] Based on any of the above embodiments, when calling the CSP interface to apply for and download the certificate, the download control can be used to call the client CSP interface on the certificate download platform to generate a key pair and a PKCS10 application, and then apply for and issue the certificate from the CA, and finally import the certificate to the client. However, when processing the CSP interface call, the embodiment of the present invention automatically connects to the server to generate a collaborative key pair and stores the private key component of the client key on the local disk. The specific process is as follows:
[0060] Step 201: synthesize a signature public key based on the client collaborative key component and the server collaborative key component;
[0061] Step 202: Call the CSP to obtain the key parameter interface and export the signature public key from the client;
[0062] Step 203: construct an application form according to the signature public key, call the CSP hash signature interface, sign the application form, and obtain an application form including the signature value;
[0063] Step 204: Send the application including the signature value to a security certification center to obtain a signature certificate;
[0064] Step 205: Call the CSP key parameter setting interface to import the signing certificate into the client, parse the signing certificate on the client, and verify whether the public key of the signing certificate is the same as the signature public key;
[0065] Step 206: If they are the same, store the signature certificate on the client, and associate the signature certificate with the signature public key.
[0066] Specifically, when the downloaded certificate is a signed certificate, applying for and downloading the certificate through the CSP interface includes:
[0067] (1) The client and the server establish a secure network channel and provide the ability to remotely call the server interface;
[0068] (2) The client generates the client SM2 collaborative key component, including the client signature public key component P1 and the client signature private key component d1, and encrypts and stores them on the local disk.
[0069] (3) The client sends the client signature public key component P1 to the server.
[0070] (4) The server generates the server SM2 collaborative key component, including the server signature public key component P2 and the server signature private key component d2, and encrypts and stores them on the server.
[0071] (5) The server uses the client SM2 signature public key component P1 and the server SM2 collaborative private key component d2 to synthesize the complete SM2 signature public key P.
[0072] (6) The server sends the server SM2 signature public key component P2 to the client.
[0073] (7) The client uses the client SM2 collaborative private key component d1 and the server SM2 signature public key component P2 to synthesize a complete SM2 signature public key P, which is stored locally. The principle of splitting the SM2 collaborative key components is: private key d = d1·d2–1, public key P = d1·P2–G = d2·P1–G, where G is the base point of the elliptic curve in the SM2 algorithm based on the ECC elliptic curve algorithm.
[0074] (8) The client interface is processed and the interface returns.
[0075] (9) The external program calls the CryptSetKeyParam interface to import the signature certificate to the client.
[0076] (10) The client parses the signature certificate and verifies that the public key of the signature certificate should be the same as the signature public key P. If they are inconsistent, the interface returns an error.
[0077] (11) The client stores the signature certificate locally and associates the signature certificate with the signature key, and the interface returns.
[0078] In some embodiments of the present invention, when the encryption service operation includes downloading a security certificate, the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, and further includes:
[0079] After synthesizing the signature public key, calling the CSP key pair generation interface to generate a temporary key pair, the temporary key pair includes a temporary public key and a temporary private key;
[0080] Construct an application based on the temporary public key, and send the application to a security certification center to obtain an encryption certificate and an encryption key pair;
[0081] Call the CSP key import interface to import the encryption key pair to the client;
[0082] Call the CSP key parameter setting interface to import the encryption certificate to the client;
[0083] Parse the encryption certificate on the client and verify whether the public key of the encryption certificate is the same as the encryption public key;
[0084] If they are the same, the encryption certificate is stored on the client, and the encryption certificate is associated with the encryption public key.
[0085] Specifically, when the downloaded certificate is a double certificate, that is, a signature certificate and an encryption certificate, applying for and downloading the certificate through the CSP interface includes:
[0086] (1) The external program calls the CryptAcquireContext interface to create a container. According to the CSP configuration registered by this program in the system, it indirectly calls the CPAcquireContext interface provided by this program (all interface calls are in this indirect calling method, which will not be repeated below). This program creates a file on the local disk as a container file for storing certificate and private key components.
[0087] (2) The external program calls the CryptGenKey interface to generate a signature key pair. This program acts as a client and starts to complete the collaborative key generation process with the server.
[0088] (3) The external program calls the CryptGenKey interface to generate an encryption key pair, including:
[0089] The client calls the server's interface for generating a temporary key pair. The server generates a temporary key pair for the PKCS#10 application (including a temporary public key Pt and a temporary private key dt). The temporary public key will be sent to the CA center in the subsequent process to encrypt the private key of the encryption certificate. The server sends the temporary public key Pt to the client. The client stores the temporary public key Pt and the interface returns.
[0090] (4) The external program calls CryptGetKeyParam to export the signature public key, and the client returns P.
[0091] (5) The external program calls CryptGetKeyParam to export the encrypted public key, and the client returns Pt.
[0092] (6) The external program constructs a PKCS#10 application and calls the CryptCreateHash / CryptHashData / CryptSighHash series of interfaces to sign the PKCS#10 application. After the client completes the processing, the interface returns.
[0093] (7) The external program calls the CryptSetKeyParam interface to import the signature certificate to the client. The client parses the signature certificate and verifies that the public key of the signature certificate should be the same as the signature public key P. If they are inconsistent, the interface returns an error. The client stores the signature certificate locally and associates the signature certificate with the signature key. The interface returns.
[0094] (8) The external program calls the CryptImportKey interface to import the encryption key pair to the client. The external program calls the CryptSetKeyParam interface to import the encryption certificate to the client. The client parses the encryption certificate and verifies that the public key of the encryption certificate should be the same as the encryption public key P'. If they are inconsistent, the interface returns an error. The client stores the encryption certificate locally and associates the encryption certificate with the encryption key. The interface returns, and the certificate download process is completed.
[0095] In an embodiment of the present invention, calling the CSP import key interface to import the encryption key pair into the client includes:
[0096] Step 301: The encrypted private key ciphertext is transmitted to the server, and the server uses a temporary private key to decrypt the encrypted private key ciphertext to obtain the encrypted private key plaintext;
[0097] Step 302: Perform collaborative key splitting on the encrypted private key plaintext to obtain a client encryption public key component, a client encryption private key component, a server encryption public key component, and a server encryption private key component; store the client encryption public key component, the server encryption public key component, and the server encryption private key component on the server; send the client encryption public key component, the client encryption private key component, and the server encryption public key component to the client, wherein the client encryption private key component is encrypted using the client signature public key component;
[0098] Step 303: On the client side, an encrypted public key is synthesized using the client-side encrypted private key component and the server-side encrypted public key component.
[0099] Specifically, the received encrypted private key ciphertext is passed to the server. The server uses the temporary private key dt generated previously to decrypt the encrypted private key ciphertext and obtain the encrypted private key plaintext. The server performs collaborative key splitting on the encrypted private key to obtain the client encrypted public key component P3, the client encrypted private key component d3, the server encrypted public key component P4, and the server encrypted private key component d4. The splitting principle is: private key d'=d3·d4–1, public key P'=d3·P4–G=d4·P3–G. When splitting, first generate a key pair P4 and d4, and then reversely calculate d3 and P3, specifically: d3=(d'+1)d4 -1, P3=d3·G. The server stores P3, P4 and d4 on the server, and sends P3, d3 and P4 to the client (where d3 is encrypted by the client public key component). The client encrypts P3, d3 and P4 and stores them locally. The client uses d3 and P4 to synthesize the encrypted public key P' and stores it locally.
[0100] Based on any of the above embodiments, the encryption service operation includes a signature operation, and the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, including:
[0101] Step 401: Call the CSP to create a hash interface to create a hash handle;
[0102] Step 402: Call the CSP calculation hash interface to pass in the original text to be signed and the client calculates the message digest of the original text to be signed, or directly call the CSP set hash interface to pass in the message digest of the original text to be signed, and then generate a first random number;
[0103] Step 403: Calculate a first intermediate result according to the message digest and the random number, and send the first intermediate result and the message digest to the server;
[0104] Step 404: Generate a second random number at the server, and calculate the server signature value component through the message digest, the second random number, and the first intermediate result; calculate the second intermediate result according to the server signature private key component, the signature value component, and the second random number; send the server signature value component and the second intermediate result to the client;
[0105] Step 405: The client calculates the client signature value component based on the client signature private key component, the first random number, the second intermediate result and the server signature value component, and concatenates the server signature value component and the client signature value component as the signature value.
[0106] In an embodiment of the present invention, an external program calls the CryptCreateHash interface to create a hash handle, and then calls CryptHashData to pass in the original text M to be signed or calls the CryptSetHashParam interface to pass in the message digest e of the original text to be signed. The external program calls the CryptSignHash interface to perform collaborative signing. The client calculates the message digest e through the original text M to be signed, and the calculation of the digest includes using the public key to calculate the Z value. The client generates a random number k1 and calculates the intermediate result Q1, Q1=k1·P2. The client sends the intermediate result Q1 and the message digest e to the server.
[0107] The server generates a random number k2, and calculates the key point (x1, y1) = k2 G + Q1 through e, k2, and Q1, and then calculates the signature value component r = (e + x1) mod n according to the standard. The intermediate result s2 is calculated through d2, r, and k2, (s2 = (d2 -1 ·(r+k2))mod n); send the signature value component r and the intermediate result s2 to the client.
[0108] The client calculates the signature value component s through d1, k1, s2, and r, s = (d1 -1 (k1+s2)–r) mod n; the client concatenates r and s as the signature value and returns it through the interface.
[0109] Based on any of the above embodiments, the encryption service operation includes collaborative encryption, and the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, including:
[0110] Step 501, the external program calls CryptAcquireContext and CryptGetUserKey interfaces to obtain the hKey handle;
[0111] Step 502: The external program calls the CryptEncrypt interface, taking the hKey handle and the plain text to be encrypted as input parameters;
[0112] Step 503: After the client obtains the hKey handle and the plain text to be encrypted, a third random number is generated;
[0113] Step 504: Calculate a key point according to the third random number and the encryption and decryption public key, where the encryption and decryption public key is a signature public key or an encryption public key, which is determined by the interface parameters;
[0114] Step 505: Use the key point to encrypt the plaintext to obtain encrypted ciphertext.
[0115] In the embodiment of the present invention, the external program calls the CSP to obtain the context and obtain the user key interface to obtain the key handle. The external program calls the CryptEncrypt interface to encrypt data, and the input parameters are hKey and the plaintext M to be encrypted.
[0116] The encryption process includes the client generating a random number k. If it is a single certificate, the client calculates the key point (x1, y1) = k·P, where P is the signature public key synthesized during the certificate issuance process. If it is a double certificate, the client calculates the key point (x1, y1) = k·P', where P' is the encryption public key synthesized during the certificate issuance process. The subsequent calculation process is consistent with the national secret standard encryption algorithm, and finally the ciphertext C1|C3|C2 is calculated through the plaintext M, and the interface returns.
[0117] Based on any of the above embodiments, calling the CSP service interface and performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component include:
[0118] Step 601: When the encryption and decryption public key is a signature public key, a partial ciphertext of the encrypted ciphertext is sent to the server, and the server calculates a third intermediate result by using the encrypted ciphertext and the server signature private key component, and sends the result to the client;
[0119] Step 602: Calculate a fourth intermediate result on the client side using the client signature private key component, the third intermediate result, and the encrypted ciphertext, use the fourth intermediate result as a key point, and use the key point to decrypt the encrypted ciphertext;
[0120] Step 603: When the encryption and decryption public key is an encryption public key, the encrypted ciphertext is sent to the server, and the server calculates a fifth intermediate result using the encrypted ciphertext and the server encryption private key component, and sends the result to the client;
[0121] Step 604: Calculate a sixth intermediate result on the client through the client signature private key component, the fifth intermediate result and the encrypted ciphertext, use the sixth intermediate result as a key point, and use the key point to decrypt the encrypted ciphertext.
[0122] In an embodiment of the present invention, an external program calls the CryptAcquireContext interface to obtain the hProv handle. The external program calls the CryptGetUserKey interface to obtain the hKey handle. The external program calls the CryptDecrypt interface to decrypt data, and the input parameters are hKey and the ciphertext to be decrypted C1|C3|C2. The client sends C1 to the server. If it is a single certificate, the server calculates the intermediate result O1 through C1 and the server-signed private key component d2. If it is a double certificate, the server calculates the intermediate result O1 through C1 and the server-encrypted private key component d4. The server sends O1 to the client. If it is a single certificate, the client calculates the intermediate result O2 through the client-signed private key component d1 and O1, C1. If it is a double certificate, the client calculates the intermediate result O2 through the client-encrypted private key component d3 and O1, C1. The intermediate result O2 is the key point (x1, y1) in the SM2 standard algorithm, and the client decrypts it through the SM2 standard algorithm.
[0123] In some embodiments of the present invention, the external program can export the public key through the CryptGetKeyParam interface, and the client directly returns the synthesized public key P or P'. The external program can delete the container, that is, the certificate and key therein, through the CryptAcquireContext interface. When the client deletes its own key component, it will notify the server to delete the corresponding server key component.
[0124] The encryption service providing method provided by the embodiment of the present invention combines the CSP interface with the collaborative key technology, and ensures the security of downloading, storing and using the certificate private key through the CSP interface without the help of dedicated hardware devices (such as USBKEY). In addition, the embodiment of the present invention adopts the standard CSP interface, which allows the CSP caller to switch to use directly and seamlessly without making any changes, and has good application adaptability.
[0125] The encryption service providing device provided by the present invention is described below. The encryption service providing device described below and the encryption service providing method described above can be referenced to each other.
[0126] Figure 2 A schematic diagram of an encryption service providing device provided by an embodiment of the present invention, such as Figure 2 As shown, the encryption service providing device provided by the embodiment of the present invention includes:
[0127] A generation module 201 is used to call the CSP encryption interface to generate a client collaborative key component and a server collaborative key component on the client and the server, respectively. The server collaborative key component is stored on the server, and the client collaborative key component is stored on the client;
[0128] The execution module 202 is used to call the CSP service interface and perform corresponding encryption service operations according to the client collaborative key component and the server collaborative key component.
[0129] The present invention provides an encryption service providing device, which generates a client collaborative key component and a server collaborative key component on the client and the server respectively by calling the CSP encryption interface, the server collaborative key component is stored on the server, and the client collaborative key component is stored on the client; the CSP service interface is called to perform corresponding encryption service operations according to the client collaborative key component and the server collaborative key component, and the collaborative key split storage feature is used to improve the security of private key storage. The complete private key plaintext does not appear in the memory or network of either the client or the server. Even if there is a risk in the client environment, the private key cannot be restored. Moreover, the functional operation requires the collaborative participation of the client and the server to complete the operation, which in principle prevents the server from privately executing signing or decryption without the knowledge of the client.
[0130] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a 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 may call the logic instructions in the memory 330 to execute the encryption service providing method, which includes: calling the CSP encryption interface, generating a client collaborative key component and a server collaborative key component on the client and the server, respectively, the server collaborative key component is stored on the server, and the client collaborative key component is stored on the client; calling the CSP service interface, and performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component.
[0131] 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 such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for 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 invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0132] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the encryption service providing method provided by the above-mentioned methods. The method includes: calling the CSP encryption interface, generating a client collaborative key component and a server collaborative key component on the client and the server respectively, the server collaborative key component is stored on the server, and the client collaborative key component is stored on the client; calling the CSP service interface, and performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component.
[0133] 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 shown as units may or may not be physical units, i.e., 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. Those of ordinary skill in the art may understand and implement it without creative effort.
[0134] 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 of each embodiment or some parts of the embodiment.
[0135] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for providing encryption services, characterized in that: include: Calling the CSP encryption interface, generating a client collaborative key component and a server collaborative key component on the client and the server, respectively, wherein the server collaborative key component is stored on the server, and the client collaborative key component is stored on the client; Calling the CSP service interface, performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component, when the downloaded certificate is a signed certificate, applying for and downloading the certificate through the CSP service interface includes: (1) The client and the server establish a secure network channel and provide the ability to remotely call the server interface; (2) The client generates client collaborative key components, including the client signature public key component P1 and the client signature private key component d1, and encrypts and stores them on the local disk; (3) The client sends the client signature public key component P1 to the server; (4) The server generates server collaborative key components, including the server signature public key component P2 and the server signature private key component d2, which are encrypted and stored on the server; (5) The server uses the client's signature public key component P1 and the server's collaborative private key component d2 to synthesize the complete signature public key P; (6) The server sends the server signature public key component P2 to the client; (7) The client uses the client collaborative private key component d1 and the server signature public key component P2 to synthesize a complete signature public key P, which is stored locally. The principle of splitting the collaborative key components is: private key d = d1·d2-1, public key P = d1·P2 - G =d2·P1-G, where G is the base point of the elliptic curve in the SM2 algorithm based on the ECC elliptic curve algorithm; (8) The client interface is processed and the interface returns; (9) The external program calls the CryptSetKeyParam interface to import the signature certificate to the client; (10) The client parses the signature certificate and verifies whether the public key of the signature certificate is the same as the signature public key P. If they are inconsistent, the interface returns an error; (11) The client stores the signature certificate locally and associates the signature certificate with the signature key, and the interface returns.
2. A method for providing encryption services according to claim 1, characterized in that: The encryption service operation includes downloading a security certificate, calling a CSP service interface, and performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component, including: Synthesize a signature public key based on the client collaborative key component and the server collaborative key component; Call the CSP to obtain the key parameter interface and export the signature public key from the client; Construct an application form according to the signature public key, call the CSP hash signature interface, sign the application form, and obtain an application form including the signature value; Sending the application including the signature value to a security certification center to obtain a signature certificate; Call the CSP key parameter setting interface to import the signing certificate into the client, parse the signing certificate on the client, and verify whether the public key of the signing certificate is the same as the signing public key; If they are the same, the signature certificate is stored on the client, and the signature certificate is associated with the signature public key.
3. A method for providing encryption services according to claim 2, characterized in that: The encryption service operation includes downloading the security certificate, calling the CSP service interface, performing the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, and further includes: After synthesizing the signature public key, calling the CSP encryption interface to generate a temporary key pair, the temporary key pair includes a temporary public key and a temporary private key; Construct an application form according to the temporary public key, and send the application form to a security certification center to obtain an encryption certificate and an encryption key pair, wherein the encryption key pair includes an encryption public key and an encryption private key ciphertext; Call the CSP key import interface to import the encryption key pair to the client; Call the CSP key parameter setting interface to import the encryption certificate to the client; Parse the encryption certificate on the client to verify whether the public key of the encryption certificate is the same as the encryption public key; If they are the same, the encryption certificate is stored on the client, and the encryption certificate is associated with the encryption public key.
4. A method for providing encryption services according to claim 3, characterized in that: The calling of the CSP import key interface to import the encryption key pair into the client includes: The encrypted private key ciphertext is transmitted to the server, and the encrypted private key ciphertext is decrypted by the temporary private key at the server to obtain the encrypted private key plaintext; Perform collaborative key splitting on the encrypted private key plaintext to obtain a client encryption public key component, a client encryption private key component, a server encryption public key component, and a server encryption private key component, store the client encryption public key component, the server encryption public key component, and the server encryption private key component on the server, and send the client encryption public key component, the client encryption private key component, and the server encryption public key component to the client, wherein the client encryption private key component is encrypted using the client signature public key component; On the client side, the client-side encrypted private key component and the server-side encrypted public key component are used to synthesize the encrypted public key.
5. A method for providing encryption services according to claim 2, characterized in that: The encryption service operation includes a signature operation, and the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, including: Call the CSP create hash interface and calculate hash interface to pass in the original text to be signed and the client calculates the message digest of the original text to be signed, or directly call the CSP set hash interface to pass in the message digest of the original text to be signed and generate a first random number; Calculate a first intermediate result according to the message digest and the first random number, and send the first intermediate result and the message digest to the server; Generate a second random number on the server, calculate the server signature value component through the message digest, the second random number, and the first intermediate result, calculate the second intermediate result according to the server signature private key component, the signature value component, and the second random number; send the server signature value component and the second intermediate result to the client; The client calculates the client signature value component based on the client signature private key component, the first random number, the second intermediate result and the server signature value component, and concatenates the server signature value component and the client signature value component as the signature value.
6. A method for providing encryption services according to claim 4, characterized in that: The encryption service operation includes collaborative encryption, and the calling of the CSP service interface performs the corresponding encryption service operation according to the client collaborative key component and the server collaborative key component, including: The external program calls CSP to obtain the context and user key interface to obtain the key handle; The external program calls the CSP encryption interface and takes the key handle and the plaintext to be encrypted as input parameters; After the client obtains the key handle and the plaintext to be encrypted, a third random number is generated; Calculate a key point according to a third random number and an encryption and decryption public key, where the encryption and decryption public key is a signature public key or an encryption public key; The key point is used to encrypt the plaintext to be encrypted to obtain an encrypted ciphertext.
7. A method for providing encryption services according to claim 6, characterized in that: The calling of the CSP service interface and performing corresponding encryption service operations according to the client collaborative key component and the server collaborative key component include: When the encryption and decryption public key is a signature public key, a partial ciphertext of the encrypted ciphertext is sent to the server, and the server calculates a third intermediate result by using the encrypted ciphertext and the server signature private key component, and sends the result to the client; Calculating a fourth intermediate result on the client through the client signature private key component, the third intermediate result and the encrypted ciphertext, using the fourth intermediate result as a key point, and using the key point to decrypt the encrypted ciphertext; When the encryption and decryption public key is an encryption public key, the encrypted ciphertext is sent to the server, and the server calculates a fifth intermediate result using the encrypted ciphertext and the server encryption private key component, and sends the result to the client; The sixth intermediate result is calculated on the client side by using the client signature private key component, the fifth intermediate result and the encrypted ciphertext, the sixth intermediate result is used as a key point, and the encrypted ciphertext is decrypted using the key point.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the encryption service providing method according to any one of claims 1 to 7 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the encryption service providing method according to any one of claims 1 to 7 is implemented.
