A secure key management method based on SoC TEE technology and integrated cryptographic module
By using a secure key management method based on SoC TEE technology and an integrated cryptographic module, secure keys are generated and updated, addressing the performance and security deficiencies in key management in TPM/TCM hardware, and achieving efficient, flexible key management and security assurance.
Patent Information
- Application Number
- CN202211596213.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2042-12-13
AI Technical Summary
Existing TPM/TCM hardware suffers from problems such as low performance, difficulty in updating, poor encryption and decryption efficiency, and difficulty in ensuring key security in the operating system in root key management. TrustZone technology has shortcomings in persistent storage and key update and maintenance.
A secure key management method based on SoC TEE technology and integrated cryptographic module is adopted. By obtaining the user password in the REE, the SMC instruction is used to switch to the TEE to execute the secure program. The integrated cryptographic module CM generates and updates the security key and caches it in the secure state memory of the TEE, restricting its use to the TEE only. This supports efficient encryption and decryption and flexible management.
It improves key security and processing efficiency, simplifies key update and destruction processes, is suitable for TrustZone security environments, and solves the performance and security deficiencies of traditional TPM/TCM.
Smart Images

Figure CN116015632B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the network security technical field, and in particular to a secure key management method based on SoC TEE technology and integrated cryptographic module. BACKGROUND
[0002] Key management refers to a complete set of technologies and procedures for establishing and maintaining key relationships between authorized parties, responsible for the entire process from key generation to final destruction, such as key generation, storage, distribution, use, backup / restoration, update, revocation and destruction. The user root key is the basis of the multi-level key system, and the security protection of other keys in the multi-level key system or the key itself is derived from the user root key. Once the root key is exposed, the entire multi-level key system will be in an insecure environment, and even the user's privacy data may be exposed, resulting in huge losses. Therefore, the protection of the user root key is particularly important.
[0003] In the trusted computing TPM (Trusted Platform Module) and TCM (Trusted Cryptography Module), the endorsement key (EK) plays the role of the user root key. EK is the key with the highest authority in the entire system, which is generated when each user is created, and is used as a parent key to directly or indirectly generate other keys, and all other keys are encrypted and protected by EK.
[0004] Although TPM / TCM has good security guarantees, it still has some problems. The traditional TPM / TCM still has many problems in application. Due to the use of cheap chips, the performance is generally low, and the physical chip has many disadvantages in cost, power consumption, heat dissipation, etc. Chip packaging is not easy to upgrade and maintain. With the rapid development of technology, these problems have become more and more prominent, and it is urgent to innovate in the structure of TPM. SoC TEE extension technology provides this possibility. For example, the TrustZone technology in ARM processors and the SGX (software guard extensions) technology in Intel processors can provide a runtime environment isolated from other software and hardware resources of the platform. Among them, the TrustZone technology is designed to have higher access and control permissions than the host after the system is powered on, and can not only replace TPM / TCM to realize the function of trusted components in many embedded systems and terminal computer systems, but also provide more and more flexible security computing capabilities.
[0005] Although TrustZone can provide a secure isolation environment for the system, it still needs password technology to provide additional privacy, integrity, provability and other protection, therefore, the generation, maintenance and storage mechanism of the root key is very important. Since the root key can be stored persistently after generation, the TrustZone mechanism itself does not guarantee a secure persistent storage mechanism, and the OTP (One Time Programmable) memory in the CPU Core only allows one-time writing, which is not conducive to the update and maintenance of the root key. Therefore, the embodiment needs a set of root key management mechanism based on SoC TEE to meet the needs of safe generation, update, use of the key, and support efficient encryption and decryption. SUMMARY
[0006] The technical problem to be solved by the present application: In view of the above problems of the prior art, a secure key management method based on SoC TEE technology and integrated cryptographic module is provided. The present application is based on the security of TEE, and can generate a secure key by using the integrated cryptographic module CM of the system on chip SOC. It is suitable for the secure key management mechanism of the TrustZone security environment, has the advantages of simple and convenient key management, high key security, and can solve the problems of difficult root key update in existing TPM / TCM hardware, poor key encryption and decryption efficiency, and difficulty in ensuring the security of the key in the operating system.
[0007] To solve the above technical problems, the technical scheme adopted by the present application is:
[0008] A secure key management method based on SoC TEE technology and integrated cryptographic module, comprising generating a secure key:
[0009] Obtaining a password input by a user in the REE;
[0010] Initiating a secure key generation request to call the SMC instruction to switch to the TEE to execute a specified security program;
[0011] Transmitting the password to the integrated cryptographic module CM through the security program, and generating a secure key by encrypting the password and the system on chip key SOC key stored in the one-time programmable register OTP through the integrated cryptographic module CM; the one-time programmable register OTP is closed after completing the system on chip key SOC key initialization to access the channel between the CPU, so that only the access channel of the integrated cryptographic module CM is retained;
[0012] Caching the generated secure key to the secure memory of the TEE to limit the use of the secure key only in the TEE.
[0013] Optionally, it further comprises updating the secure key in response to a user request:
[0014] obtaining a password input by a user in the REE, including an old password and a new password;
[0015] initiating a secure key update request to invoke an SMC instruction to switch to the TEE to execute a specified security program;
[0016] transmitting the old password to the integrated cryptographic module CM through the security program, generating a new secure key through the integrated cryptographic module CM according to the password and a system on chip key SOC key stored in the one-time programmable register OTP, encrypting a specified message message using the new secure key, and transmitting the message message to the security program;
[0017] The security program attempts to decrypt the message message. If the decryption of the message message fails, the security program switches back to the REE, reports an error, and exits. Otherwise, the security program transmits the new password to the integrated cryptographic module CM, generates a secure key through the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and caches the generated secure key in the secure memory of the TEE to limit the use of the secure key only in the TEE.
[0018] Optionally, it also includes performing secure key revocation:
[0019] If the type is password exposure, obtaining a password input by a user in the REE, initiating a secure key update request to invoke an SMC instruction to switch to the TEE to execute a specified security program, transmitting the exposed password to the integrated cryptographic module CM through the security program, generating a new secure key through the integrated cryptographic module CM according to the password and a system on chip key SOC key stored in the one-time programmable register OTP, encrypting a specified message message using the new secure key, and transmitting the message message to the security program, the security program attempts to decrypt the message message. If the decryption of the message message fails, the security program switches back to the REE, reports an error, and exits. Otherwise, the security program writes the exposed password into a preset revocation password table, so that when the security program receives a password, if the password is found in the revocation password table, the security program will not transmit the password to the integrated cryptographic module CM but will directly report an error and exit;
[0020] If the type is key exposure, the password input by the user is obtained in the REE, including the old password and the new password; a secure key update request is initiated to call the SMC instruction to switch to the TEE to execute a specified security program; the exposed password is transmitted to the integrated cryptographic module CM through the security program, and a new secure key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and the new secure key is used to encrypt a specified message message and transmit the message message to the security program; the security program attempts to decrypt the message message, and if the decryption of the message message fails, the security program switches back to the REE, reports an error and exits; otherwise, the new password is transmitted to the integrated cryptographic module CM through the security program, and a secure key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and the generated secure key is cached in the secure memory of the TEE to limit the use of the secure key only in the TEE.
[0021] Optionally, when the password input by the user is obtained, it is determined whether the password or the new password meets the preset specification, and only when the password meets the preset specification, the subsequent operation is continued; otherwise, the operation of obtaining the password input by the user is continued or the operation is exited.
[0022] Optionally, when the generated secure key is cached in the secure memory of the TEE, a record is added or updated in a preset password information table, and the fields of the record include the password used for generating the secure key, the timestamp of generating the secure key, and the number of updates, and the number of updates is a preset initial value when the record is added, and the number of updates is increased by 1 when the record is updated.
[0023] Optionally, the operation of generating the secure key by encryption includes that the integrated cryptographic module CM first hashes the password into a fixed-length value by a hash function, then performs an exclusive or operation on the fixed-length value and the system on chip key SOC key stored in the one-time programmable register OTP to obtain a seed seed for generating the secure key, and generates the secure key according to the seed seed using a specified encryption algorithm.
[0024] Optionally, the fields recorded in the password information table further include the number of hash operations when the fixed-length value is generated and whether a random number is salted;
[0025] The security program also actively updates the secure key at a regular time or based on a preset trigger mechanism:
[0026] The time stamp of generating the security key in each record in the password information table is detected, if the time stamp of generating the security key exceeds the predetermined preset life cycle, a new security key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP through encryption by increasing the number of hash used when generating the fixed-length value or through the salted random number generation, and the information of the corresponding record in the password information table is updated.
[0027] Optionally, when the user exits the system, the TEE automatically clears the security key buffered in the secure memory in the TEE.
[0028] In addition, the application also provides a security key management system based on the SoC TEE technology and the integrated cryptographic module, comprising a microprocessor and a memory connected with each other, the microprocessor is programmed or configured to execute the security key management method based on the SoC TEE technology and the integrated cryptographic module.
[0029] In addition, the application also provides a computer readable storage medium, the computer readable storage medium stores a computer program, the computer program is used for programming or configuring the microprocessor to execute the security key management method based on the SoC TEE technology and the integrated cryptographic module.
[0030] Compared with the prior art, the application mainly has the following advantages:
[0031] 1. The security of the security key is guaranteed. Compared with the traditional hardware TPM key management, the key generation adopted by the application no longer needs to permanently store the generated security key, but is changed to input the specific password of the user when the user needs to use, and the security transmission and storage characteristics of the TEE are used to cooperate with the integrated cryptographic module CM to temporarily generate the user key (the user key in the storage space will be automatically cleared when the cache is lost when power off), which not only saves the storage space of the security key, but also ensures that the security key does not exist anywhere when not in use and cannot be stolen. The generated security key is only used in the TEE, the user can only call the key related operation through the interface and get the return value, which ensures the security of the user key.
[0032] 2. The processing efficiency of the key is improved. Compared with the original pure hardware form of private data encryption and decryption, the introduction of the TEE upgrades the encryption and decryption of the key to the CPU level, ensures the security of the key, and reduces the number of data transmission between the hardware cryptographic engine through the combination of software and hardware, and speeds up the encryption and decryption efficiency.
[0033] 3. Keys are easy to update and destroy, and the management mechanism is more flexible. This invention's method of generating keys via passwords not only allows users to personalize security keys but also makes updating security keys simpler and more flexible. Furthermore, this invention's TrustZone-based key management method provides more possibilities for further improvements to key management and facilitates subsequent functional expansion.
[0034] 4. The security key management method of this invention based on SoC TEE technology and integrated cryptographic module can be applied to various security key management methods, including user root keys. Based on the security of TEE, it can use the integrated cryptographic module CM of the system on chip (SoC) to generate security keys. It is suitable for the security key management mechanism of TrustZone security environment and has the advantages of simple and convenient key management and high key security. It can solve the problems of difficult root key updates, poor key encryption and decryption efficiency, and difficulty in ensuring key security in the operating system in existing hardware such as TPM / TCM. Attached Figure Description
[0035] Figure 1 This is a schematic diagram illustrating the environmental assumptions in an embodiment of the present invention.
[0036] Figure 2 This is a schematic diagram of the relevant structure on the Phytium chip in an embodiment of the present invention.
[0037] Figure 3 This is a schematic diagram of the security key generation process in the method of this embodiment of the invention.
[0038] Figure 4 This is a schematic diagram of the initial startup process in the method of this embodiment of the invention.
[0039] Figure 5 This is a schematic diagram of the key update and key revocation process in an embodiment of the present invention. Detailed Implementation
[0040] like Figure 1 As shown, the secure key management method based on SoC TEE technology and integrated cryptographic modules in this embodiment is based on the following environmental assumptions:
[0041] 1. The System-on-Chip (SoC) contains an integrated cryptography module (CM) that supports encryption and decryption algorithms, and an SoC key that only the integrated cryptography module can access and read. This SoC key is stored in a one-time programmable register (OTP), which is write-once and immutable. In addition, the SoC processor supports TrustZone security isolation features.
[0042] 2. The One-Time Programmable Register (OTP) and its stored System-on-Chip (SOC) key have a hard-selection access function. That is, through hardware means such as jumpers, the SOC key can be accessed by either the CPU instruction or the integrated cryptographic module (CM). If access is selected by the integrated cryptographic module (CM), the CPU instruction or other hardware units cannot access the contents of the SOC key.
[0043] 3. When the on-chip system key (SOC key) is selected to be accessed by the integrated cryptographic module (CM), the encryption key of the integrated cryptographic module (CM) has two input methods: one is that when there is a non-zero value in its key register, the integrated cryptographic module (CM) uses the value in the key register as the encryption key to encrypt the input data; the other is that when the value in the key register is all zeros, the on-chip system key (SOC key) is automatically used as the encryption key to encrypt and decrypt the input data.
[0044] 4. The resources used in the TEE environment generated by the SoC processor are isolated from the user's operating system REE, and the TEE has higher privileges than the REE. The REE can only call the TEE's secure programs through pre-configured interfaces. The TEE itself has been verified through trusted boot; if there are problems with the code, the TEE will fail to start. Therefore, in this embodiment, the TEE can be considered a secure operating environment, which serves as the premise for ensuring the security of storage and computation within the TEE in this invention.
[0045] As an optional implementation method, this embodiment selects the Phytium chip as the physical hardware for implementing the solution. For example... Figure 2 As shown, the Phytium chip has a unique on-chip system key (SOC key) pre-written in the One-Time Programmable Register (OTP) at the factory. The OTP has a hard-selection access function, allowing the SOC key to be accessed by either CPU instructions or the SCTO module (the integrated cryptographic module CM on the Phytium FT-2000 / 4 development board) via jumpers or other hardware means. If access is selected by the SCTO module, neither CPU instructions nor other hardware units can access the contents of the SOC key. The SCTO module contains a key register, a random number generator, and various cryptographic algorithm engines. The key register temporarily stores the generated key; when all values in the register are 0, the SoC key is read as the key value to encrypt the input data. Besides the OTP, the SCTO module can also exchange data with the CPU. The SCTO module can obtain the user's password from the CPU to generate a key and return the generated key to the CPU.
[0046] The present application needs to solve the problem of designing a secure, easy-to-update and high-efficiency key management mechanism for the above-mentioned environment assumption. The key is only generated when the user uses the system or needs to encrypt and decrypt the private data using the key, and is temporarily stored in the secure state memory of the TEE to ensure its security, used for the encryption and decryption operation of the user's private data, to ensure that the key is not exposed and cannot be stolen through hardware during the encryption and decryption process, and the key will be cleared after power off. For the above problems, as shown in Figure 3 and Figure 4 The security key management method based on SoC TEE technology and integrated cryptographic module of the embodiment includes generating a security key:
[0047] Obtaining the password input by the user in the REE;
[0048] Initiating a security key generation request to call the SMC instruction to switch to the TEE to execute the specified security program;
[0049] Transmitting the password to the integrated cryptographic module CM through the security program, and generating a security key through the integrated cryptographic module CM according to the password and the on-chip system key SOC key stored in the one-time programmable register OTP, wherein the one-time programmable register OTP is closed after the on-chip system key SOC key initialization to access the channel between the CPU, so that only the access channel of the integrated cryptographic module CM is reserved;
[0050] Caching the generated security key to the secure state memory of the TEE to limit the use of the security key only in the TEE.
[0051] Generally, the generation of the user key mainly includes three steps: receiving the user password, processing the user password and returning the secure key. First, the user initiates a request for a secure application that generates a key in the REE, and inputs his own password, which is transmitted to the TEE by the system. The password here can be any combination of characters, but cannot exceed a certain length. Then the secure application for key generation in the TEE transmits the password to the integrated cryptographic module CM on the SoC for the generation of the user key. The second step is to process the user password. After the CM module receives the password, it uses the hash function to convert it into a fixed-length value, which is called the hashed password. Then the hashed password is used as input and is XORed with the key in the key register. Since the initial value in the key register is all 0, the key register reads the SoC key as the key for the XOR operation according to the previous environmental assumption, and the value obtained after the XOR operation is used as the seed for the user key generation. In addition, a password information table is generated in the secure state storage space of the TEE. When the system receives a new password, it writes the information of the password into the table, including the password value, the timestamp of the generation time, the number of updates, and whether there is a salt value. The last step is to return the secure key. The CM module uses the seed as input to generate the user key using its key generation engine, and transmits the user key to the key register in the CM and the TEE of the system for storage as a secure key for the encryption of user privacy data. Due to the physical isolation of the TEE mentioned above, the secure key stored in the TEE can only be processed in the TEE, thereby ensuring the security of the key. The storage medium can be selected as DRAM to clear the key after power off, ensuring that no one can obtain the key when it is not in use, or a storage medium with higher reading efficiency such as flash memory, which can manually clear the key when the system is shut down.
[0052] Further, the secure key management method based on the SoC TEE technology and the integrated cryptographic module of the present embodiment adopts a method of using the integrated cryptographic module CM in the SoC processor chip as a key generation tool and using the TrustZone to assist in security management. In addition to key generation, the method also includes key update and key destruction.
[0053] As shown in Figure 5 , the method of the present embodiment further includes updating the secure key in response to a user request:
[0054] Obtaining the user input password in the REE (general execution environment), including the old password and the new password;
[0055] initiating a secure key update request to invoke an SMC (secure monitor call) instruction to switch to TEE (trusted execution environment) execution of a specified secure program;
[0056] transmitting the old password to the integrated cryptographic module CM by the secure program, generating a new secure key by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and encrypting a specified message message by the new secure key and transmitting the message message to the secure program;
[0057] The secure program attempts to decrypt the message message, and if the decryption of the message message fails, switches back to the REE, reports an error and exits; otherwise, the secure program transmits the new password to the integrated cryptographic module CM, the integrated cryptographic module CM generates a secure key according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and caches the generated secure key to the secure memory of the TEE to limit the use of the secure key only in the TEE.
[0058] The updating of the key is divided into two cases, one is that the key life cycle ends after the key is used for a period of time, and the other is that the user initiates a request for updating the key. First, the automatic updating of the key life cycle ends. The key updating security program in the TEE regularly checks the time stamp of the password in the password information table, and when a password exceeding the specified life cycle is found, the updating operation is automatically performed on the password. The specific updating process is to increase the number of hash operations in the password generation key process, or to generate a random number with salt, and to update the time stamp, the number of hash operations and other information, and to write them into the password information table to complete the updating of the key. The key updating process initiated by the user is divided into three steps, namely verification, updating and implementation. First, verification. When the user initiates a key update request, the system will ask the user to input his own password. The password is still transmitted to the integrated cryptographic module by switching to the TEE and then by the security application to generate a key. Then the integrated cryptographic module encrypts a random number Nonce with the public key in the user key and sends it to the security updating program in the TEE. After ensuring the safety of the environment, the program decrypts the Nonce with the private key and transmits it back to the CM module. After the CM module verifies that the Nonce is correct, it begins to update the key. If any step fails, the key update will be terminated immediately. After the verification of the update is completed, the user can input a new password to update the key. The updating step is the same as the key generation process, which will not be described here. The last step is the implementation of the key update. This embodiment needs to first use the old key temporarily stored in the CM module to decrypt the encrypted private data, and then use the new key generated in the previous step to re-encrypt the data. After all the data are re-encrypted, the key update is completed.
[0059] As shown in Figure 4 the method further includes performing security key revocation:
[0060] If the type is password exposure, the password input by the user is obtained in the REE, a security key update request is initiated to call the SMC instruction to switch to the TEE to execute the specified security program; the exposed password is transmitted to the integrated cryptographic module CM by the security program, a new security key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and a specified message message is encrypted by the new security key and transmitted to the security program; the security program attempts to decrypt the message message, and if the message message fails to decrypt, it switches back to the REE, reports an error and exits; otherwise, the security program writes the exposed password into a preset revocation password table, so that when the security program receives the password, if it finds that the password is in the revocation password table, it will not be transmitted to the integrated cryptographic module CM but will directly report an error and exit;
[0061] If the type is key exposure, the password input by the user, including the old password and the new password, is obtained in the REE; a secure key update request is initiated to call the SMC instruction to switch to the TEE to execute a specified security program; the exposed password is transmitted to the integrated cryptographic module CM through the security program, the new security key is generated by the integrated cryptographic module CM according to the password and the system-on-chip key SOC key stored in the one-time programmable register OTP, and the new security key is used to encrypt a specified message message and transmit the message message to the security program; the security program attempts to decrypt the message message, and if the decryption of the message message fails, the security program switches back to the REE, reports an error and exits; otherwise, the new password is transmitted to the integrated cryptographic module CM through the security program, the security key is generated by the integrated cryptographic module CM according to the password and the system-on-chip key SOC key stored in the one-time programmable register OTP, and the generated security key is cached in the secure memory of the TEE to limit the use of the security key only in the TEE.
[0062] When the user no longer uses the key, the life cycle of the key ends, or the key may be exposed, we need to destroy the key. Here the application will be divided into two cases to perform different destruction operations on the key. The first case is that the user's password is exposed or the user no longer uses the key. Considering that the workload of operating all private data is relatively large, and the user key generated by the CM module is not exposed. We can complete the destruction of the key by adding a destroyed password table in the TEE to record the password that is no longer used. Since the user password needs to be transmitted to the hardware module through the security service in the TEE to generate the user key, after adding the destroyed password table, the system will perform a lookup to determine that the destroyed password will not be transmitted to the hardware module to generate the user key, but will prompt the user that the key has been revoked. In this way, the data modification can be reduced, and the user key can be ensured not to be exposed. The second case is that the user key is exposed. In this case, all data encrypted by the exposed key needs to be re-encrypted and then the exposed key needs to be cleared to prevent the exposed key from being used. This can be regarded as an update operation on the key.
[0063] As can be seen, the embodiment only needs the user to input the old password and the new password to assist in verification and update, and the system can complete the update of the key. Even if the user password is exposed, the password revocation table stored in the TEE proposed in the embodiment can avoid a large amount of data processing when the key is revoked, so that the way of generating the key through the password in the embodiment not only allows the user to generate a personalized security key, but also makes the security key update more convenient and flexible.
[0064] Reference Figure 4When the user feels that the current password is at risk during use, and wishes to update his own security key, the user can initiate a request for key update. When the system receives the request for key update, the user is required to input the old password to be updated and the new password to be changed, and to switch to the TEE secure environment to execute the key update program. The execution process of the program is as follows: the update program first transmits the password to the SCTO module to generate a security key, and then the SCTO module encrypts a random number Nonce with the key and transmits it to the key update program. If the program can successfully decrypt the message message, it means that the password is correct and is the current user's root key, and the key update can begin, otherwise the key update is stopped. The key update program will first generate a new security key with the new password, and then decrypt all the private data managed by the old root key and re-encrypt it with the new key. Thus, the update of the security key is completed. When the user no longer uses the system or the password and key are exposed, the key revocation operation is required. When the user initiates a request for key revocation, it will be divided into two cases: password revocation and key revocation. Password revocation is applicable to the case where the system is no longer used, but the root key is not exposed. In this case, the user only needs to input his own password, and the security program in the TEE verifies it and writes the password into the revoked password table. After that, when the system receives the password again, it will query the revoked password table and find that the password is no longer used, and return an error message. When the security key is exposed, key revocation is required. Key revocation can actually be regarded as a security key update, which completely replaces the old key with a new key to stop using the old key and eliminate the exposure risk. In this embodiment, the password information table records the number of hash operations used when generating the fixed-length value and whether to use random number salting; in this embodiment, the security program also actively updates the security key at regular intervals or based on a preset trigger mechanism: detecting the time stamp of generating the security key in each record in the password information table, if the time stamp of generating the security key exceeds the specified preset life cycle, a new security key is generated by increasing the number of hash operations used when generating the fixed-length value or by generating random number salting, and the new security key is generated by the integrated cryptographic module CM according to the password and the system-on-chip key SOC key stored in the one-time programmable register OTP, and the information in the corresponding record in the password information table is updated. Through the above-mentioned way, the automatic update mechanism of the security key can be realized, and the security of the security key is ensured.
[0065] In the embodiment, when the password input by the user is acquired, it is determined whether the password or the new password conforms to the preset specification, and the process continues only when the password conforms to the preset specification; otherwise, the process returns to acquiring the password input by the user or exits. Before a new user uses the system, a user's own security key needs to be generated, which is used to manage the user's security application and private data. When a new user is created, the system requires the user to input a password, for example, a string composed of letters, numbers and symbols such as “XyO99864=@56”, and does not determine whether the password or the new password conforms to the preset specification. It is needless to say that the preset specification can be formulated according to actual needs, for example, the length is limited, and the combination of capital letters, small letters, numbers and special symbols is required.
[0066] In the embodiment, when the generated security key is cached in the secure memory of the TEE, a record is also added or updated in the preset password information table, the fields of the record include the password used to generate the security key, the timestamp of generating the security key and the update times, and the update times are preset initial values when the record is added, and the update times are increased by 1 when the record is updated.
[0067] In the embodiment, the encryption to generate the security key includes that the integrated cryptographic module CM first hashes the password into a fixed-length value through a hash function, then performs an exclusive or operation on the fixed-length value and the system-on-chip key SOC key stored in the one-time programmable register OTP to obtain a seed seed used to generate the security key, and generates the security key according to the seed seed using a specified encryption algorithm.
[0068] Referring to Figure 3 When the security key is generated, the key generation instruction is called. After the system receives the security request of the key generation, the password is transmitted to the secure storage area, and the TEE is switched to execute the key generation program (security program). The key generation program writes the password into the password information table to record the timestamp of initially receiving the password, then transmits the received user password to the SCTO module of the Feiteng processor, first hashes it into a fixed-length value through a hash function, then performs an exclusive or operation on the fixed-length value and the system-on-chip key SOC key to obtain a seed seed used to generate the security key. Finally, the SCTO module generates the security key using the seed seed according to the national encryption algorithm, and returns the security key to the key register in the SCTO module and the secure memory (such as flash or DRAM) of the TEE for storage, which is used for subsequent user data encryption and decryption and other security operations related to user privacy, and completes the initial start of the user. After the initial start is completed, the user can perform security operations, and all private data or new keys, signature generation will be switched to the TEE environment, and the security key is processed in the TEE environment.
[0069] Another problem to be solved by the present application is to ensure that the security key will be cleared after power off. To solve the above problem, on the one hand, since the security key is cached in the secure state memory of the TEE, power off generally causes the cache to be lost, thereby improving the security of the security key; on the other hand, the present embodiment further comprises that when the user exits the system, the TEE automatically clears the security key cached in the secure state memory of the TEE. By clearing the cache related to the security key when the user exits the system, that is, the security key is not stored in the physical memory when the user does not use it, and the root key corresponding to the user is generated again only when the user logs in next time, which reduces the risk of exposure of the security key. Needless to say, based on the need to increase the security of the security key, the active clearing here can be all filled with 0 or 1, randomly filled with 0 or 1, and can be single or multiple according to the needs.
[0070] In addition, the present embodiment further provides a security key management system based on the SoC TEE technology and the integrated cryptographic module, comprising a microprocessor and a memory connected to each other, the microprocessor being programmed or configured to execute the security key management method based on the SoC TEE technology and the integrated cryptographic module. In addition, the present embodiment further provides a computer readable storage medium, the computer readable storage medium storing a computer program for being programmed or configured by the microprocessor to execute the security key management method based on the SoC TEE technology and the integrated cryptographic module.
[0071] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code. The present application is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams can be implemented by computer program instructions. The combination of flows and / or blocks in the flowcharts and / or block diagrams can also be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one flow or multiple flows and / or blocks Figure 1apparatuses that implement the functions specified in one or more flowcharts and / or blocks. These computer program instructions can also be loaded onto a computer or other programmable data processing devices to cause a series of operational steps to be performed on the computer or other programmable devices to produce a computer implemented process such that the instructions that are executed on the computer or other programmable devices provide steps for implementing the functions specified in the flowcharts and / or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 one or more flowcharts and / or blocks These computer program instructions can also be loaded onto a computer or other programmable data processing devices to cause a series of operational steps to be performed on the computer or other programmable devices to produce a computer implemented process such that the instructions that are executed on the computer or other programmable devices provide steps for implementing the functions specified in the flowcharts and / or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 one or more flowcharts and / or blocks
[0072] The above description is merely preferred embodiments of the present application, and the protection scope of the present application is not limited to the above-mentioned embodiments. Any improvement and modification made by those skilled in the art without departing from the principle of the present application shall be considered as falling within the protection scope of the present application.
Claims
1. A secure key management method based on SoC TEE technology and integrated cryptographic module, characterized in that, The method comprises the following steps: obtaining a password input by a user in a REE; initiating a security key generation request to call an SMC instruction to switch to a TEE to execute a specified security program; transmitting the password to an integrated cryptographic module CM through the security program, and generating a security key through the integrated cryptographic module CM according to the password and a system on chip key SOC key stored in a one-time programmable register OTP, wherein the one-time programmable register OTP is closed to access a channel between the CPU after completing the system on chip key SOC key initialization, so that only an access channel of the integrated cryptographic module CM is reserved; caching the generated security key to a secure memory of the TEE to limit use of the security key only in the TEE; the security key generation comprises: the integrated cryptographic module CM first hashes the password into a fixed-length value through a hash function, and then performs an exclusive or operation on the fixed-length value and the system on chip key SOC key stored in the one-time programmable register OTP to obtain a seed seed for generating the security key, and generates the security key according to the seed seed using a specified encryption algorithm; the security key management further comprises automatically clearing the security key cached in the secure memory of the TEE by the TEE when the user exits the system.
2. The secure key management method based on SoC TEE technology and integrated cryptographic module according to claim 1, characterized in that, The method further comprises performing security key update in response to a user request: obtaining a password input by a user in a REE, including an old password and a new password; initiating a security key update request to call an SMC instruction to switch to a TEE to execute a specified security program; transmitting the old password to an integrated cryptographic module CM through the security program, and generating a new security key through the integrated cryptographic module CM according to the password and a system on chip key SOC key stored in a one-time programmable register OTP, and encrypting a specified message message using the new security key and transmitting the message message to the security program; the security program attempts to decrypt the message message, if the message message fails to be decrypted, the security program switches back to the REE, reports an error and exits; otherwise, the security program transmits the new password to the integrated cryptographic module CM, and the integrated cryptographic module CM generates a security key according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and caches the generated security key to a secure memory of the TEE to limit use of the security key only in the TEE.
3. The secure key management method based on SoC TEE technology and integrated cryptographic module according to claim 1, characterized in that, The method further comprises performing security key revocation: If the type is password exposure, the user input password is obtained in the REE, a secure key update request is initiated to call the SMC instruction to switch to the TEE to execute a specified security program; the exposed password is transmitted to the integrated cryptographic module CM through the security program, a new secure key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and the new secure key is used to encrypt a specified message message and transmit the message message to the security program; the security program attempts to decrypt the message message, and if the decryption of the message message fails, the security program switches back to the REE, reports an error and exits; otherwise, the exposed password is written into a preset revoked password table through the security program, so that the security program does not transmit the password to the integrated cryptographic module CM when the password is received, but directly reports an error and exits. Otherwise, the exposed password is written into a preset revoked password table through the security program, so that the security program does not transmit the password to the integrated cryptographic module CM when the password is received, but directly reports an error and exits. If the type is key exposure, the user input password is obtained in the REE, including the old password and the new password; A secure key update request is initiated to call the SMC instruction to switch to the TEE to execute a specified security program; the exposed password is transmitted to the integrated cryptographic module CM through the security program, a new secure key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and the new secure key is used to encrypt a specified message message and transmit the message message to the security program; the security program attempts to decrypt the message message, and if the decryption of the message message fails, the security program switches back to the REE, reports an error and exits; otherwise, the new password is transmitted to the integrated cryptographic module CM through the security program, the secure key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP, and the generated secure key is cached in the secure memory of the TEE to limit the use of the secure key only in the TEE.
4. The secure key management method based on SoC TEE technology and integrated cryptographic module according to claim 1, characterized in that, When the user input password is obtained, it is determined whether the password or the new password meets the preset specification, and only when the password meets the preset specification, the process continues; Otherwise, the process of obtaining the user input password or the process of exiting continues.
5. The secure key management method based on SoC TEE technology and integrated cryptographic module according to claim 1, characterized in that, When the generated secure key is cached in the secure memory of the TEE, a record is added or updated in a preset password information table, the fields of the record include the password used for generating the secure key, the timestamp of generating the secure key, and the update times, and when the record is added, the update times are preset to an initial value, and when the record is updated, the update times are incremented by 1.
6. The secure key management method based on SoC TEE technology and integrated cryptographic module according to claim 5, characterized in that, The fields recorded in the password information table also include the number of hash operations used when generating the fixed-length value and whether a random number is salted; The security program also actively updates the secure key at a regular time or based on a preset trigger mechanism: The time stamp of generating the security key in each record in the password information table is detected, if the time stamp of generating the security key exceeds the predetermined preset life cycle, a new security key is generated by the integrated cryptographic module CM according to the password and the system on chip key SOC key stored in the one-time programmable register OTP through encryption by increasing the number of hash used when generating the fixed-length value or through the salted random number generation, and the information of the corresponding record in the password information table is updated.
7. A secure key management system based on SoC TEE technology and integrated cryptographic module, comprising a microprocessor and a memory connected to each other, characterized in that, The microprocessor is programmed or configured to perform the security key management method based on the SoC TEE technology and the integrated cryptographic module in any one of claims 1-6.
8. A computer-readable storage medium having stored therein a computer program, characterized in that, The computer program is used for programming or configuring the microprocessor to perform the security key management method based on the SoC TEE technology and the integrated cryptographic module in any one of claims 1-6.
Citation Information
Patent Citations
One-time password (OTP) generation method and system based on safety element
CN108616352A
Data encryption method and apparatus, data decryption method and apparatus, terminal, and storage medium
WO2022028289A1