Chip, data processing method and device, electronic equipment and storage medium
By adopting encapsulation mechanism and hardware acceleration technology in smart terminals, the encryption keys are derived and configured securely in partitions, which solves the problem of easy leakage of file encryption keys, and achieves a balance between high security of keys and encryption and decryption efficiency.
Patent Information
- Application Number
- CN202510106548.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-07-25
Smart Images

Figure CN120378093A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and in particular, to a chip, a data processing method, a device, an electronic device, and a storage medium. Background Art
[0002] With the rapid development of information technology, data security has become an increasingly concerned focus issue. In today's digital age, a large amount of sensitive information is stored in various intelligent terminals (such as smart phones, tablets, etc.) in the form of electronic files. During the process of transmitting, storing, and processing electronic files by these intelligent terminals, file encryption technology is relied on to protect the confidentiality and integrity of sensitive data. Among them, the security of the file encryption key used for encrypting and decrypting electronic files is of crucial importance.
[0003] In related technologies, intelligent terminals adopt a relatively simple key management method: directly storing the file encryption key in the memory of the operating system.
[0004] Although this method realizes simple and fast key access, it brings significant security risks. Once the operating system is attacked or the superuser privilege (root privilege) is obtained, the attacker can easily access the file encryption key in the memory, which will not only lead to the leakage of the encryption key, but also expose the sensitive data in the protected electronic files, thus triggering serious privacy and security risks. Summary of the Invention
[0005] This application aims to at least solve one of the technical problems in the related technologies to some extent.
[0006] To this end, this application proposes a chip, a data processing method, a device, an electronic device, and a storage medium, so as to not only ensure the high security of the key, but also improve the efficiency of file encryption and decryption by using hardware acceleration, and finally achieve the best balance between security and performance to meet the actual business requirements.
[0007] An embodiment of this application on one hand proposes a chip, including a first hardware engine and a secure partition that communicate with each other, where,
[0008] The secure partition is configured to receive an encapsulated key sent by a first execution environment, perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key, configure the first derived key into a key slot in the first hardware engine, and send the second derived key to a second execution environment; wherein, the second derived key is used for the second execution environment to generate a first key identifier;
[0009] The first hardware engine is configured to receive the first key identifier sent by the second execution environment, and associate the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
[0010] Another embodiment of this application provides a data processing method, which is applied to a secure enclave and includes:
[0011] Receiving an encapsulated key sent by a first execution environment, and performing key derivation based on the encapsulated key to obtain a first derived key and a second derived key;
[0012] Configuring the first derived key into a key slot in a first hardware engine;
[0013] Sending the second derived key to a second execution environment; wherein, the second derived key is used by the second execution environment to generate a first key identifier;
[0014] Wherein, the first key identifier is used to be associated with the key slot in the first hardware engine, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
[0015] Another embodiment of this application provides another data processing method, which is applied to a first hardware engine and includes:
[0016] In response to a configuration operation triggered by a secure enclave, configuring a first derived key into a key slot in the first hardware engine; wherein, the configuration operation is that the secure enclave responds to receiving an encapsulated key sent by a first execution environment, performs key derivation based on the encapsulated key to obtain a first derived key and a second derived key, and generates according to the first derived key;
[0017] Receiving a first key identifier sent by a second execution environment, wherein the first key identifier is generated by the second execution environment in response to the second derived key sent by the secure enclave, according to the second derived key;
[0018] Associating the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
[0019] Another embodiment of this application provides a data processing apparatus, which is applied to a secure enclave and includes:
[0020] A receiving module, configured to receive an encapsulated key sent by a first execution environment;
[0021] A derivation module, configured to perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key;
[0022] A configuration module, configured to configure the first derived key into a key slot in a first hardware engine;
[0023] A sending module, configured to send the second derived key to a second execution environment; wherein, the second derived key is used for the second execution environment to generate a first key identifier;
[0024] Wherein, the first key identifier is used to be associated with the key slot in the first hardware engine, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
[0025] In another aspect, an embodiment of the present application further provides another data processing device, which is applied to a first hardware engine and includes:
[0026] A configuration module, configured to, in response to a configuration operation triggered by a secure enclave, configure a first derived key into a key slot in the first hardware engine; wherein, the configuration operation is that the secure enclave responds to receiving an encapsulated key sent by a first execution environment, performs key derivation based on the encapsulated key to obtain a first derived key and a second derived key, and is generated according to the first derived key;
[0027] A receiving module, configured to receive a first key identifier sent by a second execution environment, wherein the first key identifier is generated by the second execution environment in response to the second derived key sent by the secure enclave;
[0028] A processing module, configured to associate the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
[0029] In another aspect, an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the data processing method described in any of the foregoing aspects.
[0030] In yet another aspect, an embodiment of the present application further provides another electronic device, including a first execution environment, a chip, and a second execution environment that are communicatively connected, wherein,
[0031] The first execution environment is configured to send an encapsulated key to the chip;
[0032] The chip is configured to perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key, configure the first derived key into a key slot of the chip, and send the second derived key to the second execution environment;
[0033] The second execution environment is used to generate a first key identifier according to the second derived key and send the first key identifier to the chip;
[0034] The chip is further used to associate the first key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated first key identifier and the key slot.
[0035] In another aspect of the embodiments of the present application, a non-transitory computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the data processing method described in any of the foregoing aspects is implemented.
[0036] In yet another aspect of the embodiments of the present application, a computer program product is provided, on which a computer program is stored. When the program is executed by a processor, the data processing method described in any of the foregoing aspects is implemented.
[0037] The chip, data processing method, device, electronic device, and storage medium provided in the present application adopt an encapsulation mechanism to enhance the security (i.e., encapsulation) of the encryption key in plaintext form (denoted as the plaintext key in the present application), and obtain an encapsulated key, which can make the original plaintext key completely invisible in the first execution environment and the second execution environment with relatively low security, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by the security partition with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet the actual business requirements.
[0038] Some of the additional aspects and advantages of the present application will be given in the following description, some will become obvious from the following description, or be understood through the practice of the present application. Description of the Drawings
[0039] The above and / or additional aspects and advantages of the present application will become obvious and easy to understand from the following description of the embodiments in conjunction with the drawings, where:
[0040] Figure 1 is a schematic diagram of the principle of encrypting and decrypting file data using ICE;
[0041] Figure 2 is a schematic diagram of the complete implementation process of software-level FBE;
[0042] Figure 3 is a schematic diagram of the management scenario of the file encryption key based on the chip;
[0043] Figure 4It is a schematic diagram of the key hierarchy when FBE does not use a hardware encapsulation key;
[0044] Figure 5 It is a schematic diagram of the key hierarchy when FBE uses a hardware encapsulation key;
[0045] Figure 6 It is a schematic diagram of the structure of the first chip provided by the embodiments of the present application;
[0046] Figure 7 It is a schematic diagram of the structure of the second chip provided by the embodiments of the present application;
[0047] Figure 8 It is a schematic diagram of the structure of the third chip provided by the embodiments of the present application;
[0048] Figure 9 It is a schematic diagram of the software and hardware architecture for implementing file encryption and decryption technology provided by the embodiments of the present application;
[0049] Figure 10 It is a schematic diagram of the key processing flow provided by the embodiments of the present application Figure 1 ;
[0050] Figure 11 It is a schematic diagram of the key processing flow provided by the embodiments of the present application Figure 2 ;
[0051] Figure 12 It is a schematic diagram of the process flow of the first data processing method provided by the embodiments of the present application;
[0052] Figure 13 It is a schematic diagram of the process flow of the second data processing method provided by the embodiments of the present application;
[0053] Figure 14 It is a schematic diagram of the structure of a data processing device provided by the embodiments of the present application;
[0054] Figure 15 It is a schematic diagram of the structure of another data processing device provided by the embodiments of the present application;
[0055] Figure 16 It is a schematic diagram of the structure of an electronic device provided by the embodiments of the present application;
[0056] Figure 17 It is a schematic diagram of the structure of another electronic device provided by the embodiments of the present application. Detailed implementation manners
[0057] Embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to explain the present application, but should not be construed as limiting the present application.
[0058] In early operating systems, a Full-Disk Encryption (FDE) solution was provided to protect sensitive data in electronic files, and then it was updated to a File-based Encryption (FBE) solution, which adopted a more fine-grained file encryption method. A reference implementation of software-level FBE was provided in the open-source project of the operating system. However, once the operating system is attacked or the root permission is obtained, the file encryption key in memory will be leaked, thus triggering serious privacy and security risks.
[0059] In terms of hardware, in order to accelerate the encryption and decryption speed of electronic files and reduce the load of the Central Processing Unit (CPU), a dedicated Inline Crypto Engine (ICE) is usually implemented in the Universal Flash Storage (UFS) Host Controller (Host Controller, abbreviated as main control) in a chip (such as a System On Chip (SOC)) in an intelligent terminal.
[0060] As an example, the encryption and decryption principle of file data can be as Figure 1 shown, mainly including the following parts:
[0061] Figure 1Among them, eMMC refers to the Embedded Multi-Media Card; the Host controller driver is responsible for communicating with the storage device; the Controller interface is responsible for interacting with the Host controller; the Cryptoengine is responsible for encrypting and decrypting file data; the Algorithm supports multiple algorithms, such as the Advanced Encryption Standard-XTS Mode (abbreviated as AES-XTS), the Advanced Encryption Standard-Cipher Block Chaining Mode (abbreviated as AES-CBC), etc.; the Key size supports different lengths, such as 128 Bits, 256 bits, 512 bits; the Host controller is used to manage the data stream and interact with the Cryptoengine through the Controller interface.
[0062] Figure 1 Among them, the Flash memory is used to store data; the Device manager is responsible for managing the data read and write operations on the disk; Encrypted data: xyz refers to the encrypted file data, which is the encrypted data stored in the Flash memory.
[0063] The first part: The transmission process of file data: When the file data is sent from the Host controller to the storage device, first, the Controller interface passes the file data to the Crypto engine, and then, the Crypto engine encrypts the file data using the pre-programmed encryption context. Finally, the encrypted file data is sent to the off-chip storage unit outside the chip (such as the off-chip non-volatile storage unit).
[0064] The second part: The encryption / decryption process of file data.
[0065] The encryption process of file data: When the file data in plaintext form is sent from the Host controller to the disk storage device, the Crypto engine encrypts the file data using the pre-programmed encryption context.
[0066] Decryption process of file data: When the encrypted file data is read back from the disk to the Host controller, the Crypto engine decrypts the encrypted file data using the same encryption context to obtain the file data in plaintext form.
[0067] Part 3: Keyslot: A keyslot is a dedicated location or container in the Crypto engine for storing encryption contexts (including encryption keys, encryption algorithms, data unit sizes, etc.). Among them, the Crypto engine has a fixed number of keyslots, and these keyslots provide the necessary resources for secure and efficient encryption and decryption operations. The Kernel of the operating system has the permission to program the encryption context into these keyslots at any time.
[0068] Each read / write request sent to the disk can be marked with the index of a keyslot, and the Crypto engine will use the encryption context programmed into the keyslot marked by the read / write request to encrypt / decrypt the data in the read / write request.
[0069] That is, for the encryption process, the Host controller sends the file data to the Crypto engine, and the Crypto engine encrypts the file data using the encryption context in the specified keyslot. For the decryption process, the Device manager reads the encrypted file data back to the Host controller, and the Crypto engine decrypts the encrypted file data using the encryption context in the same keyslot.
[0070] In summary, the solution of using ICE (i.e., the Crypto engine) in the UFS main controller to execute the encryption and decryption process of file data has at least the following advantages: improving the encryption and decryption speed: ICE can directly encrypt / decrypt when the file data enters and exits the disk without the participation of the CPU, thus significantly improving the processing speed; reducing the CPU load: by handing over the encryption and decryption tasks to dedicated hardware, the burden on the CPU is reduced, and the overall system performance is improved; enhancing security: the file data is stored in ciphertext on the disk, and even if the disk is physically accessed, the file data cannot be easily read.
[0071] In terms of software, File-based Encryption (FBE) for intelligent terminal operating systems is a file-based encryption technology that provides encryption security protection for file data on intelligent devices. Among them, FBE can encrypt individual files or file groups, and users can only access the encrypted files after the intelligent device is unlocked.
[0072] Among them, when using file-level encryption, different keys can be used to encrypt different files, and encrypted files can also be decrypted separately. The smart terminal that supports file-level encryption can also support the direct startup function. When this function is enabled, the encrypted device will directly enter the lock screen after startup, so that users can quickly use important device functions, such as accessibility services and alarms.
[0073] As an example, the Android open source project provides a complete implementation process of software-level FBE in the Fourth Extended File System (abbreviated as Ext4) or Ext4 File System, and the Flash-Friendly File System (abbreviated as F2FS), as Figure 2 shown, mainly including the following steps:
[0074] Figure 2 In it, the user process in the User Space is responsible for file opening, reading, and writing operations, and the Virtual Disk Manager (VOLD) is responsible for operations related to the file system and encryption; the file system in the Kernel supports the encryption of Ext4 and F2FS, the file system encryption module (fsrypt) is responsible for file encryption and decryption, and the keyring is used to manage encryption keys; the block encryption module (blk_crypto) in the Block layer is responsible for block-level encryption and decryption, and the blk_crypto_profile (KeyslotManager) is used to manage key slots; the default key driver (dm-default-key) in the Driver layer provides default key management, and the UFS Driver is responsible for interacting with the UFS device (i.e., the off-chip storage unit).
[0075] Figure 2 In it, ICE in the Hardware layer is located in the UFS main controller and is responsible for hardware-accelerated encryption and decryption; the UFS Host Controller is used to manage the data transmission of the UFS device; the Reprogrammable Parameter Memory Block (abbreviated as RPMB) is used to store critical security parameters.
[0076] Step 1: The user process (User Progress) performs file operations through the file system (EXT4 / F2FS).
[0077] Step 2: The file system calls fsrypt to perform file encryption and decryption operations.
[0078] Step 3: fsrypt interacts with the keyring to obtain the encryption key and performs block-level encryption and decryption through blk_crypto.
[0079] Step 4: blk_crypto interacts with the blk_crypto_profile to manage the key slots.
[0080] Step 5: UFSDriver sends the encrypted file data to the UFS device (i.e., the off-chip storage unit).
[0081] Step 6: ICE performs hardware-accelerated encryption and decryption in the UFS host controller.
[0082] In the related technology, the management scenario of the file encryption key based on the chip is as Figure 3 shown. The file encryption key is stored in the memory of the operating system in plaintext and is set to the keyslot of UFS ICE through the driver. The file encryption key is easily leaked, thus triggering serious privacy and security risks.
[0083] Figure 3 In, FBEKey refers to the file encryption key, which is managed by the Keyslot Manager and passed to ICE by the UFS ICEDriver for encryption and decryption operations. This can ensure that the file data stored on the UFS device is encrypted during transmission and storage, thereby improving the security of the file data.
[0084] Among them, the key hierarchy when FBE does not use the hardware encapsulation key can be as Figure 4As shown, the FBE class key is a 64-byte plaintext key or original key, which is used to generate other keys; HKDF (HMAC-based Key Derivation Function, a secure key derivation function that can expand a master key into multiple subkeys) - Secure Hash Algorithm 512-bit (abbreviated as SHA512) uses the SHA-512 hash function to derive multiple subkeys from the top-level key; Key identifier is a 16-byte identifier used to identify a specific file or group of files; File contents encryption key is a 64-byte AES-256-XTS key used to encrypt file contents; Filenames encryption key is a 32-byte AES-256-CTS key used to encrypt file names.
[0085] Among them, the key hierarchy when FBE uses the hardware wrapping key can be as Figure 5 shown. The FBE class key is the wrapped top-level key; the Key Derivation Function (abbreviated as KDF) is used to derive other keys from the top-level key; the File contents encryption key (inline_encryption_key) is a 64-byte AES-256-XTS key used to encrypt file contents; the original encryption key (sw_secret) is a 32-byte original key used to further derive other keys; HKDF-SHA512 uses the SHA-512 hash function to derive multiple subkeys from sw_secret; key identifier is a 16-byte identifier used to identify a specific file or group of files; Filenames encryption key is a 32-byte AES-256-CTS key used to encrypt file names.
[0086] In summary, the file encryption key of the FBE solution exists in the operating system memory in plaintext form. Without hardware support, even if the hardware wrapping key feature is enabled, when the file encryption key is set to the keyslot of UFS ICE through the driver, the file encryption key is also in plaintext form and is easily attacked, resulting in key leakage.
[0087] In view of at least one of the problems existing in the above related technologies, the present application further proposes a chip, a data processing method, a device, an electronic device, and a storage medium.
[0088] The chip, data processing method, device, electronic device, and storage medium according to the embodiments of the present application will be described below with reference to the accompanying drawings.
[0089] Figure 6 FIG. 4 is a schematic structural diagram of the first chip provided by the embodiments of the present application.
[0090] In any one of the embodiments of the present application, Figure 6 the chip 60 in FIG. 9 can be integrated into electronic devices such as mobile terminals, tablet computers, personal computers, and Internet of Things (IoT) devices.
[0091] Among them, the mobile terminal is, for example, a hardware device with various operating systems such as in-vehicle devices, mobile phones, watches, wearable devices, and personal digital assistants.
[0092] As Figure 6 shown, the chip 60 includes a securely isolated area 601 and a first hardware engine 602 that are communicatively connected. Among them,
[0093] The securely isolated area 601 is configured to receive the encapsulated key sent by the first execution environment, perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key, configure the first derived key into the key slot in the first hardware engine 602, and send the second derived key to the second execution environment; wherein, the second derived key is used by the second execution environment to generate a key identifier.
[0094] Among them, the security level of the first execution environment is higher than that of the second execution environment, and the security level of the securely isolated area 601 is higher than that of the first execution environment. Exemplarily, the first execution environment is, for example, a Trusted Execution Environment (TEE), and the second execution environment is, for example, a Regular Execution Environment (REE). Exemplarily, the second execution environment can be the User Space in the operating system.
[0095] Among them, the encapsulated key, also known as the encapsulated encryption key (such as marked as wrapped fbe class key, abbreviated as wrapped_key), is obtained by encapsulating the encryption key in plain text form (denoted as the plain text key in the present application, such as marked as fbe_class_key).
[0096] Among them, the key identifier includes but is not limited to: key ID (identifier), key index, etc.
[0097] In an embodiment of the present application, when the secure enclave 601 receives the encapsulated key sent by the first execution environment, it may use a key derivation function (abbreviated as KDF) to perform key derivation on the encapsulated key to obtain a first derived key and a second derived key. Among them, the first derived key is used to encrypt and decrypt the file content. Exemplarily, the first derived key may be marked as ice_enc_key; the second derived key is used to further derive sub-keys. For example, the second derived key may be marked as sw_secret, and the sub-key may be a key identifier (key_identifier).
[0098] In the present application, the secure enclave 601 may configure the first derived key into a key slot in the first hardware engine 602. Taking the first hardware engine 602 as an ICE engine as an example, the secure enclave 601 may include an ICE Driver. The secure enclave 601 may use this ICE Driver to configure the first derived key into the key slot in the first hardware engine 602. Moreover, the secure enclave 601 may also send the second derived key to the second execution environment. Correspondingly, when the second execution environment receives the second derived key, it may perform key derivation based on the key derivation function according to the second derived key to obtain a first key identifier. Exemplarily, taking the first key identifier as a key index as an example, the second execution environment may perform key derivation according to the second derived key to obtain a second key identifier (such as a key identifier (key_identifier)), and convert the second key identifier to obtain the first key identifier (key index); among them, the key ID and the key index have a one-to-one correspondence relationship.
[0099] In the present application, the second execution environment may also send the first key identifier (key index) to the first hardware engine 602, and write the second key identifier (key_identifier) into the keyring of the kernel of the operating system.
[0100] The first hardware engine 602 is used to receive the first key identifier sent by the second execution environment, and associate the first key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0101] Among them, the first hardware engine 602 refers to a hardware engine used to perform encryption and decryption operations on files. Exemplarily, the first hardware engine 602 may be an ICE engine, and this ICE engine may be deployed in a UFS Host Controller.
[0102] In an embodiment of the present application, when the first hardware engine 602 receives the first key identifier sent by the second execution environment, it can associate the first key identifier with the above-mentioned key slot. Exemplarily, the key slot has identification information, such as a key slot number, and the first key identifier can be associated with the key slot number. Thus, in the present application, when the first hardware engine 602 receives a file read / write request, it can perform encryption and decryption operations on the file associated with the file read / write request based on the associated first key identifier and key slot.
[0103] In any one of the embodiments of the present application, the first hardware engine 602 can perform file encryption operations by adopting the following steps A to D:
[0104] Step A: The first hardware engine 602 receives a file write request and a third key identifier sent by the second execution environment; wherein, the third key identifier is obtained by the second execution environment through converting the key identifier read from the keyring of the operating system kernel.
[0105] Exemplarily, the third key identifier can be a key index, the key identifier stored in the keyring can be key_identifier, and the second execution environment can convert the key_identifier read from the keyring to obtain the key index.
[0106] Step B: In response to the file write request, the first hardware engine 602 queries the first key slot associated with the third key identifier.
[0107] Step C: The first hardware engine 602 encrypts the first file in the file write request based on the derived key configured internally through the first key slot, and marks the encrypted first file based on the third key identifier to obtain a first encrypted file.
[0108] Exemplarily, taking the third key identifier as the key index as an example, the key index can be written into the inode (index node) of the encrypted first file to obtain the first encrypted file. Among them, the inode is a core data structure specifically used to store file metadata (metadata) so that the file system can efficiently manage and access files.
[0109] Step D: Write the first encrypted file into the off-chip storage unit outside the chip.
[0110] Among them, the off-chip storage unit includes an off-chip non-volatile storage unit, such as a UFS-class hard disk storage, etc.
[0111] In any one of the embodiments of the present application, the first hardware engine 602 can perform file decryption operations by adopting the following steps E to H:
[0112] Step E: The first hardware engine 602 receives a file read request sent by the second execution environment, and reads a second encrypted file associated with the file read request from an off-chip storage unit outside the chip.
[0113] Step F: The first hardware engine 602 queries a second key slot associated with the fourth key identifier according to the fourth key identifier marked in the second encrypted file.
[0114] Exemplarily, the fourth key identifier may be a key index. The first hardware engine 602 may read the key index from the inode of the second encrypted file, and query the second key slot associated with the key index.
[0115] Step G: The first hardware engine 602 decrypts the second encrypted file based on the derived key configured internally through the second key slot to obtain a second file.
[0116] Step H: The first hardware engine 602 sends the second file to the second execution environment.
[0117] In any embodiment of the present application, the off-chip storage unit outside the chip does not lose power when powered off, that is, in response to the power-off or power failure of the electronic device running the chip, the stored data in the off-chip storage unit is retained to improve the effectiveness of file data access and the effectiveness of file encryption and decryption.
[0118] In summary, the encryption and decryption operations of the file are both executed by the first hardware engine 602 with relatively high security inside the chip, which can improve the security of file data. And it can ensure that the file data stored in the off-chip storage unit is encrypted during transmission and storage, thereby further improving the security of file data. Exemplarily, the registers in the key slot of the first hardware engine 602 can be configured to only allow access by the secure partition 601, and the first execution environment and the second execution environment with relatively low security do not have permission to access the registers in the key slot, which can prevent the leakage of the derived key configured in the key slot, and further improve the security of file data and protect the privacy of users.
[0119] In the chip 60 according to the embodiment of the present application, an encapsulation mechanism is adopted to enhance the security (i.e., encapsulation) of the encryption key in plaintext form (denoted as the plaintext key in the present application), and an encapsulated key is obtained, so that the original plaintext key is completely invisible in the first execution environment and the second execution environment with relatively low security, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by a secure enclave with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet the actual business requirements.
[0120] The embodiment of the present application provides another chip. Figure 7 It is a schematic structural diagram of the second chip provided by the embodiment of the present application.
[0121] As Figure 7 shown, the chip 60 includes a secure enclave 601 and a first hardware engine 602 that are communicatively connected. Among them, the secure enclave 601 includes a random number generator 6011, a cryptographic algorithm engine 6012, and an internal storage unit 6013. Among them, the random number generator 6011 is used to generate a random number in response to the power-on initialization of the electronic device running the chip; the cryptographic algorithm engine 6012 is used to generate an ephemeral key according to the random number; the secure enclave 601 is used to write the ephemeral key into the internal storage unit 6013.
[0122] The secure enclave 601 is used to receive the encapsulated key sent by the first execution environment. Among them, the encapsulated key is obtained by encapsulating the plaintext key with the ephemeral key generated by the secure enclave 601; based on the encapsulated key, key derivation is performed to obtain a first derived key and a second derived key, and the first derived key is configured into the key slot in the first hardware engine 602, and the second derived key is sent to the second execution environment; among them, the second derived key is used by the second execution environment to generate a first key identifier.
[0123] It should be noted that the explanations of the first execution environment, the second execution environment, and the secure enclave 601 in the foregoing embodiments are also applicable to this embodiment, and will not be repeated here.
[0124] Among them, the internal storage unit 6013 includes but is not limited to: internal random access memory (Random Access Memory, abbreviated as RAM), multi-level cache, registers, etc. Exemplarily, the internal storage unit 6013 may be a volatile storage unit inside the secure enclave 601.
[0125] In an embodiment of the present application, the secure enclave 601 may read a temporary key from the internal storage unit 6013, and use the temporary key to decrypt the wrapped key (abbreviated as wrapped_key) to obtain the plaintext key (fbe_class_key). Then, using a key derivation function, the plaintext key (fbe_class_key) is used for key derivation to obtain a first derived key (ice_enc_key) and a second derived key (sw_secret). After that, the secure enclave 601 may configure the first derived key into a key slot in the first hardware engine 602. Exemplarily, the secure enclave 601 may also include an ICE driver (i.e., ICE Driver), and the secure enclave 601 may configure the first derived key into the key slot in the first hardware engine 602 through this ICE driver. Moreover, the secure enclave 602 may also send the second derived key to the second execution environment. Correspondingly, when the second execution environment receives the second derived key, it may perform key derivation based on the key derivation function according to the second derived key to obtain a second key identifier, and convert the second key identifier to obtain a first key identifier, send the first key identifier to the first hardware engine 602, and write the second key identifier into the key ring of the kernel of the operating system.
[0126] The first hardware engine 602 is configured to receive the first key identifier sent by the second execution environment, and associate the first key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0127] It should be noted that the explanations of the first hardware engine 602 in the foregoing embodiments also apply to this embodiment, and will not be elaborated here.
[0128] In summary, in the chip 60 of the embodiment of the present application, the wrapped key passed in by the first execution environment is decrypted and key-derived by the secure enclave 601 with a relatively high security level, and then configured into the corresponding key slot, which can further improve the security of the key.
[0129] An embodiment of the present application provides another chip. Figure 8 It is a schematic structural diagram of the third chip provided by the embodiment of the present application.
[0130] Such as Figure 8As shown, the chip 60 includes: a first hardware engine 602 and a second hardware engine 603 communicatively connected to the secure partition 601. Among them, the secure partition 601 is used to generate a temporary key and write the temporary key into the key register of the second hardware engine 603; the second hardware engine 603 is used to generate a plaintext key.
[0131] Among them, the second hardware engine 603 can also be referred to as a hardware crypto engine (Crypto Engine).
[0132] Among them, the key register (such as marked as the EpKey register) in the second hardware engine 603 does not allow the application processor (or referred to as the application central processing unit (Application Central Processing Unit, abbreviated as ACPU)) to access. The application processor is used to run the operating system and applications in the electronic device. Thus, even if the application processor core is invaded, the security of the temporary key can be guaranteed, and the situation of the encapsulated key being cracked due to the leakage of the temporary key and then the plaintext key being leaked can be avoided.
[0133] As a possible implementation manner, in response to the chip being in the sleep state, the key register in the second hardware engine 603 does not lose power, that is, during the sleep period of the chip, the stored data in the key register is retained.
[0134] The secure partition 601 is further used to receive the encapsulated key sent by the first execution environment. The encapsulated key is obtained by encapsulating the plaintext key generated by the second hardware engine 603 with the temporary key generated by the secure partition 601; perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key, configure the first derived key into the key slot in the first hardware engine 602, and send the second derived key to the second execution environment; the second derived key is used for the second execution environment to generate a first key identifier.
[0135] As a possible implementation, the secure enclave 601 can read a temporary key from the internal storage unit 6013, and use the temporary key to decrypt the encapsulated key (also known as the wrapped full - disk encryption (FBE) class key, simply referred to as the wrapped_key) to obtain the plaintext key (fbe_class_key) generated by the second hardware engine 603. Then, using a key derivation function, the secure enclave 601 derives keys from the plaintext key (fbe_class_key) to obtain a first derived key (ice_enc_key) and a second derived key (sw_secret). After that, the secure enclave 601 can configure the first derived key into a key slot in the first hardware engine 602. Exemplarily, the secure enclave 601 may also include an ICE driver (i.e., ICE Driver), and the secure enclave 601 can configure the first derived key into the key slot in the first hardware engine 602 through this ICE driver. Moreover, the secure enclave 602 can also send the second derived key to the second execution environment. Correspondingly, when receiving the second derived key, the second execution environment can, based on the key derivation function, derive keys from the second derived key to obtain a second key identifier, convert the second key identifier to obtain a first key identifier, send the first key identifier to the first hardware engine 602, and write the second key identifier into the key ring of the kernel of the operating system.
[0136] In any one of the embodiments of the present application, the key ring of the kernel of the operating system disappears when powered off, that is, in response to the power - off of the electronic device running the chip, the stored data in the key ring is cleared.
[0137] The first hardware engine 602 is configured to receive the first key identifier sent by the second execution environment, and associate the first key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0138] It should be noted that the explanations for the first hardware engine 602 in the foregoing embodiments also apply to this embodiment and will not be elaborated here.
[0139] In any one of the embodiments of the present application, the encapsulated key is read by the first execution environment from the key ring in the kernel of the operating system; the second hardware engine 603 is configured to perform the following steps I to K:
[0140] Step I: The second hardware engine 603 receives a first ciphertext key sent by the second execution environment through the first execution environment. The first ciphertext key is obtained by the second execution environment in response to each power-on of the electronic device running the chip, reading the second ciphertext key from an off-chip storage unit outside the chip, and decrypting the second ciphertext key by invoking a secure encryption / decryption key.
[0141] The secure encryption / decryption key can be a key maintained by a key management client application (keymint client application, abbreviated as keymint CA) running in the second execution environment. Exemplarily, the secure encryption / decryption key can be a KeystoreKey maintained by keymint CA.
[0142] That is, in the case of each power-on of the electronic device running the chip, the second execution environment can read the second ciphertext key from an off-chip memory outside the chip, and decrypt the second ciphertext key by invoking the secure encryption / decryption key (KeystoreKey) (i.e., decryptWithKeystoreKey) to obtain the first ciphertext key, and send the first ciphertext key to the second hardware engine 603 through the first execution environment.
[0143] Step J: The second hardware engine 603 decrypts the first ciphertext key according to a third derived key to obtain a plaintext key. The third derived key is obtained by performing key derivation on the hardware unique key (Hardware Unique Key, abbreviated as HUK) of the chip using a key derivation function.
[0144] The HUK can be stored in the one-time programmable memory (One-Time Programmable Memory or One-Time Programmable Storage, abbreviated as OTP) of the chip, which can improve the integrity and security of the HUK.
[0145] Step K: The second hardware engine 603 reads a temporary key from the key register, encapsulates the plaintext key using the temporary key to obtain an encapsulated key, and writes the encapsulated key into the keyring in the kernel of the operating system.
[0146] Therefore, in the present application, the first execution environment can read the encapsulation key from the keyring in the kernel of the operating system and send the encapsulation key to the secure enclave 601, so that the secure enclave 601 can decrypt the encapsulation key based on the temporary key to obtain the plaintext key, and perform key derivation on the plaintext key based on the key derivation function to obtain the first derived key and the second derived key, and configure the first derived key into the key slot in the first hardware engine 602, and send the second derived key to the second execution environment. Correspondingly, when the second execution environment receives the second derived key, it can perform key derivation based on the second derived key according to the key derivation function to obtain the second key identifier, and convert the second key identifier to obtain the first key identifier, and send the first key identifier to the first hardware engine 602, so that the first hardware engine 602 can associate the first key identifier with the key slot, and perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0147] In any embodiment of the present application, before performing steps I to K, the second hardware engine 603 is further configured to perform the following steps L to N:
[0148] Step L: The second hardware engine 603 generates a plaintext key in response to the first power-on or first unpacking of the electronic device running the chip.
[0149] Exemplarily, the second hardware engine 603 may also include a random number generator. The second hardware engine 603 can generate a random number through this random number generator and generate a plaintext key according to this random number.
[0150] Step M: The second hardware engine 603 performs key derivation on the HUK of the chip using the key derivation function to obtain a third derived key (for example, labeled as HUK').
[0151] Step N: The second hardware engine 603 encrypts the plaintext key using the third derived key (HUK') to obtain a first ciphertext key, and sends the first ciphertext key to the second execution environment. Correspondingly, after receiving the first ciphertext key, the second execution environment can encrypt the first ciphertext key by calling the secure encryption and decryption key (KeystoreKey) (i.e., encryptWithKeystoreKey) to obtain a second ciphertext key, and write the second ciphertext key into the off-chip storage unit outside the chip.
[0152] Therefore, in the present application, every time the electronic device running the chip is powered on, the second execution environment can read the second ciphertext key from the off-chip storage unit to trigger the execution of the above steps I to K based on the second ciphertext key.
[0153] In any one of the embodiments of the present application, the second execution environment can write the second ciphertext key into an off-chip storage unit outside the chip through the following steps O to Q:
[0154] Step O: Determine an encryption policy adapted to the access request; wherein, the access request includes a file write request and a file read request.
[0155] Among them, the encryption policies include, but are not limited to: Credential Encrypted (CE for short), Device Encrypted (DE for short); wherein, CE refers to encryption based on user credentials, that is, only when the user provides the correct authentication information can the file be decrypted and accessed; DE refers to the encryption of the entire device or the entire partition. In this mode, all user file data will be encrypted, regardless of whether user credentials are set.
[0156] Step P: Determine a target storage directory that matches the encryption policy from multiple storage directories of the off-chip storage unit.
[0157] That is, data is stored in different storage directories of the off-chip storage unit according to different encryption policies, and this data will not be lost due to power failure of the electronic device.
[0158] Step Q: Write the second ciphertext key into the target storage directory of the off-chip storage unit.
[0159] In summary, different encryption policies mean different access control mechanisms. For example, file data encrypted by CE requires user authentication to access, while file data encrypted by DE relies on device-level protection, which helps prevent unauthorized access and enhance security. Classifying and storing keys in different directories according to encryption policies makes key management and auditing clearer and more straightforward. Moreover, standardized encryption policies and storage paths reduce the possibility of configuration errors, lower the complexity of the system, and potential security risks.
[0160] For the chip 60 according to the embodiment of the present application, the key management part is sunk from the application processor and the second execution environment to the secure enclave 601 and the second hardware engine (Crypto Engine) of the chip 60, so as to enhance the security of the key, ensuring that the key does not leave the hardware (the application processor is completely invisible, and the key in plaintext form will not appear in the off-chip storage unit), improving the security level of the key, and helping to prevent cold boot attacks (a method of attack that takes advantage of the data residue phenomenon after the power-off of the volatile storage unit outside the chip (such as Double Data Rate SDRAM (Synchronous Dynamic Random Access Memory), simply referred to as DDR)) and certain online attacks (the attacker may be able to leak the operating system memory without a full-scale intrusion of the device).
[0161] In any one of the embodiments of the present application, the present application provides a file encryption and decryption technology with more secure keys to prevent cold boot attacks and certain online attacks. Exemplarily, the software and hardware architecture for implementing the file encryption and decryption technology can be as Figure 9 shown, where the secure enclave is a dedicated security subsystem integrated into the chip. Moreover, the secure enclave is independent of the main processor of the chip, has its own central processing unit (CPU) core and internal storage unit (such as internal RAM), and can provide additional security protection. Even if the A CPU core is invaded, it can protect the security of sensitive data.
[0162] Among them, the secure enclave generally may further include a secure boot read-only memory (ROM), a dedicated random number generator, and a cryptographic algorithm engine (for generating an ephemeral key), etc.
[0163] Among them, FBE TA is the abbreviation of File - Based Encryption Trusted Application, which runs in the first execution environment; keymint TA is the trusted application for key management, which runs in the first execution environment; FBE SA is the File - Based Encryption Secure Application, which runs in the secure enclave; FBE CA is the File - Based Encryption client application, which runs in the second execution environment and corresponds to FBE TA; keymint CA is the client application for key management, which runs in the second execution environment and corresponds to keymint TA.
[0164] Among them, the security level of the secure enclave is higher than that of the first execution environment, and the security level of the first execution environment is higher than that of the second execution environment.
[0165] Among them, the improved parts of the chip include: making slight design changes to the Secure Enclave and the second Crypto Engine, and adding an EpKey register; among them, the EpKey register is used to write data once during the initialization of the secure enclave. When the chip is in the sleep state or the power - down state, the EpKey register does not lose power, and it is not readable and write - locked by the ACPU software; the keyslot register in the ICE engine of the UFS host controller is configured to be accessible only by the secure enclave and not by the ACPU.
[0166] As an example, the file encryption and decryption technology provided by this application mainly includes the following two parts:
[0167] The first part: KeyMint generates / converts keys. Generate a storage key through KeyMint, and convert the storage key into a temporary key. The key processing flow chart can be as Figure 10 shown, mainly including the following steps:
[0168] Step 1: During each power - on initialization stage of the electronic device, use a true random number generator (TRNG) inside the secure enclave to generate a random number, and use this random number to generate an Ephemeral Key, and set it into the EpKey register in the second Crypto Engine.
[0169] Exemplarily, the secure enclave can use the TRNG to generate a random number, and use the cryptographic algorithm engine to generate an Ephemeral Key according to this random number.
[0170] Step 2: When the electronic device is first unpacked and used, VOLD (Virtual Disk Manager) in the second execution environment (such as User Space in the operating system) can call KeyMint CA and KeyMint TA through Keystore (Key Storage). The process is shown in Figure 10 ①generateStorageKey( Figure 10 shown by the bold dashed line in
[0171] Step 2.1: KeyMint TA can use the TRNG in the second hardware engine (Crypto Engine) to generate a fbe_class_key in plaintext form (denoted as the plaintext key in this application);
[0172] Step 2.2: Use the HUK in the one-time programmable memory (OTP) of the chip to perform key derivation to obtain HUK', and use HUK' to encrypt the fbe_class_key in plaintext form to obtain a fbe_class_key_blob;
[0173] Step 2.3: Return the fbe_class_key_blob to the second execution environment side, and then call encryptWithKeystoreKey maintained by keymintCA to encrypt the fbe_class_key_blob to obtain encrypted_key, and save it to the specified directory of the off-chip storage unit (denoted as the target storage directory in this application). Among them, the storage directories corresponding to CE and DE are different. Among them, the off-chip storage unit does not disappear when powered off.
[0174] Step 3: When the electronic device is powered on each time subsequently, it is necessary to use the encrypted_key saved in the off-chip storage unit, and call decryptWithKeystoreKey to decrypt the encrypted_key to obtain the fbe_class_key_blob, and use it as a parameter to call ②convertStorageKeyToEphemeral( Figure 10 shown by the bold solid line in
[0175] Step 3.1: KeyMint TA is responsible for passing the fbe_class_key_blob to the second hardware engine (CryptoEngine);
[0176] Step 3.2: The second hardware engine decrypts the fbe_class_key_blob using HUK' to obtain the fbe_class_key in plaintext form.
[0177] Step 3.3: The second hardware engine re-encrypts or encapsulates the fbe_class_key using the ephemeral key in the EpKey register to obtain the wrapped fbe class key (abbreviated as wrapped_key), returns it to the second execution environment, and installs it into the keyring of the kernel of the operating system. Here, the keyring is in memory and disappears when power is off.
[0178] Second part: FBE setting / derived key. The FBE TA sets the Keyslot and obtains the derived key secret through the FBE TA. The processing flow chart of the key can be as Figure 11 shown, mainly including the following steps:
[0179] Step 1. Prerequisite: The ephemeral key has been generated in the internal storage unit of the Secure Enclave and has been set into the EpKey register of the second hardware engine (Crypto Engine). Before the electronic device encrypts or decrypts a file, the Secure Enclave takes out the wrapped fbe class key (i.e., wrapped_key) from the keyring of the kernel and calls the FBE CA: Figure 11 in ① to set the keyslot (as shown by the bold dashed line in Figure 11 ), mainly including the following sub-steps:
[0180] Step 1.1: Pass the wrapped fbe class key (i.e., wrapped_key) to the Secure Enclave through the FBE TA.
[0181] Step 1.2: Inside the Secure Enclave, use the EphemeralKey previously saved in the internal storage unit to decrypt or de-encapsulate the wrapped fbe class key to obtain the fbe_class_key in plaintext form.
[0182] Step 1.3: Use the KDF algorithm to derive the keys from the fbe_class_key to obtain the ice_enc_key and sw_secret.
[0183] Step 1.4: Set ice_enc_key into the keyslot of the first hardware engine (ICE engine) of the UFSHostController through the ICE Driver.
[0184] Step 2: Figure 11 ② in Figure 11 (as shown by the bold solid line in
[0185] Obtain the derived sw_secret: Obtain sw_secret from the Secure Enclave through the FBE CA and FBETA, which mainly includes the following sub-steps:
[0186] Step 2.1: After obtaining sw_secret on the second execution environment side, perform HKDF derivation to obtain key_identifier, and install key_identifier into the keyring.
[0187] Step 2.2: key_identifier can be converted into a key index and recorded in the inode information of each file.
[0188] In summary, this application enhances the security of the encryption class key (FBE Class Key) in plaintext form of the file, and can make the FBE Class Key invisible in plaintext in the ACPU (including the first execution environment, such as TEE):
[0189] 1) Generation: The Secure Enclave generates a random number, uses the random number to generate an Ephemeral Key for encapsulation, and the second hardware engine encapsulates the plaintext key FBE Class Key based on the Ephemeral Key, and returns the encrypted form of the encapsulation key for the first execution environment to use.
[0190] 2) Configuration: The keyslot configuration of the FBE Class Key is moved down to be managed in the Secure Enclave. The first execution environment passes in the encapsulated FBE Class key, which is denoted as the encapsulation key in this application. The Secure Enclave unpacks the encapsulation key, performs key derivation, and configures it into the corresponding keyslot.
[0191] 3) Storage: The second hardware engine (Crypto Engine) unpacks the encrypted key, repackages it based on HUK', and returns it to the ACPU for storage in a specified directory of the off-chip storage unit.
[0192] 4) Loading: The ACPU extracts the encrypted key packaged with HUK' from the specified directory of the off-chip storage unit. The second hardware engine (Crypto Engine) unpacks it into a plaintext key, and then repackages it into an encrypted key using the Ephemeral Key and returns it to the ACPU (including the first execution environment, such as the TEE) for use.
[0193] 5) Usage: The ACPU (including the first execution environment, such as the TEE) holds an encrypted key packaged with the Ephemeral Key and can only perform encryption and decryption operations based on the second hardware engine (Crypto Engine), and cannot obtain the plaintext key.
[0194] In the technical solution provided by this application, since the Secure Enclave and the second hardware engine (Crypto Engine) are standard configurations of modern mobile chips, this application only makes minor design changes to the chip, such as only adding an EpKey register, and the chip implementation cost is relatively small. By sinking the key management parts of FBE and KeyMint from the ACPU (including the first execution environment, such as the TEE) to the Secure Enclave and the second hardware engine (Crypto Engine) in the chip, the security of the key is enhanced, ensuring that the key does not leave the hardware (the ACPU is completely invisible, and the plaintext key does not appear in the off-chip storage unit), improving the security level of the key, and helping to prevent cold boot attacks and certain online attacks.
[0195] Figure 12 It is a schematic flow diagram of the first data processing method provided by the embodiments of this application.
[0196] The data processing method of the embodiments of this application can be applied to the Secure Enclave in the chip. Among them, the chip can run in any electronic device, or the chip can be integrated into any electronic device.
[0197] It should be noted that the explanations of the chip in any of the foregoing embodiments also apply to the Secure Enclave in this embodiment, and their implementation principles are similar and will not be elaborated here.
[0198] Among them, the electronic device can be a mobile terminal, an Internet of Things (IOT) device, etc. The mobile terminal can be a hardware device with various operating systems such as in-vehicle devices, mobile phones, watches, wearable devices, tablet computers, personal digital assistants, etc.
[0199] It should be noted that this data processing method can be executed alone, or it can also be executed in combination with any one of the embodiments in this application or the possible implementation manners in the embodiments, or it can also be executed in combination with any one of the technical solutions in the related technologies. The embodiments of this application do not limit this.
[0200] As Figure 12 shown, this data processing method may include the following steps S1201 to S1203:
[0201] Step S1201: Receive the encapsulation key sent by the first execution environment, and perform key derivation based on the encapsulation key to obtain a first derived key and a second derived key.
[0202] Step S1202: Configure the first derived key into the key slot in the first hardware engine.
[0203] Step S1203: Send the second derived key to the second execution environment; wherein, the second derived key is used for the second execution environment to generate a first key identifier; wherein, the first key identifier is used to be associated with the key slot in the first hardware engine, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0204] In any one of the embodiments of this application, the encapsulation key is obtained by encapsulating the plaintext key with a temporary key. Step S1201 may include: reading the temporary key, and performing de-encapsulation on the encapsulation key with the temporary key to obtain the plaintext key; performing key derivation on the plaintext key to obtain a first derived key and a second derived key.
[0205] It should be noted that the explanations of the chip, the first hardware engine, the first execution environment, and the second execution environment in any of the foregoing embodiments also apply to the data processing method executed in the secure enclave in this embodiment, and their implementation principles are similar, so details are not described here.
[0206] The data processing method of the embodiment of the present application adopts an encapsulation mechanism to enhance the security (i.e., encapsulation) of the encryption key in plaintext form (denoted as the plaintext key in the present application), and obtains an encapsulated key, which can make the original plaintext key completely invisible in the first execution environment and the second execution environment with relatively low security, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by a secure enclave with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet the actual business needs.
[0207] Figure 13 It is a schematic flowchart of the second data processing method provided by the embodiment of the present application.
[0208] The data processing method of the embodiment of the present application can be applied to the first hardware engine in a chip. Among them, the chip can run in any electronic device, or the chip can be integrated into any electronic device.
[0209] It should be noted that the explanations of the chip in any of the foregoing embodiments also apply to the first hardware engine in this embodiment, and their implementation principles are similar, so they will not be elaborated here.
[0210] It should also be noted that this data processing method can be executed alone, or it can be executed together with any one of the embodiments in the present application or the possible implementation manners in the embodiments, or it can also be executed together with any one of the technical solutions in the related technologies. The embodiments of the present application do not limit this.
[0211] As Figure 13 shown, this data processing method may include the following steps S1301 to S1303:
[0212] Step S1301, in response to a configuration operation triggered by a secure enclave, configure a first derived key into the key slot in the first hardware engine; wherein, the configuration operation is that the secure enclave responds to the received encapsulated key from the first execution environment, performs key derivation based on the encapsulated key to obtain a first derived key and a second derived key, and is generated according to the first derived key.
[0213] Step S1302, receive a first key identifier sent by the second execution environment, where the first key identifier is generated by the second execution environment in response to the second derived key sent by the secure enclave according to the second derived key.
[0214] Step S1303, associate the first key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0215] In any one of the embodiments of the present application, the first key identifier is obtained by performing key derivation on the second derived key to obtain a second key identifier and then performing conversion on the second key identifier. The second execution environment is further configured to write the second key identifier into the keyring of the kernel of the operating system. Step S1303 may include: receiving a file write request and a third key identifier sent by the second execution environment; wherein the third key identifier is obtained by the second execution environment performing conversion on the key identifier read from the keyring; querying a first key slot associated with the third key identifier; encrypting a first file in the file write request based on the configured derived key through the first key slot, and marking the encrypted first file based on the third key identifier to obtain a first encrypted file; and writing the first encrypted file into an off-chip storage unit outside the chip.
[0216] In any one of the embodiments of the present application, receive a file read request sent by the second execution environment, and read a second encrypted file associated with the file read request from an off-chip storage unit outside the chip; determine a second key slot associated with a fourth key identifier according to the fourth key identifier marked on the second encrypted file; decrypt the second encrypted file based on the configured derived key through the second key slot to obtain a second file; and send the second file to the second execution environment.
[0217] It should be noted that the explanations of the chip, the first hardware engine, the secure partition, the first execution environment, and the second execution environment in any of the foregoing embodiments also apply to the data processing method executed by the first hardware engine in this embodiment. The implementation principles are similar and will not be elaborated here.
[0218] The data processing method of the embodiments of the present application adopts an encapsulation mechanism to perform security enhancement (i.e., encapsulation) on an encryption key in plaintext form (denoted as a plaintext key in the present application) to obtain an encapsulated key, which can make the original plaintext key completely invisible in the first execution environment and the second execution environment with relatively low security, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by a secure partition with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet actual business requirements.
[0219] To implement the above embodiments, the embodiments of the present application further propose a data processing device.
[0220] Figure 14 It is a schematic structural diagram of a data processing device provided by an embodiment of the present application.
[0221] As Figure 14As shown in the figure, the data processing device 1400 can be applied to a secure enclave, including: a receiving module 1410, a derivation module 1420, a configuration module 1430, and a sending module 1440.
[0222] Among them, the receiving module 1410 is used to receive the encapsulated key sent by the first execution environment;
[0223] The derivation module 1420 is used to perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key;
[0224] The configuration module 1430 is used to configure the first derived key into the key slot in the first hardware engine;
[0225] The sending module 1440 is used to send the second derived key to the second execution environment; wherein, the second derived key is used for the second execution environment to generate a first key identifier; wherein, the first key identifier is used to be associated with the key slot in the first hardware engine, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
[0226] Further, in an implementation manner of the embodiment of the present application, the encapsulated key is obtained by encapsulating the plaintext key with a temporary key; the derivation module 1420 is used to: read the temporary key, and use the temporary key to unencapsulate the encapsulated key to obtain the plaintext key; perform key derivation on the plaintext key to obtain a first derived key and a second derived key.
[0227] It should be noted that the foregoing explanation of the data processing method embodiment executed by the secure enclave also applies to the data processing device in this embodiment, and will not be elaborated here.
[0228] In the data processing device of the embodiment of the present application, an encapsulation mechanism is adopted to perform security enhancement (i.e., encapsulation) on the encryption key in plaintext form (denoted as plaintext key in this application) to obtain the encapsulated key, so that the original plaintext key is completely invisible in the first execution environment and the second execution environment with relatively low security, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by the secure enclave with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet the actual business requirements.
[0229] To implement the above embodiment, the embodiment of the present application also proposes a data processing device.
[0230] Figure 15 It is a schematic structural diagram of another data processing device provided by the embodiment of the present application.
[0231] As shown Figure 15 in the figure, the data processing device 1500 can be applied to a first hardware engine, including: a configuration module 1510, a receiving module 1520, and a processing module 1530.
[0232] Among them, the configuration module 1510 is configured to, in response to a configuration operation triggered by a secure enclave, configure a first derived key into a key slot in the first hardware engine; wherein, the configuration operation is that the secure enclave, in response to receiving an encapsulated key sent by a first execution environment, performs key derivation based on the encapsulated key to obtain a first derived key and a second derived key, and is generated according to the first derived key;
[0233] The receiving module 1520 is configured to receive a first key identifier sent by a second execution environment, wherein the first key identifier is generated by the second execution environment in response to the second derived key sent by the secure enclave according to the second derived key;
[0234] The processing module 1530 is configured to associate the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and key slot.
[0235] Further, in an implementation manner of the embodiment of the present application, the first key identifier is obtained by performing key derivation on the second derived key to obtain a second key identifier and performing conversion on the second key identifier. The second execution environment is further configured to write the second key identifier into a key ring of the kernel of the operating system. The processing module 1530 is configured to: receive a file write request and a third key identifier sent by the second execution environment; wherein the third key identifier is obtained by the second execution environment performing conversion on the key identifier read from the key ring; query a first key slot associated with the third key identifier; encrypt a first file in the file write request based on the configured derived key through the first key slot, and mark the encrypted first file based on the third key identifier to obtain a first encrypted file; write the first encrypted file into an off-chip storage unit outside the chip.
[0236] In an implementation manner of the embodiment of the present application, the processing module 1530 is configured to: receive a file read request sent by the second execution environment, and read a second encrypted file associated with the file read request from an off-chip storage unit outside the chip; query a second key slot associated with a fourth key identifier according to the fourth key identifier marked on the second encrypted file; decrypt the second encrypted file based on the configured derived key through the second key slot to obtain a second file; send the second file to the second execution environment.
[0237] It should be noted that the foregoing explanation of the data processing method embodiment executed by the first hardware engine is also applicable to the data processing device in this embodiment, and will not be elaborated here.
[0238] In the data processing device according to the embodiment of the present application, an encapsulation mechanism is adopted to perform security enhancement (i.e., encapsulation) on the encryption key in plaintext form (denoted as the plaintext key in the present application), and an encapsulated key is obtained. It can be realized that in the first execution environment and the second execution environment with relatively low security, the original plaintext key is completely invisible, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by a secure enclave with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet the actual business requirements.
[0239] To implement the above embodiment, the present application also proposes an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the data processing method described in any of the foregoing embodiments is implemented.
[0240] Figure 16 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. For example, the electronic device 1600 may be a vehicle, a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0241] Refer to Figure 16 , the electronic device 1600 may include one or more of the following components: a processing component 1602, a memory 1604, a power component 1606, a multimedia component 1608, an audio component 1610, an input / output (I / O) interface 1612, a sensor component 1614, and a communication component 1616.
[0242] The processing component 1602 generally controls the overall operation of the electronic device 1600, such as operations associated with display, telephone call, data communication, camera operation, and recording operation. The processing component 1602 may include one or more processors 1620 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 1602 may include one or more modules to facilitate the interaction between the processing component 1602 and other components. For example, the processing component 1602 may include a multimedia module to facilitate the interaction between the multimedia component 1608 and the processing component 1602.
[0243] The memory 1604 is configured to store various types of data to support the operation of the electronic device 1600. Examples of such data include instructions for any application or method operating on the electronic device 1600, contact data, phone book data, messages, pictures, videos, and the like. The memory 1604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0244] The power component 1606 provides power to the various components of the electronic device 1600. The power component 1606 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 1600.
[0245] The multimedia component 1608 includes a screen that provides an output interface between the electronic device 1600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 1608 includes a front camera and / or a rear camera. When the electronic device 1600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0246] The audio component 1610 is configured to output and / or input audio signals. For example, the audio component 1610 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 1600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 1604 or transmitted via the communication component 1616. In some embodiments, the audio component 1610 further includes a speaker for outputting audio signals.
[0247] The I / O interface 1612 provides an interface between the processing component 1602 and a peripheral interface module, and the peripheral interface module may be a keyboard, a click wheel, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a power button, and a lock button.
[0248] The sensor component 1614 includes one or more sensors for providing an assessment of various aspects of the state of the electronic device 1600. For example, the sensor component 1614 can detect the open / closed state of the electronic device 1600, the relative positioning of components, such as the display and keypad of the electronic device 1600. The sensor component 1614 can also detect a change in the position of the electronic device 1600 or a component of the electronic device 1600, the presence or absence of user contact with the electronic device 1600, the orientation or acceleration / deceleration of the electronic device 1600, and a change in the temperature of the electronic device 1600. The sensor component 1614 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 1614 can also include a light sensor, such as a Complementary Metal-Oxide-Semiconductor (CMOS) or a Charge-Coupled Device (CCD) image sensor, for use in imaging applications. In some embodiments, the sensor component 1614 can further include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0249] The communication component 1616 is configured to facilitate communication between the electronic device 1600 and other devices in a wired or wireless manner. The electronic device 1600 can access a communication standard-based wireless network, such as WiFi, 4G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component 1616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1616 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra-Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0250] In an exemplary embodiment, the electronic device 1600 can be implemented by one or more Application-Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field-Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.
[0251] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1604 including instructions, and the above instructions can be executed by a processor 1620 of the electronic device 1600 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, Random Access Memory (RAM), Compact Disc Read-Only Memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0252] To implement the above embodiments, the present application also proposes another electronic device.
[0253] Figure 17Schematic diagram of another electronic device provided by an embodiment of the present application.
[0254] As Figure 17 shown, the electronic device 170 includes a first execution environment 171, a chip 60, and a second execution environment 172 that are communicatively connected. Among them,
[0255] The first execution environment 171 is configured to send an encapsulation key to the chip 60;
[0256] The chip 60 is configured to perform key derivation based on the encapsulation key to obtain a first derived key and a second derived key, configure the first derived key into the key slot of the chip 60, and send the second derived key to the second execution environment 172;
[0257] The second execution environment 172 is configured to generate a key identifier according to the second derived key and send the key identifier to the chip 60;
[0258] The chip 60 is further configured to associate the key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated key identifier and key slot.
[0259] It should be noted that the explanations of the chip, the first hardware engine, the secure partition, the first execution environment, and the second execution environment in any of the foregoing embodiments also apply to this embodiment, and will not be repeated here.
[0260] The electronic device 170 of the embodiment of the present application adopts an encapsulation mechanism to enhance the security (i.e., encapsulation) of the encryption key in plaintext form (denoted as the plaintext key in this application) to obtain an encapsulation key, which can make the original plaintext key completely invisible in the first execution environment and the second execution environment with relatively low security, thereby greatly enhancing the security of the key. Further, the key derivation operation is performed by the secure partition with relatively high security, and the derived key is directly configured into the key slot of the first hardware engine, which not only ensures the high security of the key, but also improves the efficiency of file encryption and decryption by using hardware acceleration, and finally achieves the best balance between security and performance to meet the actual business requirements.
[0261] To implement the above embodiments, the present application also proposes a non-temporary computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the data processing method described in any of the foregoing method embodiments.
[0262] To implement the above embodiments, the present application also proposes a computer program product, on which a computer program is stored. When the computer program is executed by a processor, it implements the data processing method described in any of the foregoing method embodiments.
[0263] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0264] In addition, the terms "first" and "second" are used only for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0265] Any process or method description shown in the flowchart or described in other ways herein can be understood to represent a module, segment, or portion of code including one or more executable instructions for implementing a customized logical function or process, and the scope of the preferred embodiments of this application includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in the reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the art to which the embodiments of this application pertain.
[0266] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definite ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, a system including a processor, or other systems that can fetch instructions from and execute the instructions of the instruction execution system, apparatus, or device. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection part having one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (Random Access Memory, abbreviated as RAM), a read-only memory (Read-Only Memory, abbreviated as ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (Compact Disc Read-Only Memory, abbreviated as CDROM). In addition, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, then editing, interpreting, or otherwise processing it as appropriate, and then storing it in a computer memory.
[0267] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having suitable combinational logic gate circuits, programmable gate arrays (Programmable Gate Array, abbreviated as PGA), field programmable gate arrays (Field-Programmable Gate Array, abbreviated as FPGA), etc.
[0268] Those of ordinary skill in the art of this technology can understand that all or part of the steps carried by the method of implementing the above embodiments can be completed by a program instructing relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0269] In addition, each functional unit in various embodiments of the present application may be integrated into one processing module, may exist separately as individual physical units, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0270] The above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disc, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.
Claims
1. A chip, characterized in that, It includes a first hardware engine and a secure enclave connected by communication, where the secure enclave is used to receive the encapsulated key sent by the first execution environment, perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key, configure the first derived key into the key slot in the first hardware engine, and send the second derived key to the second execution environment; wherein, the second derived key is used for the second execution environment to generate a first key identifier; the first hardware engine is used to receive the first key identifier sent by the second execution environment and associate the first key identifier with the key slot, so as to perform encryption and decryption operations on the file through the associated first key identifier and key slot.
2. The chip according to claim 1, wherein The second derived key is used for the second execution environment to perform key derivation to obtain a second key identifier, and convert the second key identifier to obtain the first key identifier. The second execution environment is also used to write the second key identifier into the key ring of the kernel of the operating system. The first hardware engine is further used for: receiving a file write request and a third key identifier sent by the second execution environment; wherein, the third key identifier is obtained by the second execution environment converting the key identifier read from the key ring; querying the first key slot associated with the third key identifier; encrypting the first file in the file write request based on the configured derived key through the first key slot, and marking the encrypted first file based on the third key identifier to obtain a first encrypted file; writing the first encrypted file into the off-chip storage unit outside the chip.
3. The chip according to claim 1, characterized in that The first hardware engine is further used for: receiving a file read request sent by the second execution environment and reading a second encrypted file associated with the file read request from the off-chip storage unit outside the chip; querying the second key slot associated with the fourth key identifier according to the fourth key identifier marked on the second encrypted file; decrypting the second encrypted file based on the configured derived key through the second key slot to obtain a second file; sending the second file to the second execution environment.
4. The chip according to claim 1, characterized in that, The encapsulated key is obtained by encapsulating the plaintext key with a temporary key generated by the secure enclave; the secure enclave includes a random number generator and a cryptographic algorithm engine; the random number generator is used to generate a random number in response to the power-on initialization of the electronic device running the chip; the cryptographic algorithm engine is used to generate the temporary key according to the random number; the secure enclave is further used to write the temporary key into the internal storage unit.
5. The chip according to claim 4, characterized in that, The secure enclave is used for: reading the temporary key from the internal storage unit and using the temporary key to unencapsulate the encapsulated key to obtain the plaintext key; performing key derivation on the plaintext key to obtain the first derived key and the second derived key; configuring the first derived key into the key slot in the first hardware engine; Send the second derived key to the second execution environment; wherein, the second derived key is used by the second execution environment for key derivation to obtain a second key identifier, convert the second key identifier to obtain the first key identifier, and write the second key identifier into the keyring of the kernel of the operating system.
6. The chip according to claim 1, characterized in that, The chip further includes a second hardware engine, and the encapsulated key is obtained by encapsulating the plaintext key generated by the second hardware engine using a temporary key generated by the secure enclave. The secure enclave is further configured to write the temporary key into the key register of the second hardware engine. Wherein, the key register does not allow access by the application processor, and the application processor is used to run the operating system and application programs in the electronic device.
7. The chip according to claim 6, characterized in that, In response to the chip being in the sleep state, retain the stored data in the key register.
8. The chip according to claim 6, characterized in that, The encapsulated key is read by the first execution environment from the keyring in the kernel of the operating system; the second hardware engine is configured to: Receive a first ciphertext key sent by the second execution environment through the first execution environment; wherein, the first ciphertext key is that the second execution environment reads a second ciphertext key from an off-chip storage unit outside the chip in response to each power-on of the electronic device running the chip, and decrypts the second ciphertext key by invoking a secure encryption / decryption key. Decrypt the first ciphertext key according to a third derived key to obtain the plaintext key; wherein, the third derived key is obtained by key derivation based on the hardware unique key HUK of the chip. Read the temporary key from the key register, encapsulate the plaintext key using the temporary key to obtain the encapsulated key, and write the encapsulated key into the keyring in the kernel of the operating system.
9. The chip according to claim 8, wherein In response to the electronic device losing power, clear the stored data in the keyring.
10. The chip according to claim 8, characterized in that, The second hardware engine is further configured to: Generate the plaintext key in response to the first power-on and use of the electronic device running the chip. Perform key derivation based on the hardware unique key HUK of the chip to obtain the third derived key. Encrypt the plaintext key using the third derived key to obtain the first ciphertext key, and send the first ciphertext key to the second execution environment. Wherein, the first ciphertext key is used by the second execution environment to encrypt the first ciphertext key by invoking the secure encryption / decryption key to obtain the second ciphertext key, and write the second ciphertext key into the off-chip storage unit outside the chip.
11. The chip according to claim 10, characterized in that, The second execution environment is configured to: Determine an encryption policy adapted to the access request; wherein, the access request includes a file write request and a file read request. Determine a target storage directory matching the encryption policy from multiple storage directories in the off-chip storage unit. Write the second ciphertext key into the target storage directory in the off-chip storage unit.
12. The chip according to any one of claims 2-11, characterized in that, In response to the electronic device running the chip losing power, retain the stored data in the off-chip storage unit outside the chip.
13. The chip according to any one of claims 1-11, characterized in that, The security level of the first execution environment is higher than that of the second execution environment; The security level of the secure enclave is higher than that of the first execution environment.
14. The chip according to any one of claims 1-11, characterized in that, The registers in each key slot of the first hardware engine are only accessible to the secure enclave.
15. A data processing method, characterized in that, Applied to the secure enclave, it includes: Receiving an encapsulated key sent by the first execution environment, and performing key derivation based on the encapsulated key to obtain a first derived key and a second derived key; Configuring the first derived key into a key slot in the first hardware engine; Sending the second derived key to the second execution environment; wherein, the second derived key is used by the second execution environment to generate a first key identifier; Wherein, the first key identifier is used to associate with the key slot in the first hardware engine, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
16. The method according to claim 15, wherein The encapsulated key is obtained by encapsulating a plaintext key using a temporary key; The performing key derivation based on the encapsulated key to obtain a first derived key and a second derived key includes: Reading the temporary key, and performing de-encapsulation on the encapsulated key using the temporary key to obtain the plaintext key; Performing key derivation on the plaintext key to obtain the first derived key and the second derived key.
17. A data processing method, characterized in that, Applied to the first hardware engine, it includes: In response to a configuration operation triggered by the secure enclave, configuring the first derived key into the key slot in the first hardware engine; wherein, the configuration operation is performed by the secure enclave in response to receiving an encapsulated key sent by the first execution environment, performing key derivation based on the encapsulated key to obtain a first derived key and a second derived key, and generating according to the first derived key; Receiving a first key identifier sent by the second execution environment, wherein the first key identifier is generated by the second execution environment in response to the second derived key sent by the secure enclave; Associating the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
18. The method according to claim 17, wherein The first key identifier is obtained by performing key derivation on the second derived key to obtain a second key identifier and performing conversion on the second key identifier. The second execution environment is further used to write the second key identifier into the keyring of the kernel of the operating system. The performing encryption and decryption operations on a file through the associated first key identifier and the key slot includes: Receiving a file write request and a third key identifier sent by the second execution environment; wherein, the third key identifier is obtained by the second execution environment performing conversion on the key identifier read from the keyring; Querying the first key slot associated with the third key identifier; Encrypting the first file in the file write request based on the configured derived key through the first key slot, and marking the encrypted first file based on the third key identifier to obtain a first encrypted file; Writing the first encrypted file into the off-chip storage unit outside the chip.
19. The method according to claim 17, wherein Performing encryption and decryption operations on a file through the associated first key identifier and the key slot includes: Receiving a file read request sent by the second execution environment, and reading a second encrypted file associated with the file read request from an off-chip storage unit outside the chip; Querying a second key slot associated with the fourth key identifier according to the fourth key identifier marked in the second encrypted file; Decrypting the second encrypted file through the second key slot based on a configured derived key to obtain a second file; Sending the second file to the second execution environment.
20. A data processing device, characterized in that, Applied to a secure enclave, including: A receiving module for receiving an encapsulated key sent by a first execution environment; A key derivation module for performing key derivation based on the encapsulated key to obtain a first derived key and a second derived key; A configuration module for configuring the first derived key into a key slot in a first hardware engine; A sending module for sending the second derived key to a second execution environment; wherein the second derived key is used by the second execution environment to generate a first key identifier; Wherein the first key identifier is used to be associated with the key slot in the first hardware engine, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
21. A data processing device, characterized in that, Applied to a first hardware engine, including: A configuration module for, in response to a configuration operation triggered by a secure enclave, configuring a first derived key into a key slot in the first hardware engine; wherein the configuration operation is that the secure enclave, in response to receiving an encapsulated key sent by a first execution environment, performs key derivation based on the encapsulated key to obtain a first derived key and a second derived key, and generates according to the first derived key; A receiving module for receiving a first key identifier sent by a second execution environment, wherein the first key identifier is generated by the second execution environment in response to the second derived key sent by the secure enclave; A processing module for associating the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and the key slot.
22. An electronic device, characterized in that, Including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the steps of the method according to claim 15 or 16, or implements the steps of the method according to any one of claims 17 to 19.
23. An electronic device, characterized in that, Including a first execution environment, a chip, and a second execution environment that are communicatively connected, wherein, The first execution environment is used to send an encapsulated key to the chip; The chip is used to perform key derivation based on the encapsulated key to obtain a first derived key and a second derived key, configure the first derived key into a key slot of the chip, and send the second derived key to the second execution environment; The second execution environment is used to generate a first key identifier according to the second derived key and send the first key identifier to the chip; The chip is further configured to associate the first key identifier with the key slot, so as to perform encryption and decryption operations on a file through the associated first key identifier and key slot.
24. A non-transitory computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the program instruction is executed by a processor, it implements the steps of the method described in claim 15 or 16, or implements the steps of the method described in any one of claims 17 to 19.