Key management method, key encryption method, data encryption method and related equipment
By using the root key to generate and encrypt the target key in the processor's built-in password module, the problem of insufficient security of the encryption and decryption results in IPSec VPN technology is solved, and higher security and stability are achieved.
Patent Information
- Application Number
- CN202411822734.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-11
AI Technical Summary
In IPSec VPN technology, the security of the execution results of the encryption and decryption program is difficult to guarantee, which affects the security of the VPN connection.
Encryption and storage of the target key is ensured by using the root key to generate the target key ciphertext in the processor's built-in cipher module and merging it into a proprietary memory.
Improve the security of the execution results of the encryption and decryption operation, ensure the security of the target key and application key, and enhance the overall security of VPN connections.
Smart Images

Figure CN119728101A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and specifically to a key management method, a key encryption method, a data encryption method, and related devices. Background Art
[0002] A virtual private network (VPN) is a technology for establishing a private network on a public network, which allows a secure connection to be established between two or more private networks on a public network. For example, IPsec (Internet Protocol Security) VPN is a VPN technology that uses IPsec to achieve remote access. It establishes an IPsec tunnel between two or more private networks on the public network and ensures the security of the VPN connection through encryption and verification algorithms. In order to achieve automatic negotiation of IPSec protection parameters and tunnels, it is necessary to use the execution results of the encryption and decryption program (such as the key keys generated during the execution process). Therefore, the security of the execution results of the encryption and decryption program is very important for the reliable implementation of IPsec.
[0003] In this context, how to provide a technical solution to improve the security of the execution results of the encryption and decryption programs has become a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a key management method, a key encryption method, a data encryption method and related devices to improve the security of the execution results of encryption and decryption operations.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions.
[0006] In a first aspect, an embodiment of the present invention provides a key management method, which is applied to a cryptographic module built into a processor, and the method includes:
[0007] receiving a key management request, the key management request being used to request management of a target key, the key management request including key management requirement information; the target key being used to encrypt at least an application key, the application key being a key key for implementing secure data transmission in a virtual private network;
[0008] Generate a target key ciphertext corresponding to the target key using the root key of the cryptographic module;
[0009] The target key ciphertext and the target key identification information in the key management requirement information are combined and saved in a dedicated memory storing the root key; the storage content of the dedicated memory is managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor;
[0010] And, returning index information, wherein the index information is used to index the storage location of the target key ciphertext and the target key identification information.
[0011] In a second aspect, an embodiment of the present invention provides a key encryption method, which is applied to a cryptographic module built into a processor, and the method includes:
[0012] receiving a key encryption request, the key encryption request including at least index information and target key identification information; the index information is obtained based on the key management method according to the first aspect;
[0013] Retrieving the stored target key ciphertext and target key identification information from the dedicated memory of the processor based on the index information;
[0014] When the received target key identification information and the stored target key identification information are successfully verified, decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain a target key, wherein the target key is used to encrypt at least an application key;
[0015] Encrypting the application key determined by the key encryption request using the target key to obtain an application key ciphertext and application key integrity verification information;
[0016] The application key ciphertext and application key integrity verification information are returned.
[0017] In a third aspect, an embodiment of the present invention provides a data encryption method, which is applied to a cryptographic module built into a processor, and the method includes:
[0018] Receiving a data encryption request, wherein the data encryption request includes data to be encrypted and encryption requirement information;
[0019] Acquire a data encryption key according to the encryption requirement information, wherein the data encryption key at least includes an application key, and the application key is obtained by decrypting the application key ciphertext returned by the key encryption method according to the second aspect;
[0020] Encrypting the data to be encrypted using the data encryption key to obtain encrypted data ciphertext;
[0021] Returns the encrypted data ciphertext.
[0022] In a fourth aspect, an embodiment of the present invention provides a processor, including: a built-in cryptographic module;
[0023] The password module includes:
[0024] A key management module, configured to receive a key management request, wherein the key management request is used to request management of a target key, and the key management request includes key management requirement information; the target key is at least used to encrypt an application key, and the application key is a key key for implementing secure data transmission in a virtual private network;
[0025] An algorithm operation module, used to generate a target key ciphertext corresponding to a target key using the root key of the cryptographic module;
[0026] The key management module is further used to merge and save the target key ciphertext and the target key identification information in the key management requirement information into a dedicated memory storing the root key; and return index information, wherein the index information is used to index the storage location of the target key ciphertext and the target key identification information;
[0027] The storage content of the dedicated memory is managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor.
[0028] In a fifth aspect, an embodiment of the present invention provides a cryptographic device, including:
[0029] A processor as described in the fourth aspect.
[0030] A key management method provided by an embodiment of the present invention is applied to a cryptographic module built into a processor, the method comprising: receiving a key management request, the key management request being used to request management of a target key, the key management request comprising key management requirement information; the target key being used to at least encrypt an application key, the application key being a key key for implementing secure data transmission in a virtual private network; using a root key of the cryptographic module to generate a target key ciphertext corresponding to the target key; merging the target key ciphertext and the target key identification information in the key management requirement information and saving them in a dedicated memory storing the root key; the storage content of the dedicated memory being managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor; and returning index information, the index information being used to index the storage location of the target key ciphertext and the target key identification information.
[0031] It can be seen that the technical solution provided by the embodiment of the present invention uses the root key of the password module to encrypt the target key according to the key management request. Since the root key of the password module is the only root key generated inside the password module, and the root key is stored in the proprietary memory of the processor. The storage content of the proprietary memory is visible inside the password module, and other modules except the password module are not visible, that is, it is managed by the password module and other modules except the password module are not accessible. Therefore, after the target key is encrypted by the root key, the target key ciphertext and the target key identification information are further stored in the proprietary memory, which can ensure the security of the target key encryption process and the security of the target key ciphertext; at the same time, since the storage content stored in the proprietary memory is loaded into the secure memory for use when in use, and the target key is at least used to encrypt the application key, the application key is a key key for the virtual private network to realize data security transmission. Therefore, the security of the target key ciphertext and the subsequent use of the target key to encrypt the application key can be effectively protected, thereby improving the security of the application key and the security of the execution result of the encryption program. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in 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 only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0033] Figure 1A It is a flowchart of a key management method provided by an embodiment of the present invention;
[0034] Figure 1B is another flowchart of the key management method provided by an embodiment of the present invention;
[0035] Figure 2A It is a schematic diagram of a flow chart of a key encryption method provided by an embodiment of the present invention;
[0036] Figure 2B is another schematic diagram of a key encryption method provided by an embodiment of the present invention;
[0037] Figure 3 is another schematic diagram of a key encryption method provided by an embodiment of the present invention;
[0038] Figure 4 It is a flow chart of a data encryption method provided by an embodiment of the present invention;
[0039] Figure 5 is a schematic diagram of the structure of a processor provided by an embodiment of the present invention;
[0040] Figure 6 It is a schematic diagram of the implementation process of the user-mode IKE program based on the Linux system provided by an embodiment of the present invention;
[0041] Figure 7 is a schematic diagram of a process of executing a user program by a processor provided by an embodiment of the present invention;
[0042] Figure 8 is a schematic diagram of the structure of a cryptographic device provided by an embodiment of the present invention;
[0043] Fig. 9 It is a schematic diagram of the implementation process of the cryptographic device executing the key management request provided by the embodiment of the present invention;
[0044] Fig.10 It is a schematic diagram of the implementation process of the cryptographic device provided by the embodiment of the present invention executing the key encryption request;
[0045] Fig.11 It is a schematic diagram of an implementation process of a cryptographic device executing a data encryption request provided by an embodiment of the present invention;
[0046] Fig.12 It is another schematic diagram of the implementation process of the cryptographic device provided in an embodiment of the present invention executing a data encryption request. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0048] With the popularization of computer network applications, how to interconnect internal networks in different regions in a safe and convenient way to achieve resource sharing, and how to access internal networks conveniently and quickly are becoming increasingly important. VPN technology can meet the above needs. VPN technology allows a secure connection to be established between two or more private networks on a public network by establishing a private network on the public network.
[0049] IPsec (Internet Protocol Security) is a VPN technology. It is a framework consisting of two types of protocols: AH (Authentication Header) protocol and ESP (Encapsulated Security Payload) protocol. The purpose of IPsec is to provide high security features for IP (Internet Protocol), including data encryption, authentication and data tamper-proof functions. VPN is a solution generated by implementing this security feature.
[0050] That is, IPsec is a technical means to implement VPN, and VPN is a way of applying IPsec.
[0051] IPSec is a protocol suite that provides confidentiality, data integrity, authentication, and protection against replay attacks for network communications. It ensures the security of data transmission over the insecure public Internet by encrypting and / or verifying data packets at the IP layer. IPsec is widely used to build virtual private networks (VPNs), protect data transmission between data centers, and support secure access for remote users. In order to achieve automatic negotiation of IPSec protection parameters and tunnels, the support of the Internet Key Exchange protocol (Internet Key Exchange) is required. IKE (Internet Key Exchange) is the signaling protocol of IPSec, which provides IPSec with services for automatic negotiation of key exchange and establishment of security alliances, and can simplify the use and management of IPSec, as well as the configuration and maintenance of IPSec.
[0052] Therefore, it is very necessary to ensure the security of the execution results (such as key keys) of encryption and decryption programs such as IKE. Based on this, an embodiment of the present invention provides a key management method for improving the security of the execution results of encryption and decryption programs.
[0053] Please refer to Figure 1A , Figure 1A The present invention provides a key management method according to an embodiment of the present invention. The method is applied to a cryptographic module built into a processor.
[0054] like Figure 1A Said method comprises the following steps:
[0055] Step S101: receiving a key management request, wherein the key management request is used to request management of a target key, and the key management request includes key management requirement information.
[0056] The target key is at least used to encrypt an application key, and the application key is a key key for implementing secure data transmission in a virtual private network.
[0057] During the process of the cryptographic module executing the encryption and decryption program, there are some critical keys with a higher security level. The target key can at least be used to encrypt these critical keys (application keys) with a higher security level, thereby improving the security of the application keys.
[0058] For example, when the encryption and decryption program is the IKE program described above, the application key can be the initiator's private key (priv_i) in the step of "the initiator of the communication uses its own private key to de-encrypt the responder's key exchange key, one-time random number, identity information and encrypted certificate" during the execution of the IKE program.
[0059] In some implementations, the application key with a higher security level may also be the SKEYID_e key during the execution of the IKE program, also known as the IEK key (IPsec Encryption Key), and the ISK key (IPsec Security Key), also known as SKEYID_d.
[0060] The ISK key is used to derive encryption material for IPsec. It is generated based on the shared key (DH value) and nonce value (random number) calculated by the Diffie-Hellman algorithm and is used for the subsequent IPsec SA (Security Association) establishment and key generation.
[0061] The IEK key is used to encrypt subsequent messages of the IKE protocol. It is also calculated using the Diffie-Hellman algorithm and the nonce value, ensuring the security of subsequent messages of the IKE protocol.
[0062] Step S102: Generate a target key ciphertext corresponding to the target key using the root key of the cryptographic module.
[0063] The root key is a unique key generated inside the cryptographic module when it leaves the factory. The generated root key is stored in a proprietary memory, which is only managed by the cryptographic module. The content stored inside the proprietary memory is visible inside the cryptographic module and is invisible to other programs stored in the processor, which has a high degree of privacy.
[0064] The proprietary memory may be a non-volatile random access memory (NVRAM), which is disposed inside the processor and managed by a cryptographic module.
[0065] Step S103, the target key ciphertext and the target key identification information in the key management requirement information are combined and saved in a dedicated memory storing the root key.
[0066] The storage content of the dedicated memory is managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor.
[0067] There is a physical isolation between the processor's secure memory and the processor's normal memory, so loading the storage content into the secure memory can ensure the security when using the storage content (such as the target key ciphertext stored above).
[0068] In one implementation, in order to facilitate the determination of the storage location of the target key ciphertext and the target key identification information, the key management requirement information may further include: target key index information; step S103 may include:
[0069] The target key ciphertext and the target key identification information in the key management requirement information are combined and saved in the corresponding position of the dedicated memory indicated by the target key index information, so that the target key index information is used as the returned index information.
[0070] The target key identification information (which can be an arbitrary 32-bit unsigned integer) is included in the key management requirements. Since the target key ciphertext is stored in a dedicated memory in the embodiment of the present invention and index information is returned, the target key identification information can be used to verify the target key usage authority when the target key is subsequently obtained based on the target key ciphertext, thereby ensuring the safe use of the target key.
[0071] Step S104: return index information, where the index information is used to index the storage location of the target key ciphertext and the target key identification information.
[0072] Since the target key is generated and stored inside the processor and is not returned to the user program, it can also be called an internal key.
[0073] The user program may be a program that needs to perform encryption and decryption operations, such as an IKE program, a Boxcryptor program, a Gpg4win program for signing and encrypting files and emails, and the like.
[0074] When the program for performing encryption and decryption operations is the aforementioned IKE program, the target key may be a KEK (Key Encryption Key) key, an ISK key, or an IEK (IPsec Encryption Key) key.
[0075] It should be noted that the ISK key and IEK key as the target key (internal key) have the same generation principle as the ISK key and IEK key as the application key, but their functions are different. The ISK key and IEK key as the application key can be used in the second phase of the IKE program execution and are protected by the target key. The ISK key and IEK key as the internal key are used in the process of acting on other non-encrypted application keys.
[0076] The IKE process consists of two phases:
[0077] The first phase (also called IKE_SA_INIT or Main Mode) is mainly used to establish a secure channel, namely ISAKMP SA (Internet Security Association and Key Management Protocol Security Association), and generate key materials for subsequent communications in the process. These key materials include keys for authentication (SKEYID_a), keys for encryption (SKEYID_e), and key materials for generating IPsec SA keys (SKEYID_d).
[0078] In the second phase (also called Quick Mode or IPSec SA negotiation phase), these key materials are used to negotiate the IPsec SA, that is, to determine the security parameters and keys used to protect the actual data transmission.
[0079] In the second stage, the key material generated in the first stage is used to derive the encryption key SKEYID_e to encrypt the messages in the negotiation process to ensure that only the communicating parties can understand the content of the negotiation, thereby protecting the IPsec SA negotiation process from being eavesdropped or tampered with by unauthorized third parties.
[0080] Furthermore, the message integrity and identity verification are performed using SKEYID_a derived from the key material generated in the first phase. In the second phase, the quick mode uses SKEYID_a to ensure the integrity of the data and verify the identity of the data source, ensuring that the message has not been tampered with during transmission.
[0081] And, using SKEYID_d (i.e., ISK key) generated in the first phase, the key material for generating IPsec SA is derived from the first phase. In the second phase, the quick mode needs to derive keys for generating IPsec SA from SKEYID_d, which will be used in the actual IPsec encryption and authentication process.
[0082] Among them, the keys SKEYID_e (ie, IEK key) and SKEYID_d (ie, ISK key) used for encryption can be the application keys with higher security levels mentioned above; the keys that can be used to encrypt and protect these application keys with higher security levels are the target keys described in the embodiments of the present invention.
[0083] It can be seen that the technical solution provided by the embodiment of the present invention uses the root key of the password module to encrypt the target key according to the key management request. Since the root key of the password module is the only root key generated inside the password module, and the root key is stored in the proprietary memory of the processor. The storage content of the proprietary memory is visible inside the password module, and other modules except the password module are not visible, that is, it is managed by the password module and other modules except the password module are not accessible. Therefore, after the target key is encrypted by the root key, the target key ciphertext and the target key identification information are further stored in the proprietary memory, which can ensure the security of the target key encryption process and the security of the target key ciphertext; at the same time, since the storage content stored in the proprietary memory is loaded into the secure memory for use when in use, and the target key is at least used to encrypt the application key, the application key is a key key for the virtual private network to realize data security transmission. Therefore, the security of the target key ciphertext and the subsequent use of the target key to encrypt the application key can be effectively protected, thereby improving the security of the application key and the security of the execution result of the encryption program.
[0084] To ensure the security of the use of the root key and the accurate generation of the target key, in one embodiment, the key management request also includes root key authentication information and generation type indication information of the target key.
[0085] Please refer to Figure 1B , Figure 1B FIG. 1 is another flow chart of the key management method provided by an embodiment of the present invention. Figure 1B As shown, before step S102, the following steps are also included:
[0086] Step S110: Verify the permission to use the root key of the cryptographic module using the root key authentication information.
[0087] The root key authentication code refers to a mechanism used to verify the identity and integrity of the root key in the key management system. The root key is at the top level of the hierarchical symmetric key structure and is used to generate or protect smart card-level subkeys and subordinate institution subkeys.
[0088] By verifying the root key authentication information, the secure use of the root key is ensured.
[0089] Step S111, when the verification is successful, a random number is generated.
[0090] After the cryptographic module verifies the root key authentication information and determines that the user (eg, the user program that issues the key management request: IKE program) has the root key usage authority, the cryptographic module can generate the target key using the random number generated by the true random number generator.
[0091] A True Random Number Generator (TRNG) is a device that generates random numbers through physical processes rather than computer programs. This generator uses the inherent randomness in nature, such as atmospheric noise, radioactive decay and other physical phenomena, to produce completely unpredictable random numbers. The key to a true random number generator lies in the uncertainty in the physical process and the authenticity of the noise source. Through reasonable design and implementation, it can generate high-quality and unpredictable random numbers with confidentiality.
[0092] Step S112: according to the type of the target key indicated by the generation type indication information, use the random number to generate a target key of a corresponding type.
[0093] Based on the above content, it can be known that the keys used to realize the secure transmission of data over a virtual private network generated during the execution of the IKE program include multiple types. Therefore, the corresponding type of target key can be generated based on the generation type of the target key indicated in the key management request (i.e., the generation type indication information).
[0094] In one implementation, the type of the target key includes an encryption type, and the target key of the encryption type is an encryption key; step S112 may include:
[0095] The random number is used as an encryption key, and the encryption key is used to encrypt an application key.
[0096] The encryption key may be a KEK key.
[0097] When the generation type indication information indicates that a KEK key is to be generated, the generated random number may be directly used as the KEK key.
[0098] In some other implementations, the type of the target key includes a verification type, and the target key of the verification type is a verification key; step S112 may include:
[0099] The random number is used as a private key, and the private key is a verification key. The verification key is used to enable a virtual private network to achieve secure data transmission.
[0100] The target key for securely transmitting data over a private network may be the IKE key or ISK key described above as an internal key.
[0101] When the generation type indication information indicates that an IEK key or an ISK key is to be generated, the random number is used as a private key, and the private key is a target key for securely transmitting data over a virtual private network.
[0102] When the target key is a target key for transmitting data over a virtual private network, generating the private key also includes:
[0103] Perform cryptographic operations on the private key to generate a public key; and return the public key according to a public key usage request indicated by the key management requirement information.
[0104] When a public key is generated by performing cryptographic operations based on a private key, it can be achieved through the SM2 elliptic curve cryptography algorithm.
[0105] When using the SM2 elliptic curve cryptography algorithm to generate a public key, the first step is to generate a private key: select a random number d as the private key (such as the random number generated by the true random number generator mentioned above), and this private key is a random integer less than n;
[0106] The second step is to calculate the public key: by multiplying the private key d with the base point G (under the group operation of the elliptic curve), the public key Q is calculated.
[0107] The public key calculation formula can be expressed as:
[0108] Public key Q = d·G, where G is the base point and d is the private key.
[0109] When the user program is instructed in the key management requirement information to use the public key, the plain text of the public key can be directly returned.
[0110] The embodiment of the present invention also provides a key encryption method, which is applied to a cryptographic module built into a processor. The method is used to generate an application key and implement encryption protection of the application key based on the target key in the key management method provided in the above embodiment.
[0111] Please refer to Figure 2A , Figure 2AIt is a flowchart of a key encryption method provided by an embodiment of the present invention.
[0112] like Figure 2A As shown, the method may include the following steps:
[0113] Step S201: receiving a key encryption request, wherein the key encryption request at least includes index information and target key identification information.
[0114] The index information is obtained based on the key management method described in any one of the aforementioned embodiments.
[0115] The key encryption request may be issued by a user program to request the cryptographic module to encrypt the application key.
[0116] Step S202: acquiring the stored target key ciphertext and target key identification information from the dedicated memory of the processor based on the index information.
[0117] In the key management method described in the aforementioned embodiment, the target key ciphertext and the target key identification information have been saved in the dedicated memory of the processor, so the decryption process of the target key ciphertext and the target key usage process are safe.
[0118] Therefore, when encrypting the application key, the target key ciphertext and target key identification information stored in the proprietary memory can be retrieved based on the index information. Since the storage content in the proprietary memory is managed by the cryptographic module, and the storage content is loaded into the processor's secure memory for use when in use, when encrypting the key (application key), the target key ciphertext and target key identification information obtained from the proprietary memory are loaded into the secure memory for use, further ensuring security during use, that is, security when encrypting the application key.
[0119] The application key is a key key with a higher security level in the user program, such as the aforementioned SKEYID_e key or priv_i key. Therefore, after decrypting the target key ciphertext stored in the proprietary memory in the aforementioned key management method, the target key is used to encrypt and protect the application key, which can improve the security of the application key and meet the security requirements of the application key.
[0120] Step S203, when the received target key identification information and the stored target key identification information are successfully verified, the stored target key ciphertext is decrypted using the root key of the cryptographic module to obtain the target key.
[0121] The target key is used at least to encrypt the application key.
[0122] Verification of the received target key identification information and the saved target key identification information can ensure that the use of the target key is safe, that is, the user program that currently issues the key encryption request for application key encryption has the authority to use the target key.
[0123] Based on the aforementioned key management method, it can be known that the encryption process of the target key is implemented using the root key of the cryptographic module, and the root key is also stored in a dedicated memory. Therefore, the root key can be used to decrypt the target key ciphertext to obtain the target key (target key plaintext).
[0124] It is understandable that in the key (application key) encryption process, the target key is mainly used to encrypt the application key, so the target key can be an encryption key, such as a KEK key. The corresponding target key identification information can be encryption key identification information, such as a KEK key identification code.
[0125] Step S204: encrypt the application key determined by the key encryption request using the target key to obtain an application key ciphertext and application key integrity verification information.
[0126] The application key integrity verification information can be used to verify the application key in the subsequent use of the application key. The application key integrity verification information can be a hash value generated during the encryption process of the target key to the application key.
[0127] Step S205: Return the application key ciphertext and application key integrity verification information.
[0128] Since the application key is a critical key with a higher security level, in the embodiment of the present invention, the target key ciphertext stored in the dedicated memory is decrypted and then used to encrypt the application key, and the application key ciphertext and application key integrity verification information are returned to the user program to ensure the security of the application key.
[0129] It can be seen that the technical solution provided by the embodiment of the present invention, when processing a key encryption request, obtains the saved target key ciphertext and target key identification information from the proprietary memory according to the index information returned when the password module executes the key management request; since the storage content of the proprietary memory can only be seen inside the password module, that is, it is managed by the password module, other modules are inaccessible except the password module, and the root key of the password module is the only root key generated inside it, which is also stored in the proprietary memory. Therefore, after obtaining the target key ciphertext, the root key can be used to decrypt the target key to obtain the target key, and the target key can be further used to encrypt the application key, and the application key ciphertext and application key integrity verification information are returned, so that the security of the application key can be effectively protected, the security of the application key can be improved, and the security of the execution result of the encryption and decryption program can be improved.
[0130] To ensure the security of using the root key, the key generation request may also include root key authentication information.
[0131] Please refer to Figure 2B , Figure 2B It is another flowchart of the key encryption method provided by an embodiment of the present invention.
[0132] like Figure 2B As shown in step S203, the method may further include:
[0133] Step S210, using the root key authentication information to verify whether the user has the permission to use the root key of the cryptographic module, if yes, execute step S203, if not, execute step S211.
[0134] When the verification is successful, it means that the root key can be used, and the root key of the cryptographic module can be used to decrypt the target key ciphertext that has been verified by the target key authentication information to obtain the target key.
[0135] Step S211, stopping the step of decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key when the received target key identification information and the stored target key identification information are successfully verified.
[0136] In order to fully meet the encryption protection of application keys with a higher security level, in one implementation, during the process of encrypting the application key, the step of generating the application key can be determined based on a specific key encryption request.
[0137] Please refer to Figure 3 , Figure 3 It is another flowchart of the key encryption method provided by an embodiment of the present invention.
[0138] like Figure 3As shown, the method includes:
[0139] Step S301, determine application key loading information, the application key loading information includes target key identification information, index information, application key ciphertext, and application key integrity verification information.
[0140] Step S302: using the index information to obtain the encryption key ciphertext and encryption key identification information stored in the dedicated memory.
[0141] Since the target key is used to encrypt and protect the application key, the target key may be an encryption key, such as the KEK key mentioned above, and the target key identification information may be encryption key identification information.
[0142] Step S303, using the root key authentication information to verify whether the user has the right to use the root key, if yes, execute step S304, if not, execute step S308.
[0143] Step S304, using the received encryption key identification information and the saved encryption key identification information to perform verification, and determine whether the verification result is passed, if yes, execute step S305, if not, execute step S308.
[0144] Step S305: Decrypt the stored encryption key ciphertext using the root key to obtain the encryption key.
[0145] Step S306: Based on the indication information of the source providing the application key, obtain the application key determined by the key encryption request.
[0146] The application key providing source indication information is used to indicate the providing source of the application key, and corresponds to the security level of the application key.
[0147] Since the types of application keys are different, they also have different security levels, that is, among the application keys of the same high security level, there is a further security level division between the application keys. The application keys of different security levels will have different sources of provision, so the application key can be accurately determined based on the source indication information.
[0148] Step S307: encrypt the application key using the encryption key to obtain application key ciphertext and application key integrity verification information.
[0149] Step S308: The cryptographic module stops executing the key encryption request.
[0150] In one implementation, the application key providing source indication information indicates that the application key providing source is a cryptographic module, and step S306 may include:
[0151] Generate random numbers;
[0152] The random number is determined as an application key.
[0153] When the source indication information of the application key indicates that the cryptographic module provides the source, it means that such application key has a further high security level among the key keys with higher security levels. At this time, the cryptographic module can be used to generate a random number through a true random number generator, and then the random number can be used as the application key.
[0154] The application key generated using the random number may be a symmetric or asymmetric key such as an ISK key / IEK key / KEK key generated by the same method when generating the target key (ISK / IEK / KEK key) in the aforementioned key management method.
[0155] It should be noted that among the encryption keys and verification keys generated in the key management method, the encryption key is used to encrypt the application key, and the verification key is used to process keys other than the encrypted application key. Although ISK keys, KEK keys, and IEK keys are generated in both the target key and the application key, their application scenarios are different.
[0156] After the cryptographic module completes the generation of the application key, the decrypted encryption key (such as the KEK key) is used to encrypt the generated application key to obtain the application key ciphertext (the asymmetric key only encrypts the private key). At the same time, the encryption key is used to perform an HMAC (Hash-based Message Authentication Code) operation on the application key to obtain a hash value (application key integrity verification information). The application key ciphertext and the application key hash value are returned to the user program to facilitate the subsequent use of the application key.
[0157] In some other implementations, the application key providing source indication information indicates that the providing source of the application key is a user program.
[0158] The security level of the application key that can be directly provided by the user program is lower than the security level of the application key generated by the cryptographic module mentioned above.
[0159] The application key provided by the user may be, for example, the aforementioned SKEYID_e key. The SKEYID_e key may be used in the second phase of the IKE program execution: negotiation protection. Therefore, SKEYID_e is more important and is an application key with a higher security level, and encryption keys may be used to achieve enhanced protection.
[0160] Since the user program directly provides the application key, the key encryption request can directly carry the application key. At this time, the cryptographic module can directly use the decrypted encryption key to encrypt the application key provided by the user program to obtain the application key ciphertext (the asymmetric key only encrypts the private key), and use the encryption key to perform HMAC operation on the application key to obtain the hash value (application key integrity verification information), and return the application key ciphertext and application key hash value to the user program.
[0161] At this point, the encryption protection of the application key is completed. The user program can obtain the application key ciphertext and application key integrity verification information returned by the cryptographic module, so that the application key itself will not be leaked. When the application key corresponding to the application key ciphertext needs to be used again in the future, the application key ciphertext and application key integrity verification information can be used to decrypt the application key ciphertext using the cryptographic module, and the application key can be used indirectly through the cryptographic module to achieve encryption protection of the application key.
[0162] The embodiment of the present invention further provides a data encryption method, which uses at least the application key ciphertext provided by the aforementioned embodiment to decrypt and obtain an application key, and then implements data encryption using the decrypted application key.
[0163] Please refer to Figure 4 , Figure 4 It is a flow chart of a data encryption method provided by an embodiment of the present invention.
[0164] like Figure 4 As shown, the method includes:
[0165] Step S401: receiving a data encryption request, wherein the data encryption request includes data to be encrypted and encryption requirement information.
[0166] Step S402: acquiring a data encryption key according to the encryption requirement information, wherein the data encryption key is at least an application key.
[0167] The application key is obtained by decrypting the application key ciphertext returned by the key encryption method described in any of the aforementioned embodiments.
[0168] The application key is encrypted and protected by the target key (mainly the encryption key), so the security of the application key is guaranteed. In the process of encrypting the data to be encrypted using the application key, the security of the data encryption process can be improved.
[0169] Step S403: encrypt the data to be encrypted using the data encryption key to obtain encrypted data ciphertext.
[0170] Step S404, returning the encrypted data ciphertext.
[0171] It can be seen that the technical solution provided by the embodiment of the present invention, when processing a data encryption request, at least uses the application key ciphertext returned when the password module executes the key encryption request, and uses the application key obtained after decryption as the data encryption key to encrypt the data to be encrypted. Since the application key ciphertext is obtained by encrypting the target key, and the target key is obtained based on the decryption of the target key ciphertext, the target key ciphertext is obtained by the index information returned when the password module executes the key management request; since the storage content of the proprietary memory can only be seen inside the password module, that is, it is managed by the password module, other modules except the password module are inaccessible, and the root key of the password module is the only root key generated inside it, which is also stored in the proprietary memory. Therefore, the decryption of the target key ciphertext is safe, and then the implementation of decrypting the application key using the target key obtained after decryption is also safe, which effectively protects the security of the application key, and then improves the security of encrypting the data to be encrypted using the application key.
[0172] To ensure the security of using the application key, in one embodiment, when the data encryption key is an application key, before the step of obtaining the data encryption key according to the encryption requirement information, the method further includes:
[0173] Determine application key loading information, wherein the application key loading information includes target key identification information, index information, application key ciphertext, and application key integrity verification information;
[0174] Using the index information, obtaining the target key ciphertext and target key identification information stored in the dedicated memory of the processor;
[0175] At least when the received target key identification information and the stored target key identification information are successfully verified, decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key;
[0176] Decrypting the application key ciphertext using the target key to obtain the application key;
[0177] When the received application key integrity verification information is successfully verified, the application key is loaded into the secure memory of the processor as the data encryption key.
[0178] When the application key is in use, it can be loaded into the secure memory using the cryptographic module.
[0179] The application key ciphertext and the application key integrity verification information are generated by the key encryption method described in the above embodiment. Therefore, when using the application key, the user program can provide the application key ciphertext and the application key integrity verification information (such as a hash value) to achieve decryption and use of the application key ciphertext through the cryptographic module.
[0180] Based on the key encryption method provided in the above embodiment, it can be known that when generating the application key ciphertext, the target key ciphertext and target key identification information stored in the dedicated memory are used. Therefore, when using the application key, the encryption requirement information includes the target key identification information and the index information. The target key ciphertext and target key identification information stored in the dedicated memory are obtained through the index information, and then the stored target key identification information is verified using the received target key identification information.
[0181] When the target key authentication information is successfully verified, it means that the target key has the right to use it. At this time, the root key can be used to decrypt the acquired target key ciphertext to obtain the target key. Then the target key can be used to decrypt the application key ciphertext to obtain the application key, and after verifying the application key integrity verification information in the encryption requirement information, the application key is loaded into the processor's secure memory as the data encryption key for the data to be encrypted.
[0182] In some other implementations, the application key loading request further includes: root key identification information; at least when the received target key identification information and the saved target key identification information are successfully verified, decrypting the saved target key ciphertext using the root key of the cryptographic module to obtain the target key includes:
[0183] When the root key authentication information is successfully verified, and the received target key authentication information and the stored target key authentication information are successfully verified, the stored target key ciphertext is decrypted using the root key of the cryptographic module to obtain the target key.
[0184] The root key authentication information is used to confirm the usage authority of the root key and ensure the decryption security of the target key ciphertext.
[0185] When both the root key identification information and the target key identification information have been successfully verified, the security of the target key ciphertext decryption is fully ensured, and the root key can be used to decrypt the target key ciphertext.
[0186] To ensure the subsequent reliable use of the application key in the secure memory, in one embodiment, the encryption requirement information further includes: application key identification information; after the step of decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key when the root key identification information is successfully verified, and the received target key identification information and the stored target key identification information are successfully verified, and before the step of encrypting the data to be encrypted using the data encryption key to obtain the encrypted data ciphertext, the method further includes:
[0187] Combining the application key and the application key identification information and storing them in the secure memory of the processor;
[0188] Return application key index information, where the application key index information is used to index the storage location of the application key and the application key identification information in the secure memory.
[0189] The application key authentication information is used to verify the use authority of the application key in the subsequent actual use of the application key to ensure that the use of the application key is safe and reliable.
[0190] The application key index information is used as index information when using the application key. The application key index information may be a handle.
[0191] After the application key index information is returned, the user program can encrypt and use the application key. When using the application key, the data encryption request also includes the application key index information and the application key identification information; step S403 includes:
[0192] Acquire the application key and application key identification information stored in the secure memory according to the application key index information;
[0193] Verifying the stored application key authentication information using the application key authentication information;
[0194] When the verification is successful, the data to be encrypted is encrypted using the application key to obtain an encrypted data ciphertext.
[0195] It can be seen that when the application key is used as a data encryption key, the application key is first loaded into the secure memory for storage, and then the application key index information is returned. When the application key is actually used, the user program actually uses the application key index and the cryptographic module uses the application key to encrypt data on its behalf.
[0196] Therefore, the security of application key usage can be ensured, thereby ensuring the security of data encryption.
[0197] In some other implementations, the data encryption key may also include an external key provided by a user program; the encryption requirement information may also include encryption algorithm information for encrypting the data to be encrypted;
[0198] Step S403 includes:
[0199] The encryption algorithm indicated by the encryption algorithm information is run, and the data to be encrypted is encrypted using the external key to obtain an encrypted data ciphertext.
[0200] In some steps of key negotiation performed by the user program, there are some scenarios where external keys are used for encryption directly. For example, when an asymmetric public key provided by the other party is used for encryption, the cryptographic module can also support the direct use of external keys to encrypt the data to be encrypted without the need for operations such as pre-loading the application key into secure memory.
[0201] An embodiment of the present invention further provides a processor for implementing the key management method, key encryption method and data encryption method described in the above embodiments.
[0202] Please refer to Figure 5 , Figure 5 It is a structural diagram of a processor provided by an embodiment of the present invention.
[0203] like Figure 5 As shown, the processor 1 may include: a built-in cryptographic module 11;
[0204] The password module 11 includes:
[0205] The key management module 12 is used to receive a key management request, wherein the key management request is used to request management of a target key, and the key management request includes key management requirement information; the target key is at least used to encrypt an application key, and the application key is a key key for implementing secure data transmission in a virtual private network;
[0206] The algorithm operation module 13 is used to generate a target key ciphertext corresponding to the target key using the root key of the cryptographic module 11;
[0207] The key management module 12 is further used to merge and save the target key ciphertext and the target key identification information in the key management requirement information into a dedicated memory storing the root key; and return index information, wherein the index information is used to index the storage location of the target key ciphertext and the target key identification information;
[0208] The storage content of the dedicated memory is managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor.
[0209] The cryptographic module 11 built into the processor 1 is encapsulated inside the processor 1 and includes two parts:
[0210] The first is a cryptographic coprocessor, which is responsible for cryptographic operations, namely the "algorithm operation module 13";
[0211] The second is a security processor + firmware, which is responsible for key management, namely the "key management module 12".
[0212] The cryptographic module 11 is a dedicated module that provides services for key generation, key management, encryption and decryption acceleration, etc. Since encryption and decryption related operations are implemented in hardware and integrated with the processor 1, it can play a vital role in scenarios with high security requirements and high-performance encryption and decryption operations.
[0213] IPSec VPN technology is commonly used based on the Linux system user-mode IKE program + kernel-mode XFRM combination solution, please refer to Figure 6 , Figure 6 The figure is a schematic diagram of the implementation process of the user-mode IKE program based on the Linux system provided in an embodiment of the present invention.
[0214] like Figure 6 As shown, the user-mode IKE program (such as commonly used swan-type app support, such as libswan, strongswan, etc.) is responsible for negotiating IKE SA and IPSec SA, interacting with the negotiation results with the XFRM (eXtensible Flow Representation and Marking, a framework for implementing IPsec) framework to implement IPsec policy configuration, and XFRM is responsible for data packet encryption and decryption operations. The IKE program performs IKEv1 or IKEv2 negotiation.
[0215] Based on Figure 6 The following problems exist in the execution of the IKE program and the use of the execution results:
[0216] (1) Among the types of IPSec keys, working keys and session keys are used to protect the negotiation process and encrypt business data. They are subject to mandatory requirements for periodic updates or updates based on traffic conditions. In addition, they can be placed in volatile storage devices for ease of use. They are destroyed when the device is powered off or the network connection is disconnected, so they are relatively safe. However, device keys are asymmetric keys and are the initial reliance of the entire device for key negotiation. They are generally held for a long time and will not be changed periodically, so they are required to be saved after power failure. The IKE program manages device keys by default, storing them directly in memory in plain text, or even on the hard disk, which can cause security risks. Therefore, the security level of the execution results of the IKE program (device keys, session keys, working keys) is not high enough.
[0217] Among them, device key: public and private key pairs used for asymmetric algorithms, including signature key pairs and encryption key pairs, used for verification and digital signatures.
[0218] Working key: The key obtained in the first phase of key exchange, used to protect the session key exchange process.
[0219] Session key: The key obtained in the second phase of key exchange, used to encrypt data messages and message MAC.
[0220] (2) During the IKE key negotiation process, a large number of asymmetric algorithms, symmetric algorithms, and verification algorithms are used for operations such as signing / verifying, encryption and decryption, and data verification. The native code of the IKE program (libswan, strongswan, etc.) uses software to provide cryptographic operations. The software algorithm operation consumes a lot of processor computing power, which in turn affects the performance improvement of the number of new connections per second of the IPSec VPN product. Therefore, the performance of the cryptographic algorithm executed by software during the IKE key negotiation process is low.
[0221] Therefore, in the embodiment of the present invention, the processor 1 with a built-in cryptographic module 11 can realize the function of executing the encryption and decryption program with the help of the cryptographic module 11. On the basis of improving the performance of executing the cryptographic algorithm, the root key of the key management module 12 of the cryptographic module 11 is further used as the device key to encrypt and protect the session key, working key and other critical keys (application keys) with a higher security level.
[0222] Since the root key is stored in a dedicated memory, which is a non-volatile memory on the one hand and its internal storage content is inaccessible except for the cryptographic module 11 (key management module 12) on the other hand, the security of the root key as the device key and the security of the target key encrypted based on the root key can be ensured, thereby improving the security of the application key in the process of using the target key to encrypt and protect the application key.
[0223] The dedicated memory is located in the processor 1 , and may be inside the cryptographic module 11 or outside the cryptographic module 11 .
[0224] The key management module 12 and the algorithm operation module 13 can execute the key management request described in the above embodiment.
[0225] Among them, the key management module 12 is used to parse and split the received key management request to generate various control instructions, such as storage, generation, import, export, use, destruction and other control instructions; then send each control instruction and the information carried in the key management request (such as key management requirement information) to the algorithm operation module 13, control the algorithm operation module 13 to execute each control instruction, and return the execution result to the key management module 12, and the key management module 12 returns the final result to the user program (such as the IKE program) to complete the execution of the key management request.
[0226] It can be seen that the technical solution provided by the embodiment of the present invention uses the root key of the password module to encrypt the target key according to the key management request. Since the root key of the password module is the only root key generated inside the password module, and the root key is stored in the proprietary memory of the processor. The storage content of the proprietary memory is visible inside the password module, and other modules except the password module are not visible, that is, it is managed by the password module and other modules except the password module are not accessible. Therefore, after the target key is encrypted by the root key, the target key ciphertext and the target key identification information are further stored in the proprietary memory, which can ensure the security of the target key encryption process and the security of the target key ciphertext; at the same time, since the storage content stored in the proprietary memory is loaded into the secure memory for use when in use, and the target key is at least used to encrypt the application key, the application key is a key key for the virtual private network to realize data security transmission. Therefore, the security of the target key ciphertext and the subsequent use of the target key to encrypt the application key can be effectively protected, thereby improving the security of the application key and the security of the execution result of the encryption program.
[0227] In some other embodiments, the key management module 12 is further configured to receive a key encryption request, the key encryption request including at least the index information and the target key identification information; and obtain the stored target key ciphertext and the target key identification information from the dedicated memory of the processor based on the index information;
[0228] The algorithm operation module 13 is further configured to, when the received target key identification information and the stored target key identification information are successfully verified, decrypt the stored target key ciphertext using the root key of the cryptographic module to obtain the target key, wherein the target key is at least used to encrypt the application key; and encrypt the application key determined by the key encryption request using the target key to obtain the application key ciphertext and the application key integrity verification information;
[0229] The key management module 12 is further configured to return the application key ciphertext and application key integrity verification information.
[0230] The key management module 12 and the algorithm operation module 13 may also execute a key encryption request to generate an application key ciphertext and application key integrity verification information.
[0231] In some other embodiments, the key management module 12 is further used to receive a data encryption request, the data encryption request including the data to be encrypted and encryption requirement information; and obtain a data encryption key according to the encryption requirement information, the data encryption key at least including an application key, the application key is obtained after decrypting the application key ciphertext;
[0232] The algorithm operation module 13 is further used to encrypt the data to be encrypted using the data encryption key to obtain the encrypted data ciphertext;
[0233] The key management module 12 is also used to return the encrypted data ciphertext.
[0234] The key management module 12 and the algorithm operation module 13 can also execute a data encryption request, so as to encrypt the data to be encrypted by at least using the application key.
[0235] Optionally, the key management request, the key encryption request and the data encryption request received by the key management module 12 are generated based on an execution process of a user program executed by the cryptographic module 11 .
[0236] To facilitate understanding of the generation of various requests (key management request, key encryption request, and data encryption request), the user program is an IKE program as an example for description.
[0237] Please refer to Figure 7 , Figure 7 It is a schematic diagram of the process of executing a user program by a processor provided by an embodiment of the present invention. Figure 7 The user program is taken as the IKE program as an example.
[0238] like Figure 7 As shown, the initiator is represented by "i" and the receiver is represented by "r".
[0239] "HDR" represents an ISAKMP (Internet Security Association and Key Management Protocol) message header;
[0240] “SA” stands for a payload containing one or more security association proposals;
[0241] "HDR*" means that the payload following the ISAKMP header is encrypted;
[0242] "CERT_sig_r" represents the signature certificate payload of the responder;
[0243] "CERT_enc_r" represents the encrypted certificate payload of the responder;
[0244] “HASH_i” represents the initiator’s hash payload;
[0245] "HASH_r" represents the responder hash payload;
[0246] "Ni" represents the nonce payload of the initiator;
[0247] "Nr" represents the nonce payload of the responder;
[0248] “Idi” represents the initiator’s identification payload;
[0249] "IDr" represents the identification payload of the responder;
[0250] "prv_i" represents the initiator's private key;
[0251] "prv_r" represents the responder private key;
[0252] “pub_i” represents the initiator’s public key;
[0253] "pub_r" represents the responder's public key;
[0254] “ _b" represents the load The body of the packet is the remaining payload without the ISAKMP general header.
[0255] When the processor's cryptographic module executes the IKE program, the interaction between the initiator and the receiver mainly includes:
[0256] Message 1: The initiator sends a security association payload encapsulated with a proposal payload to the responder.
[0257] Message 2: The responder sends a security association payload and the responder's signature certificate and encryption certificate. The payload indicates that it accepts the SA proposal sent by the initiator.
[0258] Message 3 and Message 4: The initiator and responder exchange data, including random number "nonce", identity (ID) and other payloads. "Nonce" is a parameter required to generate encryption keys and verification keys, and ID is the identifier of the initiator or responder. These data are generated using the temporary key Sk (Sk is generated by the IKE program, and the SK described below is i The data is encrypted with a temporary key generated on behalf of the initiator), Sk is encrypted with the public key in the other party's encryption certificate, and both parties digitally sign the data.
[0259] In Message 3 and Message 4, the composition of "XCH_i" is similar to that of "XCH_r", and the composition of "SIG_i" is similar to that of "SIG_r". For ease of description, the following only takes the initiator (i) as an example for description:
[0260] The expression of "XCH_i" can be:
[0261] XCH_i=asym_encrypt(Ski, pub_r)|sym_encrypt(Ni, Ski)|sym_encrypt(IDi, Ski)|CERT_sig_i|CERT_enc_i;
[0262] The expression of "SIG_r" can be:
[0263] SIG_i_b=asym_encrypt(Ski_b|Ni_b|IDi_b|CERT_enc_i_b, priv_i);
[0264] Among them, asym_encrypt(x, y) represents the asymmetric encryption of x using key y, and sym_encrypt(x, y) represents the symmetric encryption of x using key y; IDi is the identity of the initiator, and priv_i is the private key of the initiator. The asymmetric encryption algorithm and the symmetric encryption algorithm used in the above process are negotiated and determined by message 1 and message 2. The temporary key Sk and the random number N are randomly generated by the initiator and the responder respectively. The key management request can be generated after message 1 and message 2, or it can be generated synchronously.
[0265] In the asym_encrypt(Ski, pub_r) operation in the above process, the "pub_r" used is the responder's encryption public key obtained from the other party's encryption certificate, so the "asym_encrypt(Ski, pub_r)" operation only needs to directly use "pub_r" as an external key and call the encryption process using the external key. Similarly, in the "sym_encrypt(Ni, Ski) and sym_encrypt(IDi, Ski)" operations, Ski is a symmetric encryption key, and the encryption process is directly called as an external key.
[0266] The "priv_i" participating in the "asym_encrypt(Ski_b|Ni_b|IDi_b|CERT_enc_i_b, priv_i)" operation is the encryption private key of the initiator, which has a high security level and cannot exist in plain text. Therefore, it is necessary to perform the previous "internal key generation" -> "application key generation" -> "application key loading" steps, and then use "priv_i" through "handle" to complete the subsequent encryption operation. Therefore, the key management request can also be generated in the process of message 3 and message 4.
[0267] After message 3 and message 4 are finished, each generates a basic key parameter SKEYID for generating subsequent keys, including the SKEYID_e key used to protect message 5 and message 6 and the second phase negotiation process. The key encryption request and data encryption request can be generated during message 5 and message 6.
[0268] Messages 5 and 6 use the key "SKEYID_e" for symmetric encryption. The purpose is to authenticate the initiator and responder to each other in the previous exchange process. The specific process will not be described here. "SKEYID_e" is also used for the subsequent IKE second-phase negotiation protection. Therefore, "SKEYID_e" is relatively important and needs to be protected. By providing the corresponding application key plaintext (the aforementioned source is the user program), execute the "application key generation" -> "application key loading" method to encrypt "SKEYID_e" into ciphertext and immediately destroy the "SKEYID_e" plaintext. When using it, execute the "use application key" process to import "SKEYID_e" into the key management module of the cryptographic module, provide encryption algorithm information and data to be encrypted, use the algorithm operation module to execute the encryption algorithm, and use SKEYID_e to encrypt the ciphertext data. Including message 5, message 6 and the second phase (quick mode) negotiation of IKE, the handle corresponding to SKEYID_e can be used to complete the operation.
[0269] Quick mode exchanges rely on the key parameter SKEYID and the key derived from it generated in the first phase of the main mode exchange to negotiate the IPSec SA security policy and derive the IPSec session key. The information exchanged in quick mode is protected by symmetric encryption, and all payloads except the ISAKMP header must be encrypted. In quick mode, a hash payload item follows the ISAKMP header. This hash is used for message integrity verification and data source identity authentication.
[0270] During the main mode + quick mode negotiation process described above, the key is used several times and the corresponding encryption / decryption / hash operations are performed. Using the steps described in this method, the capabilities of the built-in cryptographic module of the processor can be fully called, the security level of key use, and the powerful cryptographic operation performance of the cryptographic module hardware can be improved.
[0271] The embodiment of the present invention further provides a cryptographic device to support the functional implementation of the above processor.
[0272] Please refer to Figure 8 , Figure 8 It is a schematic diagram of the structure of a cryptographic device provided in an embodiment of the present invention.
[0273] like Figure 8 Said cryptographic device comprises:
[0274] Processor 1;
[0275] The cryptographic device may further include:
[0276] The cryptographic module interface 2 is used to interact with the user program and the cryptographic module 11 of the processor 1, and provide the cryptographic module 11 with a request issued by the user program, wherein the request includes at least one of a key management request, a key encryption request, and a data encryption request.
[0277] The cryptographic module interface 2 may be an abstracted API (Application Programming Interface) interface that allows different software components to interact in a unified manner. For example, it may be a cryptographic library that provides user programs with the ability to use the cryptographic module 11 of the processor 1 with a standard SDF (Smart / Secure Device Function) interface (a fixed function name), which includes a user-mode driver and encapsulation of hardware algorithm capabilities.
[0278] It can be seen that the technical solution provided by the embodiment of the present invention uses the root key of the password module to encrypt the target key according to the key management request. Since the root key of the password module is the only root key generated inside the password module, and the root key is stored in the proprietary memory of the processor. The storage content of the proprietary memory is visible inside the password module, and other modules except the password module are not visible, that is, it is managed by the password module and other modules except the password module are not accessible. Therefore, after the target key is encrypted by the root key, the target key ciphertext and the target key identification information are further stored in the proprietary memory, which can ensure the security of the target key encryption process and the security of the target key ciphertext; at the same time, since the storage content stored in the proprietary memory is loaded into the secure memory for use when in use, and the target key is at least used to encrypt the application key, the application key is a key key for the virtual private network to realize data security transmission. Therefore, the security of the target key ciphertext and the subsequent use of the target key to encrypt the application key can be effectively protected, thereby improving the security of the application key and the security of the execution result of the encryption program.
[0279] The following describes the process of using the cryptographic device to execute the IKE program to implement the aforementioned requests.
[0280] Please refer to Fig. 9 , Fig. 9 It is a schematic diagram of the implementation process of the cryptographic device executing the key management request provided by the embodiment of the present invention.
[0281] Fig. 9 In the user program, the password module interface ( Fig. 9 The key management request is sent by the user to the server (taking the cryptographic library as an example), and the key management request may include root key identification information and key management requirement information (target key index information (IDX), target key identification information).
[0282] The cryptographic library sends a key management request to the key management module 12, and the key management module 12 verifies whether the user program has the root key usage authority based on the root key authentication information in the key management request.
[0283] After the root key authentication information is successfully verified, the key management module 12 generates a target key using a random number generated by a true random number generator.
[0284] The key management module 12 sends the target key and the root key to the algorithm operation module 13, and of course also sends a control instruction for encrypting the target key; then the algorithm operation module 13 executes the control instruction for encrypting the target key, encrypts the target key using the root key to generate a target key ciphertext, and returns the target key ciphertext to the key management module 12.
[0285] The key management module 12 combines the target key ciphertext and the target key identification information and saves them to the corresponding location in the processor's proprietary memory according to the target key index information, and returns the index information (target key index information) to the cryptographic library, which returns the index information to the user program.
[0286] Once the target key (e.g. ISK / IEK / KEK key) is generated and encrypted, it is stored in a dedicated memory together with the root key. The user program does not need to obtain the target key. It only needs to call the index information (IDX) and provide the target key identification information before applying to the key management module 12 for the use of the corresponding target key.
[0287] Please refer to Fig.10 , Fig.10 It is a schematic diagram of the implementation process of the cryptographic device provided in an embodiment of the present invention executing a key encryption request.
[0288] like Fig.10 As shown, when the cryptographic device executes a key encryption request, the implementation process may include:
[0289] The user program calls the cryptographic module 11 through the cryptographic library to process the key encryption request.
[0290] The key encryption request issued by the user program includes root key identification information, index information (mainly encryption key index information: KEK key index information), target key identification information (mainly encryption key identification information: KEK identification information), application key ciphertext, and application key.
[0291] The cryptographic library sends the key encryption request to the key management module 12, and the key management module 12 obtains the target key ciphertext (mainly the KEK key ciphertext) and target key identification information (mainly the KEK key identification information) stored in the dedicated memory based on the index information. Then, the root key identification information and the received KEK key identification information and the stored KEK key identification information are verified.
[0292] After the received KEK key identification information and root key identification information are successfully verified, the saved KEK key ciphertext and root key are sent to the algorithm operation module 13. Of course, there may also be a control instruction for KEK key decryption. The algorithm operation module 13 executes the control instruction for KEK key decryption, decrypts the KEK key ciphertext using the root key, obtains the KEK key, and returns the KEK key (KEK key plaintext) to the key management module 12.
[0293] The key management module 12 generates an application key (eg, KEK key / IEK key / ISK key) using a random number generated by a true random number generator, and sends the application key and KEK key to the algorithm operation module 13. Of course, there may also be a control instruction for encrypting the application key.
[0294] The algorithm operation module 13 executes the control instruction of application key encryption, encrypts the application key with the KEK key, generates the application key ciphertext, and calculates the application key integrity verification information (hash value) with the KEK key; and returns the application key integrity verification information and the application key ciphertext to the key management module 12.
[0295] The key management module 12 returns the application key ciphertext and the application key integrity verification information to the user program through the password library, completing the encryption protection of the application key.
[0296] After the application key is generated and encrypted, the user program obtains the application key ciphertext, and the application key plaintext will not be leaked. When the user program needs to use the application key, it first loads the application key to the key management module 12, and then the application key can be used indirectly through the key management module 12.
[0297] Please refer to Fig.11 , Fig.11 It is a schematic diagram of an implementation process of a cryptographic device executing a data encryption request provided by an embodiment of the present invention.
[0298] Fig.11 The diagram shown in FIG. 1 is a schematic diagram of the implementation process when the data encryption key is an application key.
[0299] When the application key is used as the data encryption key, the application key is first loaded and then used. Fig.11 As shown, the user program calls the cryptographic module 11 through the cryptographic library to execute the data encryption request.
[0300] Before executing a data encryption request, the application key is first loaded into the secure memory, so the application key loading information is first determined, and the application key loading information includes root key identification information, target key identification information, index information, application key ciphertext, and application key integrity verification information.
[0301] That is, the user program first sends application key loading information to the cryptographic library. The application key loading information includes: application key ciphertext and application key integrity verification information returned by the key management module 12 via the cryptographic library; at the same time, in order to decrypt the application key and use the application key safely, the application key loading information also includes root key identification information, target key identification information (mainly KEK key identification information), index information (mainly KEK index information that indexes the KEK key ciphertext), and application key identification information.
[0302] The cryptographic library sends the application key loading information to the key management module 12. The key management module 12 uses the index information to obtain the KEK key ciphertext and KEK key identification information stored in the dedicated memory. The saved KEK key identification information and the received KEK key identification information are used for verification, as well as the root key identification information. After successful verification, the root key and the obtained saved KEK key ciphertext are sent to the algorithm operation module 13, and a control instruction for KEK key decryption is sent at the same time.
[0303] The algorithm operation module 13 executes the control instruction of KEK key decryption, decrypts the KEK key ciphertext using the root key, obtains the KEK key, and returns the KEK key to the key management module 12 .
[0304] The key management module 12 sends the KEK key and the application key ciphertext, the application key integrity verification information, the control instruction for decrypting the application key, and the control instruction for generating the integrity verification information to the algorithm operation module 13 .
[0305] The algorithm operation module 13 first executes the control instruction of application key decryption, and uses the KEK key to decrypt the application key ciphertext to obtain the application key; then executes the control instruction of integrity verification information generation, and verifies the received application key integrity verification information; during the verification process, the KEK key can be used to calculate the hash value of the decrypted application key again, and the recalculated application key integrity verification information and the received application key integrity verification information are compared. If the comparison results are consistent, the verification is successful. At this time, the algorithm operation module 13 returns the application key to the key management module 12.
[0306] The key management module 12 combines the application key and the application key identification information and saves them in the secure memory of the processor 1, and returns the application key index information to the cryptographic library, for example, returns a handle handle.
[0307] Then, when the application key is used to encrypt the data to be encrypted, the data encryption request issued by the user program may also include the application key index information and the application key identification information and the data to be encrypted.
[0308] The cryptographic module 11 is called through the cryptographic library, and the key management module 12 receives the application key index information in the data encryption request, obtains the application key and application key identification information saved in the secure memory; uses the application key identification information to compare and verify the saved application key identification information; after successful verification, the application key and the data to be encrypted and the control instruction of the data encryption are sent to the algorithm operation module 13.
[0309] The algorithm operation module 13 executes the control instruction of data encryption, encrypts the data to be encrypted using the application key, generates encrypted data ciphertext, and returns the encrypted data ciphertext to the key management module 12.
[0310] The key management module 12 returns the encrypted data ciphertext to the user program through the cryptographic library.
[0311] It can be seen that when the user program uses the application key, it is not necessary to obtain the plain text of the application key, and the relevant cryptographic operations are also performed inside the cryptographic module 11 to protect the security of the application key and data encryption operations. As long as the application key is not destroyed, the application key only needs to be loaded once, and when the application key is used subsequently, it only needs to provide the correct application key index information (handle) and application key identification information to the key management module 12. This can improve the execution efficiency of the encryption and decryption program execution, and improve the security of the execution results of the encryption and decryption program.
[0312] Please refer to Fig.12 , Fig.12 It is another schematic diagram of the implementation process of the cryptographic device provided in an embodiment of the present invention executing a data encryption request.
[0313] Fig.12 The diagram shown in FIG. 1 is a schematic diagram of the implementation process when the data encryption key is an external key.
[0314] When an external key is used as a data encryption key, in a data encryption request issued by a user program, encryption requirement information may include encryption algorithm information for encrypting the data to be encrypted.
[0315] The user program sends a data encryption request to the cryptographic library, and the cryptographic library calls the cryptographic module 11 to execute the data encryption request.
[0316] The data encryption request may include the data to be encrypted, encryption algorithm information, and external keys.
[0317] The key management module 12 sends the external key, encryption algorithm information, the external key and the control instruction of data encryption to the algorithm operation module 13 .
[0318] The algorithm operation module 13 executes the control instruction of data encryption, runs the encryption algorithm, encrypts the data to be encrypted using the external key, and obtains the encrypted data ciphertext.
[0319] The algorithm operation module 13 returns the encrypted data ciphertext to the key management module 12, and the key management module 12 returns the encrypted data ciphertext to the user program through the password library.
[0320] The above describes multiple implementation schemes provided by the embodiments of the present invention. The various optional methods introduced in the implementation schemes can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible implementation schemes, which can all be considered as implementation schemes disclosed and open in the embodiments of the present invention.
[0321] Although the embodiments of the present invention are disclosed above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. A key management method, characterized in that: Applied to a cryptographic module built into a processor, the method comprises: receiving a key management request, the key management request being used to request management of a target key, the key management request including key management requirement information; the target key being used to encrypt at least an application key, the application key being a key key for implementing secure data transmission in a virtual private network; Generate a target key ciphertext corresponding to the target key using the root key of the cryptographic module; The target key ciphertext and the target key identification information in the key management requirement information are combined and saved in a dedicated memory storing the root key; the storage content of the dedicated memory is managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor; And, returning index information, wherein the index information is used to index the storage location of the target key ciphertext and the target key identification information.
2. The key management method according to claim 1, characterized in that: The key management request also includes root key identification information and target key generation type indication information; before the step of using the root key of the cryptographic module to generate a target key ciphertext corresponding to the target key, it also includes: Verifying the use authority of the root key of the cryptographic module by using the root key authentication information; When the verification succeeds, a random number is generated; According to the type of the target key indicated by the generation type indication information, the random number is used to generate a target key of a corresponding type.
3. The key management method according to claim 2, characterized in that: The key management requirement information also includes: target key index information; the target key ciphertext and the target key identification information in the key management requirement information are combined and saved in a dedicated memory storing the root key, including: The target key ciphertext and the target key identification information in the key management requirement information are combined and saved in the corresponding position of the dedicated memory indicated by the target key index information, so that the target key index information is used as the returned index information.
4. The key management method according to claim 2, characterized in that: The type of the target key includes an encryption type, and the target key of the encryption type is an encryption key; and the generating of the target key of the corresponding type by using the random number according to the type of the target key indicated by the generation type indication information includes: The random number is used as an encryption key, and the encryption key is used to encrypt an application key.
5. The key management method according to claim 2, characterized in that: The type of the target key includes a verification type, and the target key of the verification type is a verification key; and the generating of the target key of the corresponding type by using the random number according to the type of the target key indicated by the generation type indication information includes: The random number is used as a private key, and the private key is a verification key. The verification key is used to enable a virtual private network to achieve secure data transmission.
6. The key management method according to claim 5, characterized in that: Also includes: Perform cryptographic operations on the private key to generate a public key; And, returning the public key according to the public key usage request indicated by the key management requirement information.
7. A key encryption method, characterized in that: Applied to a cryptographic module built into a processor, the method comprises: receiving a key encryption request, wherein the key encryption request includes at least index information and target key identification information; the index information is obtained based on the key management method according to any one of claims 1 to 6; Retrieving the stored target key ciphertext and target key identification information from the dedicated memory of the processor based on the index information; When the received target key identification information and the stored target key identification information are successfully verified, decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain a target key, wherein the target key is used to encrypt at least an application key; Encrypting the application key determined by the key encryption request using the target key to obtain an application key ciphertext and application key integrity verification information; The application key ciphertext and application key integrity verification information are returned.
8. The key encryption method according to claim 7, characterized in that: The key encryption request also includes root key identification information; before the step of decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key when the received target key identification information and the stored target key identification information are successfully verified, the method further includes: Verifying the use authority of the root key of the cryptographic module by using the root key authentication information; When the verification is successful, the step of decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key is performed when the received target key identification information and the stored target key identification information are successfully verified.
9. The key encryption method according to claim 8, characterized in that: The key encryption request also includes information indicating a source of application key; Before the step of encrypting the application key determined by the key encryption request with the target key to obtain the application key ciphertext and the application key integrity verification information, the step further includes: Based on the indication information of the source providing the application key, the application key determined by the key encryption request is obtained.
10. The key encryption method according to claim 9, characterized in that: The application key providing source indication information indicates that the application key providing source is a cryptographic module, and obtaining the application key determined by the key encryption request based on the application key providing source indication information includes: Generate random numbers; The random number is determined as an application key.
11. The key encryption method according to claim 9, characterized in that: The application key providing source indication information indicates that the application key providing source is a user program.
12. The key encryption method according to any one of claims 7 to 10, characterized in that: The target key includes an encryption key of an encryption type, and the target key identification information includes encryption key identification information.
13. A data encryption method, characterized in that: Applied to a cryptographic module built into a processor, the method comprises: Receiving a data encryption request, wherein the data encryption request includes data to be encrypted and encryption requirement information; Acquire a data encryption key according to the encryption requirement information, wherein the data encryption key at least includes an application key, and the application key is obtained by decrypting an application key ciphertext returned by the key encryption method according to any one of claims 7 to 12; Encrypting the data to be encrypted using the data encryption key to obtain encrypted data ciphertext; Returns the encrypted data ciphertext.
14. The data encryption method according to claim 13, characterized in that: When the data encryption key is an application key, before the step of obtaining the data encryption key according to the encryption requirement information, the method further includes: Determine application key loading information, wherein the application key loading information includes target key identification information, index information, application key ciphertext, and application key integrity verification information; Using the index information, obtaining the target key ciphertext and target key identification information stored in the dedicated memory of the processor; At least when the received target key identification information and the stored target key identification information are successfully verified, decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key; Decrypting the application key ciphertext using the target key to obtain the application key; When the received application key integrity verification information is successfully verified, the application key is loaded into the secure memory of the processor as the data encryption key.
15. The data encryption method according to claim 14, characterized in that: The application key loading information further includes: root key identification information; at least when the received target key identification information and the saved target key identification information are successfully verified, decrypting the saved target key ciphertext using the root key of the cryptographic module to obtain the target key includes: When the root key authentication information is successfully verified, and the received target key authentication information and the stored target key authentication information are successfully verified, the stored target key ciphertext is decrypted using the root key of the cryptographic module to obtain the target key.
16. The data encryption method according to claim 15, characterized in that: The encryption requirement information further includes: application key identification information; after the step of decrypting the stored target key ciphertext using the root key of the cryptographic module to obtain the target key when the root key identification information is successfully verified, and the received target key identification information and the stored target key identification information are successfully verified, and before the step of encrypting the data to be encrypted using the data encryption key to obtain the encrypted data ciphertext, the method further includes: Combining the application key and the application key identification information and storing them in the secure memory of the processor; Return application key index information, where the application key index information is used to index the storage location of the application key and the application key identification information in the secure memory.
17. The data encryption method according to claim 16, characterized in that: The data encryption request also includes application key index information and application key identification information; the step of encrypting the data to be encrypted using the data encryption key to obtain the encrypted data ciphertext includes: Acquire the application key and application key identification information stored in the secure memory according to the application key index information; Verifying the stored application key authentication information using the application key authentication information; When the verification is successful, the data to be encrypted is encrypted using the application key to obtain an encrypted data ciphertext.
18. The data encryption method according to claim 13, characterized in that: The data encryption key also includes an external key provided by a user program; the encryption requirement information includes encryption algorithm information for encrypting the data to be encrypted; The step of encrypting the data to be encrypted by using the data encryption key to obtain encrypted data ciphertext includes: The encryption algorithm indicated by the encryption algorithm information is run, and the data to be encrypted is encrypted using the external key to obtain an encrypted data ciphertext.
19. A processor, characterized in that: include: Built-in password module; The password module includes: A key management module, configured to receive a key management request, wherein the key management request is used to request management of a target key, and the key management request includes key management requirement information; the target key is at least used to encrypt an application key, and the application key is a key key for implementing secure data transmission in a virtual private network; An algorithm operation module, used to generate a target key ciphertext corresponding to a target key using the root key of the cryptographic module; The key management module is further used to merge and save the target key ciphertext and the target key identification information in the key management requirement information into a dedicated memory storing the root key; and return index information, wherein the index information is used to index the storage location of the target key ciphertext and the target key identification information; The storage content of the dedicated memory is managed by the cryptographic module, and when the storage content is used, the cryptographic module loads the storage content into the secure memory of the processor.
20. The processor of claim 19, wherein: The key management module is further configured to receive a key encryption request, the key encryption request including at least the index information and the target key identification information; and, based on the index information, obtain the stored target key ciphertext and the target key identification information from the dedicated memory of the processor; The algorithm operation module is further configured to, when the received target key identification information and the stored target key identification information are successfully verified, decrypt the stored target key ciphertext using the root key of the cryptographic module to obtain the target key, wherein the target key is at least used to encrypt the application key; and encrypt the application key determined by the key encryption request using the target key to obtain the application key ciphertext and the application key integrity verification information; The key management module is also used to return the application key ciphertext and application key integrity verification information.
21. The processor of claim 20, wherein: The key management module is further configured to receive a data encryption request, the data encryption request including the data to be encrypted and encryption requirement information; and obtain a data encryption key according to the encryption requirement information, the data encryption key at least including an application key, the application key being obtained after decrypting the application key ciphertext; The algorithm operation module is further used to encrypt the data to be encrypted using the data encryption key to obtain the encrypted data ciphertext; The key management module is also used to return the encrypted data ciphertext.
22. The processor of claim 21, wherein: The key management request, the key encryption request and the data encryption request received by the key management module are generated based on the execution process of the user program executed by the cryptographic module.
23. A cryptographic device, characterized in that: include: A processor as claimed in any one of claims 19 to 22.
24. The cryptographic device according to claim 23, wherein: Also includes: The cryptographic module interface is used to interact with the user program and the cryptographic module of the processor, and provide the cryptographic module with a request issued by the user program, wherein the request includes at least one of a key management request, a key encryption request, and a data encryption request.
Citation Information
Patent Citations
Data encryption and decryption method and device, computing equipment and storage medium
CN112235289A
Identity authentication method and protection method for ensuring security of encryption device
CN112257119A
Method and system for processing root key file request
CN116055044A
Key loading method, key system and readable storage medium
CN116506120A
Cited By
Key negotiation method and device and related equipment
CN120639294A
Key agreement method, apparatus, and related device
CN120639294B
Key management method, key encryption method, data encryption method, and related device
EP4790946A1