Data storage methods and electronic devices
By storing the security key independently in each TEE and performing local authentication calculations, the security problem of RPMB data writing in a multi-TEE framework is solved, achieving higher security and accuracy, and simplifying the data writing process.
Patent Information
- Application Number
- CN202211048230.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-08-30
AI Technical Summary
In a Trusted Execution Environment (TEE) framework, a TEE that does not store a security key may pose a security risk when calling the security keys of other TEEs, leading to security issues when writing data to the Replay Protected Memory Block (RPMB).
A unique security key is stored in each TEE, and authentication calculations are performed locally to avoid key calls across TEEs. The Hypervisor module and TA ensure that data packets are accurately transmitted to the corresponding storage area, and hash operations are used to improve the reliability of authentication data.
It improves the security and accuracy of writing data to RPMB in a multi-TEE framework, reduces data interaction caused by key calls, simplifies the writing process, and enhances the targeting and security of data storage.
Smart Images

Figure CN117668932B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and more specifically, to a data storage method and an electronic device. Background Technology
[0002] A replay-protected memory block (RPMB) typically refers to a separate physical partition in memory, often used to store sensitive data such as keys. This memory can include Universal Flash Storage (UFS) and Embedded Multi Media Card (eMMC).
[0003] With the continuous advancement of terminal technology, the Trusted Execution Environment (TEE) architecture has become a common approach. Typically, the RPMB (Reliable Execution Module) requires a secure key to authenticate the data to be stored sent by the TEE, and stores the data only if authentication is successful. Since the secure key can only be stored in one TEE, in a multi-TEE framework, a TEE that does not store a secure key needs to call the secure key from a TEE that does store it to perform authentication calculations and obtain initial authentication data. This initial authentication data then informs the RPMB's decision on whether to store the data. However, a TEE that does not store a secure key may experience security key leakage during the secure key call process, posing a security risk.
[0004] Therefore, improving the security of data written to RPMB by each TEE in a multi-TEE framework has become an urgent problem to be solved. Summary of the Invention
[0005] This application provides a data storage method that can improve the security of data written to the RPMB by each TEE in a multi-TEE framework.
[0006] Firstly, a data storage method is provided, applied in an electronic device. The electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area in the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. A first security key is stored in the first TEE and the first storage area. The first security key is used to perform authentication calculations on the first storage area and the first TA for data to be stored. The data to be stored is data written to the first storage area. The method includes:
[0007] The first TA sends a first data packet to the first storage area. The first data packet includes data to be stored and first authentication data. The first authentication data is the data obtained by the first TA after authenticating the data to be stored using the first security key.
[0008] The first storage area stores the data to be stored based on the first security key.
[0009] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, it sends a first data packet obtained based on the data to be stored and the first authentication data to the first storage area. The first storage area stores the data to be stored based on the same first security key. This ensures that when the first TEE stores data to its corresponding first storage area, the first security key used is the same as the one stored in the first TEE, eliminating the need to retrieve security keys from other TEEs. This avoids potential security key leakage that might occur when retrieving security keys from other TEEs, thus improving the security of writing data to the RPMB in a multi-TEE framework. Furthermore, by adopting the data storage method provided in the embodiments of this application, each TEE does not need to call the security key with each other during the process of writing data to the RPMB, which reduces data interaction caused by calling the security key and simplifies the process of writing data to the RPMB.
[0010] In conjunction with the first aspect, in some implementations of the first aspect, at least two TEEs also include a second TEE, the RPMB includes a second storage area, the second TEE corresponds to the second storage area, and the second TEE and the second storage area store a second security key, which is different from the first security key.
[0011] It should be understood that the storage device supports the functionality of multiple RPMB regions, meaning different security keys can be written to different RPMB partitions. Correspondingly, different security keys can also be stored in different TEEs.
[0012] For example, if the first TEE refers to TEE-0, the corresponding first storage region refers to RPMB region0, and the first security key refers to secure key0, then the second TEE can refer to TEE-1, the corresponding second storage region can refer to RPMB region0, and the second security key can refer to secure key1. Usually, secure key0 and secure key1 are different.
[0013] In the embodiments of this application, at least two first TEEs include a first TEE and a second TEE. The first TEE corresponds to a first storage area, and the second TEE corresponds to a second storage area. A first security key is stored in the first storage area and the first TEE, while a second security key is stored in the second TEE and the second storage area. The first security key and the second security key are different. This ensures that even if data is mistakenly sent to the first storage area when the second TEE writes data to the second storage area, the first storage area will not verify the written data using the first security key because the first and second security keys are different. Therefore, the first storage area cannot store the data sent by the second TEE, thus improving the specificity of data writing to the RPMB partition by each TEE. Furthermore, because the security keys stored in the first TEE and the second TEE are different, meaning the security key used when writing data to the first storage area is different from the security key used when writing data to the second storage area, different security keys are used when writing data to each RPMB partition, further improving the security of data written to the RPMB.
[0014] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device further includes a kernel, which includes a hypervisor module. The first TA sends a first data packet to the first storage area, including: the first TA sending the first data packet to the hypervisor module; and the hypervisor module sending the first data packet to the first storage area.
[0015] It should be understood that the Hypervisor module has the ability to access all physical devices on the electronic machine, including disks and memory. After the server starts, the Hypervisor module loads the operating systems of all virtual machine clients (including TEE-0, TEE-1, and storage devices) and allocates memory, disk, and network for the virtual machines. This allows the Hypervisor module to directly allocate data interfaces for the first TEE and storage devices, enabling data transfer between TEE-0 and storage devices, and between TEE-1 and storage devices.
[0016] In conjunction with the first aspect, in some implementations of the first aspect, the first data packet includes a first parameter, which is used to indicate a first storage area; the Hypervisor module sends the first data packet to the first storage area, including: the Hypervisor module determines the first storage area based on the first parameter; the Hypervisor module sends the first data packet to the first storage area.
[0017] The first parameter can be the SECURITY PROTOCOL SPECIFIC parameter, which is used to indicate the identifier of the RPMB partition to which the first data packet is sent.
[0018] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, it sends a first data packet obtained based on the data to be stored, first parameters, and the first authentication data to a Hypervisor module. The Hypervisor module determines, based on the first parameters, that the recipient of the first data packet is the first storage area, and then sends the first data packet to the first storage area. The first storage area stores the data to be stored based on the same first security key. This allows the Hypervisor module to accurately send the first data packet to the first storage object, further improving the accuracy of writing data to the first storage area by using an independent security key to authenticate the data written to the first storage area.
[0019] In conjunction with the first aspect, in some implementations of the first aspect, the kernel also includes an ATF module, and the first TA sends a first data packet to the Hypervisor module, including: the first TA sending a first data packet to the ATF module; and the ATF module sending a first data packet to the Hypervisor module.
[0020] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area in the RPMB. The at least two TEEs include a first TEE, in which a first trusted application (TA) runs. The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtains first authentication data, and then sends the first data packet obtained based on the data to be stored and the first authentication data to the first storage area. The process of sending the first data packet to the first storage area can be done through an ATF module. Typically, sending data to the RPMB through the ATF module is a pre-set process, so there is no need for the user to set up a process for sending data to the RPMB, which improves the convenience of writing data from the first TEE to the first storage area.
[0021] In conjunction with the first aspect, in some implementations of the first aspect, the kernel further includes a first TEE tz driver module, and the hypervisor module sends a first data packet to the first storage area, including: the hypervisor module sending a first data packet to the first TEE tz driver module; and the first TEE tz driver module sending a first data packet to the first storage area.
[0022] In conjunction with the first aspect, in some implementations of the first aspect, the kernel further includes a storage device driver module, wherein the first TEE tz driver module sends a first data packet to the first storage area, including: the first TEE tz driver module sending a first data packet to the storage device driver module; and the storage device driver module sending a first data packet to the first storage area.
[0023] It should be understood that the TEE-1tz driver module is a module within the kernel. With the TEE-1tz driver module being a kernel module, the Hypervisor module can send the first data packet to RPMB region 1 according to a pre-set process.
[0024] In the embodiments of this application, when the Hypervisor module sends the first data packet to the first storage area, it utilizes the first TEE tz driver module in the kernel. This allows the first data packet to be sent using a pre-set process, eliminating the need for the user to set the process for sending the first data packet to the first storage area, thus improving the convenience of writing data to the first storage area.
[0025] In conjunction with the first aspect, in some implementations of the first aspect, the first storage area stores the data to be stored based on the first security key, including: the first storage area uses the first security key to perform authentication calculation on the data to be stored in the first data packet to obtain second authentication data; and when the first authentication data and the second authentication data match, the first storage area stores the data to be stored.
[0026] It should be understood that the first authentication data is obtained by performing authentication calculations on the data to be stored using the first security key, and the second authentication data is also obtained by performing authentication calculations on the data to be stored using the same first security key. In other words, when the first security key, the data to be stored, and the authentication calculation method are the same, the first authentication data and the second authentication data are obtained by performing the same calculations on the same data using the same security key, and therefore, the first authentication data and the second authentication data are identical.
[0027] The data storage method provided in the embodiments of this application includes an electronic device comprising at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, a first data packet obtained based on the data to be stored and the first authentication data is sent to the first storage area. The first storage area uses the same first security key to perform the same authentication calculations on the data to be stored in the first data packet, obtaining second authentication data. If the first authentication data and the second authentication data match, the data to be stored is stored, based on the same first security key. This ensures that all data stored in the first storage area is verified by the first storage area using an independent security key, effectively preventing attacks from unknown sources and improving the security of data stored in the first storage area.
[0028] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device further includes a rich execution environment (REE) and a first device, wherein a first client application (CA) runs in the REE, and the method further includes: receiving a first operation, the first operation being used to instruct the acquisition of data to be stored; in response to the first operation, the first CA sending a first request to a first transaction controller (TA), the first request being used to instruct the first TA to acquire the data to be stored; in response to the first request, the first TA instructing the first device to collect first data; and the first TA obtaining the data to be stored based on the first data.
[0029] In conjunction with the first aspect, in some implementations of the first aspect, the first device includes a fingerprint sensor.
[0030] In conjunction with the first aspect, in some implementations of the first aspect, the first device includes a camera.
[0031] In conjunction with the first aspect, in some implementations of the first aspect, the first TA includes a face TA and a first RPMB service module. The first RPMB service module stores the first security key, and the data to be stored is face recognition data. The first TA sends a first data packet to the Hypervisor module, including: the face TA instructing the camera to collect face recognition data; the face TA sending the face recognition data to the first RPMB service module; the first RPMB service module generating the first data packet based on the face recognition data; and the first RPMB service module sending the first data packet to the Hypervisor module.
[0032] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device further includes a rich execution environment (REE) and a camera, wherein a face client application (CA) runs in the REE. Before the face TA instructs the camera to acquire face recognition data, the method further includes: the face CA detecting a face recognition registration operation, the face recognition registration operation being used to instruct the acquisition of face recognition data; in response to the face recognition registration operation, the face CA sending a face recognition registration request to the face TA, the face recognition registration request being used to instruct the face TA to acquire face recognition data; the aforementioned face TA instructing the camera to acquire face recognition data includes: in response to the face recognition registration request, the face TA instructing the camera to acquire face recognition data.
[0033] In conjunction with the first aspect, in some implementations of the first aspect, the first TA includes a fingerprint TA and a second RPMB service module. The second RPMB service module stores the first security key, and the data to be stored is fingerprint data. The first TA sends a first data packet to the Hypervisor module, including: the fingerprint TA instructing the fingerprint sensor to collect fingerprint data; the fingerprint TA sending the fingerprint data to the second RPMB service module; the second RPMB service module generating the first data packet based on the fingerprint data; and the second RPMB service module sending the first data packet to the Hypervisor module.
[0034] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device further includes a rich execution environment (REE) and a fingerprint sensor, wherein a fingerprint client application (CA) runs in the REE, and before the fingerprint TA instructs the fingerprint sensor to acquire fingerprint data, the method further includes: the fingerprint CA detecting a fingerprint registration operation, the fingerprint registration operation being used to instruct the acquisition of fingerprint data; in response to the fingerprint registration operation, the fingerprint CA sending a fingerprint registration request to the fingerprint TA, the fingerprint registration request being used to instruct the fingerprint TA to acquire fingerprint data; the aforementioned fingerprint TA instructing the fingerprint sensor to acquire fingerprint data includes: in response to the fingerprint registration request, the fingerprint TA instructing the fingerprint sensor to acquire fingerprint data.
[0035] In conjunction with the first aspect, in some implementations of the first aspect, the kernel also includes an ATF module, and the second RPMB service module sends a first data packet to the Hypervisor module, including: the second RPMB service module sending a first data packet to the ATF module; and the ATF module sending a first data packet to the Hypervisor module.
[0036] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area in the RPMB. The at least two TEEs include a first TEE, in which a fingerprint TA and a second RPMB service module are running. The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The fingerprint TA collects fingerprint data and sends it to the second RPMB service module. The second RPMB service module uses the first security key to perform authentication calculations on the fingerprint data to obtain first authentication data. Then, it sends the first data packet obtained based on the fingerprint data and the first authentication data to the first storage area. In the process of sending the first data packet to the first storage area, it can be sent to the first storage area through an ATF module. Typically, sending data to the RPMB through the ATF module is a pre-set process, so there is no need for the user to set how to send data to the RPMB, which improves the convenience of writing data from the first TEE to the first storage area.
[0037] In conjunction with the first aspect, in some implementations of the first aspect, the above authentication calculation includes HMAC calculation.
[0038] In the embodiments of this application, the second TA uses a security key to perform authentication calculation on the data to be stored through hash operation to obtain the first authentication data. Since hash operation is a widely used encryption algorithm that has withstood various forms of attacks, the first authentication data obtained through hash operation is more reliable encrypted data, thereby improving the security of obtaining the first authentication data.
[0039] In a second aspect, a data storage device is provided, including a unit for performing any of the methods in the first aspect. The device may be a server, a terminal device, or a chip within a terminal device. The device may include an acquisition unit and a processing unit.
[0040] When the device is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may also include a memory for storing computer program code, which, when the processor executes the computer program code stored in the memory, causes the terminal device to perform any of the methods in the first aspect.
[0041] When the device is a chip within a terminal device, the processing unit can be an internal processing unit of the chip, and the input unit can be an output interface, pin, or circuit, etc.; the chip may also include a memory, which can be an internal memory of the chip (e.g., a register, cache, etc.) or an external memory (e.g., a read-only memory, random access memory, etc.); the memory is used to store computer program code, and when the processor executes the computer program code stored in the memory, the chip performs any of the methods in the first aspect.
[0042] In one possible implementation, the memory is used to store computer program code; the processor executes the computer program code stored in the memory, and when the computer program code stored in the memory is executed, the processor controls the execution: a first TA sends a first data packet to a first storage area, the first data packet including data to be stored and first authentication data, the first authentication data being data obtained by the first TA after authenticating the data to be stored using a first security key; the first storage area stores the data to be stored based on the first security key.
[0043] Thirdly, a computer-readable storage medium is provided, the computer-readable storage medium storing computer program code, which, when executed by a data storage device, causes the data storage device to perform any of the data storage methods in the first aspect.
[0044] Fourthly, a computer program product is provided, the computer program product comprising: computer program code, which, when executed by a data storage device, causes the data storage device to perform any of the apparatus methods in the first aspect.
[0045] In embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, it sends a first data packet, obtained based on the data to be stored and the first authentication data, to the first storage area. The first storage area stores the data to be stored based on the same first security key. This ensures that when the first TEE stores data to its corresponding first storage area, the first security key used is the same as the one stored in the first TEE, eliminating the need to retrieve security keys from other TEEs. This avoids potential security key leakage that might occur when retrieving security keys from other TEEs, thus improving the security of writing data to the RPMB in a multi-TEE framework. Furthermore, by adopting the data storage method provided in the embodiments of this application, each TEE does not need to call the security key with each other during the process of writing data to the RPMB, which reduces data interaction caused by calling the security key and simplifies the process of writing data to the RPMB. Attached Figure Description
[0046] Figure 1 This is a schematic diagram of the RPMB data writing process;
[0047] Figure 2 This is a schematic diagram of the logical addresses of multiple RPMB partitions;
[0048] Figure 3 This is a schematic diagram of a hardware system for an electronic device applicable to this application;
[0049] Figure 4 This is a schematic diagram of a software system applicable to an electronic device of this application;
[0050] Figure 5 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application;
[0051] Figure 6 This is a schematic diagram of an electronic device for data storage provided in an embodiment of this application;
[0052] Figure 7 This is a flowchart illustrating a data storage method provided in an embodiment of this application;
[0053] Figure 8This is a schematic diagram of another data storage electronic device provided in an embodiment of this application;
[0054] Figure 9 This is a flowchart illustrating another data storage method provided in an embodiment of this application;
[0055] Figure 10 This is a schematic diagram illustrating the data flow of a data storage method provided in an embodiment of this application;
[0056] Figure 11 This is a schematic diagram illustrating a data format for a write request provided in an embodiment of this application;
[0057] Figure 12 This is a schematic diagram of a data format for a first data packet provided in an embodiment of this application;
[0058] Figure 13 This is a flowchart illustrating another data storage method provided in an embodiment of this application;
[0059] Figure 14 This is a schematic diagram illustrating the data flow of another data storage method provided in this application embodiment;
[0060] Figure 15 This is a schematic diagram of an electronic device provided in this application;
[0061] Figure 16 This is a schematic diagram of an electronic device for data storage provided in this application. Detailed Implementation
[0062] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0063] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.
[0064] For ease of understanding, some concepts related to the embodiments of this application are illustrated by way of example for reference.
[0065] 1. RPMB
[0066] RPMB refers to a separate physical partition in memory, typically used to store data that needs to be protected against unauthorized tampering, such as public keys and serial numbers related to fingerprint payments on mobile phones. Typically, RPMB authenticates write operations, but read operations do not.
[0067] It should be understood that during the manufacturing process of electronic devices, a unique security key is generated for each device and written into the OTP area of the device's memory. The OTP area is a region that can only be written to once. Simultaneously, the host of the electronic device stores this security key in a secure execution environment (e.g., TEE). When the host writes data to the RPMB, the RPMB can use this security key for authentication.
[0068] For example, let's illustrate this by having a host (a trusted application TA in a TEE) write data to a device (e.g., a UFS).
[0069] like Figure 1 As shown, the Host sends a Write Cnt request and a random number to the Device to retrieve the Write Cnt count from the Device. Upon receiving the Write Cnt request, the Device uses a security key to perform an HMAC calculation on the Write Cnt count and the random number to generate a first MAC. The Device then fills the corresponding area of the RPMB data packet with the Write Cnt, the random number, and the first MAC, generating an RPMB data packet, and sends the RPMB data packet to the Host. When the Host receives the RPMB data packet, it uses a security key to perform an HMAC calculation on the Write Cnt and the random number in the RPMB data packet to obtain a second MAC. It compares the values of the first MAC and the second MAC to see if they match. If they match, it compares the random number sent by the Host to the Device with the random number in the RPMB data packet. If they match, the Host determines that the Write Cnt in the RPMB data packet is trustworthy.
[0070] Furthermore, the Host uses a security key to perform HMAC calculation on the destination address of the data to be stored, the data to be stored, and the Write Cnt to obtain a third MAC. This third MAC is then filled into the MAC area of the RPMB packet to obtain an updated RPMB packet, which is then sent to the Device. The Device receives the updated RPMB packet, performs HMAC calculation on the destination address of the data to be stored, the data to be stored, and the Write Cnt using the security key to obtain a fourth MAC. This fourth MAC is compared with the third MAC. If they match, the Device compares the Write Cnt in the updated RPMB packet with the Write Cnt in the Device. If they match, the Host stores the data to be stored from the updated RPMB packet into the corresponding destination address and increments the Write Cnt in the Device to obtain the updated Write Cnt.
[0071] In one possible scenario, RPMB refers to a region within UFS. Based on the description in the JESD220E document for UFS 3.0 and later protocols, storage devices support the functionality of multiple RPMB regions. When a storage device supports multiple RPMB regions, each region in the RPMB has its own independent authentication key, counter, and result storage, and the starting value of the logical address of each region in the RPMB is 0.
[0072] In this context, the logical address of each region within an RPMB starts at address 0. For example, as shown... Figure 2 As shown, the physical address of RPMBregion0 starts at 0x00000000, the logical address of RPMB region0 starts at 0x00000000, and the region size of region0 is 12M bits. The physical address of RPMB region1, which is adjacent to RPMB region0, starts at 0x00800000, but the logical address of RPMB region1 also starts at 0x00000000, and the region size of RPMBregion1 is 4M bits.
[0073] 2. Trusted Execution Environment (TEE)
[0074] A TEE (Transport Execution Environment) refers to a separate, secure operating environment within a terminal device, typically logically isolated from the Rich Execution Environment (REE). TEEs are equipped with robust protection measures to defend against easily exploitable software attacks on the conventional REE side. Therefore, TEEs are generally used for tasks requiring high security.
[0075] 3. Rich execution environment (REE)
[0076] REE typically refers to a general-purpose operating environment on terminal devices, which is an operating environment without specific security features. For example, Android and iOS systems are both REEs.
[0077] The TEE and REE are isolated from each other. Typically, the REE cannot directly access the hardware and software resources of the TEE and can only interact through an authorized application programming interface.
[0078] 4. Trusted Application (TA)
[0079] TA typically refers to applications running on a TEE (Trusted Application Environment). It provides security services for applications running outside of the TEE.
[0080] 5. Client Application (CA)
[0081] CA typically refers to applications that run on REE.
[0082] 6. Hypervisor
[0083] The Hypervisor is an intermediate software layer running between the underlying physical server and the operating system. It provides access to all physical devices on the electronic device, including disks and memory. The Hypervisor coordinates hardware resource access and provides protection between virtual machines. After the server starts, the Hypervisor loads the operating system for all virtual machine clients and allocates memory, disk space, and network resources to the virtual machines. Based on the Hypervisor mechanism, multiple TEEs can run simultaneously on an electronic device.
[0084] 7. ATF
[0085] ATF( Trusted Firmware is a type of software designed for... The chip provides underlying open-source firmware code. The firmware divides the entire system into four run levels: EL0, EL1, EL2, and EL3. Specifically, the application runs at EL0, the driver at EL1, the Hypervisor module at EL2, and the ATF module at EL3.
[0086] Currently, in terminal devices employing a multi-TEE architecture, each TEE needs to write data to the RPMB. It should be understood that the RPMB requires a secure key to authenticate the data to be stored sent by the TEE, and stores the data only after successful authentication. Since the RPMB requires the same secure key for authentication, regardless of which TEE stores this secure key, other TEEs must use this secure key for authentication calculations and interact with the TEE storing the secure key. During this data interaction, the secure key may be leaked, posing a security risk. The data storage method provided in this application aims to improve the security of data writing from each TEE to the RPMB in a multi-TEE framework.
[0087] The data storage method provided in this application can be applied to electronic devices. Optionally, the electronic device includes a terminal device, which may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device can be a mobile phone, smart TV, wearable device, tablet computer, computer with wireless transceiver function, virtual reality (VR) terminal device, augmented reality (AR) terminal device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, etc. The embodiments of this application do not limit the specific technology or device form used in the terminal device.
[0088] For example, Figure 3A schematic diagram of the structure of electronic device 100 is shown. Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0089] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0090] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0091] For example, in an embodiment of this application, processor 110 can be used to execute the data storage method provided in the embodiment of this application; for example, a first trusted application TA sends a first data packet to a second trusted application, the first data packet including data to be stored, the data to be stored being data to be written to the RPMB, the first TA referring to a trusted application running on a first TEE, and the second TA referring to a trusted application running on a second TEE; the second TA uses a security key to perform authentication calculation on the data to be stored in the first data packet to obtain first authentication data; the second TA generates a second data packet based on the first authentication data and the data to be stored; the second TA sends the second data packet to the RPMB; the RPMB stores the data to be stored based on the second data packet.
[0092] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0093] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0094] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can utilize the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.
[0095] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0096] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0097] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0098] Optionally, the memory (also called storage device) in electronic devices includes eMMC and Universal File Store (UFS). The RPMB in the memory is typically used to store data with confidentiality requirements. When writing data to the RPMB, authentication calculation is required using a pre-stored security key to obtain authenticated data. The RPMB verifies the written data using the security key stored on it, and only after successful verification is the verified data stored on the RPMB.
[0099] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0100] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0101] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0102] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0103] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0104] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0105] It should be noted that any electronic device mentioned in the embodiments of this application may include more or fewer modules in electronic device 100.
[0106] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0107] Figure 4 This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.
[0108] The layered architecture of the electronic device 100 divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0109] The application layer can include a series of application packages.
[0110] like Figure 4 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0111] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0112] like Figure 4 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0113] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0114] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0115] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0116] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0117] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0118] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0119] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0120] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0121] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0122] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0123] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0124] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0125] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0126] A 2D graphics engine is a graphics engine for 2D drawing.
[0127] The kernel layer is the layer between hardware and software. The kernel layer includes at least display drivers, camera drivers, audio drivers, sensor drivers, Wi-Fi drivers, etc.
[0128] It should be noted that the electronic device mentioned in the embodiments of this application may include more or fewer modules of the above-mentioned electronic device.
[0129] The application scenarios provided by the embodiments of this application are described below with reference to the accompanying drawings.
[0130] With the continuous development of terminal technology, multi-TEE architecture has become a common architecture. For example, such as... Figure 5As shown, the terminal device includes three TEEs and a storage device, namely TEE-0, TEE-1, TEE-2, and UFS. The RPMB in the UFS includes three RPMB partitions: RPMB region0, RPMB region1, and RPMB region2. The RPMB partition corresponding to TEE-0 is RPMB region0, the RPMB partition corresponding to TEE-1 is RPMB region1, and the RPMB partition corresponding to TEE-2 is RPMB region2. Data written to the RPMB by TEE-0 is stored in RPMB region0, data written to the RPMB by TEE-1 is stored in RPMB region1, and data written to the RPMB by TEE-2 is stored in RPMB region2.
[0131] Specifically, TEE-0 and RPMB region0 store the same secure key 0, TEE-1 and RPMB region1 store the same secure key 1, and TEE-2 and RPMB region2 store the same secure key 2.
[0132] The following explanation uses TEE-0 (the first TEE) as an example to illustrate how data written to the RPMB partition is stored. When TEE-0 writes data to RPMB region0 (the first storage region), TEE-0 uses secure key0 (the first security key) to perform authentication calculations on the data to be stored, generating a data packet to be sent to RPMB region0. After receiving the data packet sent by TEE-0, RPMB region0 uses secure key0 to verify the data packet, and if the verification passes, stores the data to be stored in the data packet.
[0133] It should be understood that the process of writing data to TEE-1 and TEE-2 is similar to the process of writing data to TEE-0 described above, and will not be repeated here.
[0134] Since each TEE can use the security key stored on it to write data to the corresponding RPMB partition, the situation of each TEE calling each other's security keys is avoided, thus avoiding the possibility of security key leakage during the process of calling each other's security keys.
[0135] It should be understood that the above are illustrative examples of application scenarios and do not limit the application scenarios of this application in any way.
[0136] The following is combined with Figures 6 to 12 The data storage method provided in the embodiments of this application will be described in detail.
[0137] The data storage method provided in this application can be applied to electronic devices including at least two TEEs. For example, such as... Figure 6 As shown, the electronic device includes TEE-0, TEE-1, and TEE-2. The storage device within the electronic device includes three RPMB partitions: RPMB region0, RPMB region1, and RPMB region2. TEE-0 and RPMB region0 store the same secure key 0, TEE-1 and RPMB region1 store the same secure key 1, and TEE-2 and RPMB region2 store the same third security key. A first TA running in TEE-0 (equivalent to the first TEE) generates a first data packet based on the data to be stored and sends the first data packet to RPMB region0 (equivalent to the first storage region). RPMB region0 verifies the first data packet and stores the data to be stored in the first data packet after successful verification. It should be understood that the first TEE can also refer to TEE-1, and correspondingly, the first storage region can refer to RPMB region1, and the first security key can refer to secure key 1. The first TEE can also refer to TEE-2, and correspondingly, the first storage region can refer to RPMB region2, and the first security key can refer to secure key 2. This application embodiment does not limit this.
[0138] Optionally, if the first TEE also refers to TEE-0, the corresponding first storage region refers to RPMB region0, and the first security key refers to secure key0, then the second TEE can refer to TEE-1, the corresponding second storage region can refer to RPMB region0, and the second security key refers to secure key1. Usually, secure key0 and secure key1 are different.
[0139] For ease of understanding, Figures 7 to 12 The illustrated embodiment uses TEE-0 as an example, where the first TEE refers to TEE-0, the corresponding first storage region refers to RPMB region0, and the first security key refers to secure key0. Figure 13 and Figure 14 The illustrated embodiment uses TEE-1 as an example, the first storage area as RPMB region1, and the first security key as secure key1.
[0140] The following is combined with Figure 7 For application in Figure 6The data storage method of the electronic device shown is described in detail.
[0141] Figure 7 This is a flowchart illustrating a data storage method provided in one embodiment of this application, such as... Figure 7 As shown, this method is applied to, for example Figure 6 In the electronic device shown. The method includes:
[0142] S101, the first TA sends the first data packet to the first storage region (i.e., RPMB region0).
[0143] The first data packet includes data to be stored and first authentication data. The data to be stored refers to the data written to RPMBregion0, and the first authentication data refers to the data obtained by authenticating the data to be stored using secure key0 (equivalent to the first security key). The first TA refers to the trusted application running on TEE-0 (equivalent to the first TEE), and RPMB region0 (equivalent to the first storage region) refers to the RPMB partition on the storage device corresponding to TEE-0.
[0144] It should be understood that storage devices based on UFS 3.0 and later protocols support the multiple RPMB region function. When a storage device supports multiple RPMB regions, it can be divided into multiple RPMB partitions. Each RPMB partition has its own independent authentication key, counter, and result storage. This allows each RPMB partition to use its own independent authentication key to verify the data to be stored.
[0145] It should be understood that during the manufacturing process of electronic devices, security keys are programmed into the memory of the electronic device. Simultaneously, these security keys are written into the TEE (Telematics Equipment). This allows the TEE to use the security key to perform authentication calculations on the data to be stored when writing data to the RPMB (Real-Time Block Memory), obtaining authenticated data. This enables the RPMB to ensure the security of the written data by verifying the authenticated data. Since the electronic device in this embodiment includes multiple RPMB partitions, each RPMB partition has a different security key. That is, the process of programming the security key into the storage device of the electronic device involves programming the corresponding security key into each RPMB partition in the storage device and then programming the corresponding security key into the corresponding TEE.
[0146] In one possible scenario, the process of writing security keys to TEE and storage devices can be done by directly writing the security keys according to a pre-set path, without requiring an additional application to initiate the security key writing process.
[0147] In one possible scenario, the process of writing security keys to TEE and storage devices can be carried out by calling the control program on the production line, following a preset path.
[0148] It should be understood that the storage device supports the functionality of multiple RPMB regions, meaning different security keys can be written to different RPMB partitions.
[0149] For example, if the RPMB partition corresponding to TEE-0 is RPMB region0 and the security key of RPMB region0 is secure key0, then during the production of electronic devices, secure key0 is burned into RPMB region0 and simultaneously written into TEE-0.
[0150] For example, the RPMB partition corresponding to TEE-1 is RPMB region1, and the security key of RPMB region1 is secure key1. In the process of manufacturing electronic devices, secure key1 is burned into RPMB region1 and simultaneously written into TEE-1.
[0151] For example, the RPMB partition corresponding to TEE-2 is RPMB region2, and the security key of RPMB region2 is secure key2. In the process of manufacturing electronic devices, secure key2 is burned into RPMB region2 and simultaneously written into TEE-2.
[0152] Optionally, if the first TEE refers to TEE-0, the corresponding first storage region refers to RPMB region0, and the first security key refers to secure key0, then the second TEE can refer to TEE-1, the corresponding second storage region can refer to RPMB region0, and the second security key refers to secure key1. Usually, secure key0 and secure key1 are different.
[0153] This means that the security keys used for authenticating written data are different in different RPMBs, allowing different RPMB partitions to use different security keys to authenticate the data written to the RPMB.
[0154] In the embodiments of this application, at least two first TEEs include a first TEE and a second TEE. The first TEE corresponds to a first storage area, and the second TEE corresponds to a second storage area. A first security key is stored in the first storage area and the first TEE, while a second security key is stored in the second TEE and the second storage area. The first security key and the second security key are different. This ensures that even if data is mistakenly sent to the first storage area when the second TEE writes data to the second storage area, the first storage area will not verify the written data using the first security key because the first and second security keys are different. Therefore, the first storage area cannot store the data sent by the second TEE, thus improving the specificity of data writing to the RPMB partition by each TEE. Furthermore, because the security keys stored in the first TEE and the second TEE are different, meaning the security key used when writing data to the first storage area is different from the security key used when writing data to the second storage area, different security keys are used when writing data to each RPMB partition, further improving the security of data written to the RPMB.
[0155] The data to be stored can refer to the data collected by the first TA on TEE-0.
[0156] For example, the first TA in TEE-0 is an application that requires fingerprint data for encryption and decryption. The data to be stored may refer to the fingerprint data collected by the first TA through a fingerprint scanner.
[0157] For example, the first TA in TEE-0 is an application that needs to encrypt and decrypt audio data. The data to be stored may refer to the audio data captured by the first TA through a microphone.
[0158] For example, the first TA in TEE-0 is an application that requires a character password for encryption and decryption. The data to be stored may refer to the character data obtained by the first TA through receiving user click operations on the display screen.
[0159] For example, the first TA in TEE-0 is an application that needs to encrypt and decrypt iris data. The data to be stored can refer to the iris data captured by the first TA through a camera.
[0160] For example, the first TA in TEE-0 is an application that requires facial recognition for encryption and decryption. The data to be stored may refer to the facial data captured by the first TA through a camera.
[0161] For example, the first TA can also be an application that provides security services to the CA, and the data to be stored can refer to the password data sent by the CA to the first TA, including but not limited to the aforementioned fingerprint data, voice data, character data, iris data and facial data.
[0162] After obtaining the data to be stored, the first TA can use secure key0 stored in TEE-0 to perform authentication calculations on the data to be stored, obtaining the first authentication data. Then, the first authentication data and the data to be stored are combined into a packet to obtain the first data packet, which is then sent to the RPMB partition corresponding to TEE-0, namely RPMB region0.
[0163] Optionally, authentication computation can refer to hash computation. Hash computation can be a computational method that calculates data using a hash-based Message Authentication Code (HMAC), a method of message authentication based on a hash function and a key. HMAC is the authentication service method chosen by many current security protocols and is widely used. For example, HMAC is widely used in Internet Protocol Security (IPSec) and other network protocols (such as SSL) and has withstood various forms of attacks. Based on this, HMAC can also be referred to as the existing Internet security standard.
[0164] For example, the first TA can use secure key0 to perform hash calculations on the data to be stored to obtain the first authentication data.
[0165] In the embodiments of this application, the first TA uses secure key0 to perform authentication calculation on the data to be stored through hash calculation to obtain the first authentication data. Since hash calculation is a widely used encryption algorithm that has withstood various forms of attacks, the first authentication data obtained through hash calculation is more reliable encrypted data, thereby improving the security of obtaining the first authentication data.
[0166] For example, the first TA can also use secure key0 to calculate the data to be stored using the Cipher Block Chaining-Message Authentication Code (CMAC) to obtain the first authentication data.
[0167] It should be understood that the first TA can combine the first authentication data and the data to be stored into a packet according to a preset data format to obtain the first data packet.
[0168] For example, the first TA can place the first authentication data before the data to be stored, and combine the first authentication data and the data to be stored into a packet to obtain the first data packet.
[0169] For example, the first TA can place the first authentication data after the data to be stored, and then combine the data to be stored and the first authentication data into a packet to obtain the first data packet.
[0170] In one possible scenario, the first TA can assemble the first authentication data, the data to be stored, and the write request into a first data packet, and then send the first data packet to RPMB region 0 (i.e., the first storage region) corresponding to the first TA in the storage device.
[0171] S102. The first storage region (i.e., RPMB region0) stores the data to be stored based on secure key0.
[0172] After receiving the first data packet, RPMB region0 can first unpack the first data packet to obtain the data to be stored and the first authentication data. RPMB region0 can then verify the first authentication data based on the secure key 0 stored in RPMB region0, and if the verification passes, store the data to be stored from the first data packet.
[0173] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, it sends a first data packet obtained based on the data to be stored and the first authentication data to the first storage area. The first storage area stores the data to be stored based on the same first security key. This ensures that when the first TEE stores data to its corresponding first storage area, the first security key used is the same as the one stored in the first TEE, eliminating the need to retrieve security keys from other TEEs. This avoids potential security key leakage that might occur when retrieving security keys from other TEEs, thus improving the security of writing data to the RPMB in a multi-TEE framework. Furthermore, by adopting the data storage method provided in the embodiments of this application, each TEE does not need to call the security key with each other during the process of writing data to the RPMB, which reduces data interaction caused by calling the security key and simplifies the process of writing data to the RPMB.
[0174] In one possible scenario, the data to be stored could be data required for encryption and decryption, which has high security requirements and is typically stored in RPMB.
[0175] For example, the data to be stored could be facial recognition data, that is, data captured by a camera. Applications running on the Android system that require encryption, such as Alipay, could also be stored. Upon receiving a face recognition registration request from a user, the fingerprint CA sends the request to the face TA (i.e., the first TA) in the first TEE. Based on this request, the face TA accesses the camera, collects face recognition data, and sends the collected data back to the face TA. Then, the face TA can send the collected face recognition data to the corresponding RPMB partition (i.e., the first storage area) for storage via the Hypervisor module in the kernel.
[0176] The data storage method provided in this application embodiment can be applied to, for example, Figure 8 In the electronic device shown. For example, such as... Figure 8As shown, the electronic device includes TEE-0, TEE-1, the kernel, and a storage device. The storage device includes two RPMB partitions, RPMB region0 and RPMB region1. It should be understood that the kernel refers to the core component of the operating system, serving as the primary interface between the computer's physical hardware and the processes running on it. The kernel can include multiple modules. For example, ... Figure 8 As shown, the kernel includes a Hypervisor module, a TEE-0tz driver module, a TEE-1tz driver module, and a storage device driver module. The RPMB partition corresponding to TEE-0 is RPMB region0, and the RPMB partition corresponding to TEE-1 is RPMB region1. TEE-0 and RPMB region0 store the same security key, secure key0, and TEE-1 and RPMB region1 store the same security key, secure key1. It should be understood that secure key0 and secure key1 are usually different. TEE-0 runs a fingerprint TA and a first RPMB service module, where the first RPMB service module stores secure key0. TEE-1 runs a face TA and a second RPMB service module, where the second RPMB service module stores secure key1. The fingerprint TA can send the first data packet to RPMB region0 through the Hypervisor module. The face TA can send the first data packet to RPMB region1 through the Hypervisor module. Optionally, the electronic device also includes an ATF module.
[0177] It should be understood that electronic devices can be divided into four operating levels: EL0, EL1, EL2, and EL3. Applications operate at EL0, meaning that applications requiring encryption (fingerprint CA), fingerprint TA, the first RPMB service module, face TA, and the second RPMB service module in the Android system operate at EL0. The TEE-OTZT driver module, TEE-ITZT driver module, and storage device driver module operate at EL1. The hypervisor module operates at EL2. The ATF module operates at EL3. Storage devices and fingerprint sensors operate at the hardware layer.
[0178] The Hypervisor module has the ability to access all physical devices on the electronic devices, including disks and memory. After the server starts, the Hypervisor module loads the operating systems of all virtual machine clients (including TEE-0, TEE-1, and storage devices) and allocates memory, disk, and network for the virtual machines. This allows the Hypervisor module to directly allocate data interfaces for the first TEE and storage devices, enabling data transfer between TEE-0 and storage devices, and between TEE-1 and storage devices.
[0179] It should be understood that the first TEE can refer to TEE-0 or TEE-1, and the embodiments of this application do not limit this.
[0180] When the first TEE refers to TEE-0, the corresponding first storage area can refer to RPMB region0, the first security key can refer to secure key0, and the first TA can include fingerprint TA and the first RPMB service module.
[0181] When the first TEE refers to TEE-1, the corresponding first storage area can refer to RPMB region1, the first security key can refer to secure key1, and the first TA can include the face TA and the second RPMB service module.
[0182] The following is combined with Figures 9 to 11 right Figure 8 The data storage method of the electronic device shown is described in detail.
[0183] Figure 9 This is a flowchart illustrating a data storage method provided in one embodiment of this application, which is applied to... Figure 8 The electronic device shown illustrates the specific process of how a face TA writes data to the corresponding RPMB region 0. For ease of understanding, [the following is used as an example]. Figure 10 The data flow diagram shown is used to illustrate this. Figure 9 The example shown. Figure 9 and Figure 10 As shown, the method includes:
[0184] S201. The face recognition CA running on the Android system (REE) detected a face recognition registration operation (equivalent to the first operation).
[0185] Among them, the facial recognition registration operation can be used to instruct the acquisition of facial recognition data.
[0186] S202. In response to the face recognition registration operation, the face CA sends a face recognition registration request to the TEE-0tz driver module (equivalent to the first TEE tz driver module) in the kernel.
[0187] The S203 and TEE-0tz driver modules send a face recognition registration request to the Hypervisor module.
[0188] S204, the Hypervisor module sends a face recognition registration request to the face TA in TEE-0.
[0189] It should be understood that the first TA refers to the application running in the first TEE, which can refer to one TA or multiple TAs. For example, such as... Figure 8 As shown, the first TA may include a face TA and a first RPMB service module.
[0190] S205. Face TA responds to the face recognition registration request by calling the security camera to collect face recognition data (data to be stored).
[0191] S206. The face recognition TA sends the face recognition data and the request to store the face recognition data in RPMB region0 to the first RPMB service module in TEE-0.
[0192] For example, a face TA can be used Figure 11 The format shown indicates that face recognition data is sent to the first RPMB service module, along with a request to store the face recognition data in RPMB region 0. For example... Figure 10 As shown, this includes the amount of data written to the cmd id via RPMB, the amount of data in RPMBdata, and RPMB data. RPMB data can be face recognition data.
[0193] S207. The first RPMB service module uses secure key0 to perform authentication calculations on the face recognition data to obtain the first authentication data.
[0194] Optionally, authentication computation can refer to hash computation. Hash computation can be a computational method that calculates data using a hash-based Message Authentication Code (HMAC), and is a method of message authentication based on a hash function and a key.
[0195] For example, the first RPMB service module can use the first security key to perform authentication calculations on the data to be stored via HMAC. HMAC is a widely used authentication method employed by many current security protocols. For instance, it is widely used in Internet Protocol Security (IPSec) and other network protocols (such as SSL) and has withstood various forms of attacks. Therefore, HMAC can also be considered an existing Internet security standard.
[0196] In the embodiments of this application, the first TA uses the first security key to perform authentication calculation on the data to be stored through hash operation to obtain the first authentication data. Since hash operation is a widely used encryption algorithm that has withstood various forms of attacks, the first authentication data obtained through hash operation is more reliable encrypted data, thereby improving the security of obtaining the first authentication data.
[0197] For example, the first RPMB service module can also use the first security key to calculate the data to be stored using the Cipher Block Chaining-Message Authentication Code (CMAC) to obtain the first authentication data.
[0198] S208, the first RPMB proxy service module packages the first authentication data and the face recognition data to obtain the first data packet.
[0199] Optionally, the generated first data packet may also include a random number, a count value, the storage address of the face recognition data, the operation result of the face recognition data, and the cmd id.
[0200] Here, the random number can refer to a hardware-generated random number, which is used by the electronic device for encryption. Since each RPMB partition has an independent counter, the count value can refer to the current count value of the counter in the first storage area. The storage address of the face recognition data can refer to the storage address of the face recognition data in RPMB region0.
[0201] For example, the data format of the first data packet can be as follows: Figure 12As shown, this includes MAC, RPMB data, random number, write counter, storage address, operation result on face recognition data, and written cmd id. Here, MAC can refer to the first authentication data, RPMB data can be face recognition data, and the storage address can be the storage address of the face recognition data in RPMB region0.
[0202] S209. The first RPMB proxy service module sends the first data packet to the Hypervisor module.
[0203] The S210 and Hypervisor modules send the first data packet to the TEE-0tz driver module in the kernel.
[0204] Optionally, the first data packet also includes the SECURITY PROTOCOL SPECIFIC parameter (equivalent to the first parameter). The SECURITY PROTOCOL SPECIFIC parameter is used to indicate the identifier of the RPMB partition to which the first data packet is sent.
[0205] It should be understood that after the Hypervisor module receives the first data packet, it can determine the target RPMB partition, i.e., the first storage area, based on the SECURITY PROTOCOLSPECIFIC parameter. Then, the Hypervisor module can establish a data channel to send the first data packet to the first storage area, which is the process shown in steps S211 to S212 below.
[0206] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, it sends a first data packet obtained based on the data to be stored, first parameters, and the first authentication data to a Hypervisor module. The Hypervisor module determines, based on the first parameters, that the recipient of the first data packet is the first storage area, and then sends the first data packet to the first storage area. The first storage area stores the data to be stored based on the same first security key. This allows the Hypervisor module to accurately send the first data packet to the first storage object, further improving the accuracy of writing data to the first storage area by using an independent security key to authenticate the data written to the first storage area.
[0207] S211, the TEE-0tz driver module sends the first data packet to the storage device driver module.
[0208] For example, the storage device driver module refers to the eMMC driver module.
[0209] For example, the storage device driver module refers to the UFS driver module.
[0210] S212, The storage device driver module sends the first data packet to RPMB region0.
[0211] S213, RPMB region0 (equivalent to the first storage region) uses secure key0 to perform authentication calculation on the data to be stored in the first data packet to obtain the second authentication data.
[0212] S214, RPMB region0 stores the data to be stored if the first authentication data and the second authentication data match.
[0213] It should be understood that the first authentication data is obtained by performing authentication calculations on the data to be stored using the first security key, and the second authentication data is also obtained by performing authentication calculations on the data to be stored using the same first security key. In other words, when the first security key, the data to be stored, and the authentication calculation method are the same, the first authentication data and the second authentication data are obtained by performing the same calculations on the same data using the same security key, and therefore, the first authentication data and the second authentication data are identical.
[0214] It should be understood that obtaining the first authentication data and the second authentication data requires separate authentication calculations for the data to be stored. Considering the errors that may occur during the authentication calculations, the first authentication data and the second authentication data are considered to match if the identical portions exceed a preset threshold. If the first authentication data and the second authentication data are determined to match, the first storage area can store the data to be stored.
[0215] The data storage method provided in the embodiments of this application includes an electronic device comprising at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtaining first authentication data. Then, a first data packet obtained based on the data to be stored and the first authentication data is sent to the first storage area. The first storage area uses the same first security key to perform the same authentication calculations on the data to be stored in the first data packet, obtaining second authentication data. If the first authentication data and the second authentication data match, the data to be stored is stored, based on the same first security key. This ensures that all data stored in the first storage area is verified by the first storage area using an independent security key, effectively preventing attacks from unknown sources and improving the security of data stored in the first storage area.
[0216] In one possible scenario, the data to be stored could be data collected by a fingerprint sensor. This applies to applications running on the Android system that require encryption, such as Alipay. Upon receiving a fingerprint registration request from a user, the fingerprint CA sends the request to the fingerprint TA (i.e., the first TA) in the first TEE. Based on the fingerprint registration request, the fingerprint TA calls the fingerprint sensor to collect fingerprint data and sends the collected fingerprint data back to the fingerprint TA. Then, the fingerprint TA can send the collected fingerprint data to the corresponding RPMB partition (i.e., the first storage area) for storage through the Hypervisor module in the kernel.
[0217] Figure 13 This is a flowchart illustrating a data storage method provided in one embodiment of this application, which is applied to... Figure 8 The electronic device shown illustrates the specific process of how the fingerprint TA writes data to the corresponding RPMB region 1. For ease of understanding, [the following is used as an example]. Figure 14 The data flow diagram shown is used to illustrate this. Figure 13 The example shown.
[0218] It should be understood that the process of writing data from the face TA and fingerprint TA to the corresponding RPMB partition can be performed in response to the same operation or in response to different operations, and the embodiments of this application do not limit this.
[0219] like Figure 13 and Figure 14 As shown, the method includes:
[0220] S301, The fingerprint CA running in the Android system (REE) detected the fingerprint registration operation (equivalent to the first operation).
[0221] Among them, the fingerprint registration operation can be used to indicate the acquisition of fingerprint data.
[0222] It should be understood that the fingerprint registration request may include a VM id, which is used to indicate the recipient of the fingerprint registration request, that is, the fingerprint TA in TEE-1.
[0223] S302, the fingerprint CA responds to the fingerprint registration operation by sending a fingerprint registration request to the TEE-1tz driver module in the kernel.
[0224] S303, the first TEE tz driver module sends a fingerprint registration request to the Hypervisor module.
[0225] S304, the Hypervisor module sends a fingerprint registration request to the ATF module.
[0226] The Hypervisor module determines that the recipient of the fingerprint registration request is the fingerprint TA in TEE-1 based on the VM id in the fingerprint registration request, and then establishes a data channel to send the fingerprint registration request to the fingerprint TA.
[0227] In some cases, data interaction between the Hypervisor module and the first TA running in the first TEE must be through the ATF module. That is, the fingerprint registration request sent by the Hypervisor module to the fingerprint TA needs to go through the ATF module.
[0228] In some possible scenarios, the Hypervisor module can directly interact with the first TA running in the first TEE, without going through the ATF module. That is, the fingerprint registration request sent by the Hypervisor module to the fingerprint TA does not need to go through the ATF module.
[0229] Optionally, the Hypervisor module can send a fingerprint registration request to the ATF module.
[0230] The S305 and ATF modules send a fingerprint registration request to the fingerprint TA in TEE-1.
[0231] It should be understood that, Figure 13 In the illustrated embodiment, the first TEE refers to TEE-1.
[0232] It should be understood that the first TA refers to an application running in the first TEE, which can refer to one TA or multiple TAs. In the embodiments of this application, such as... Figure 8 As shown, the first TA refers to the fingerprint TA and the second RPMB service running in TEE-1.
[0233] S306. The fingerprint TA responds to the fingerprint registration request and instructs the fingerprint sensor to collect fingerprint data (data to be stored).
[0234] S307, the fingerprint TA sends the fingerprint data and the request to store it in RPMB region 1 to the second RPMB service module in TEE-1.
[0235] For example, fingerprint TA can be used as Figure 10 The format shown indicates that fingerprint data is sent to the second RPMB service module and a request is made to store fingerprint data in RPMB region 1.
[0236] S308, the second RPMB service module uses secure key1 to perform authentication calculation on the fingerprint data to obtain the first authentication data.
[0237] It should be understood that when the first TEE is TEE-1, the first security key refers to secure key1. The second RPMB service module can use secure key1 to perform authentication calculations on the fingerprint data to obtain the first authentication data.
[0238] S309, the second RPMB proxy service module packages the first authentication data and fingerprint data to obtain the first data packet.
[0239] Optionally, the generated first data packet may also include a random number, a count value, the storage address of the fingerprint data, the operation result of the fingerprint data, and the cmd id to be written.
[0240] Here, the random number can refer to a hardware-generated random number, which is used by the electronic device for encryption. Since each RPMB partition has an independent counter, the count value can refer to the current count value of the counter in the first storage area. The storage address of the fingerprint data can refer to the storage address of the fingerprint data in the first storage area.
[0241] For example, the data format of the first data packet can be as follows: Figure 11 As shown, this includes MAC, RPMB data, random number, write counter, address, operation result on fingerprint data, and written cmd id. Here, MAC can refer to the first authentication data, RPMB data can be the fingerprint data, and the storage address can be the storage address of the fingerprint data in RPMB region1.
[0242] S310, the second RPMB proxy service module sends the first data packet to the ATF module.
[0243] S311, the ATF module sends the first data packet to the Hypervisor module.
[0244] S312, the Hypervisor module sends the first data packet to the TEE-1tz driver module (equivalent to the first TEE tz driver module) in the kernel.
[0245] It should be understood that the TEE-1tz driver module is a module within the kernel. With the TEE-1tz driver module being a kernel module, the Hypervisor module can send the first data packet to RPMB region 1 according to a pre-set process.
[0246] In the embodiments of this application, when the Hypervisor module sends the first data packet to the first storage area, it utilizes the first TEE tz driver module in the kernel. This allows the first data packet to be sent using a pre-set process, eliminating the need for the user to set the process for sending the first data packet to the first storage area, thus improving the convenience of writing data to the first storage area.
[0247] The S313 and TEE-1tz driver modules send the first data packet to the storage device driver module.
[0248] For example, the storage device driver module refers to the eMMC driver module.
[0249] For example, the storage device driver module refers to the UFS driver module.
[0250] The TEE-1tz driver module can send the first data packet directly to the storage device driver module, or it can forward the first data packet to the storage device driver module through other modules.
[0251] Optionally, the REE also runs a TEE-1RPMB driver module (not shown in the figure). The TEE-1tz driver module can send the first data packet to the storage device driver module by forwarding it to the storage device driver module through the TEE-1RPMB driver module.
[0252] For example, one possible implementation of S313 "TEE-1tz driver module sends first data packet to storage device driver module" includes:
[0253] Step 1: The TEE-1tz driver module forwards the first data packet to the TEE-1RPMB driver module.
[0254] Step 2: The TEE-1RPMB driver module redirects to the storage device driver module to send the first data packet.
[0255] S314. The storage device driver module sends the first data packet to the first storage area.
[0256] S315, RPMB region1 (equivalent to the first storage area) uses secure key1 to perform authentication calculation on the data to be stored in the first data packet to obtain the second authentication data.
[0257] S316, RPMB region1 stores the data to be stored if the first authentication data and the second authentication data match.
[0258] In the embodiments of this application, the electronic device includes at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area in the RPMB. The at least two TEEs include a first TEE, in which a first trusted application (TA) runs. The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. The first TEE stores a first security key, and the first storage area stores the same first security key as the one in the first TEE. The first TA uses the first security key to perform authentication calculations on the data to be stored, obtains first authentication data, and then sends the first data packet obtained based on the data to be stored and the first authentication data to the first storage area. The process of sending the first data packet to the first storage area can be done through an ATF module. Typically, sending data to the RPMB through the ATF module is a pre-set process, so there is no need for the user to set up a process for sending data to the RPMB, which improves the convenience of writing data from the first TEE to the first storage area.
[0259] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0260] Figure 15 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0261] It should be understood that electronic devices can perform Figures 6 to 14 The data storage method shown includes an electronic device comprising at least two Trusted Execution Environments (TEEs) and a Replay Protection Memory Block (RPMB). One of the at least two TEEs corresponds one-to-one with a storage area within the RPMB. The at least two TEEs include a first TEE running a first trusted application (TA). The RPMB includes a first storage area, and the first TEE corresponds to the first storage area. A first security key is stored in both the first TEE and the first storage area. The first security key is used to perform authentication calculations on the data to be stored between the first storage area and the first TA. The data to be stored is data written to the first storage area. The electronic device also includes an acquisition unit 610 and a processing unit 620.
[0262] The processing unit 620 is used to control the first TA to send a first data packet to the first storage area. The first data packet includes data to be stored and first authentication data. The first authentication data is the data obtained by the first TA after authenticating the data to be stored using the first security key. The first storage area stores the data to be stored based on the first security key.
[0263] Optionally, as an embodiment, at least two TEEs also include a second TEE, the RPMB includes a second storage area, the second TEE corresponds to the second storage area, and a second security key is stored in the second TEE and the second storage area, the second security key being different from the first security key.
[0264] Optionally, as an embodiment, the electronic device further includes a kernel, which includes a hypervisor module. The processing unit 620 is used to control the first TA to send a first data packet to the hypervisor module; the hypervisor module sends the first data packet to the first storage area.
[0265] Optionally, as an embodiment, the first data packet includes a first parameter, which is used to indicate a first storage area; the Hypervisor module sends the first data packet to the first storage area, and the processing unit 620 is used to control the Hypervisor module to determine the first storage area based on the first parameter; the Hypervisor module sends the first data packet to the first storage area.
[0266] Optionally, as an embodiment, the kernel further includes an ATF module, and the processing unit 620 is used to control the first TA to send a first data packet to the ATF module; the ATF module sends the first data packet to the Hypervisor module.
[0267] Optionally, as an embodiment, the kernel further includes a first TEE tz driver module, and the processing unit 620 is used to control the Hypervisor module to send a first data packet to the first TEE tz driver module; the first TEE tz driver module sends the first data packet to the first storage area.
[0268] Optionally, as an embodiment, the kernel further includes a storage device driver module, and the processing unit 620 is used to control the first TEE tz driver module to send a first data packet to the storage device driver module; the storage device driver module sends the first data packet to the first storage area.
[0269] Optionally, as an embodiment, the processing unit 620 is used to control the first storage area to perform authentication calculation on the data to be stored in the first data packet using the first security key to obtain the second authentication data; if the first authentication data and the second authentication data match, the first storage area stores the data to be stored.
[0270] Optionally, as an embodiment, the electronic device further includes a rich execution environment (REE) and a first device, wherein a first client application (CA) runs in the REE, and a processing unit 620 is used to control the reception of a first operation, the first operation being used to instruct the acquisition of data to be stored; in response to the first operation, the first CA sends a first request to a first transaction controller (TA), the first request being used to instruct the first TA to acquire the data to be stored; in response to the first request, the first TA instructs the first device to collect first data; and the first TA obtains the data to be stored based on the first data.
[0271] Optionally, as an embodiment, the first device includes a fingerprint sensor.
[0272] Optionally, as an embodiment, the first device includes a camera.
[0273] Optionally, as an embodiment, the first TA includes a face TA and a first RPMB service module. The data to be stored is face recognition data. The processing unit 620 is used to control the face TA to instruct the camera to collect face recognition data; the face TA sends face recognition data to the first RPMB service module; the first RPMB service module generates a first data packet based on the face recognition data; and the first RPMB service module sends the first data packet to the Hypervisor module.
[0274] Optionally, as an embodiment, the electronic device further includes a rich execution environment (REE) and a camera. A face client application (CA) runs in the REE. Before the face TA instructs the camera to collect face recognition data, the processing unit 620 controls the face CA to detect a face recognition registration operation. The face recognition registration operation is used to instruct the acquisition of face recognition data. In response to the face recognition registration operation, the face CA sends a face recognition registration request to the face TA. The face recognition registration request is used to instruct the face TA to acquire face recognition data. In response to the face recognition registration request, the face TA instructs the camera to collect face recognition data.
[0275] Optionally, as an embodiment, the first TA includes a fingerprint TA and a second RPMB service module. The data to be stored is fingerprint data. The processing unit 620 is used to control the fingerprint TA to instruct the fingerprint sensor to collect fingerprint data; the fingerprint TA sends the fingerprint data to the second RPMB service module; the second RPMB service module generates a first data packet based on the fingerprint data; and the second RPMB service module sends the first data packet to the Hypervisor module.
[0276] Optionally, as an embodiment, the electronic device further includes a rich execution environment (REE) and a fingerprint sensor. A fingerprint client application (CA) runs in the REE. Before the fingerprint sensor instructs the fingerprint TA to collect fingerprint data, the processing unit 620 controls the fingerprint CA to detect a fingerprint registration operation. The fingerprint registration operation is used to instruct the fingerprint sensor to collect fingerprint data. In response to the fingerprint registration operation, the fingerprint CA sends a fingerprint registration request to the fingerprint TA. The fingerprint registration request is used to instruct the fingerprint TA to collect fingerprint data. In response to the fingerprint registration request, the fingerprint TA instructs the fingerprint sensor to collect fingerprint data.
[0277] Optionally, as an embodiment, the kernel further includes an ATF module, and the processing unit 620 is used to control the second RPMB service module to send a first data packet to the ATF module; the ATF module sends the first data packet to the Hypervisor module.
[0278] Optionally, as an example, the authentication calculation includes a hash HMAC calculation.
[0279] The electronic device provided in this embodiment is used to execute the data storage method of the above embodiment. The technical principle and technical effect are similar, and will not be described again here.
[0280] It should be noted that the aforementioned data electronic equipment is embodied in the form of functional units. The term "unit" here can be implemented in software and / or hardware, without specific limitations.
[0281] It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0282] This application embodiment can divide an electronic device into functional modules based on the above method examples. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one module. It should be noted that the module division in this application embodiment is illustrative and represents only one logical functional division; other division methods may be used in actual implementation. It should also be noted that the module names in this application embodiment are illustrative, and the names of the modules are not limited in actual implementation.
[0283] For example, a "unit" can be a software program, a hardware circuit, or a combination of both that implements the above functions. The hardware circuit may include an application-specific integrated circuit (ASIC), electronic circuitry, a processor (e.g., a shared processor, a proprietary processor, or a group processor) and memory for executing one or more software or firmware programs, integrated logic circuitry, and / or other suitable components that support the described functions.
[0284] Therefore, the units of the various examples described in the embodiments of this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0285] Figure 16 A schematic diagram of the structure of an electronic device provided in this application is shown. Figure 16 The dashed lines in the diagram indicate that the unit or module is optional. The electronic device 700 can be used to implement the data storage method described in the above method embodiments.
[0286] Electronic device 700 includes one or more processors 701, which support the data storage method in the method embodiments of electronic device 700. Processor 701 can be a general-purpose processor or a special-purpose processor. For example, processor 701 can be a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.
[0287] The processor 701 can be used to control the electronic device 700, execute software programs, and process data from the software programs. The electronic device 700 may also include a communication unit 705 for inputting (receiving) and outputting (transmitting) signals.
[0288] For example, electronic device 700 may be a chip, communication unit 705 may be the input and / or output circuit of the chip, or communication unit 705 may be the communication interface of the chip, and the chip may be a component of terminal device or other electronic device.
[0289] For example, electronic device 700 can be a terminal device, communication unit 705 can be the transceiver of the terminal device, or communication unit 705 can be the transceiver circuit of the terminal device.
[0290] The electronic device 700 may include one or more memories 702, which store a program 704. The program 704 can be executed by the processor 701 to generate instructions 703, causing the processor 701 to execute the impedance matching method described in the above method embodiments according to the instructions 703.
[0291] Optionally, the memory 702 may also store data. Optionally, the processor 701 may also read the data stored in the memory 702, which may be stored at the same memory address as the program 704, or the data may be stored at a different memory address than the program 704.
[0292] The processor 701 and memory 702 can be configured separately or integrated together; for example, integrated on the system on chip (SOC) of the terminal device.
[0293] For example, the memory 702 can be used to store the related program 704 of the data storage method provided in the embodiments of this application, and the processor 701 can be used to call the related program 704 of the data storage method stored in the memory 702 when performing data storage, and execute the data storage method of the embodiments of this application; including: a first TA sending a first data packet to a first storage area, the first data packet including data to be stored and first authentication data, the first authentication data being the data obtained by the first TA after authenticating the data to be stored using a first security key; the first storage area storing the data to be stored based on the first security key.
[0294] This application also provides a computer program product that, when executed by processor 701, implements the data storage method described in any of the method embodiments of this application.
[0295] The computer program product can be stored in memory 702, for example, program 704. Program 704 is finally converted into an executable object file that can be executed by processor 701 after processing such as preprocessing, compilation, assembly and linking.
[0296] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, implements the data storage method described in any of the method embodiments of this application. The computer program may be a high-level language program or an executable object program.
[0297] The computer-readable storage medium is, for example, memory 702. Memory 702 can be volatile memory or non-volatile memory, or memory 702 can include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0298] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0299] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0300] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0301] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0302] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and other division methods may exist in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0303] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0304] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0305] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data storage method, the method being applied to an electronic device, characterized in that, The method includes: A first trusted application (TA) sends a first data packet to a first storage area. The first data packet includes first data to be stored and first authentication data. The first trusted application (TA) is located in a first trusted execution environment (TEE). The first storage area is located in a replay protection memory block (RPMB). The first trusted execution environment (TEE) stores a first security key. The first authentication data is data obtained by performing authentication calculations on the first data to be stored using the first security key. The first storage area stores the first data to be stored based on the first security key, and the first storage area stores the first security key; The second trusted application (TA) sends a second data packet to the second storage area. The second data packet includes second data to be stored and second authentication data. The second trusted application (TA) is located in the second trusted execution environment (TEE). The second storage area is located in the replay protection memory block (RPMB). The second trusted execution environment (TEE) is different from the first trusted execution environment (TEE). The second storage area is different from the first storage area. The second trusted execution environment (TEE) stores a second security key. The second authentication data is the data obtained after performing the authentication calculation on the second data to be stored using the second security key. The second storage area stores the second data to be stored based on the second security key, and the second storage area stores the second security key.
2. The method according to claim 1, characterized in that, The electronic device includes a kernel, which includes a hypervisor module. The first trusted application (TA) sends a first data packet to the first storage area, including: The first trusted application (TA) sends the first data packet to the Hypervisor module; The Hypervisor module sends the first data packet to the first storage area.
3. The method according to claim 2, characterized in that, The first data packet includes a first parameter, which is used to indicate the first storage area; The Hypervisor module sends the first data packet to the first storage area, including: The Hypervisor module determines the first storage area based on the first parameter; The Hypervisor module sends the first data packet to the first storage area.
4. The method according to claim 3, characterized in that, The kernel also includes an ATF module, and the first trusted application (TA) sends the first data packet to the Hypervisor module, including: The first trusted application (TA) sends the first data packet to the ATF module; The ATF module sends the first data packet to the Hypervisor module.
5. The method according to any one of claims 2 to 4, characterized in that, The kernel further includes a first trusted execution environment (TEE) TZ driver module, and the hypervisor module sends the first data packet to the first storage area, including: The Hypervisor module sends the first data packet to the first Trusted Execution Environment (TEE) tz driver module; The first Trusted Execution Environment (TEE) tz driver module sends the first data packet to the first storage area.
6. The method according to claim 5, characterized in that, The kernel further includes a storage device driver module, wherein the first Trusted Execution Environment (TEE) TZ driver module sends the first data packet to the first storage area, including: The first Trusted Execution Environment (TEE) TZ driver module sends the first data packet to the storage device driver module; The storage device driver module sends the first data packet to the first storage area.
7. The method according to any one of claims 1 to 4, characterized in that, The first storage area stores the first data to be stored, including: The first storage area uses a first security key to perform authentication calculations on the first data to be stored in the first data packet to obtain third authentication data; If the first authentication data and the third authentication data match, the first storage area stores the first data to be stored.
8. The method according to any one of claims 1 to 4, characterized in that, The electronic device further includes a rich execution environment (REE) and a first device, wherein a first client application CA runs in the rich execution environment (REE), and the method further includes: Receive a first operation, the first operation being used to instruct the acquisition of the first data to be stored; In response to the first operation, the first client application CA sends a first request to the first trusted application TA, the first request being used to instruct the first trusted application TA to obtain the first data to be stored; In response to the first request, the first trusted application TA instructs the first device to collect the first data; The first trusted application TA obtains the first data to be stored based on the first data.
9. The method according to claim 8, characterized in that, The first device includes a fingerprint sensor.
10. The method according to claim 8, characterized in that, The first device includes a camera.
11. The method according to claim 2, characterized in that, The first trusted application TA includes a face trusted application TA and a first RPMB service module. The first RPMB service module stores a first security key, and the first data to be stored is face recognition data. The first trusted application TA sends the first data packet to the Hypervisor module, including: The trusted face application TA instructs the camera to collect face recognition data; The trusted face application TA sends the face recognition data to the first RPMB service module; The first RPMB service module generates the first data packet based on the face recognition data; The first RPMB service module sends the first data packet to the Hypervisor module.
12. The method according to claim 11, characterized in that, The electronic device further includes a rich execution environment (REE) and the camera, wherein a face client application (CA) runs in the REE, and the method further includes the following steps before the face trusted application (TA) instructs the camera to acquire face recognition data: The face recognition client application CA detects a face recognition registration operation, which is used to indicate the acquisition of the face recognition data; In response to the face recognition registration operation, the face client application CA sends a face recognition registration request to the face trusted application TA, the face recognition registration request being used to instruct the face trusted application TA to obtain face recognition data; The trusted face application TA instructs the camera to collect face recognition data, including: In response to the face recognition registration request, the face trusted application TA instructs the camera to collect the face recognition data.
13. The method according to claim 2, characterized in that, The first trusted application TA includes a fingerprint trusted application TA and a first RPMB service module. The first RPMB service module stores the first security key, and the first data to be stored is fingerprint data. The first trusted application TA sends the first data packet to the Hypervisor module, including: The fingerprint trusted application TA instructs the fingerprint sensor to collect fingerprint data; The fingerprint trusted application TA sends the fingerprint data to the first RPMB service module; The first RPMB service module generates the first data packet based on the fingerprint data; The first RPMB service module sends the first data packet to the Hypervisor module.
14. The method according to claim 13, characterized in that, The electronic device further includes a rich execution environment (REE) and the fingerprint sensor, wherein a fingerprint client application (CA) runs in the REE, and the method further includes, before the fingerprint trusted application (TA) instructs the fingerprint sensor to acquire fingerprint data: The fingerprint client application CA detects a fingerprint registration operation, which is used to instruct the acquisition of the fingerprint data. In response to the fingerprint registration operation, the fingerprint client application CA sends a fingerprint registration request to the fingerprint trusted application TA, the fingerprint registration request being used to instruct the fingerprint trusted application TA to obtain fingerprint data; The fingerprint trusted application TA instructs the fingerprint sensor to collect fingerprint data, including: In response to the fingerprint registration request, the fingerprint trusted application (TA) instructs the fingerprint sensor to acquire the fingerprint data.
15. The method according to claim 13, characterized in that, The kernel also includes an ATF module, and the first RPMB service module sends the first data packet to the Hypervisor module, including: The first RPMB service module sends the first data packet to the ATF module; The ATF module sends the first data packet to the Hypervisor module.
16. The method according to any one of claims 1 to 4, characterized in that, The authentication calculation includes HMAC calculation.
17. A chip, characterized in that, Includes a processor, which, when executing instructions, performs the method as described in any one of claims 1 to 16.
18. An electronic device, characterized in that, The electronic device includes a processor configured to couple with a memory, read instructions from the memory, and cause the electronic device to perform the method as described in any one of claims 1 to 16 according to the instructions.
19. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the method of any one of claims 1 to 16.
Citation Information
Patent Citations
Data storage method and electronic equipment
CN117668933A