Key protection method, cryptographic operation method, key protection apparatus, cryptographic operation apparatus, processor, chip, and electronic device
By storing and encrypting application keys in a secure processor within the processor, and combining this with an authorization verification mechanism, the problem of insufficient key security is solved, achieving the effect of improving key security while maintaining performance.
Patent Information
- Application Number
- PCT/CN2024/140224
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-21
- Filing Date
- 2024-12-18
- Publication Date
- 2025-12-26
AI Technical Summary
While prioritizing cryptographic performance, current technologies suffer from insufficient key security, posing risks of leakage and unauthorized access, and lack comprehensive key lifecycle management.
A security processor is set up inside the processor to store application keys and encrypt them with root protection key information. Combined with the permission verification mechanism, it is ensured that only authorized applications can access the key management interface, so as to realize the secure export and use of application keys.
It enhances the security of application keys, prevents unauthorized access and leakage, reduces the overhead of peripheral access for cryptographic operations, and balances the performance of cryptographic operations.
Smart Images

Figure CN2024140224_26122025_PF_FP_ABST
Abstract
Description
Key protection methods, cryptographic operation methods, key protection devices, cryptographic operation devices, processors, chips and electronic devices
[0001] This application claims priority to Chinese Patent Application No. 202410814574.6, filed on June 21, 2024, the disclosure of which is incorporated herein by reference in its entirety. Technical Field
[0002] This disclosure relates to a key protection method, a cryptographic operation method, a key protection device, a cryptographic operation device, a processor, a chip, and an electronic device. Background Technology
[0003] With the rapid development of information and network technologies, ensuring data security has become paramount. A primary method for ensuring data security is to encrypt data using cryptographic keys, thereby guaranteeing the confidentiality of data transmission and storage.
[0004] As the foundation of cryptographic operations (i.e., the key is the basis for encrypting and decrypting data), ensuring the security of the key is of paramount importance. Therefore, how to provide technical solutions to improve key security while maintaining the performance of cryptographic operations has become a pressing technical problem for those skilled in the art. Summary of the Invention
[0005] In view of this, the present disclosure provides a key protection method, a cryptographic operation method, a key protection device, a cryptographic operation device, a processor, a chip, and an electronic device to improve key security while taking into account the performance of cryptographic operations.
[0006] To achieve the above objectives, the present disclosure provides the following technical solutions.
[0007] In a first aspect, embodiments of this disclosure provide a key protection method applied to a security processor configured within a processor, the method comprising:
[0008] Obtain a key export request, the key export request being used to request the export of an application key, and the key export request carrying at least permission information; wherein, the security processor stores at least one application key;
[0009] When the permission information is verified, the root protection key information is invoked to protect at least the exported application key and generate a protected application key; wherein, the root protection key information is stored inside the processor.
[0010] Apply the key after exporting and protecting.
[0011] Secondly, embodiments of this disclosure provide a cryptographic operation method applied to an application processor configured within a processor, the method comprising:
[0012] Obtain cryptographic operation instructions, which are used to perform cryptographic operations on the data to be operated on; the cryptographic operation instructions at least indicate the data to be operated on and the protected application key; wherein the protected application key is derived based on the key protection method described in the first aspect above;
[0013] The protected application key is restored to at least the application key corresponding to the protected application key.
[0014] Using the application key, cryptographic operations are performed on the data to be processed to obtain the cryptographic operation result.
[0015] Thirdly, embodiments of this disclosure provide a key protection device applied to a security processor disposed within a processor, the device comprising:
[0016] A request acquisition unit is used to acquire a key export request, wherein the key export request is used to request the export of an application key, and the key export request carries at least permission information; wherein, the security processor stores at least one application key;
[0017] The protection unit is used to invoke the root protection key information when the permission information verification is successful, and at least protect the exported application key to generate a protected application key; wherein the root protection key information is stored inside the processor.
[0018] The export unit is used to export the protected application key.
[0019] Fourthly, embodiments of this disclosure provide a cryptographic operation device applied to an application processor configured within a processor, the device comprising:
[0020] The instruction acquisition unit is used to acquire cryptographic operation instructions, which are used to perform cryptographic operations on the data to be operated on; the cryptographic operation instructions at least indicate the data to be operated on and the protected application key; wherein the protected application key is derived based on the key protection method described in the first aspect above.
[0021] The restoration unit is used to restore the protected application key, and at least obtain the application key corresponding to the protected application key.
[0022] The cryptographic operation unit is used to perform cryptographic operations on the data to be operated on using the application key, and obtain the cryptographic operation result.
[0023] Fifthly, embodiments of this disclosure provide a processor, including: a security processor, an application processor, and a root protection key module;
[0024] The security processor is used to store at least one application key and to perform key management on the application key; the key management on the application key by the security processor includes security protection when the application key is exported; wherein, the security processor performs security protection when the application key is exported based on the key protection method described in the first aspect above.
[0025] The application processor is configured to execute instructions for application calls; the instructions for application calls include cryptographic operation instructions for performing cryptographic operations; wherein the application processor executes the cryptographic operation instructions based on the cryptographic operation method described in the second aspect above;
[0026] The root protection key module is used to store root protection key information; the root protection key information is used to protect at least the application key that the security processor needs to export.
[0027] Sixthly, embodiments of this disclosure provide a chip including the processor described in the fifth aspect above.
[0028] In a seventh aspect, embodiments of this disclosure provide an electronic device including the chip described in the sixth aspect above.
[0029] The key protection method provided in this disclosure can be applied to a security processor internally configured in a processor to provide security protection when the security processor exports application keys. For example, the security processor can obtain a key export request, which requests the export of an application key and carries at least authorization information. The security processor can store at least one application key. Therefore, after the authorization information is verified, the security processor can call the root protection key information (stored internally in the processor) to perform protection processing on at least the exported application key, obtaining a protected application key. Furthermore, the security processor can export the protected application key, thus achieving security protection when it is necessary to export an application key from the security processor.
[0030] Since the application key is stored in the security processor, and when it needs to be exported from the security processor for cryptographic operations, the exported application key can be protected by the root protection key information. Therefore, the exported application key is a protected application key, not a plaintext application key, which prevents the application key from being leaked during export and improves the security of the application key. Furthermore, verifying the permission information carried in the key export request before exporting the application key ensures that the security processor continues to respond to authorized key export requests, avoiding the threat of application key leakage from unauthorized key export requests. At the same time, as an internal device of the processor, using the security processor to perform security protection and export processing of the application key avoids the overhead of peripheral access to the application key, while maintaining the performance of cryptographic operations. Therefore, the key protection method provided in this disclosure embodiment can improve key security while maintaining the performance of cryptographic operations. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0032] Figure 1 is an example diagram of key protection implemented within the processor;
[0033] Figure 2 is an example diagram of a processor provided in an embodiment of this disclosure;
[0034] Figure 3 is a flowchart of the key protection method provided in an embodiment of this disclosure;
[0035] Figure 4 is a processing example diagram of key protection provided in the embodiments of this disclosure;
[0036] Figure 5 is a flowchart of the cryptographic operation method provided in the embodiment of this disclosure;
[0037] Figure 6 is a format example diagram of cryptographic operation instructions provided in the embodiments of this disclosure;
[0038] Figure 7 is another flowchart of the cryptographic operation method provided in the embodiment of this disclosure;
[0039] Figure 8 is an example diagram of another format of cryptographic operation instructions provided in an embodiment of this disclosure;
[0040] Figure 9 is a processing example diagram of cryptographic operations provided in an embodiment of this disclosure;
[0041] Figure 10 is an example diagram of a key caching unit provided in an embodiment of this disclosure;
[0042] Figure 11 is another flowchart of the cryptographic operation method provided in the embodiments of this disclosure;
[0043] Figure 12 is another example of cryptographic operations provided in an embodiment of this disclosure;
[0044] Figure 13 is a block diagram of a key protection device provided in an embodiment of this disclosure; and
[0045] Figure 14 is a block diagram of a cryptographic operation device provided in an embodiment of this disclosure. Detailed Implementation
[0046] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this disclosure.
[0047] A key is a parameter used in cryptography to encrypt and decrypt data (that is, cryptographic operations are operations that use a key to encrypt or decrypt data). If a key is leaked or illegally stolen, the data encrypted with that key may be illegally cracked, causing data security to fail. Therefore, it is necessary to provide a key protection scheme to protect the security of the key.
[0048] For computer systems (such as computer devices) performing cryptographic operations, one key protection scheme involves storing and protecting the keys using an external cryptographic module, such as a physical device like a cryptographic card. However, since the cryptographic module is a peripheral device, the computer system needs to access the key in the module every time it performs a cryptographic operation. This incurs additional peripheral access overhead for each operation, reducing performance. This is especially problematic when dealing with small data volumes (e.g., encrypting small blocks of data, a few bytes or hundreds of bytes), where peripheral access overhead constitutes a significant portion of the overall cryptographic overhead, severely impacting performance.
[0049] For computer systems performing cryptographic operations, another key protection scheme is to implement key protection within the computer system itself, such as within the processor performing the cryptographic operations. As an example, Figure 1 shows an example of implementing key protection within the processor. As shown in Figure 1, the processor, as the computing execution device in the computer system, is mainly used to interpret and execute the instructions of computer programs; processors include, for example, CPUs (Central Processing Units) and GPUs (Graphics Processing Units). A processor can have one or more processor cores 110, which can be execution units within the processor capable of independently performing computational tasks; processor cores include, for example, CPU cores and GPU cores. With multiple processor cores, multiple processor cores can execute multiple processes or threads simultaneously, thereby improving the processor's computing power through multitasking.
[0050] The processor runs cryptographic applications, which are applications that require cryptographic operations. In other words, the application's data needs to be encrypted or decrypted using cryptographic operations. The key used to perform cryptographic operations on the data of the cryptographic application is called the application key. In the example in Figure 1, the processor core can encrypt and protect the application key, and then use the encrypted application key to perform cryptographic operations on the data of the cryptographic application.
[0051] Specifically, as shown in Figure 1, the processor core 110 internally includes an IWKey (Instruction Writable Key) register 111. The IWKey register is a write-only register used to store the encryption key used to encrypt the application key (i.e., the encryption key is used to encrypt the application key). For example, a user can set the IWKey register using a key setting instruction to write the encryption key into it. Then, the processor core can call a key encryption instruction to use the encryption key written in the IWKey register to encrypt the application key (which can be externally input) and generate an encrypted application key. Therefore, when a cryptographic application running on the processor requires key operations, the processor core 110 can use the encrypted application key to perform cryptographic operations on the application's data, thus providing secure protection for the application's data. The type of cryptographic operation can be encryption or decryption, depending on the specific key operation requirements.
[0052] The key protection method illustrated in Figure 1 allows cryptographic operations on data to be performed using the encrypted application key. This means the cryptographic operations use the encrypted application key, not the plaintext version, and therefore do not access the plaintext application key, thus providing a degree of security protection for the application key. However, the key protection method illustrated in Figure 1 still has security issues and limitations, as shown in the following aspects:
[0053] There is a risk of exposing the encryption key when setting the IWKey register. Specifically, the IWKey register needs to be set by the user, and the process of setting the IWKey register by the user carries the risk of exposing the encryption key. For example, the encryption key may be illegally intercepted during the process of setting the IWKey register. Once the encryption key used to set the IWKey register is leaked, the application key encrypted with the encryption key will be illegally decrypted, which seriously threatens the data security of the cryptographic application.
[0054] The write-only nature of the IWKey register poses a DoS (Denial of Service) attack risk. Specifically, malicious programs may exploit this write-only feature to launch a DoS attack. For example, a malicious program could modify the value written to the IWKey register (i.e., modify the encryption key written to the IWKey register), rendering the application key encrypted with that key invalid. It should be noted that a DoS attack is a type of network security attack that prevents legitimate users from accessing or using network services or resources by making them unavailable.
[0055] There are limitations in protecting the use of application keys. Specifically, while the IWKey mechanism in Figure 1 ensures that the plaintext application key is not leaked, it does not restrict or protect the use of the encrypted application key. Once an attacker obtains the encrypted application key, even though the attacker does not know the plaintext form of the application key, they can still use the encrypted application key to perform encryption and decryption operations. It can be seen that the key protection method in Figure 1 is not complete and does not consider the protection at the key usage level.
[0056] The key protection method of the IWKey mechanism in Figure 1 lacks complete key lifecycle management. Specifically, although the key protection method of the IWKey mechanism supports the encryption protection of externally input application keys, it does not support other management functions such as direct key creation. Therefore, the key management capability of the IWKey mechanism is weaker than that of a cryptographic module used as a peripheral device. For example, a cryptographic module used as a peripheral device can provide lifecycle management such as key generation, storage, application, and destruction.
[0057] Based on the shortcomings of the key protection schemes described above, embodiments of this disclosure provide improved key protection schemes to enhance key security while maintaining the performance of cryptographic operations.
[0058] As an optional implementation, Figure 2 exemplarily illustrates an example diagram of a processor provided in an embodiment of this disclosure. The processor includes, but is not limited to, any one of a CPU, GPU, etc. For example, the processor referred to in an embodiment of this disclosure may be a processor chip. Referring to Figure 2, the processor may include: a Secure Processor (SP) 210, an Application Processor (AP) 220, and a root protection key module 230.
[0059] The security processor 210 may be a device within a processor used for key management (KM), primarily implementing key management functions. In this embodiment, the application key can be stored internally within the security processor, and the application key is not visible to the outside of the security processor (e.g., the application key is not visible to external devices or users of the security processor), thereby ensuring that the application key is not exposed to the external environment of the security processor, and thus preventing unauthorized access or theft of the application key. The application key is used for cryptographic operations such as encryption and decryption of data in cryptographic applications.
[0060] In an optional implementation, the security processor can provide a command interface, allowing authorized external devices or users to interact with the security processor through predefined security commands to perform key management functions such as application key generation, import, export, update, storage, and destruction. In other words, authorized external devices or users can interact with the security processor by calling its command interface and using predefined security commands to manage the lifecycle of application keys.
[0061] In an optional implementation, as shown in Figure 2, the security processor 210 may include a key management module 211 and a secure storage space 212. The key management module 211 may be a module device within the security processor that implements key management functions, such as a logic circuit device within the security processor that implements key management functions. The secure storage space 212 may be a storage space within the security processor used to store application keys. For example, the secure storage space may be embedded within the security processor and provide physical and logical protection measures to prevent unauthorized access to the application keys stored in the secure storage space.
[0062] In one implementation example, the key management module is responsible for managing and processing operations related to application keys, including but not limited to the generation, import, export, use, update, and destruction of application keys. For example, the key management module can manage at least one application key, and at least one application key is stored in a secure storage space; in an optional implementation, this disclosure embodiment supports the key management module managing multiple application keys, and multiple application keys are stored in a secure storage space. Meanwhile, applications running on the processor cannot directly access or interact with application keys; they can only access application keys through the command interface provided by the key management module. Furthermore, applications using the command interface provided by the key management module need to pass permission verification, including but not limited to identity authentication and operation authorization, to ensure that only legitimate and authorized applications can use the command interface to access application keys. As an example, this disclosure embodiment allows applications that have passed permission verification to use the command interface provided by the key management module to import commands such as application key generation, import, export, update, and destruction (e.g., key management requests), and the key management module is responsible for processing these commands to achieve lifecycle management of application keys.
[0063] It should be noted that the command interface provided by the security processor (specifically, the command interface provided by the key management module within the security processor) can be a limited command interface. A limited command interface means that its functionality and access permissions are restricted and defined to meet the security management requirements of the keys. For example, the command interface may only provide the necessary functions for key management, without offering extensive or unnecessary features, thus meeting the application's key security management needs. The functions of the command interface may include, but are not limited to, generating, importing, exporting, updating, and destroying keys. Alternatively, the access permissions of the command interface may be controlled, allowing only authenticated and authorized users or applications to invoke the command interface to trigger key management.
[0064] Application processor 220 can be an execution unit of the processor that performs computing tasks, and can be used to execute applications and complete various computing tasks; in one example, application processor can be a processor core in the processor. In the embodiments of this disclosure, application processor can perform cryptographic operations. For example, application processor can set a Crypto Instruction Set (CIS), which can be a specific set of instructions designed to support cryptographic operations (such as encryption and decryption operations).
[0065] In optional implementations, the cryptographic operation instruction set may include cryptographic operation instructions for one or more cryptographic algorithms, such as encryption operation instructions and decryption operation instructions for the SM4 algorithm. It should be noted that a cryptographic algorithm is an algorithm that implements cryptographic operations (i.e., an algorithm that implements data encryption and decryption). The type of cryptographic algorithm can be determined according to actual settings and is not limited to the SM4 algorithm. For example, embodiments of this disclosure support any cryptographic algorithm capable of implementing cryptographic operations, such as symmetric encryption algorithms, asymmetric encryption algorithms, and homomorphic encryption algorithms. Taking symmetric encryption algorithms as an example, embodiments of this disclosure may employ cryptographic algorithms such as AES (Advanced Encryption Standard), 3DES (Triple Data Encryption Standard), and SM4. Taking asymmetric encryption algorithms as an example, embodiments of this disclosure may employ cryptographic algorithms such as RSA (Rivest Shamir Adleman) and ECC (Elliptic Curve Cryptography).
[0066] In an optional implementation, the application processor can execute the cryptographic operation process corresponding to the cryptographic operation instruction based on the input data of the cryptographic operation instruction and the application key for performing cryptographic operations on the input data, thereby realizing cryptographic operation; wherein, the cryptographic operation can be an encryption operation or a decryption operation, depending on the current requirements of the cryptographic operation.
[0067] The root protection key module 230 is a device within the processor used to store root protection key (RPK) information. The RPK information can be used to protect application keys, and it can be shared by the security processor and the application processor (i.e., the security processor and the application processor share the root protection key information). In an optional implementation, the root protection key information may include a root encryption key (REK) and a root integrity key (RIK); the root encryption key can be used for encryption protection of the application key; the root integrity key can be used for integrity protection of the encryption result of the root encryption key. Further, the root protection key information may also include relevant attribute information of the root encryption key and the root integrity key.
[0068] It should be noted that the root protection key information stored in the root protection key module is internal processor information and can only be accessed and used within the processor; it is invisible to external devices. For example, the root protection key information (specifically, the root encryption key and root consistency key) stored in the root protection key module can be accessed by the security processor and application processor within the processor, but cannot be accessed by applications running on the processor, to ensure that the root protection key information is not leaked.
[0069] In an optional implementation, the root protection key module can be a storage space within the processor capable of storing information. For example, a specific address space within the processor can serve as the root protection key module to store root protection key information. For instance, the root protection key module can be a storage space embedded within the processor (such as registers or RAM within the processor), and the address of this storage space can be configured to a specific address within the processor, such as a high-order address reserved within the processor. Therefore, the root protection key module can be considered as a specific address space within the processor used to store root protection key information, such as a high-order address space reserved within the processor.
[0070] It should be noted that the high-order address space, such as the space near the upper limit of the address space (i.e., the space with larger address values), can have its range set according to actual conditions, and this embodiment does not limit it. It should be further noted that during processor manufacturing, the high-order address space within the processor can be reserved for special purposes (such as firmware operation, system management mode, security operation, etc.). By setting the high-order address space to be inaccessible to the applications and operating system running on the processor, but accessible only to internal processor components, the root protection key information stored in the high-order address space can be accessed by the internal security processor and application processor, but not by the applications running on the processor.
[0071] In an optional implementation, the root protection key information can be pre-loaded into the processor and stored in the root protection key module. For example, during processor initialization, the root protection key information can be set by the security processor and loaded into the root protection key module. For instance, the key management module in the security processor can set the values of the root encryption key and the root consistency key at processor startup and load them into the root protection key module, for example, by storing them in the high-order address space reserved by the processor. In a further optional implementation, the security processor (specifically, its key management module) can set the root protection key information to be the same each time the processor starts (e.g., the root encryption key and the root consistency key remain the same each time the processor starts), so that the application key protected by the root protection key information remains usable after a computer system reboot.
[0072] Based on the processor architecture provided in this disclosure, the key protection method provided in this disclosure is described below. The key protection method provided in this disclosure can support the protection of application keys. The steps performed by each device module in the key protection method described below can be considered as the corresponding functions of each device module. Therefore, the functional content of each device module of the processor illustrated in Figure 2 can be cross-referenced with the method content described below.
[0073] As an optional implementation, Figure 3 exemplarily illustrates an optional flowchart of the key protection method provided in the embodiments of this disclosure. Referring to Figure 3, the key protection method may include the following steps.
[0074] In step S310, the cryptographic application sends a key export request to the security processor. The key export request is used to request the export of the application key, and the key export request carries at least authorization information.
[0075] In an optional implementation, based on the command interface provided by the security processor, the cryptographic application running on the processor can send a key export request to the security processor through the command interface (e.g., the export interface) provided by the security processor for exporting the application key when it needs to export the application key. Correspondingly, the security processor can obtain the key export request.
[0076] In an optional implementation, based on the permission verification mechanism of the security processor's command interface, the cryptographic application needs to have the corresponding permissions when requesting to export the application key using the export interface, so that the key export request can at least carry permission information. In an optional implementation, the permission information can be information such as a token or digital certificate provided by the cryptographic application to indicate the cryptographic application's permissions.
[0077] In an optional implementation, where the security processor stores multiple application keys, the cryptographic application can specify the application key to be exported when requesting the security processor to export the application key. Therefore, the cryptographic application needs to identify the application key to be exported. For example, the key export request can carry an identifier for the application key to identify the application key to be exported; the identifier is used to uniquely identify the application key, and different application keys have different identifiers.
[0078] In an optional implementation, the identifier of the application key can be identifying information that refers to the application key but does not contain the actual content of the application key. For example, the identifier of the application key can be a handle to the application key, where the handle can be an abstract reference to the application key, representing the application key but not containing its actual content. Therefore, even if the handle to the application key is maliciously leaked, it will not directly threaten the security of the application key. In a corresponding example, the key export request sent by the cryptographic application can carry the identifier of the application key (e.g., the handle to the application key) and authorization information.
[0079] It should be noted that in other possible implementations, the cryptographic application may not specify the application key to be exported. For example, the application key to be exported may be randomly selected by the security processor, or the application key to be exported may be selected in a certain order of multiple stored application keys. Thus, the key export request may not carry the identifier of the application key (e.g., the handle of the application key).
[0080] In an optional implementation, the cryptographic application can specifically run on an application processor within the processor, so that step S310 can be executed by the application processor running the cryptographic application.
[0081] In step S311, the security processor verifies whether the permission information is approved. If not, step S312 is executed; if yes, step S313 is executed.
[0082] After receiving a key export request, the security processor can verify the permission information carried in the request to determine whether the cryptographic application issuing the request has the permission to export the application key. In other words, if the security processor fails to verify the permission information, it means the cryptographic application does not have the permission to export the application key, and the process can proceed to step S312 to end; that is, if the cryptographic application does not have the permission to export the application key, the security processor can choose not to respond to the key export request and directly end the process. If the security processor verifies the permission information successfully, it means the cryptographic application has the permission to export the application key, and the process can proceed to step S313 to continue the subsequent application key export processing.
[0083] For example, in a certificate-based authentication mechanism, the permission information provided by a cryptographic application may include the application's digital certificate. For instance, the application can prove its identity by providing a digital certificate issued by a trusted certificate authority. The security processor can then check the validity of the application's digital certificate, such as its signature, certificate authority, expiration date, and revocation list, to achieve certificate-based access control. Similarly, in a token-based authentication mechanism, the permission information provided by a cryptographic application may include its token. The security processor can then check the validity of the token, such as its expiration date, signature, and whether the permissions declared on the token correspond to the exported application key, to achieve token-based access control. For example, embodiments of this disclosure can also perform permission verification based on the permission level of the cryptographic application. The permission information provided by the cryptographic application can include the permission level information of the cryptographic application. The security processor can then check whether the permission level of the cryptographic application corresponds to the permission level of the application key being exported, thereby achieving permission verification based on the application's permission level. It should be noted that, in possible implementations, the computer system administrator can define permission levels for various applications (e.g., using a program permission matrix to describe the resources that different types of applications are allowed to access). In defining the permission levels of various applications, a corresponding permission level can be defined for applications with the permission to export application keys. Furthermore, the permission level of an application can be dynamically adjusted, so the application with the permission to export application keys can change dynamically.
[0084] It should be noted that the methods and mechanisms for verifying permission information can be set according to actual conditions, and this disclosure does not impose any limitations. This disclosure supports using a single verification mechanism for permission information, or it can combine multiple verification mechanisms to verify permission information.
[0085] In step S312, the process ends.
[0086] In step S313, the security processor calls the root protection key information to perform protection processing on at least the exported application key, and generates a protected application key.
[0087] As an optional implementation, after the authentication information is verified, the security processor can determine the exported application key from a plurality of stored application keys based on the identifier (e.g., a handle to the application key) provided by the cryptographic application. For example, based on the identifier (e.g., a handle to the application key) carried in the key export request, the security processor can determine the application key that matches the identifier (e.g., a handle to the application key) stored in the multiple application keys, and use it as the exported application key. It should be noted that embodiments of this disclosure can also support the security processor determining the exported application key by random selection or sequential selection, and are not limited to determining the exported application key by an identifier (e.g., a handle). In this case, the cryptographic application may not provide an identifier (e.g., a handle to the application key). In other possible implementations, embodiments of this disclosure can also support the security processor storing an application key, so that the exported application key can be uniquely determined.
[0088] Based on the protection requirements of the exported application key, the embodiments of this disclosure can at least provide security protection for the exported application key. The root protection key information stored in the root protection key module can be used to protect the application key. The security processor can call the root protection key information stored in the root protection key module to at least perform protection processing on the exported application key to obtain the protected application key (PAK).
[0089] In a further optional implementation, when protecting the exported application key, the permission information provided by the cryptographic application can be protected simultaneously. For example, the security processor can call the root protection key information stored in the root protection key module to protect the exported application key and the permission information (the permission information is carried by the key export request), thus obtaining the protected application key. Of course, simultaneously protecting the permission information is only an optional method, and embodiments of this disclosure can also support not protecting the permission information.
[0090] In an optional implementation that simultaneously protects application keys and permission information, the security processor can combine the exported application key with the permission information carried in the key export request to form information to be protected (including the exported application key and permission information), and then perform protection processing through root protection key information to obtain the protected application key. In other words, in this implementation, the root protection key information performs overall protection processing on the exported application key and permission information to obtain the protected application key; correspondingly, the protected application key can be the result of protecting the exported application key and permission information as a whole.
[0091] In optional implementations, the protection processing using root protection key information can be divided into: encryption protection and consistency protection. Encryption protection mainly ensures the confidentiality of the exported content (the exported content may be application keys and permission information, or it may be application keys), preventing the exported content from being illegally stolen. Consistency protection mainly ensures the integrity of the exported content, preventing the exported content from being tampered with during transmission and / or storage.
[0092] In an optional implementation, the root encryption key in the root protection key information can be used to encrypt at least the derived application key, resulting in an encrypted application key (i.e., the encrypted application key is at least the encrypted result of the application key). Therefore, in an optional implementation, the security processor can invoke the root encryption key to encrypt at least the derived application key, obtaining the encrypted application key. In an optional implementation, the encryption algorithm used for encryption protection can be, for example, the SM4 symmetric encryption algorithm.
[0093] Furthermore, while simultaneously protecting the exported application key and permission information, the root encryption key can encrypt both the exported application key and permission information to obtain an encrypted application key. For example, the security processor can call the root encryption key to encrypt the exported application key and permission information, resulting in an encrypted application key. In this case, the encrypted application key can be the overall encryption result of encrypting both the exported application key and permission information.
[0094] Correspondingly, the encrypted application key can be regarded as the result of encrypting the exported application key using the root encryption key, or the result of encrypting the exported application key and permission information using the root encryption key.
[0095] Based on encryption protection, even if the application key is illegally intercepted or leaked after protection, the confidentiality of the application key, or the application key and permission information, will be guaranteed because the root encryption key is securely stored in the root protection key module.
[0096] In an optional implementation, the root consistency key in the root protection key information can perform consistency protection on the encrypted application key, thereby obtaining consistency protection information. For example, the security processor can invoke the root consistency key to perform consistency protection processing on the encrypted application key, obtaining consistency protection information. As an example, consistency protection processing can be implemented by generating a message authentication code or digital signature for the encrypted application key.
[0097] In an optional implementation, the encrypted application key and the consistency protection information can form a protected application key. For example, embodiments of this disclosure can first encrypt the exported application key and permission information, and then perform consistency protection on the result of the encryption protection, thereby combining the result of the encryption protection and the result of the consistency protection to obtain the protected application key; correspondingly, the protected application key may include the encrypted application key and the consistency protection information corresponding to the encrypted application key.
[0098] It should be noted that in other possible implementations, the embodiments of this disclosure may not include consistency protection. For example, the security processor may at least encrypt the exported application key (and may also encrypt the permission information simultaneously), so that the encrypted result can be used as the protected application key. For instance, the embodiments of this disclosure may call the root encryption key to encrypt the exported application key and permission information to obtain an encrypted application key, and use the encrypted application key as the generated protected application key without further consistency protection processing; in this case, the root protection key information may not include the root consistency key.
[0099] Accordingly, the embodiments of this disclosure can obtain the protected application key based at least on the encrypted application key; for example, the encrypted application key can be used as the protected application key; or, for another example, further consistency protection processing can be performed, combining the encrypted application key and the consistency protection information corresponding to the encrypted application key to obtain the protected application key.
[0100] In step S314, the security processor returns the protected application key to the cryptographic application.
[0101] After generating the protected application key, the security processor can export it. For example, the protected application key can be returned to a cryptographic application that requires the application key (e.g., a cryptographic application that sent a key export request), so that when the cryptographic application invokes the application processor's cryptographic operation instructions, the application processor can use the protected application key to perform cryptographic operations on the application's data.
[0102] As an example, Figure 4 illustrates an exemplary processing diagram of key protection provided by an embodiment of this disclosure. As shown in Figure 4, the cryptographic application can send a key export request carrying a handle and permission information to the key management module. After verifying the permission information, the key management module can determine the exported application key from multiple stored application keys using the handle. Then, the key management module can call the root encryption key stored in the root protection key module to encrypt the exported application key and permission information to obtain the encrypted application key. Furthermore, the key management module can call the consistency protection key stored in the root protection key module to perform consistency protection processing on the encrypted application key (e.g., calculating a message authentication code or digital signature) to obtain consistency protection information. Thus, the key management module can return the protected application key formed by the encrypted application key and the consistency protection information to the cryptographic application.
[0103] In a further optional implementation, after obtaining the protected application key, the cryptographic application can store the protected application key in the internal storage space of the computer system, for example, in the computer system's memory or registers, so that the application processor can call it when executing cryptographic operation instructions.
[0104] In a further optional implementation, the security processor can process key management requests after the permissions of the application running on the processor have been verified, to support key management such as the generation, import, update, and destruction of application keys. For example, the security processor can obtain key management requests (which can be issued by the application running on the processor) through a command interface; after the permissions of the key management request have been verified (for example, after verifying that the application issuing the key management request has the authority to manage application keys; the relevant content and mechanisms of permission verification can be similarly described in the corresponding section above), the security processor can process the key management request; wherein, the key management request is used to request management of any of the following for the application keys stored by the security processor: generation, import, update, and destruction of application keys, etc. Of course, key management can also involve the export of application keys; for the relevant content on the export management of application keys, please refer to the description of the relevant content on key protection methods above.
[0105] As can be seen, the security processor can perform key management on application keys, and this key management can include security protection during application key export. Therefore, the security processor can perform security protection during application key export based on the key protection method provided in this embodiment. Furthermore, the execution content related to the security processor in the key protection method provided in this embodiment can be executed by the key management module within the security processor.
[0106] The key protection method provided in this disclosure can be applied to a security processor (specifically, a key management module within the security processor) to provide security protection when the security processor exports application keys. For example, the security processor can obtain a key export request from a cryptographic application. This request requests the export of an application key and carries at least authorization information. At least one application key can be stored within the security processor (specifically, the application key can be stored in a secure storage space within the security processor). After authorization verification, the security processor can call the root protection key information stored in the root protection key module to at least protect the exported application key, obtaining a protected application key. Furthermore, the security processor can export the protected application key, thus achieving security protection when an application key needs to be exported from the security processor.
[0107] Since the application key is stored in the security processor, and when it needs to be exported from the security processor for cryptographic operations, the exported application key can be protected by the root protection key information. Therefore, the exported application key is a protected application key, not a plaintext application key, which prevents the application key from being leaked during export and improves the security of the application key. Furthermore, verifying the permission information carried in the key export request before exporting the application key ensures that the security processor continues to respond to authorized key export requests, avoiding the threat of application key leakage from unauthorized key export requests. At the same time, as an internal device of the processor, using the security processor to perform security protection and export processing of the application key avoids the overhead of peripheral access to the application key, while maintaining the performance of cryptographic operations. Therefore, the key protection method provided in this disclosure embodiment can improve key security while maintaining the performance of cryptographic operations.
[0108] Furthermore, the root protection key information, which protects the exported application key and permission information, is stored in the root protection key module. The root protection key module, as a storage space within the security processor, is configured to be accessed only by the security processor and application processor inside the processor, and not by the application running on the processor. This ensures that the root protection key information is not leaked, thereby further enhancing the security of the key.
[0109] Based on the processor architecture and key protection scheme provided in this disclosure, the cryptographic operation method provided in this disclosure is described below. Cryptographic operation can be considered as the process by which an application processor executes cryptographic operation instructions to encrypt and decrypt data in a cryptographic application. It should be noted that the steps performed by each device module in the cryptographic operation method described below can be regarded as the corresponding functions of each device module. Therefore, the functional content of each device module of the processor illustrated in Figure 2 can be referred to in correspondence with the method described below.
[0110] As an optional implementation, Figure 5 exemplarily illustrates an optional flowchart of the cryptographic operation method provided in the embodiments of this disclosure, which can be executed by an application processor. For example, the application processor can execute instructions invoked by an application, which may include cryptographic operation instructions for performing cryptographic operations, thereby enabling the application processor to execute cryptographic operation instructions based on the cryptographic operation method provided in the embodiments of this disclosure.
[0111] Referring to Figure 5, the cryptographic operation method may include the following steps.
[0112] In step S510, a cryptographic operation instruction is obtained. The cryptographic operation instruction is used to perform cryptographic operations on the data to be operated on. The cryptographic operation instruction at least indicates the data to be operated on and the protection application key.
[0113] In an optional implementation, the cryptographic application running on the application processor can invoke cryptographic operation instructions when it needs to perform cryptographic operations, such as encryption and decryption, on the data to be processed. For example, the application processor can set a cryptographic operation instruction set (CIS), and the cryptographic application can invoke cryptographic operation instructions in the CIS to request cryptographic operations on the data to be processed.
[0114] In an optional implementation, the cryptographic operation instruction may at least indicate the data to be operated on and the protected application key. The data to be operated on can be considered as the data to be cryptographically operated on (encrypted or decrypted) by the cryptographic application; for example, when the cryptographic operation is encryption, the data to be operated on can be plaintext data, and when the cryptographic operation is decryption, the data to be operated on can be ciphertext data. The protected application key indicated by the cryptographic operation instruction can be derived based on the key protection method provided in the embodiments of this disclosure. For example, after the protected application key is derived based on the key protection method provided in the embodiments of this disclosure, it can be stored in the internal storage space of the computer system. Thus, the cryptographic operation instruction can indicate the internal storage space storing the protected application key to achieve the indication of the protected application key; for example, the storage address of the protected application key in the internal storage space can be used as the source operand of the cryptographic operation instruction. For details regarding the protected application key, please refer to the description in the corresponding section above, which will not be repeated here.
[0115] In an optional implementation, the cryptographic operation instruction can indicate the data to be operated on and the protected application key through operands. For example, the data to be operated on and the protected application key can be used as operands in the cryptographic operation instruction (specifically, source operands). For example, taking the cryptographic operation instruction of SM4 as an example, Figure 6 exemplarily shows an example format diagram of the cryptographic operation instruction provided in the embodiments of this disclosure. As shown in Figure 6, the format of the cryptographic operation instruction may include the instruction name of the cryptographic operation instruction, the destination operand (DST), the first source operand, and the second source operand.
[0116] The instruction name indicates the name of the cryptographic operation instruction, such as the instruction name of the SM4 encryption operation instruction (SM4ENC) and the instruction name of the SM4 decryption operation instruction.
[0117] The destination operand corresponds to the result of the cryptographic operation performed by the cryptographic instruction. The result could be, for example, the encrypted result or the decrypted result. Optionally, the destination operand can indicate the index address of the cryptographic result; for example, the result can be stored in the computer system's memory space, so the destination operand can indicate the index address of the storage space where the result is stored, such as the memory address of the memory containing the result or the register index of the register containing the result.
[0118] The first source operand (SRC) is a source operand in a cryptographic operation instruction, corresponding to the data to be operated on. Optionally, the first source operand can indicate the index address of the data to be operated on; for example, the data to be operated on can be stored in the computer system's memory space, so the first source operand can indicate the index address of the memory space where the data to be operated on is stored, such as the memory address of the memory where the data to be operated on is stored, or the register index of the register where the data to be operated on is stored, etc. Thus, the application processor can obtain the data to be operated on based on the first source operand.
[0119] The second source operand is another source operand in the cryptographic operation instruction, corresponding to the exported protected application key. For example, after the protected application key is exported from the security processor, it can be stored in the computer system's internal storage space. The second source operand can then indicate the index address of the protected application key, which is used to index the storage space where the exported protected application key is stored. That is, the second source operand can indicate the index address of the storage space where the exported protected application key is stored, such as the memory address of the memory where the protected application key is stored, or the register index of the register where the protected application key is stored. Therefore, the application processor can obtain the protected application key based on the second source operand.
[0120] In step S511, the protected application key is restored to obtain at least the application key corresponding to the protected application key.
[0121] The application processor can obtain the protected application key based on the instructions of the cryptographic operation instructions. Since the protected application key is the result of protection processing using the root protection key information, in an optional implementation, the application processor can call the root protection key information stored in the root protection key module to restore the protected application key, thereby obtaining at least the application key corresponding to the protected application key that can be used for cryptographic operations.
[0122] In an optional implementation, the protection processing based on the root protection key information can be divided into encryption protection and consistency protection. Thus, the protected application key can include the encrypted application key and the corresponding consistency protection information. Furthermore, after obtaining the root protection key information, the application processor can re-determine the consistency protection information of the encrypted application key based on the root consistency key in the root protection key information (e.g., recalculating the message authentication code or digital signature of the encrypted application key based on the root consistency key). The re-determined consistency protection information is compared with the consistency protection information in the protected application key. If the comparison results are consistent, it is considered that the content of the encrypted application key has not been tampered with during transmission and storage, and the consistency verification passes. If the comparison results are inconsistent, it is considered that the content of the encrypted application key has been illegally tampered with during transmission and storage, and the consistency verification fails. In this case, the embodiments of this disclosure can terminate the subsequent process.
[0123] In a further optional implementation, after the consistency verification of the encrypted application key passes, the encrypted application key can be decrypted based on the root encryption key in the root protection key information to obtain at least the application key corresponding to the protected application key. Furthermore, the result of decrypting the encrypted application key may also include permission information (e.g., permission information provided by the cryptographic application when requesting to export the application key). This corresponds to the situation where key protection simultaneously protects the exported application key and the permission information.
[0124] It should be noted that in other possible implementations, if no consistency protection is set, the protected application key can be the encrypted application key. Thus, the application processor can decrypt the protected application key based on the root encryption key in the root protection key information to obtain at least the corresponding application key (and possibly also the authorization information).
[0125] In step S512, the application key is used to perform cryptographic operations on the data to be processed, and the cryptographic operation result is obtained.
[0126] After obtaining the application key, the application processor can use it to perform cryptographic operations on the data to be processed, and obtain the cryptographic result. In an optional implementation, the cryptographic result, as the destination operand of the cryptographic operation instruction, can be stored in the storage space (such as memory or a register) corresponding to the index address of the destination operand.
[0127] In an optional implementation, the cryptographic operation can be an encryption operation, allowing the application processor to use an application key to encrypt the data to be processed (plaintext data) and obtain the encrypted result (ciphertext data corresponding to the data to be processed). Furthermore, if the application processor subsequently needs to perform decryption operations on the encrypted result, the protected application key used for the decryption operation should be consistent with the protected application key used for the encryption operation. This ensures that the application keys used for the corresponding encryption and decryption operations are identical, thereby guaranteeing the correctness of encryption and decryption. For example, if the protected application key is used as the second source operand in a cryptographic operation instruction, then the second source operand in the decryption operation instruction can be consistent with the second source operand of the corresponding encryption operation instruction. That is, the index addresses of the protected application keys for the corresponding encryption and decryption operation instructions are consistent, thus ensuring that the application keys used for the corresponding encryption and decryption operations are identical.
[0128] In an optional implementation, the cryptographic operation can be a decryption operation, so that the application processor can use the application key to perform a decryption operation on the data to be operated on (ciphertext data) to obtain the decryption result (plaintext data corresponding to the data to be operated on). At this time, the protected application key used for the decryption operation is consistent with the protected application key used for the encryption operation of the data to be operated on (ciphertext data) obtained by encryption, which can be achieved by keeping the second source operand consistent.
[0129] In a further optional implementation, the cryptographic operation instruction of this disclosure embodiment may also indicate the permission information of the cryptographic application that calls the cryptographic operation instruction, for use in verifying the correctness of the permission information during the cryptographic operation process; at this time, the protected application key is restored, and in addition to obtaining the application key, permission information (i.e., the permission information provided by the cryptographic application when requesting to export the application key) can also be obtained; thus, by verifying the correctness of the permission information indicated by the cryptographic operation instruction with the permission information in the protected application key, it can be determined whether the cryptographic application currently calling the cryptographic operation instruction has the permission to use the application key. In an optional implementation, FIG7 exemplarily shows another optional flowchart of the cryptographic operation method provided by the embodiments of this disclosure. This cryptographic operation method can be executed by an application processor, and the corresponding flowchart parts of FIG7 and FIG5 can be referred to each other, and will not be described again below; referring to FIG7, the cryptographic operation method may include the following steps.
[0130] In step S710, a cryptographic operation instruction is obtained, which is used to perform cryptographic operations on the data to be operated on; the cryptographic operation instruction at least indicates the data to be operated on, the protected application key, and the authorization information.
[0131] In this embodiment of the disclosure, the cryptographic operation instruction also indicates permission information, such as the permission information of the cryptographic application currently invoking the cryptographic operation instruction. In an optional implementation, the cryptographic operation instruction may add a source operand to indicate the permission information. Optionally, FIG8 exemplarily shows another format example diagram of the cryptographic operation instruction provided in this embodiment of the disclosure. Combining FIG6 and FIG8, the format of the cryptographic operation instruction may further include a third source operand; the third source operand is another source operand in the cryptographic operation instruction, corresponding to the authorization information (AUTH) of the cryptographic application currently invoking the cryptographic operation instruction. For example, the authorization information may be stored in the computer system's storage space, so the third source operand may indicate the index address of the authorization information, that is, the third source operand may indicate the index address of the storage space storing the authorization information, such as the memory address of the memory storing the authorization information, or the register index of the register storing the authorization information, etc. Thus, the application processor can obtain the authorization information based on the third source operand.
[0132] In step S711, the protected application key is restored to obtain the application key and permission information corresponding to the protected application key.
[0133] In this embodiment of the disclosure, restoring the protected application key can simultaneously obtain the application key and permission information; correspondingly, when performing application key protection processing, it corresponds to the situation where the application key and permission information are protected simultaneously. The relevant content can be referred to the description of the corresponding section above, and will not be elaborated here.
[0134] In step S712, based on the permission information corresponding to the protected application key, the permission information indicated by the cryptographic operation instruction is verified to be correct. If not, step S713 is executed; if yes, step S714 is executed.
[0135] This embodiment of the disclosure can utilize the permission information obtained from the restoration process (i.e., the permission information corresponding to the protected application key) to verify the correctness of the permission information indicated by the cryptographic operation instruction. For example, it can compare whether the permission information obtained from the restoration process is consistent with the permission information indicated by the cryptographic operation instruction. If the permission information is incorrect (i.e., the correctness verification of the permission information fails), it indicates that the cryptographic application currently calling the cryptographic operation instruction does not have the permission to use the application key, and thus the application processor can terminate the cryptographic operation process. If the permission information is correct (i.e., the correctness verification of the permission information passes), it indicates that the cryptographic application currently calling the cryptographic operation instruction has the permission to use the application key, and thus the application processor can continue to perform subsequent cryptographic operation processes.
[0136] In step S713, the process ends.
[0137] In step S714, the application key is used to perform cryptographic operations on the data to be processed, and the cryptographic operation result is obtained.
[0138] The content related to step S714 can be similarly referred to step S512 shown in Figure 5. It should be noted that since Figures 5 and 7 are different embodiment flowcharts, the flowchart steps with similar content use different step numbers.
[0139] In one implementation example, Figure 9 exemplarily illustrates a processing example diagram of cryptographic operations provided by an embodiment of this disclosure. As shown in Figure 9, the cryptographic operation instruction has operands: SRC (indicating the data to be operated), PAK (indicating the protected application key), AUTH (indicating permission information), and DST (destination operand). Thus, when the application processor executes the cryptographic operation instruction, it can restore the protected application key based on the root protection key information in the root protection key module (which may involve a consistency verification process and a decryption process) to obtain the application key and permission information corresponding to the protected application key. Then, the permission information obtained from the restoration process is compared with the permission information of the cryptographic operation instruction for correctness verification. If the correctness verification is successful, the application key obtained from the restoration process can be used to perform cryptographic operations on the data to be operated, and the resulting cryptographic operation is used as the destination operand and stored in the storage space (memory or register) corresponding to the destination operand.
[0140] In a further optional implementation, if the restoration of the protected application key is performed using the root protection key information (see the corresponding description above), it involves at least the calling and decryption of the root protection key information (and may also involve a consistency verification process), which may result in significant computational overhead. Since the restoration of the protected application key is on the critical path of cryptographic operations, significant computational overhead will undoubtedly reduce the overall processing performance of cryptographic instructions. Therefore, this embodiment considers setting up a key cache unit in the application processor to cache the cached information of the protected application keys historically used by the application processor. The cached information of the protected application keys may include at least the application key corresponding to the protected application key, thereby accelerating the restoration efficiency of the protected application key.
[0141] As an optional implementation, Figure 10 exemplarily illustrates an example diagram of the key caching unit provided in an embodiment of this disclosure. As shown in Figure 10, the key caching unit may include multiple cache entries. One cache entry may be used to cache cache information of a protected application key that has been used historically by the application processor. For example, one cache entry may cache at least a tag of a protected application key and the application key corresponding to the protected application key. The tag of the protected application key may be information that identifies the protected application key, used to locate the cache entry containing the cache information of the protected application key among multiple cache entries. Optionally, the tag of the protected application key may be the protected application key itself, such as directly using the protected application key as the tag; alternatively, the tag of the protected application key may also be an identifier calculated based on the protected application key, such as the digest information of the protected application key.
[0142] Furthermore, in addition to caching the application key corresponding to the protected application key, this embodiment of the present disclosure can also cache the permission information corresponding to the protected application key; correspondingly, the cached information of the protected application key may include the tag of the protected application key, the application key corresponding to the protected application key, and the permission information. For example, referring to Figure 10, a cache entry can cache the tag of a protected application key, the application key corresponding to the protected application key, and the permission information.
[0143] Based on the settings of the cached information of the protected application key, when the application processor performs the restoration process on the protected application key, it can first determine whether the protected application key has cached information. If so, the restoration process on the protected application key can be performed based on the cached information, thereby obtaining at least the corresponding application key (and possibly the permission information), thus avoiding the computational overhead caused by using the root protection key information for restoration. If not, the root protection key information must be used to restore the protected application key.
[0144] In an optional implementation, FIG11 exemplarily shows another optional flowchart of the cryptographic operation method provided in the embodiments of the present disclosure. The cryptographic operation method can be executed by an application processor. The corresponding flowchart parts of FIG11 and FIG7 can be referred to each other, and will not be described again below. Referring to FIG11, the cryptographic operation method may include the following steps.
[0145] In step S011, a cryptographic operation instruction is obtained. The cryptographic operation instruction is used to perform cryptographic operations on the data to be operated on. The cryptographic operation instruction at least indicates the data to be operated on, the protected application key, and the permission information.
[0146] In step S012, it is determined whether there is cached information for the protected application key. If yes, step S013 is executed; otherwise, step S014 is executed.
[0147] In an optional implementation, this embodiment of the present disclosure can use the tag of the protected application key to query whether there is a cache entry corresponding to the tag in the application processor (specifically, the key cache unit in the application processor). If yes (i.e., the tag of the protected application key is hit in the key cache unit), then the protected application key has cached information, indicating that the application processor has used the protected application key in the past, and the cached information of the protected application key has been cached in advance. Thus, this embodiment of the present disclosure can proceed to step S013 to obtain the corresponding application key and permission information from the cached information of the protected application key. If no (i.e., the tag of the protected application key is not hit in the key cache unit), then the protected application key does not have cached information, indicating that the application processor has not used the protected application key in the past. Thus, this embodiment of the present disclosure can proceed to step S014 to restore the protected application key using the root protected key information.
[0148] In step S013, the application key and permission information corresponding to the protected application key are obtained from the cache information of the protected application key.
[0149] After performing step S013, you can proceed to the next step S016.
[0150] In step S014, the root protection key information is invoked to restore the protected application key, thereby obtaining the application key and permission information corresponding to the protected application key.
[0151] It is evident that there are two possible ways to restore the protected application key: one is to restore the protected application key by using the cached information of the protected application key to obtain the corresponding application key and permission information (involving obtaining the corresponding application key and permission information from the cached information of the protected application key); the other is to restore the protected application key by calling the root protection key information to obtain the corresponding application key and permission information (involving the calling of the root protection key information, the consistency verification process, the decryption process, etc.).
[0152] In step S015, based on the application key and permission information corresponding to the obtained protected application key, cache information of the protected application key is cached.
[0153] After executing step S014, this embodiment of the disclosure can obtain the application key and permission information corresponding to the protected application key, thereby caching the corresponding cached information of the protected application key in the application processor. For example, based at least on the tag of the protected application key, the corresponding application key and permission information, the cache entry of the protected application key is updated in the application processor (specifically, it may be the key cache unit in the application processor), and the updated cache entry is used to cache the tag of the protected application key, as well as the corresponding application key and permission information.
[0154] In step S016, based on the permission information corresponding to the protected application key, the permission information indicated by the cryptographic operation instruction is verified to be correct. If not, step S017 is executed; if yes, step S018 is executed.
[0155] In step S017, the process ends.
[0156] In step S018, the application key corresponding to the protected application key is used to perform cryptographic operations on the data to be processed, and the cryptographic operation result is obtained.
[0157] It should be noted that since Figure 7 and Figure 11 are different implementation flow diagrams, the flow steps with similar content use different step numbers.
[0158] It should be further noted that the process shown in Figure 11 can also be implemented without permission information. The corresponding alternative implementation can be adapted and referred to in conjunction with the previous description, which will not be elaborated here.
[0159] As an implementation example, Figure 12 exemplarily illustrates another processing example diagram of cryptographic operations provided in the embodiments of this disclosure. In conjunction with Figures 9 and 12, when the application processor executes the cryptographic operation instruction, it can first query the key cache unit to see if there is a corresponding cache entry based on the tag of the protected application key indicated by the cryptographic operation instruction.
[0160] If so (i.e., there is a cache entry corresponding to the tag of the protected application key in the key cache unit), then the cache is hit, and the corresponding application key and permission information can be obtained from the queried cache entry;
[0161] If not (i.e., there is no cache entry corresponding to the tag of the protected application key in the key cache unit), then the cache miss occurs. It is necessary to restore the protected application key based on the root protection key information in the root protection key module (which may involve consistency verification and decryption processes) to obtain the application key and permission information corresponding to the protected application key. At this time, the cache entry corresponding to the protected application key can be further updated in the key cache unit so that the key cache unit has a cache entry for caching the tag of the protected application key, the corresponding application key, and the permission information.
[0162] Furthermore, the permission information corresponding to the protected application key can be verified against the permission information of the cryptographic operation instruction. If the verification is successful, the application key corresponding to the protected application key can be used to perform cryptographic operations on the data to be operated on, and the result of the cryptographic operation is used as the destination operand and stored in the storage space corresponding to the destination operand.
[0163] In a further optional implementation, this disclosure also provides a key protection device applied to a security processor disposed within a processor. In an optional implementation, this key protection device can be considered as a functional module unit optionally configured by the key management module within the security processor to implement the key protection method provided by this disclosure. The module unit content described below can be referred to in correspondence with the method content described above.
[0164] As an optional implementation, FIG13 exemplarily illustrates an optional block diagram of the key protection device provided in the embodiments of this disclosure. As shown in FIG13, the key protection device may include:
[0165] The request acquisition unit 131 is used to acquire a key export request, the key export request being used to request the export of an application key, and the key export request carrying at least permission information; wherein, the security processor stores at least one application key;
[0166] The protection unit 132 is used to call the root protection key information when the permission information verification is passed, to at least protect the exported application key and generate a protected application key; wherein the root protection key information is stored inside the processor.
[0167] Export unit 133 is used to export the protected application key.
[0168] In an optional implementation, the root protection key information includes at least a root encryption key. Optionally, the protection unit 132 is used to invoke the root protection key information to perform protection processing on at least the exported application key, generating a protected application key including:
[0169] Call the root encryption key to encrypt at least the exported application key to obtain the encrypted application key;
[0170] At least based on the encrypted application key, a protected application key is obtained.
[0171] In an optional implementation, the root protection key information further includes a root consistency key. Optionally, the protection unit 132 is used to invoke the root protection key information to perform protection processing on at least the derived application key, and the generated protected application key further includes:
[0172] After obtaining the encrypted application key, the root consistency key is invoked to perform consistency protection processing on the encrypted application key, thereby obtaining the consistency protection information corresponding to the encrypted application key.
[0173] Optionally, the protection unit 132 is used to obtain the protected application key based at least on the encrypted application key, including:
[0174] By combining the encrypted application key and the corresponding consistency protection information, the protected application key is obtained.
[0175] In an optional implementation, protection unit 132 is used to invoke the root encryption key to encrypt at least the exported application key, resulting in an encrypted application key including:
[0176] The root encryption key is invoked to encrypt the exported application key and the aforementioned permission information, resulting in an encrypted application key.
[0177] In an optional implementation, the key export request also carries an identifier for the application key; the identifier for the application key is identification information that refers to the application key but does not contain the actual content of the application key. Optionally, before the protection unit 132 executes the step of calling the root protection key information, at least protecting the exported application key, and generating a protected application key, the key protection device (specifically, a key management module) can also be used to: determine, from multiple application keys stored in the security processor, the application key that matches the identifier of the application key, as the exported application key.
[0178] In an optional implementation, the key protection device (specifically, a key management module) can also be used to: obtain a key management request through a command interface; process the key management request after the permission verification of the key management request is passed; the key management request is used to request management of the application key stored in the security processor for any of the following: generation, import, update, and destruction of the application key.
[0179] In a further optional implementation, this disclosure also provides a cryptographic operation device applied to an application processor configured within a processor. In this optional implementation, the cryptographic operation device can be considered as a functional module unit optionally configured by the application processor to implement the cryptographic operation method provided in this disclosure. The module unit content described below can be referred to in correspondence with the method content described above.
[0180] As an optional implementation, FIG14 exemplarily illustrates an optional block diagram of the cryptographic operation apparatus provided in the embodiments of this disclosure. As shown in FIG14, the cryptographic operation apparatus may include:
[0181] The instruction acquisition unit 141 is used to acquire cryptographic operation instructions, which are used to perform cryptographic operations on the data to be operated on; the cryptographic operation instructions at least indicate the data to be operated on and the protected application key; wherein, the protected application key is derived based on the key protection method provided in the embodiments of this disclosure;
[0182] The restoration unit 142 is used to restore the protected application key, and at least obtain the application key corresponding to the protected application key.
[0183] The cryptographic operation unit 143 is used to perform cryptographic operations on the data to be operated on using the application key to obtain the cryptographic operation result.
[0184] In an optional implementation, the format of the cryptographic operation instruction includes: an instruction name, a destination operand, a first source operand, and a second source operand; wherein, the destination operand corresponds to the cryptographic operation result and indicates the index address of the cryptographic operation result; the first source operand corresponds to the data to be operated on and indicates the index address of the data to be operated on; the second source operand corresponds to the protected application key and indicates the index address of the protected application key, and the index address of the protected application key is used to index the storage space where the protected application key is exported and stored, and the storage space is the internal storage space of the computer system.
[0185] In an optional implementation, the restoration unit 142 is used to restore the protected application key, and at least obtain the application key corresponding to the protected application key, including:
[0186] The root protection key information is invoked to restore the protected application key, thereby obtaining at least the application key corresponding to the protected application key; wherein the root protection key information is stored inside the processor.
[0187] In an optional implementation, the restoration unit 142 is used to restore the protected application key, and at least obtain the application key corresponding to the protected application key, including:
[0188] Determine whether the protected application key has cached information; wherein, the application processor stores cached information of previously used protected application keys;
[0189] If so, then at least the application key corresponding to the protected application key can be obtained from the cache information of the protected application key;
[0190] If not, invoke the root protection key information to restore the protected application key, and at least obtain the application key corresponding to the protected application key.
[0191] In an optional implementation, the restoration unit 142, used to determine whether the protected application key has cached information, includes:
[0192] Using the tag of the protected application key, query whether there is a cache entry corresponding to the tag; wherein, the application processor stores multiple cache entries, and each cache entry caches cache information of a protected application key that the application processor has used in the past; the cache information of the protected application key includes at least: the tag of the protected application key and the corresponding application key.
[0193] In an optional implementation, the restoration unit 142 is used to obtain, at least from the cached information of the protected application key, the application key corresponding to the protected application key, including:
[0194] At least the application key corresponding to the protected application key can be obtained from the cache entry corresponding to the tag of the protected application key.
[0195] In an optional implementation, after the restoration unit 142 executes the step of calling the root protection key information and restoring the protected application key to obtain at least the application key corresponding to the protected application key, the cryptographic operation device can also be used to: update the cache entry of the protected application key based at least on the tag of the protected application key and the corresponding application key.
[0196] In an optional implementation, the cached information of the protected application key further includes: permission information corresponding to the protected application key. Optionally, the restore unit 142 is used to obtain at least the application key corresponding to the protected application key from the cache entry corresponding to the tag of the protected application key, including:
[0197] The application key and permission information corresponding to the protected application key are obtained from the cache entry corresponding to the tag of the protected application key.
[0198] In an optional implementation, the root protection key information includes at least a root encryption key. Optionally, the restoration unit 142 is used to invoke the root protection key information to restore the protected application key, obtaining at least the application key corresponding to the protected application key, including:
[0199] Based on the root encryption key, the protected application key is decrypted to obtain at least the application key corresponding to the protected application key.
[0200] In an optional implementation, the root protection key information further includes: a root consistency key; the protected application key includes: an encrypted application key and consistency protection information corresponding to the encrypted application key. Optionally, the restoration unit 142 is used to call the root protection key information to restore the protected application key, at least obtaining the application key corresponding to the protected application key, which further includes:
[0201] Based on the root consistency key, the consistency protection information of the encrypted application key is re-determined;
[0202] The redefined consistency protection information is compared with the consistency protection information in the protected application key;
[0203] If the comparison results match, then the step of decrypting the protected application key based on the root encryption key is performed to obtain at least the application key corresponding to the protected application key.
[0204] The cryptographic operation instruction also indicates permission information; the restoration unit 142 performs restoration processing on the protected application key and also obtains the permission information corresponding to the protected application key. Optionally, the cryptographic operation device can also be used to: before the cryptographic operation unit 143 executes the step of using the application key to perform cryptographic operations on the data to be operated and obtain the cryptographic operation result, verify whether the permission information indicated by the cryptographic operation instruction is correct according to the permission information corresponding to the protected application key; if the permission information indicated by the cryptographic operation instruction is verified to be correct, then the cryptographic operation unit 143 executes the step of using the application key to perform cryptographic operations on the data to be operated and obtain the cryptographic operation result.
[0205] In an optional implementation, the permission information indicated by the cryptographic operation instruction corresponds to the third source operand in the format of the cryptographic operation instruction, and the third source operand indicates the index address of the permission information indicated by the cryptographic operation instruction.
[0206] In a further optional implementation, this disclosure also provides a chip, including the processor provided in this disclosure. Optionally, the functions of the security processor, application processor, and root protection key module disposed within the processor can be referred to the description in the corresponding sections above.
[0207] In a further optional implementation, embodiments of this disclosure also provide an electronic device (such as a computer device, such as a terminal device or a server device), including the chip provided in embodiments of this disclosure.
[0208] The foregoing describes multiple embodiment schemes provided by the present disclosure. The optional methods described in each embodiment scheme can be combined and cross-referenced with each other without conflict, thereby extending to a variety of possible embodiment schemes. These can all be considered as the embodiment schemes disclosed and made public by the present disclosure.
[0209] While the embodiments disclosed herein are as described above, this disclosure is not limited thereto. Any person skilled in the art can make various alterations and modifications without departing from the spirit and scope of this disclosure; therefore, the scope of protection of this disclosure should be determined by the scope defined in the claims.
Claims
1. A key protection method applied to a security processor arranged in a processor, comprising: obtaining a key derivation request, the key derivation request being used to request derivation of an application key, and the key derivation request carrying at least permission information; wherein the security processor stores at least one application key; when the permission information is verified, invoking root protection key information to at least protect the derived application key to generate a protected application key; wherein the root protection key information is stored in the processor; deriving the protected application key.
2. The method of claim 1, wherein, The root protection key information at least includes a root encryption key; the invoking root protection key information to at least protect the derived application key to generate a protected application key comprises: invoking the root encryption key to at least encrypt the derived application key to obtain an encrypted application key; obtaining the protected application key based at least on the encrypted application key.
3. The method of claim 2, wherein, The root protection key information further includes a root consistency key; The invoking root protection key information to at least protect the derived application key to generate a protected application key further comprises: after obtaining the encrypted application key, invoking the root consistency key to protect the encrypted application key to obtain consistency protection information corresponding to the encrypted application key; The obtaining the protected application key based at least on the encrypted application key comprises: obtaining the protected application key by combining the encrypted application key and the consistency protection information corresponding to the encrypted application key.
4. The method of claim 2 or 3, wherein, The invoking the root encryption key to at least encrypt the derived application key to obtain an encrypted application key comprises: invoking the root encryption key to encrypt the derived application key and the permission information to obtain the encrypted application key.
5. The method according to any one of claims 1 to 4, wherein, The key derivation request further carries an identifier of the application key; the identifier of the application key is identification information referring to the application key but not containing the actual content of the application key; Before the step of invoking the root protection key information to at least protect the derived application key to generate a protected application key, the method further comprises: determining, from a plurality of application keys stored in the security processor, an application key matching the identifier of the application key as the derived application key. 6.The method according to any one of claims 1-5, further comprising: obtaining a key management request through a command interface; processing the key management request after the permission of the key management request is verified; The key management request is used to request management of an application key stored in the security processor, including at least one of the following: generation, import, update and destruction of the application key. 7.A cryptographic operation method applied to an application processor arranged in a processor, comprising: obtaining a cryptographic operation instruction, the cryptographic operation instruction being used to perform cryptographic operation on to-be-operated data; the cryptographic operation instruction at least indicates to-be-operated data and a protected application key; wherein the protected application key is derived based on the key protection method according to any one of claims 1-6. The post-protection application key is restored to obtain at least an application key corresponding to the post-protection application key; The application key is used to perform a cryptographic operation on the to-be-operated data to obtain a cryptographic operation result.
8. The password operation method of claim 7, wherein, The format of the cryptographic operation instruction comprises: an instruction name of the cryptographic operation instruction, a destination operand, a first source operand and a second source operand; the destination operand corresponds to the cryptographic operation result and indicates an index address of the cryptographic operation result; the first source operand corresponds to the to-be-operated data and indicates an index address of the to-be-operated data; and the second source operand corresponds to the post-protection application key and indicates an index address of the post-protection application key, which is used to index a storage space saved after derivation of the post-protection application key, and the storage space is a storage space inside a computer system.
9. The password operation method of claim 7 or 8, wherein, The restoring of the post-protection application key comprises: Root protection key information is called to restore the post-protection application key to obtain at least an application key corresponding to the post-protection application key; and the root protection key information is stored in the processor.
10. The password operation method of claim 7 or 8, wherein, The restoring of the post-protection application key comprises: It is judged whether the post-protection application key has cache information; the application processor saves cache information of a post-protection application key used in the past; If yes, at least an application key corresponding to the post-protection application key is obtained from the cache information of the post-protection application key; If no, root protection key information is called to restore the post-protection application key to obtain at least an application key corresponding to the post-protection application key.
11. The password operation method of claim 10, wherein, The judgment of whether the post-protection application key has cache information comprises: Whether a cache entry corresponding to the tag of the post-protection application key exists is queried by using the tag of the post-protection application key; the application processor saves a plurality of cache entries, one cache entry caches cache information of one post-protection application key used in the past by the application processor; and the cache information of the post-protection application key at least comprises: the tag of the post-protection application key and a corresponding application key. The obtaining of at least the application key corresponding to the post-protection application key from the cache information of the post-protection application key comprises: At least the application key corresponding to the post-protection application key is obtained from the cache entry corresponding to the tag of the post-protection application key.
12. The password operation method of claim 11, wherein, After the step of calling the root protection key information to restore the post-protection application key to obtain at least an application key corresponding to the post-protection application key, the method further comprises: At least based on the tag of the post-protection application key and the corresponding application key, the cache entry of the post-protection application key is updated.
13. The cryptographic operation method according to any one of claims 11-12, wherein, The cache information of the post-protection application key further comprises: permission information corresponding to the post-protection application key. The at least one application key corresponding to the protected application key is obtained from the cache entry corresponding to the label of the protected application key, and the method comprises the following steps of: The at least one application key corresponding to the protected application key is obtained from the cache entry corresponding to the label of the protected application key.
14. The password operation method according to any one of claims 9 to 13, wherein, The root protection key information at least comprises a root encryption key; the root protection key information is called to perform restoration processing on the protected application key, and at least one application key corresponding to the protected application key is obtained, and the method comprises the following steps of: The protected application key is decrypted based on the root encryption key, and at least one application key corresponding to the protected application key is obtained.
15. The password operation method of claim 14, wherein, The root protection key information further comprises a root consistency key; the protected application key comprises an encrypted application key and consistency protection information corresponding to the encrypted application key; The root protection key information is called to perform restoration processing on the protected application key, and at least one application key corresponding to the protected application key is obtained, and the method further comprises the following steps of: The consistency protection information of the encrypted application key is re-determined based on the root consistency key; The re-determined consistency protection information is compared with the consistency protection information in the protected application key; If the comparison result is consistent, the protected application key is decrypted based on the root encryption key, and at least one application key corresponding to the protected application key is obtained.
16. The password operation method according to any one of claims 7 to 15, wherein, The password operation instruction further indicates the permission information; the restoration processing on the protected application key further obtains the permission information corresponding to the protected application key; The method further comprises the following steps of: Before the step of performing password operation on the to-be-operated data by using the application key to obtain a password operation result, it is verified whether the permission information indicated by the password operation instruction is correct according to the permission information corresponding to the protected application key; If the permission information indicated by the password operation instruction is verified to be correct, the step of performing password operation on the to-be-operated data by using the application key to obtain a password operation result is executed.
17. The password operation method of claim 16, wherein, The permission information indicated by the password operation instruction corresponds to a third source operand in the format of the password operation instruction, and the third source operand indicates an index address of the permission information indicated by the password operation instruction. 18.A key protection apparatus, applied to a security processor arranged in a processor, comprising: A request obtaining unit configured to obtain a key derivation request, the key derivation request being used to request derivation of an application key, and the key derivation request carrying at least permission information; wherein the security processor stores at least one application key; A protection unit configured to, when the permission information is verified to be correct, call root protection key information to at least protect the derived application key to generate a protected application key; wherein the root protection key information is stored in the processor; A derivation unit configured to derive the protected application key. 19.A password operation apparatus, applied to an application processor arranged in a processor, comprising: An instruction obtaining unit configured to obtain a cryptographic operation instruction, the cryptographic operation instruction being used for performing a cryptographic operation on to-be-operated data; the cryptographic operation instruction indicating at least the to-be-operated data and a protected application key; wherein the protected application key is derived based on the key protection method in any one of claims 1-6; A restoring unit configured to perform a restoring process on the protected application key to obtain at least an application key corresponding to the protected application key; A cryptographic operation unit configured to perform a cryptographic operation on the to-be-operated data by using the application key to obtain a cryptographic operation result.
20. A processor comprising: A secure processor, an application processor, and a root protection key module; The secure processor is configured to store at least one application key and perform key management on the application key; the key management on the application key performed by the secure processor includes security protection during application key derivation; wherein the security protection during application key derivation is performed by the secure processor based on the key protection method in any one of claims 1-6; The application processor is configured to execute an instruction called by an application program; the instruction called by the application program includes a cryptographic operation instruction for performing a cryptographic operation; wherein the cryptographic operation instruction is executed by the application processor based on the cryptographic operation method in any one of claims 7-17; The root protection key module is configured to store root protection key information; the root protection key information is used for performing protection processing on at least an application key to be derived by the secure processor.
21. The processor of claim 20, wherein, The secure processor includes a secure storage space and a key management module; the secure storage space is configured to store an application key; the key management module is configured to perform key management on the application key; the key management module has a command interface for importing a key management request, and the command interface is allowed to be used by an application program that passes an authority verification.
22. The processor of claim 20 or 21, wherein, The application processor is provided with a key cache unit; the key cache unit includes a plurality of cache entries, and one cache entry caches cache information of one protected application key that has been historically used by the application processor; The cache information of the protected application key includes a label of the protected application key, and corresponding application key and authority information.
23. A chip comprising the processor of any one of claims 20-22.
24. An electronic device comprising the chip of claim 23.
Citation Information
Patent Citations
Key protection method, password operation method, device and related equipment
CN120675699A
Key export techniques
CA3147153A1
Code scanning payment method, apparatus and device, and information sending and secret key management method, apparatus and device
CN111047313A
Key management method and related device
CN112822021A
Cryptographic module, cryptographic operation method, CPU chip and electronic equipment
CN114722410A