Key protection method, password operation method, device and related equipment
By storing and encrypting application keys in the processor's security processor, and performing encryption and consistency protection after permission verification, a protected application key is generated, which solves the problem of insufficient key security and improves key security and processor performance.
Patent Information
- Application Number
- CN202410814574.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2025-09-19
AI Technical Summary
While existing technologies take into account the performance of cryptographic operations, the security of keys is insufficient, there are risks of leakage and unauthorized access threats, and there is a lack of complete key lifecycle management.
The application key is stored in the processor's security processor and encrypted and consistent with the root protection key information. The protected application key is generated and exported only after the permission verification is passed. The security processor and application processor inside the processor are used for key management and cryptographic operations.
It improves the security of application keys, prevents unauthorized access and leakage, takes into account the performance of cryptographic operations, and achieves a balance between processor security and performance.
Smart Images

Figure CN120675699A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data security technology, and specifically to a key protection method, a cryptographic operation method, an apparatus, and related equipment. Background Art
[0002] With the rapid development of information technology and network technology, ensuring data security has become particularly important. One of the main ways to ensure data security is to encrypt data using keys to ensure confidentiality during data transmission and storage.
[0003] As the foundation of cryptographic operations (i.e., keys are the basis for encrypting and decrypting data), ensuring key security is extremely important. Therefore, how to provide a technical solution to improve key security while maintaining cryptographic performance has become a pressing technical challenge for those skilled in the art. Summary of the Invention
[0004] In view of this, the embodiments of the present application provide a key protection method, a cryptographic operation method, an apparatus and related equipment to improve the security of the key while taking into account the performance of the cryptographic operation.
[0005] To achieve the above objectives, the embodiments of the present application provide the following technical solutions.
[0006] In a first aspect, an embodiment of the present application provides a key protection method, which is applied to a security processor provided in a processor, and the method includes:
[0007] 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;
[0008] When the permission information is verified, calling the root protection key information, performing protection processing on at least the derived application key, and generating a protected application key; wherein the root protection key information is stored inside the processor;
[0009] Apply the key after exporting the protection.
[0010] In a second aspect, an embodiment of the present application provides a cryptographic operation method, which is applied to an application processor provided in a processor, the method comprising:
[0011] Obtaining a cryptographic operation instruction, the cryptographic operation instruction being used to perform a cryptographic operation on data to be operated; the cryptographic operation instruction at least indicates the data to be operated and a protected application key; wherein the protected application key is derived based on the key protection method described in the first aspect above;
[0012] Restoring the protected application key to obtain at least the application key corresponding to the protected application key;
[0013] The application key is used to perform cryptographic operations on the data to be operated to obtain a cryptographic operation result.
[0014] In a third aspect, an embodiment of the present application provides a key protection device, which is applied to a security processor provided in a processor, and the device includes:
[0015] a request obtaining unit, configured to obtain a key derivation request, wherein the key derivation request is used to request derivation of an application key, and the key derivation request carries at least permission information; wherein the security processor stores at least one application key;
[0016] a protection unit, configured to, when the permission information is verified, call the root protection key information, perform protection processing on at least the derived application key, and generate a protected application key; wherein the root protection key information is stored inside the processor;
[0017] The export unit is used to export the protected application key.
[0018] In a fourth aspect, an embodiment of the present application provides a cryptographic operation device, which is applied to an application processor provided in a processor, and the device includes:
[0019] an instruction acquisition unit, configured to acquire a cryptographic operation instruction, the cryptographic operation instruction being configured to perform a cryptographic operation on data to be operated; the cryptographic operation instruction indicating at least the data to be operated and a protected application key; wherein the protected application key is derived based on the key protection method described in the first aspect above;
[0020] a restoration unit, configured to restore the protected application key to at least obtain an application key corresponding to the protected application key;
[0021] The cryptographic operation unit is used to perform cryptographic operation on the data to be operated using the application key to obtain a cryptographic operation result.
[0022] In a fifth aspect, an embodiment of the present application provides a processor, comprising: a security processor, an application processor, and a root protection key module;
[0023] The security processor is configured to store at least one application key and perform key management on the application key; the key management performed by the security processor on the application key includes security protection during application key derivation; wherein the security processor performs security protection during application key derivation based on the key protection method described in the first aspect above;
[0024] The application processor is configured to execute instructions called by an application program; the instructions called by the application program 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;
[0025] The root protection key module is used to store root protection key information; the root protection key information is used to at least protect the application key that needs to be exported by the security processor.
[0026] In a sixth aspect, an embodiment of the present application provides a chip comprising the processor as described in the fifth aspect above.
[0027] In a seventh aspect, an embodiment of the present application provides an electronic device comprising the chip as described in the sixth aspect above.
[0028] The key protection method provided in the embodiments of the present application can be applied to a security processor provided inside a processor to provide security protection when the security processor exports an application key. For example, the security processor can obtain 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 can store at least one application key; thus, after the permission information is verified, the security processor can call the root protection key information (the root protection key information is stored inside the processor) to perform protection processing on at least the exported application key to obtain a protected application key; furthermore, the security processor can export the protected application key to achieve security protection when it is necessary to export the application key from the security processor.
[0029] 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 result of the application key export is the protected application key, not the application key in plain text. This can prevent the application key from being leaked during export, thereby improving the security of the application key. Furthermore, before the application key is exported, the permission information carried by the key export request is verified, which can ensure that the security processor continues to respond to authorized key export requests and avoid the threat of unauthorized key export requests to the disclosure of the application key. At the same time, as a device inside the processor, the security processor uses the security processor to perform security protection and export processing on the application key, which can avoid the peripheral access overhead of the application key and take into account the performance of cryptographic operations. Therefore, the key protection method provided in the embodiment of the present application can improve the security of the key while taking into account the performance of cryptographic operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0031] Figure 1 An example diagram for implementing key protection within a processor.
[0032] Figure 2 This is an example diagram of a processor provided in an embodiment of the present application.
[0033] Figure 3 Flowchart of the key protection method provided in an embodiment of the present application.
[0034] Figure 4 An example diagram of key protection processing provided in an embodiment of the present application.
[0035] Figure 5 Flowchart of the cryptographic operation method provided in an embodiment of the present application.
[0036] Figure 6 This is an example diagram of the format of the cryptographic operation instructions provided in the embodiments of the present application.
[0037] Figure 7 Another flowchart of the cryptographic operation method provided in an embodiment of the present application.
[0038] Figure 8 This is another example diagram of the format of the cryptographic operation instructions provided in an embodiment of the present application.
[0039] Figure 9 This is an example diagram of the processing of cryptographic operations provided in an embodiment of the present application.
[0040] Figure 10 This is an example diagram of a key cache unit provided in an embodiment of the present application.
[0041] Figure 11 Another flowchart of the cryptographic operation method provided in an embodiment of the present application.
[0042] Figure 12 Another example diagram of the processing of cryptographic operations provided in an embodiment of the present application.
[0043] Figure 13 A block diagram of a key protection device provided in an embodiment of the present application.
[0044] Figure 14 A block diagram of a cryptographic computing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0046] A key is a parameter used in cryptography to encrypt and decrypt data (that is, a cryptographic operation is an operation that uses a key to encrypt or decrypt data). If the key is leaked or illegally stolen, the data encrypted with the key may be illegally cracked, resulting in data security failure. Therefore, a key protection solution is needed to protect the security of the key.
[0047] For computer systems (such as computer devices) that perform cryptographic operations, one key protection scheme is to store and protect the key using a cryptographic module connected to the computer system. The cryptographic module is a physical device such as a cryptographic card. However, the cryptographic module is a peripheral (external device) of the computer system. This means that the computer system needs to use peripheral access to access the key in the cryptographic module every time it performs a cryptographic operation. This results in additional peripheral access overhead for each cryptographic operation, which reduces the performance of the cryptographic operation. Especially when the amount of data in the cryptographic operation is small (for example, the cryptographic operation encrypts a small data block of a few bytes or a few hundred bytes), the peripheral access overhead accounts for a large proportion of the overall cryptographic operation overhead, seriously affecting the performance of the cryptographic operation.
[0048] For a computer system that runs cryptographic operations, another key protection scheme is to implement key protection within the computer system, for example, within the processor that runs the cryptographic operation. As an example, Figure 1 An example diagram of implementing key protection in a processor is shown. Figure 1 As shown, a processor, as a computing execution device in a computer system, is primarily used to interpret and execute instructions from computer programs. Examples of processors include a CPU (Central Processing Unit) and a GPU (Graphics Processing Unit). A processor may include one or more processor cores 110, which are execution units within the processor that can independently perform computing tasks. Examples of processor cores include CPU cores and GPU cores. When multiple processor cores are provided, the multiple processor cores can simultaneously execute multiple processes or threads, thereby improving the processor's computing power through multitasking.
[0049] The processor runs a cryptographic application. The cryptographic application can be an application that has cryptographic operation requirements. In other words, the data of the application needs to be encrypted and decrypted using cryptographic operations. The key used to perform cryptographic operations on the data of the cryptographic application can be called an application key. Figure 1 In an example, a processor core in a processor may encrypt and protect an application key, and use the encrypted application key to perform cryptographic operations on data of a cryptographic application.
[0050] Specifically, such as Figure 1 As shown, the processor core 110 is internally provided with an IWKey (Instruction Writable Key) register 111. The IWKey register may be a register that allows only writing but not reading, and is used to store an encryption key for encrypting the application key (that is, the encryption key is a key for encrypting the application key). For example, a user may set the IWKey register through a key setting instruction to write an encryption key into the IWKey register; then, the processor core may call a key encryption instruction and use the encryption key written into the IWKey register to encrypt and protect the application key to be protected (the application key to be protected may be input externally) to generate an encrypted application key. Thus, when the cryptographic application running on the processor has a key operation requirement, the processor core 110 may use the encrypted application key to perform cryptographic operations on the data of the cryptographic application to achieve secure protection of the data of the cryptographic application; the type of cryptographic operation may be an encryption operation or a decryption operation, depending on the specific key operation requirement.
[0051] Figure 1 The example key protection method can use the encrypted application key to perform cryptographic operations on data. That is, the cryptographic operation uses the encrypted application key, not the plaintext application key. Therefore, the cryptographic operation does not touch the plaintext application key, which can achieve a certain degree of security protection for the application key. However, Figure 1 The key protection method in this example still has security issues and limitations, as shown in the following aspects:
[0052] 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, during the process of setting the IWKey register, the encryption key may be illegally intercepted. Once the encryption key used to set the IWKey register is leaked, the application key encrypted with the encryption key will be illegally decrypted, seriously threatening the data security of the cryptographic application.
[0053] The write-only feature of the IWKey register poses a DoS (Denial of Service) risk. Specifically, an unauthorized program could exploit the write-only, but read-only, nature of the IWKey register to launch a DoS attack. For example, an unauthorized program could modify the value written to the IWKey register (i.e., modify the encryption key written to the IWKey register), thereby invalidating the application key encrypted using the encryption key. A DoS attack is a network security attack that prevents legitimate users from accessing or using network services or resources by making them unavailable.
[0054] There are limitations on the protection of application key usage; specifically, Figure 1 Although the key protection method of the example IWKey mechanism ensures that the plaintext application key is not leaked, it does not restrict and protect the use of the encrypted application key. Once an attacker obtains the encrypted application key, even if the attacker does not know the plaintext form of the application key, he can still use the encrypted application key for encryption and decryption operations. Figure 1 The key protection method in the example is not complete and does not take into account the protection of key usage.
[0055] Lack of complete key lifecycle management; specifically, Figure 1 Although the key protection method of the example IWKey mechanism supports 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 key protection method of the IWKey mechanism is weaker than that of a cryptographic module used as a peripheral. For example, a cryptographic module used as a peripheral can provide lifecycle management such as key generation, storage, application, and destruction.
[0056] Based on the defects of the key protection scheme described above, the embodiments of the present application provide an improved key protection scheme to enhance the security of the key while taking into account the performance of cryptographic operations.
[0057] As an optional implementation, Figure 2 The example diagram of the processor provided by the embodiment of the present application is shown as an example. The processor includes but is not limited to any one of CPU, GPU, etc. For example, the processor referred to in the embodiment of the present application can be a processor chip. Figure 2 The processor may include: a secure processor (SP) 210, an application processor (AP) 220, and a root protection key module 230.
[0058] The security processor 210 may be a device provided in the processor for performing key management (KM), which primarily implements key management functions. In an embodiment of the present application, the application key may be stored inside the security processor, and the application key is not visible to the outside of the security processor (for example, 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, thereby preventing the application key from being accessed or stolen without authorization. The application key is a key used for performing cryptographic operations such as encryption and decryption of data in a cryptographic application.
[0059] In an optional implementation, the security processor may provide an external command interface, allowing authorized external devices or users of the security processor to interact with the security processor through predefined secure commands to implement key management functions such as application key generation, import, export, update, storage, and destruction. In other words, authorized external devices or users of the security processor can interact with the security processor using predefined secure commands by calling the security processor's command interface to manage the lifecycle of application keys.
[0060] In an optional implementation, combined with Figure 2 As shown, the security processor 210 may be provided with a key management module 211 and a secure storage space 212. The key management module 211 may be a module component within the security processor that implements key management functions, such as a logic circuit component within the security processor that implements key management functions. The secure storage space 212 may be a storage space within the security processor for storing 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 application keys stored within the secure storage space.
[0061] 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, the embodiment of the present application supports the key management module to manage multiple application keys, and multiple application keys are stored in a secure storage space. At the same time, the application running on the processor cannot directly contact or access the application key, and can only access the application key through the command interface provided by the key management module. Furthermore, the application needs to pass permission verification to use the command interface provided by the key management module, including but not limited to identity authentication, operation authorization and other permission verification, so as to ensure that only legitimate and authorized applications can use the command interface to access the application key. As an example, the embodiment of the present application allows applications that have passed permission verification to use the command interface provided by the key management module to import commands such as generation, import, export, update and destruction of application keys (such as key management requests), and the key management module is responsible for processing commands such as generation, import, export, update and destruction of application keys to achieve lifecycle management of application keys.
[0062] It should be noted that the command interface provided by the security processor (specifically, it can be the command interface provided by the key management module in the security processor) can be a limited command interface. A limited command interface means that the functions and access rights of the command interface are restricted and defined to meet the security management requirements of the key. For example, the functions of the command interface are necessary functions to implement key management, and do not provide extensive or non-essential functions, thereby meeting the security management requirements of application keys. The functions of the command interface include but are not limited to generation, import, export, update and destruction. For another example, the access rights of the command interface are controlled, and only authenticated and authorized users or applications can call the command interface to trigger key management.
[0063] The application processor 220 may be an execution unit of a processor that performs computing tasks and may be used to execute application programs and complete various computing tasks. In one example, the application processor may be a processor core within a processor. In embodiments of the present application, the application processor may perform cryptographic operations. For example, the application processor may be configured with a cryptographic instruction set (CIS), which may be a set of specific instructions designed to support cryptographic operations (such as encryption and decryption operations).
[0064] In an optional implementation, the cryptographic operation instruction set may include cryptographic operation instructions of one or more cryptographic algorithms, such as encryption operation instructions of the SM4 algorithm, decryption operation instructions of the SM4 algorithm, etc. 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, the embodiments of the present application support any cryptographic algorithm that can implement cryptographic operations, such as symmetric encryption algorithms, asymmetric encryption algorithms, and homomorphic encryption algorithms. Taking symmetric encryption algorithms as an example, the embodiments of the present application can adopt cryptographic algorithms such as AES (Advanced Encryption Standard), 3DES (Triple Data Encryption Standard), and SM4. Taking asymmetric encryption algorithms as an example, the embodiments of the present application can adopt cryptographic algorithms such as RSA (Rivest Shamir Adleman) and ECC (Elliptic Curve Cryptography).
[0065] 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 use the application key for performing cryptographic operations on the input data, thereby realizing the cryptographic operation; wherein the cryptographic operation can be an encryption operation or a decryption operation, depending on the current requirements of the cryptographic operation.
[0066] The root protection key module 230 is a device set in the processor for storing root protection key (RPK) information. The root protection key information can be used to protect application keys, and the root protection key information can be shared by the security processor and the application processor (that is, 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); wherein the root encryption key can be used for encryption protection of application keys; the root integrity key can be used to provide consistency protection for the encryption result of the root encryption key. Furthermore, the root protection key information may also include relevant attribute information of the root encryption key and relevant attribute information of the root integrity key.
[0067] It should be noted that the root protection key information stored in the root protection key module is internal to the processor and can only be accessed and used within the processor. It is invisible to external devices of the processor. For example, the root protection key information stored in the root protection key module (specifically, the root encryption key and root consistency key) 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.
[0068] In an optional implementation, the root protection key module can be a storage space inside the processor that can realize information storage. For example, a specific address space inside the processor can be used as a root protection key module to store root protection key information. For example, the root protection key module can be a storage space embedded in the processor (such as a register, RAM, or other storage space inside the processor), and the address of the storage space can be configured as a specific address inside the processor, such as a high-order address reserved inside the processor; thus, the root protection key module can be regarded as a specific address space inside the processor for storing root protection key information, such as a high-order address space reserved inside the processor.
[0069] It should be noted that the high address space, for example, the space close to the upper address limit of the address space, that is, the space with a larger address value in the address space, the high address range can be set according to actual conditions, and the embodiments of the present application are not limited. It should be further noted that when the processor is manufactured, the high address space within the processor can be reserved for special purposes (such as firmware operation, system management mode, security operation and other special purposes); thereby, by setting the high address space not to be accessed by the application and operating system running on the processor, but to be accessed by the device inside the processor, the root protection key information stored corresponding to the high address space can be accessed by the security processor and application processor inside the processor, but not by the application running on the processor.
[0070] In an optional implementation, the root protection key information can be pre-loaded inside the processor and stored in the root protection key module. For example, during the initialization process of starting the processor, the root protection key information can be set by the security processor and loaded into the root protection key module. For example, the key management module in the security processor can set the value of the root encryption key and the value of the root consistency key when the processor starts, and load them into the root protection key module, such as saving them in the high address space reserved by the processor. In a further optional implementation, the security processor (specifically, the key management module of the security processor) can set the value of the root protection key information to be the same each time the processor starts (for example, each time the processor starts, the value of the set root encryption key remains the same, and the value of the root consistency key remains the same), so that the application key protected by the root protection key information is still available after the computer system is restarted.
[0071] Based on the processor architecture provided in the embodiment of the present application, the key protection method provided in the embodiment of the present application is introduced below. The key protection method provided in the embodiment of the present application can support the protection processing of application keys. The steps performed by each device module in the content of the key protection method described below can be regarded as the corresponding functions of each device module, thereby Figure 2 The functional contents of each device module of the exemplary processor can be referenced in correspondence with the method contents described below.
[0072] As an optional implementation, Figure 3 The optional flow chart of the key protection method provided by the embodiment of the present application is shown as an example. Figure 3 , the key protection method may include the following steps.
[0073] In step S310, the cryptographic application sends a key derivation request to the security processor, where the key derivation request is used to request derivation of an application key, and the key derivation request carries at least permission information.
[0074] In an optional implementation, based on a command interface provided by the security processor, a cryptographic application running on the processor may, when there is a need to export an application key, send a key export request to the security processor via a command interface (e.g., an export interface) provided by the security processor for exporting application keys, thereby requesting the security processor to export the application key. Accordingly, the security processor may receive the key export request.
[0075] In an alternative implementation, based on the permission verification mechanism of the security processor's command interface, a cryptographic application must have the corresponding permission when requesting to export an application key using the export interface. Therefore, the key export request may include at least permission information. In an alternative implementation, the permission information may be information indicating the permission of the cryptographic application, such as a token or digital certificate provided by the cryptographic application.
[0076] In an optional implementation, based on the situation 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 include an application key identifier to identify the application key to be exported. The application key identifier is used to uniquely identify the application key, and different application keys have different identifiers.
[0077] In an optional implementation, the identifier of the application key can be identification information that can refer 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 of the application key, where the handle can be an abstract reference to the application key that represents the application key but does not contain the actual content of the application key. Therefore, even if the handle of the application key is maliciously leaked, it will not directly threaten the security of the application key. In this example, the key derivation request sent by the cryptographic application can carry the identifier of the application key (e.g., the handle of the application key) and permission information.
[0078] It should be noted that in other possible implementations, the cryptographic application may not specify the application key to be exported. For example, the security processor may randomly select the application key to be exported, or select the exported application key according to a certain order of multiple stored application keys, etc., so that the key export request may not carry the identifier of the application key (such as the handle of the application key).
[0079] In an optional implementation, the cryptographic application may be specifically run on an application processor within the processor, so that step S310 may be performed by the application processor running the cryptographic application.
[0080] In step S311, the security processor verifies whether the permission information is passed. If not, step S312 is executed. If so, step S313 is executed.
[0081] After receiving a key export request, the security processor can verify the permission information carried in the key export request to determine whether the cryptographic application that issued the key export request has permission to export the application key. In other words, if the security processor fails to verify the permission information, it means that the cryptographic application does not have permission to export the application key, and the process can proceed to step S312 to end the process. In other words, if the cryptographic application does not have permission to export the application key, the security processor can not respond to the key export request and directly end the process. If the security processor passes the permission information verification, it means that the cryptographic application has permission to export the application key, and the process can proceed to step S313 to continue the subsequent application key export processing flow.
[0082] For example, under a digital certificate-based authentication mechanism, the permission information provided by the cryptographic application may include the cryptographic application's digital certificate. For example, the cryptographic application may prove its identity by providing a digital certificate issued by a trusted certificate authority. Thus, the security processor may check the validity of the cryptographic application's digital certificate, such as checking the digital certificate's signature, certificate authority, digital certificate expiration time, digital certificate revocation list, etc., to implement digital certificate-based permission verification. For example, under a token-based authentication mechanism, the permission information provided by the cryptographic application may include the cryptographic application's token. Thus, the security processor may check the validity of the cryptographic application's token, such as checking the token's validity period, signature, and whether the permissions declared in the token correspond to the exported application key, to implement token-based permission verification. For example, the embodiments of the present application may also perform permission verification based on the permission level of the cryptographic application, so that the permission information provided by the cryptographic application may include the permission level information of the cryptographic application, and then the security processor may check whether the permission level of the cryptographic application corresponds to the permission level of the export application key, so as to realize permission verification based on the permission level of the program; it should be noted that, in a possible implementation, the administrator of the computer system can define the permission levels of various applications (for example, through a program permission matrix to describe the resources that different types of applications can be allowed to access), so that in the process of defining the permission levels of various applications, corresponding permission levels can be defined for applications with the permission to export application keys; further, the permission level of the application can be dynamically adjusted, so that the application with the permission to export application keys can be dynamically changed.
[0083] It should be noted that the method and mechanism for verifying permission information can be set according to actual conditions, and the present application embodiment does not limit it. The present application embodiment supports the use of a single verification mechanism for permission information, and can also combine multiple verification mechanisms to verify permission information.
[0084] In step S312, the process ends.
[0085] In step S313, the security processor calls the root protection key information, performs protection processing on at least the derived application key, and generates a protected application key.
[0086] As an optional implementation, after the verification permission information is passed, the security processor can determine the derived application key from multiple stored application keys based on the identifier of the application key provided by the cryptographic application (e.g., the handle of the application key); for example, based on the identifier of the application key carried in the key derivation request (e.g., the handle of the application key), determine the application key that matches the identifier of the application key (e.g., the handle of the application key) from multiple application keys stored by the security processor as the derived application key. It should be noted that the embodiments of the present application may also support the security processor to determine the derived application key by random selection or sequential selection, and is not limited to determining the derived application key by an identifier (e.g., a handle). In this case, the cryptographic application may not provide an identifier (e.g., a handle) of the application key. In other possible implementations, the embodiments of the present application may also support the security processor to store an application key so that the derived application key can be uniquely determined.
[0087] Based on the protection requirements of the exported application key, the embodiment of the present application can at least perform security protection on 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).
[0088] In a further optional implementation, when protecting the exported application key, the permission information provided by the cryptographic application can also be protected. 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 permission information (the permission information is carried in the key export request) to obtain the protected application key. Of course, protecting the permission information at the same time is only an optional method, and embodiments of the present application can also support not protecting the permission information.
[0089] In an optional implementation that simultaneously protects application keys and permission information, the security processor may combine the derived application key with the permission information carried in the key derivation request to form the information to be protected (including the derived application key and permission information), and then perform protection processing on this information using the root protection key information to obtain a protected application key. In other words, in this implementation, the root protection key information performs a comprehensive protection processing on the derived application key and permission information to obtain the protected application key; accordingly, the protected application key may be the result of the comprehensive protection of the derived application key and permission information.
[0090] In an optional implementation, the protection processing using root protection key information can be divided into: encryption protection and consistency protection; among them, 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) to prevent the exported content from being illegally stolen; consistency protection mainly ensures the integrity of the exported content to prevent the exported content from being tampered with during the transmission process and / or storage process.
[0091] 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 to obtain an encrypted application key (i.e., the encrypted application key is at least the encrypted result of the application key). Thus, in an optional implementation, the security processor can call the root encryption key to encrypt at least the derived application key to obtain the encrypted application key. In an optional implementation, the encryption algorithm used for the encryption protection can be, for example, the SM4 symmetric encryption algorithm.
[0092] Furthermore, when simultaneously protecting the exported application key and permission information, the root encryption key can be used to encrypt 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 to obtain an encrypted application key. In this case, the encrypted application key can be the overall encryption result of the exported application key and permission information.
[0093] Accordingly, the encrypted application key can be regarded as the result of encrypting the derived application key using the root encryption key, or the result of encrypting the derived application key and permission information using the root encryption key.
[0094] Based on encryption protection, even if the protected application key is illegally intercepted or leaked, 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.
[0095] In an optional implementation, the root consistency key in the root protection key information can be used to perform consistency protection on the encrypted application key, thereby obtaining consistency protection information. For example, the security processor can call the root consistency key to perform consistency protection on the encrypted application key to obtain consistency protection information. As an example, the consistency protection process can be implemented by generating a message authentication code or digital signature for the encrypted application key.
[0096] In an optional implementation, the encrypted application key and the consistency protection information can form a protected application key. For example, in an embodiment of the present application, the derived application key and permission information can be encrypted and protected first, and then the encrypted protection result can be consistency protected, thereby combining the encrypted protection result and the consistency protection result to obtain the protected application key; accordingly, the protected application key can include the encrypted application key and the consistency protection information corresponding to the encrypted application key.
[0097] It should be noted that in other possible implementations, the embodiments of the present application may not set consistency protection. For example, the security processor may encrypt and protect at least the exported application key (and may also encrypt and protect the permission information at the same time), so that the encryption result can be used as the protected application key. For example, the embodiments of the present application may call the root encryption key, encrypt the exported application key and permission information, obtain the 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.
[0098] Accordingly, the embodiments of the present application 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; for another example, further consistency protection processing can be performed to combine the encrypted application key and the consistency protection information corresponding to the encrypted application key to obtain the protected application key.
[0099] In step S314, the security processor returns the protected application key to the cryptographic application.
[0100] After generating the protected application key, the security processor can derive the protected application key. For example, the protected application key can be returned to a cryptographic application that requires the application key (e.g., a cryptographic application that sends a key derivation request) so that when the cryptographic application invokes a cryptographic operation instruction of the application processor, the application processor can use the protected application key to perform cryptographic operations on the data of the cryptographic application.
[0101] As an example, Figure 4 An exemplary diagram of a key protection process provided by an embodiment of the present application is shown as follows: Figure 4As shown, 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 the multiple stored application keys through 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; and 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 (such as calculating a message authentication code or a digital signature, etc.) to obtain consistency protection information; thereby, 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.
[0102] In a further optional implementation, after obtaining the protected application key, the cryptographic application may store the protected application key in a storage space inside the computer system, for example, storing the protected application key in the memory or register of the computer system so that the application processor can call it when executing cryptographic operation instructions.
[0103] In a further optional implementation, the security processor may process a key management request after the key management request of an application running on the processor passes permission verification, thereby supporting key management functions such as the generation, importation, update, and destruction of application keys. For example, the security processor may obtain a key management request through a command interface (the key management request may be issued by an application running on the processor); after the permission verification of the key management request passes (for example, after verifying that the application issuing the key management request has permission to manage application keys, the relevant content and mechanism of permission verification can be similarly referred to as described in the corresponding section above), the security processor may process the key management request; wherein the key management request is used to request any of the following management functions for application keys stored on the security processor: generation, importation, update, and destruction of application keys. Of course, key management may also involve the export of application keys. For information related to the export management of application keys, please refer to the description of the key protection method above.
[0104] As can be seen, the security processor can perform key management on application keys, and this key management by the security processor can include security protection during application key derivation. Thus, the security processor can perform security protection during application key derivation based on the key protection method provided in the embodiments of the present application. Furthermore, the execution content of the key protection method provided in the embodiments of the present application related to the security processor can be executed by the key management module in the security processor.
[0105] The key protection method provided in the embodiments of the present application can be applied to a security processor provided within a 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, 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 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); thus, after the permission information is verified, the security processor can call the root protection key information stored in the root protection key module, perform protection processing on at least the exported application key, and obtain a protected application key; furthermore, the security processor can export the protected application key to achieve security protection when the application key needs to be exported from the security processor.
[0106] 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 result of the application key export is the protected application key, not the application key in plain text. This can prevent the application key from being leaked during export, thereby improving the security of the application key. Furthermore, before the application key is exported, the permission information carried by the key export request is verified, which can ensure that the security processor continues to respond to authorized key export requests and avoid the threat of unauthorized key export requests to the disclosure of the application key. At the same time, as a device inside the processor, the security processor uses the security processor to perform security protection and export processing on the application key, which can avoid the peripheral access overhead of the application key and take into account the performance of cryptographic operations. Therefore, the key protection method provided in the embodiment of the present application can improve the security of the key while taking into account the performance of cryptographic operations.
[0107] Furthermore, the root protection key information for protecting the exported application keys and permission information is stored in the root protection key module. The root protection key module serves as a storage space within the security processor, which is configured to be accessed by the security processor and application processor inside the processor, but cannot be accessed by the application programs running on the processor, thereby ensuring that the root protection key information is not leaked and further improving the security of the key.
[0108] Based on the processor architecture and key protection scheme provided by the embodiment of the present application, the cryptographic operation method provided by the embodiment of the present application is introduced below. The cryptographic operation can be regarded as the process of the application processor executing the cryptographic operation instruction to encrypt and decrypt the data of the cryptographic application. It should be noted that the steps performed by each device module in the content of the cryptographic operation method described below can be regarded as the corresponding functions of each device module, so that Figure 2The functional contents of each device module of the exemplary processor can be referenced in correspondence with the method contents described below.
[0109] As an optional implementation, Figure 5 An exemplary flowchart of an optional cryptographic operation method provided in an embodiment of the present application is shown. The cryptographic operation method can be executed by an application processor. For example, the application processor can execute instructions called by an application program, and the instructions called by the application program may include cryptographic operation instructions for performing cryptographic operations. Thus, the application processor can execute the cryptographic operation instructions based on the cryptographic operation method provided in an embodiment of the present application.
[0110] Reference Figure 5 , the cryptographic operation method may include the following steps.
[0111] In step S510, a cryptographic operation instruction is obtained, where the cryptographic operation instruction is used to perform a cryptographic operation on the data to be operated, and the cryptographic operation instruction at least indicates the data to be operated and a protected application key.
[0112] In an optional implementation, a cryptographic application running on an application processor can invoke cryptographic operation instructions when a cryptographic operation is required, thereby performing cryptographic operations such as encryption and decryption on the data to be operated by the cryptographic application. For example, the application processor can be provided with a cryptographic operation instruction set (CIS), and the cryptographic application can invoke cryptographic operation instructions in the cryptographic operation instruction set to request cryptographic operations to be performed on the data to be operated.
[0113] In an optional implementation, the cryptographic operation instruction may at least indicate the data to be operated and the protected application key. The data to be operated can be regarded as data to be cryptographically operated (encrypted or decrypted) by the cryptographic application program; for example, when the cryptographic operation to be performed is an encryption operation, the data to be operated may be plaintext data, and when the cryptographic operation to be performed is a decryption operation, the data to be operated may 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 embodiment of the present application. For example, after the protected application key is derived based on the key protection method provided in the embodiment of the present application, it can be stored in the internal storage space of the computer system, so that the cryptographic operation instruction can indicate the internal storage space for 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 the relevant content about the protected application key, please refer to the description of the corresponding part above, which will not be repeated here.
[0114] In an optional implementation, the cryptographic operation instruction can indicate the data to be operated and the protected application key through operands. For example, the data to be operated and the protected application key can be used as operands in the cryptographic operation instruction (specifically, they can be source operands). For example, taking the cryptographic operation instruction of SM4 as an example, Figure 6 The following is an example of the format of the cryptographic operation instruction provided in the embodiment of the present application, as shown in FIG. Figure 6 As shown, the format of the cryptographic operation instruction may include the instruction name of the cryptographic operation instruction, a destination operand (Destination Operand, DST), a first source operand and a second source operand.
[0115] The instruction name indicates the instruction name of the cryptographic operation instruction, such as the instruction name of the SM4 encryption operation instruction (SM4 ENC) and the SM4 decryption operation instruction.
[0116] The destination operand corresponds to the cryptographic operation result after the cryptographic operation instruction performs the cryptographic operation, such as the encryption result after encryption or the decryption result after decryption. Optionally, the destination operand may indicate the index address of the cryptographic operation result; for example, the cryptographic operation result may be stored in a storage space of a computer system, and thus the destination operand may indicate the index address of the storage space storing the cryptographic operation result, such as the memory address of the memory storing the cryptographic operation result or the register index of the register storing the cryptographic operation result.
[0117] The first source operand is a source operand (SRC) in a cryptographic operation instruction, corresponding to the data to be operated on. Optionally, the first source operand may indicate an index address of the data to be operated on. For example, the data to be operated on may be stored in a memory space of a computer system, and thus the first source operand may indicate an index address of the memory space storing the data to be operated on, such as the memory address of a memory storing the data to be operated on, or the register index of a register storing the data to be operated on. Thus, the application processor can obtain the data to be operated on based on the first source operand.
[0118] The second source operand is another source operand in the cryptographic operation instruction, corresponding to the derived protected application key. For example, after the protected application key is derived from the security processor, it can be stored in a storage space within the computer system, so that the second source operand can indicate the index address of the protected application key, wherein the index address of the protected application key is used to index the storage space where the protected application key is stored after it is derived. That is, the second source operand can indicate the index address of the storage space where the derived protected application key is stored, such as the memory address of the memory storing the protected application key, or the register index of the register storing the protected application key. Thus, the application processor can obtain the protected application key based on the second source operand.
[0119] In step S511, the protected application key is restored to at least obtain the application key corresponding to the protected application key.
[0120] The application processor can obtain the protected application key based on the instructions of the cryptographic operation instruction; 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 at least obtaining the application key corresponding to the protected application key that can be used for cryptographic operations.
[0121] In an optional implementation, the protection processing based on the root protection key information can be divided into encryption protection and consistency protection, so that the protected application key can include the encrypted application key and the consistency protection information corresponding to the encrypted application key; further, after obtaining the root protection key information, the application processor can redetermine the consistency protection information of the encrypted application key based on the root consistency key in the root protection key information (for example, recalculate the message authentication code or digital signature of the encrypted application key based on the root consistency key); compare the redetermined consistency protection information 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 the transmission process and storage process, 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 the transmission process and storage process, and the consistency verification fails. At this time, the embodiment of the present application can terminate the subsequent process.
[0122] In a further optional implementation, the embodiment of the present application may, after the consistency verification of the encrypted application key is passed, decrypt the encrypted application key based on the root encryption key in the root protection key information, thereby obtaining 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 (such as the permission information provided by the cryptographic application when requesting to export the application key). This situation may correspond to the situation where the exported application key and permission information are protected simultaneously during key protection.
[0123] It should be noted that in other possible implementations, if consistency protection is not set, the protected application key can be an encrypted application key, so that the application processor can decrypt the protected application key based on the root encryption key in the root protection key information, and at least obtain the corresponding application key (and may also obtain permission information).
[0124] In step S512, a cryptographic operation is performed on the data to be operated using the application key to obtain a cryptographic operation result.
[0125] After obtaining the application key, the application processor can use the application key to perform a cryptographic operation on the data to be operated to obtain a cryptographic operation result. In an optional implementation, the cryptographic operation result serves as the destination operand of the cryptographic operation instruction and can be stored in the storage space corresponding to the index address of the destination operand (such as memory or register).
[0126] In an optional implementation, the cryptographic operation can be an encryption operation, so that the application processor can use the application key to perform an encryption operation on the data to be operated (plaintext data) to obtain an encryption result (ciphertext data corresponding to the data to be operated). Furthermore, if the application processor needs to perform a corresponding decryption operation on the encryption result later, the protected application key used for the decryption operation should be consistent with the protected application key used for the encryption operation, so that the application keys used for the corresponding encryption operation and decryption operation are consistent, thereby ensuring the correctness of encryption and decryption. For example, if the protected application key is used as the second source operand in the cryptographic operation instruction, 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 address of the protected application key of the corresponding encryption operation instruction and decryption operation instruction is consistent, so that the application keys used for the corresponding encryption operation and decryption operation are consistent.
[0127] 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 (ciphertext data) to obtain a decryption result (plaintext data corresponding to the data to be operated); at this time, the protected application key used in the decryption operation is consistent with the protected application key used in the encryption operation to encrypt the data to be operated (ciphertext data), which can be achieved by keeping the second source operand consistent.
[0128] In a further optional implementation, the cryptographic operation instruction of the embodiment of the present application may also indicate the permission information of the cryptographic application that calls the cryptographic operation instruction, so as to verify 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, the 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, Figure 7 Another optional flowchart of the cryptographic operation method provided in an embodiment of the present application is shown as an example. The cryptographic operation method can be executed by an application processor. Figure 7 and Figure 5 The corresponding process parts can be referenced to each other and will not be repeated below; Figure 7 , the cryptographic operation method may include the following steps.
[0129] In step S710, a cryptographic operation instruction is obtained, where the cryptographic operation instruction is used to perform a cryptographic operation on the data to be operated; the cryptographic operation instruction at least indicates the data to be operated, a protected application key, and permission information.
[0130] In an embodiment of the present application, the cryptographic operation instruction also indicates permission information, such as the permission information of the cryptographic application currently calling the cryptographic operation instruction. In an optional implementation, the cryptographic operation instruction can add a source operand to indicate the permission information. Optionally, Figure 8 Another example of the format of the cryptographic operation instruction provided in the embodiment of the present application is shown in FIG. Figure 6 and Figure 8As shown, 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 calling the cryptographic operation instruction. For example, the authorization information may be stored in the storage space of the computer system, so that 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. Thus, the application processor may obtain the authorization information based on the third source operand.
[0131] In step S711, the protected application key is restored to obtain the application key and permission information corresponding to the protected application key.
[0132] In an embodiment of the present application, the application key after protection is restored, and the application key and permission information can be obtained at the same time; accordingly, when the application key is protected, it corresponds to the situation where the application key and permission information are protected at the same time. The relevant content can be referred to the description of the corresponding part of the previous text and will not be expanded here.
[0133] In step S712, based on the permission information corresponding to the protected application key, it is verified whether the permission information indicated by the cryptographic operation instruction is correct. If not, step S713 is executed; if so, step S714 is executed.
[0134] The embodiment of the present application can use the permission information obtained by the restoration process (i.e., the permission information corresponding to the application key after protection) to verify the correctness of the permission information indicated by the cryptographic operation instruction, such as comparing whether the permission information obtained by the restoration process is consistent with the permission information indicated by the cryptographic operation instruction; if the verification permission information is incorrect (i.e., the correctness verification of the permission information fails), it means that the cryptographic application currently calling the cryptographic operation instruction does not have the permission to use the application key, so that the application processor can end the cryptographic operation process; if the verification permission information is correct (i.e., the correctness verification of the permission information passes), it means that the cryptographic application currently calling the cryptographic operation instruction has the permission to use the application key, so that the application processor can continue with the subsequent cryptographic operation process.
[0135] In step S713, the process ends.
[0136] In step S714, a cryptographic operation is performed on the data to be operated using the application key to obtain a cryptographic operation result.
[0137] The relevant contents of step S714 can be referred to in the same way. Figure 5Step S512 is shown. It should be noted that, due to Figure 5 and Figure 7 These are different implementation procedures, so process steps with similar contents use different step numbers.
[0138] In an implementation example, Figure 9 An example diagram of a cryptographic operation process provided by an embodiment of the present application is shown as follows: Figure 9 As shown, the cryptographic operation instruction has operands: SRC (indicating 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 of 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 by the restoration process is verified for correctness with the permission information of the cryptographic operation instruction; if the correctness verification passes, the application key obtained by the restoration process can be used to perform cryptographic operation on the data to be operated, and the obtained cryptographic operation result is used as the destination operand and saved in the storage space (memory or register) corresponding to the destination operand.
[0139] In a further optional implementation, if the root protection key information is used to restore the protected application key (the relevant content can be referred to the description of the corresponding part of the previous text), it involves at least the calling and decryption of the root protection key information and other processes (it may also involve the consistency verification process), which may bring about a large computational overhead; and the restoration of the protected application key is in the critical path of the cryptographic operation. If the restoration of the protected application key has a large computational overhead, it will undoubtedly lead to a reduction in the overall processing performance of the cryptographic operation instructions. Based on this, the embodiment of the present application considers setting a key cache unit in the application processor to cache the cache information of the protected application key that has been used in the history of the application processor. The cache information of the protected application key can at least include the application key corresponding to the protected application key to speed up the efficiency of the restoration of the protected application key.
[0140] As an optional implementation, Figure 10 An example diagram of a key cache unit provided in an embodiment of the present application is shown as follows: Figure 10As shown, the key cache unit may include multiple cache entries, and 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 an application key corresponding to the protected application key. The tag of the protected application key may be information that can identify the protected application key, and is used to locate the cache entry where the cache information of the protected application key is located 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 of the protected application key; optionally, the tag of the protected application key may also be an identifier calculated based on the protected application key, such as summary information of the protected application key.
[0141] Furthermore, in addition to caching the application key corresponding to the protected application key, the embodiment of the present application can also cache the permission information corresponding to the protected application key; accordingly, the cached information of the protected application key may include the label of the protected application key, the application key corresponding to the protected application key, and the permission information. Figure 10 As shown, a cache entry can cache a tag of a protected application key, an application key corresponding to the protected application key, and permission information.
[0142] Based on the setting of the cache information of the protected application key, when the application processor restores the protected application key, it can first determine whether the protected application key has cache information; if so, the protected application key can be restored based on the cache information of the protected application key, so that at least the corresponding application key (and possibly the permission information) can be obtained to avoid the computational overhead brought by the use of the root protection key information for restoration; if not, the root protection key information needs to be used to restore the protected application key.
[0143] In an optional implementation, Figure 11 Another optional flowchart of the cryptographic operation method provided in an embodiment of the present application is exemplarily shown. The cryptographic operation method can be executed by an application processor. Figure 11 and Figure 7 The corresponding process parts can be referenced to each other and will not be repeated below; Figure 11 , the cryptographic operation method may include the following steps.
[0144] In step S011, a cryptographic operation instruction is obtained, where the cryptographic operation instruction is used to perform a cryptographic operation on the data to be operated, and the cryptographic operation instruction at least indicates the data to be operated, a protected application key, and permission information.
[0145] In step S012, it is determined whether there is cache information of the protected application key. If so, step S013 is executed; if not, step S014 is executed.
[0146] In an optional implementation, the embodiment of the present application can use the tag of the protected application key to query the application processor (specifically, it can be the key cache unit in the application processor) whether there is a cache entry corresponding to the tag; if so (that is, the tag of the protected application key hits in the key cache unit), then there is cache information for the protected application key, indicating that the application processor has used the protected application key in the past, and the cache information of the protected application key has been cached in advance, so that the embodiment of the present application can enter step S013 to obtain the corresponding application key and permission information from the cache information of the protected application key; if not (that is, the tag of the protected application key does not hit in the key cache unit), then there is no cache information for the protected application key, indicating that the application processor has not used the protected application key in the past, so that the embodiment of the present application can enter step S014 to use the root protection key information to restore the protected application key.
[0147] 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.
[0148] After executing step S013, the process may proceed to step S016.
[0149] In step S014, the root protection key information is called to restore the protected application key to obtain the application key and permission information corresponding to the protected application key.
[0150] It can be seen that there are two possible ways to restore the protected application key, including: restoring the protected application key through the cache 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 cache information of the protected application key); and restoring 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 processing, etc.).
[0151] In step S015 , cache information of the protected application key is cached based on the obtained application key and permission information corresponding to the protected application key.
[0152] After executing step S014, embodiments of the present application can obtain the application key and permission information corresponding to the protected application key, thereby caching the corresponding cache information of the protected application key in the application processor. For example, based on at least the tag of the protected application key, the corresponding application key, and the permission information, a cache entry for the protected application key is updated in the application processor (specifically, a key cache unit in the application processor), and the updated cache entry is used to cache the tag of the protected application key, the corresponding application key, and the permission information.
[0153] In step S016, based on the permission information corresponding to the protected application key, it is verified whether the permission information indicated by the cryptographic operation instruction is correct. If not, step S017 is executed; if so, step S018 is executed.
[0154] In step S017, the process ends.
[0155] In step S018, a cryptographic operation is performed on the data to be operated using the application key corresponding to the protected application key to obtain a cryptographic operation result.
[0156] It should be noted that due to Figure 7 and Figure 11 These are different implementation procedures, so process steps with similar contents use different step numbers.
[0157] It needs to be further explained that Figure 11 The process shown may also not use permission information. The corresponding alternative implementation can be combined with the previous description for reference and will not be expanded here.
[0158] As an implementation example, Figure 12 Another example diagram of a cryptographic operation according to an embodiment of the present application is shown in FIG. Figure 9 and Figure 12 As shown, when executing a cryptographic operation instruction, the application processor may first query whether there is a corresponding cache entry in the key cache unit based on the tag of the protected application key indicated by the cryptographic operation instruction;
[0159] If yes (i.e., there is a cache entry corresponding to the tag of the protected application key in the key cache unit), then the cache hit occurs, and the corresponding application key and permission information can be obtained from the queried cache entry;
[0160] 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, and 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 a consistency verification process and a decryption process) 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 that caches the tag of the protected application key, the corresponding application key, and permission information;
[0161] Furthermore, the permission information corresponding to the protected application key can be verified for correctness with the permission information of the cryptographic operation instruction; if the correctness verification passes, the application key corresponding to the protected application key can be used to perform cryptographic operations on the operation data, and the obtained cryptographic operation result is used as the destination operand and saved in the storage space corresponding to the destination operand.
[0162] In a further optional implementation, embodiments of the present application also provide a key protection device for use with a security processor within a processor. In this optional implementation, the key protection device can be considered a functional module unit optionally provided by a key management module within the security processor to implement the key protection method provided in embodiments of the present application. The module unit contents described below can be referenced in conjunction with the method contents described above.
[0163] As an optional implementation, Figure 13 An optional block diagram of the key protection device provided in an embodiment of the present application is shown as an example. Figure 13 As shown, the key protection device may include:
[0164] a request obtaining unit 131 configured to obtain a key derivation request, wherein the key derivation request is used to request derivation of an application key, and the key derivation request carries at least permission information; wherein the security processor stores at least one application key;
[0165] A protection unit 132, configured to, when the permission information is verified, call the root protection key information, perform protection processing on at least the derived application key, and generate a protected application key; wherein the root protection key information is stored within the processor;
[0166] The exporting unit 133 is configured to export the protected application key.
[0167] In an optional implementation, the root protection key information includes at least: a root encryption key. Optionally, the protection unit 132 is configured to call the root protection key information and at least perform protection processing on the derived application key, and the generated protected application key includes:
[0168] Calling the root encryption key, encrypting at least the derived application key to obtain the encrypted application key;
[0169] Based at least on the encrypted application key, a protected application key is obtained.
[0170] In an optional implementation, the root protection key information also includes a root consistency key. Optionally, the protection unit 132 is configured to call the root protection key information and at least perform protection processing on the derived application key, and the generated protected application key also includes:
[0171] After obtaining the encrypted application key, the root consistency key is called to perform consistency protection processing on the encrypted application key to obtain consistency protection information corresponding to the encrypted application key.
[0172] Optionally, the protection unit 132 is configured to obtain the protected application key based at least on the encrypted application key, including:
[0173] The encrypted application key and the consistency protection information corresponding to the encrypted application key are combined to obtain the protected application key.
[0174] In an optional implementation, the protection unit 132 is configured to call the root encryption key and encrypt at least the derived application key, where the encrypted application key includes:
[0175] The root encryption key is called to encrypt the derived application key and the permission information to obtain an encrypted application key.
[0176] In an optional implementation, the key derivation request also carries an application key identifier; the application key identifier is identification information that refers to the application key but does not include the actual content of the application key. Optionally, before the protection unit 132 executes the steps of invoking the root protection key information, performing at least protection processing on the derived application key, and generating a protected application key, the key protection device (specifically, the key management module) may also be configured to: determine, from multiple application keys stored in the security processor, an application key that matches the application key identifier, and use it as the derived application key.
[0177] 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 authority verification of the key management request is passed; the key management request is used to request the management of any of the following application keys stored in the security processor: generation, import, update and destruction of application keys.
[0178] In a further optional implementation, the embodiments of the present application further provide a cryptographic operation device for use in an application processor within a processor. In this optional implementation, the cryptographic operation device can be considered a functional module unit that the application processor optionally configures to implement the cryptographic operation method provided in the embodiments of the present application. The module unit contents described below can be referenced in conjunction with the method contents described above.
[0179] As an optional implementation, Figure 14 An optional block diagram of the cryptographic operation device provided in an embodiment of the present application is shown as an example. Figure 14 As shown, the cryptographic operation device may include:
[0180] An instruction acquisition unit 141 is configured to acquire a cryptographic operation instruction for performing a cryptographic operation on data to be operated; the cryptographic operation instruction indicates at least the data to be operated and a protected application key; wherein the protected application key is derived based on the key protection method provided in an embodiment of the present application;
[0181] A restoration unit 142 is configured to restore the protected application key to obtain at least an application key corresponding to the protected application key;
[0182] The cryptographic operation unit 143 is configured to perform a cryptographic operation on the data to be operated using the application key to obtain a cryptographic operation result.
[0183] In an optional implementation, the format of the cryptographic operation instruction includes: the instruction name of the cryptographic operation instruction, 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 and indicates the index address of the data to be operated; 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 saved after the protected application key is derived, and the storage space is the storage space inside the computer system.
[0184] In an optional implementation, the restoration unit 142 is configured to restore the protected application key to obtain at least the application key corresponding to the protected application key, including:
[0185] The root protection key information is called to restore the protected application key to at least obtain the application key corresponding to the protected application key; wherein the root protection key information is stored inside the processor.
[0186] In an optional implementation, the restoration unit 142 is configured to restore the protected application key to obtain at least the application key corresponding to the protected application key, including:
[0187] Determining whether cached information of the protected application key exists; wherein the application processor stores cached information of the protected application key that has been used in the past;
[0188] If so, obtaining at least the application key corresponding to the protected application key from the cache information of the protected application key;
[0189] If not, call the root protection key information, restore the protected application key, and at least obtain the application key corresponding to the protected application key.
[0190] In an optional implementation, the restoring unit 142 is configured to determine whether cached information of the protected application key exists, including:
[0191] 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 one cache entry caches cache information of a protected application key that has been historically used by the application processor; the cache information of the protected application key includes at least: the tag of the protected application key and the corresponding application key.
[0192] In an optional implementation, the restoring unit 142 is configured to obtain at least the application key corresponding to the protected application key from the cached information of the protected application key, including:
[0193] At least the application key corresponding to the protected application key is obtained from the cache entry corresponding to the tag of the protected application key.
[0194] In an optional implementation, after the restoration unit 142 executes the step of calling the root protection key information, restoring the protected application key, and at least obtaining 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 label of the protected application key and the corresponding application key.
[0195] In an optional implementation, the cache information of the protected application key further includes: permission information corresponding to the protected application key. Optionally, the restoration unit 142 is configured 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:
[0196] 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.
[0197] In an optional implementation, the root protection key information includes at least: a root encryption key. Optionally, the restoration unit 142 is configured to call the root protection key information and perform restoration processing on the protected application key, obtaining at least an application key corresponding to the protected application key including:
[0198] The protected application key is decrypted based on the root encryption key to obtain at least an application key corresponding to the protected application key.
[0199] 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 configured to call the root protection key information and perform restoration processing on the protected application key, at least obtaining an application key corresponding to the protected application key further includes:
[0200] Re-determining the consistency protection information of the encrypted application key based on the root consistency key;
[0201] Comparing the re-determined consistency protection information with the consistency protection information in the protected application key;
[0202] If the comparison results are consistent, the step of decrypting the protected application key based on the root encryption key to at least obtain the application key corresponding to the protected application key is executed.
[0203] The cryptographic operation instruction also indicates permission information; the restoration unit 142 performs restoration processing on the protected application key and obtains 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 a cryptographic operation on the data to be operated and obtain a cryptographic operation result, verify whether the permission information indicated by the cryptographic operation instruction is correct based on the permission information corresponding to the protected application key; if the permission information indicated by the cryptographic operation instruction is verified to be correct, the cryptographic operation unit 143 executes the step of using the application key to perform a cryptographic operation on the data to be operated and obtain a cryptographic operation result.
[0204] In an optional implementation, the permission information indicated by the cryptographic operation instruction corresponds to a third source operand in the format of the cryptographic operation instruction, and the third source operand indicates an index address of the permission information indicated by the cryptographic operation instruction.
[0205] In a further optional implementation, the embodiment of the present application further provides a chip including the processor provided in the embodiment of the present application. Optionally, the functions of the security processor, application processor, and root protection key module provided in the processor can refer to the description of the corresponding parts above.
[0206] In a further optional implementation, an embodiment of the present application also provides an electronic device (eg, a computer device such as a terminal device or a server device), comprising the chip provided in an embodiment of the present application.
[0207] The above describes multiple embodiment schemes provided by the embodiments of the present application. The various optional methods introduced in each embodiment scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible embodiment schemes, which can all be considered as embodiment schemes disclosed and open in the embodiments of the present application.
[0208] Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims.
Claims
1. A key protection method, characterized in that: Applied to a security processor provided in a processor, the method comprises: 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, calling the root protection key information, performing protection processing on at least the derived application key, and generating a protected application key; wherein the root protection key information is stored inside the processor; Apply the key after exporting the protection.
2. The method according to claim 1, characterized in that The root protection key information includes at least: a root encryption key; the calling of the root protection key information, at least performing protection processing on the derived application key, and generating the protected application key includes: Calling the root encryption key, encrypting at least the derived application key to obtain the encrypted application key; Based at least on the encrypted application key, a protected application key is obtained.
3. The method according to claim 2, characterized in that The root protection key information also includes a root consistency key; the calling of the root protection key information at least performs protection processing on the derived application key, and the generation of the protected application key also includes: After obtaining the encrypted application key, call the root consistency key, perform consistency protection processing on the encrypted application key, and obtain the consistency protection information corresponding to the encrypted application key; The obtaining of the protected application key based at least on the encrypted application key includes: The encrypted application key and the consistency protection information corresponding to the encrypted application key are combined to obtain the protected application key.
4. The method according to claim 2 or 3, characterized in that The calling of the root encryption key, encrypting at least the derived application key to obtain the encrypted application key, includes: The root encryption key is called to encrypt the derived application key and the permission information to obtain an encrypted application key.
5. The method according to claim 1, wherein The key derivation request also carries an identifier of the application key; the identifier of the application key is identification information that refers to the application key but does not include the actual content of the application key; Before executing the steps of calling the root protection key information, performing protection processing on at least the derived application key, and generating a protected application key, the method further includes: An application key matching the identifier of the application key is determined from a plurality of application keys stored in the security processor as the derived application key.
6. The method according to claim 1, characterized in that The method further comprises: Obtain key management requests through the command interface; After the authority verification of the key management request is passed, the key management request is processed; the key management request is used to request any of the following management of the application key stored in the security processor: generation, import, update and destruction of the application key.
7. A cryptographic operation method, characterized in that: Applied to an application processor provided in the processor, the method includes: Obtaining a cryptographic operation instruction, the cryptographic operation instruction being used to perform a cryptographic operation on data to be operated; the cryptographic operation instruction at least indicates the data to be operated 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 to 6; Restoring the protected application key to obtain at least the application key corresponding to the protected application key; The application key is used to perform a cryptographic operation on the data to be operated to obtain a cryptographic operation result.
8. The cryptographic operation method according to claim 7, wherein: The format of the cryptographic operation instruction includes: the instruction name of the cryptographic operation instruction, 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 and indicates the index address of the data to be operated; 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 saved after the protected application key is derived, and the storage space is the storage space inside the computer system.
9. The cryptographic operation method according to claim 7, wherein: The restoring process of the protected application key to obtain at least the application key corresponding to the protected application key includes: The root protection key information is called to restore the protected application key to at least obtain the application key corresponding to the protected application key; wherein the root protection key information is stored inside the processor.
10. The cryptographic operation method according to claim 7, wherein: The restoring process of the protected application key to obtain at least the application key corresponding to the protected application key includes: Determining whether cached information of the protected application key exists; wherein the application processor stores cached information of the protected application key that has been used in the past; If so, obtaining at least the application key corresponding to the protected application key from the cache information of the protected application key; If not, call the root protection key information, restore the protected application key, and at least obtain the application key corresponding to the protected application key.
11. The cryptographic operation method according to claim 10, wherein: The determining whether cached information exists for the protected application key includes: Using the tag of the protected application key, querying 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 has been historically used by the application processor; the cache information of the protected application key includes at least: the tag of the protected application key and the corresponding application key; The acquiring, from the cached information of the protected application key, at least the application key corresponding to the protected application key comprises: At least the application key corresponding to the protected application key is obtained from the cache entry corresponding to the tag of the protected application key.
12. The cryptographic operation method according to claim 11, wherein: After executing the steps of calling the root protection key information, restoring the protected application key, and obtaining at least an application key corresponding to the protected application key, the method further includes: A cache entry for the protected application key is updated based at least on the tag of the protected application key and the corresponding application key.
13. The cryptographic operation method according to any one of claims 11 to 12, characterized in that: The cache information of the protected application key also includes: permission information corresponding to the protected application key; The obtaining, from the cache entry corresponding to the tag of the protected application key, at least the application key corresponding to the protected application key comprises: 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.
14. The cryptographic operation method according to any one of claims 9 to 10, characterized in that: The root protection key information includes at least: a root encryption key; the calling of the root protection key information, performing restoration processing on the protected application key, and obtaining at least an application key corresponding to the protected application key includes: The protected application key is decrypted based on the root encryption key to obtain at least an application key corresponding to the protected application key.
15. The cryptographic operation method according to claim 14, wherein: The root protection key information also includes: a root consistency key; the protected application key includes: an encrypted application key and consistency protection information corresponding to the encrypted application key; The calling of the root protection key information and the restoration of the protected application key to obtain at least an application key corresponding to the protected application key further include: Re-determining the consistency protection information of the encrypted application key based on the root consistency key; Comparing the re-determined consistency protection information with the consistency protection information in the protected application key; If the comparison results are consistent, the step of decrypting the protected application key based on the root encryption key to at least obtain the application key corresponding to the protected application key is executed.
16. The cryptographic operation method according to any one of claims 7 to 12, characterized in that: The cryptographic operation instruction also indicates permission information; the restoration process of the protected application key also obtains permission information corresponding to the protected application key; The method further comprises: Before executing the step of performing a cryptographic operation on the data to be operated using the application key to obtain a cryptographic operation result, verifying whether the permission information indicated by the cryptographic operation instruction is correct based on the permission information corresponding to the protected application key; If the authority information indicated by the cryptographic operation instruction is verified to be correct, the step of using the application key to perform a cryptographic operation on the data to be operated to obtain a cryptographic operation result is executed.
17. The cryptographic operation method according to claim 16, wherein: The permission information indicated by the cryptographic operation instruction corresponds to a third source operand in the format of the cryptographic operation instruction, and the third source operand indicates an index address of the permission information indicated by the cryptographic operation instruction.
18. A key protection device, characterized in that: A security processor provided in a processor, the device comprising: a request obtaining unit, configured to obtain a key derivation request, wherein the key derivation request is used to request derivation of an application key, and the key derivation request carries 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, call the root protection key information, perform protection processing on at least the derived application key, and generate a protected application key; wherein the root protection key information is stored inside the processor; The export unit is used to export the protected application key.
19. A cryptographic computing device, characterized in that: Applicable to an application processor provided in a processor, the device comprising: an instruction acquisition unit, configured to acquire a cryptographic operation instruction, the cryptographic operation instruction being used to perform a cryptographic operation on data to be operated; the cryptographic operation instruction at least indicating the data to be operated 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 to 6; a restoration unit, configured to restore the protected application key to at least obtain an application key corresponding to the protected application key; The cryptographic operation unit is used to perform cryptographic operation on the data to be operated using the application key to obtain a cryptographic operation result.
20. A processor, characterized in that: include: Security processor, application processor, and root protection key module; The security processor is configured to store at least one application key and perform key management on the application key; the key management performed by the security processor on the application key includes security protection during application key derivation; wherein the security processor performs security protection during application key derivation based on the key protection method according to any one of claims 1 to 6; The application processor is configured to execute instructions called by an application; the instructions called by the application include cryptographic operation instructions for performing cryptographic operations; wherein the application processor executes the cryptographic operation instructions based on the cryptographic operation method according to any one of claims 7 to 17; The root protection key module is used to store root protection key information; the root protection key information is used to at least protect the application key that needs to be exported by the security processor.
21. The processor according to claim 20, wherein: The security processor includes a secure storage space and a key management module; the secure storage space is used to store application keys; the password management module is used to perform key management on application keys; the key management module has a command interface for importing key management requests, and the command interface allows applications that have passed permission verification to use it.
22. The processor according to claim 20, 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 a protected application key that has been used in the past by the application processor; The cache information of the protected application key includes: a label of the protected application key, and the corresponding application key and permission information.
23. A chip, characterized in that: Comprising a processor as claimed in any one of claims 20 to 22.
24. An electronic device, characterized in that: Comprising the chip as claimed in claim 23.
Citation Information
Patent Citations
Cryptographic module, cryptographic operation method, CPU chip and electronic equipment
CN114722410A
Password application method and device, equipment and storage medium
CN114944960A
Microprocessor with program and data protection function under multi-task environment
EP1202150A2
Creating, using, and managing protected cryptography keys
US20230269076A1
Creating, using, and managing protected cryptography keys
WO2022051189A1
Cited By
Key protection method, cryptographic operation method, key protection apparatus, cryptographic operation apparatus, processor, chip, and electronic device
EP4712406A1
Key protection method, cryptographic operation method, key protection apparatus, cryptographic operation apparatus, processor, chip, and electronic device
WO2025260658A1