Data storage method and electronic device
By sending the data to be stored in the first TEE that does not store the security key to the second TEE that stores the security key for authentication calculation in the multi-TEE architecture, the problem of not being able to write data to RPMB in the multi-TEE framework is solved, realizing the function that each TEE can store data to RPMB, and improving the security of data storage and resource utilization efficiency.
Patent Information
- Application Number
- CN202210879893.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-25
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-07-25
AI Technical Summary
In a Trusted Execution Environment (TEE) framework, the Secure Key can only be stored in one TEE, which prevents other TEEs from calling the Secure Key to perform calculations on the data. Consequently, it is impossible to achieve the function of each TEE being able to write data to the Replay Protected Memory Block (RPMB).
By sending the data to be stored to the second TA in the second TEE that stores the security key through the first trusted application (TA) in the first TEE that does not store the security key, the second TA uses the security key to perform authentication calculation on the data to be stored, generates an authentication data packet, and sends it to the RPMB for storage, thus enabling each TEE in the multi-TEE architecture to write data to the RPMB.
This enables any TEE in a multi-TEE architecture to store data to the RPMB, improving the security and reliability of data storage, avoiding unnecessary data transfer, and saving resources.
Smart Images

Figure CN117492636B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data processing, and more particularly, to a data storage method and an electronic device. BACKGROUND
[0002] Replay Protected Memory Block (RPMB) generally refers to a separate physical partition in a memory, which is often used to store sensitive data such as keys. The memory can include Universal Flash Storage (UFS) and Embedded Multi Media Card (eMMC). When writing data to the RPMB, the Trusted Execution Environment (TEE) uses a Secure Key to calculate the first authentication data for the to-be-stored data, and then sends the to-be-stored data and the first authentication data to the RPMB. The RPMB receives the above data, and similarly, the RPMB uses the same authentication algorithm to calculate the second authentication data for the to-be-stored data using the Secure Key. If the first authentication data and the second authentication data are the same, the above to-be-stored data is stored.
[0003] With the continuous progress of terminal technology, the multi- Trusted Execution Environment (TEE) architecture has become a common architecture. Generally, the Secure Key can only be stored in one TEE. In the case of a terminal device using a multi-TEE framework, since the Secure Key can only be stored in one TEE, other TEEs cannot call the Secure Key to calculate the first authentication data for the data, thus making the RPMB unable to complete the authentication of the to-be-stored data, resulting in the RPMB being unable to store the to-be-written data, and further resulting in the inability to implement the function of each TEE being able to write data to the RPMB.
[0004] Therefore, how to implement the function of each TEE being able to write data to the RPMB in a multi-TEE framework has become a problem to be solved. SUMMARY
[0005] The present application provides a data storage method, which can implement the function of each TEE being able to write data to the RPMB in a multi-TEE framework.
[0006] In a first aspect, a data storage method is provided, which is applied to an electronic device comprising at least two trusted execution environments (TEEs), the at least two TEEs comprising a first TEE and a second TEE, the first TEE being a TEE without storing a security key, and the second TEE being a TEE storing a security key, the method comprising:
[0007] a first trusted application (TA) sending to-be-stored data to a second TA, the first TA being a trusted application running on the first TEE, and the second TA being a trusted application running on the second TEE;
[0008] the second TA performing authentication calculation on the to-be-stored data by using the security key to obtain first authentication data;
[0009] the second TA obtaining a first data packet according to the first authentication data and the to-be-stored data;
[0010] the second TA sending the first data packet to a replay protection memory block (RPMB);
[0011] the RPMB storing the to-be-stored data in the first data packet.
[0012] The data storage method provided in the embodiments of the present application is applied to an electronic device including at least two TEEs, the at least two TEEs including a first TEE and a second TEE, the first TEE being a TEE in which a security key is not stored, and the second TEE being a TEE in which a security key is stored, and the method includes: a first TA sending to-be-stored data to a second TA, the first TA being a trusted application running on the first TEE, and the second TA being a trusted application running in the second TEE; the second TA performing calculation on the to-be-stored data by using the security key to obtain first authentication data, and obtaining a first data packet according to the first authentication data and the to-be-stored data; the second TA sending the first data packet to a replay protection memory block (RPMB); and the RPMB storing the to-be-stored data in the first data packet after performing calculation authentication on the first data packet by using the security key and passing the authentication. That is, in the embodiments of the present application, because the security key is not stored in the first TEE, if the first TA running in the first TEE needs to store to-be-stored data to the RPMB, the first TA cannot obtain the security key to perform authentication calculation on the to-be-stored data, so that the first TA cannot directly store the to-be-stored data to the RPMB. Meanwhile, because the security key is stored in the second TEE, the first TA in the first TEE can send the to-be-stored data to the second TA in the second TEE, so that the second TA performs authentication calculation on the to-be-stored data by using the stored security key to obtain first authentication data, and generates a second data packet according to the first authentication data and the to-be-stored data, and the second TA can send the second data packet to the RPMB, so that the to-be-stored data in the first TEE in which the security key is not stored is stored to the RPMB. Thus, it is realized that any one of the multiple TEEs in the electronic device can store data to the RPMB.
[0013] With reference to the first aspect, in some implementations of the first aspect, the first trusted application (TA) running in the first TEE sends to-be-stored data to a second trusted application (TA) running in the second TEE, including:
[0014] The first TA sends the to-be-stored data to a client application (CA) running in a rich execution environment (REE).
[0015] The CA sends the to-be-stored data to the second TA.
[0016] In the embodiments of the present application, in the process that the first TA sends the to-be-stored data to the second TA, the to-be-stored data is first sent to a CA running in the REE, and then the to-be-stored data is forwarded to the second TA by the CA. In this way, when the first TA sends the to-be-stored data to the second TA, the existing data channel between the REE and the first TEE and the data channel between the REE and the second TEE can be used, and it is not necessary to additionally establish a data channel between the first TEE and the second TEE. That is, by forwarding the to-be-stored data to the second TA through the CA running in the REE, the first TA can perform data transmission to the second TA through the existing data channel, and the unstable data transmission caused by newly establishing a data channel is avoided.
[0017] With reference to the first aspect, in some implementations of the first aspect, the first TA sends the to-be-stored data to a client application (CA) running in a rich execution environment (REE), and the method comprises the following steps.
[0018] The first TA sends the collected to-be-stored data to a kernel (kernel).
[0019] The kernel sends the to-be-stored data to the CA.
[0020] In the embodiments of the present application, the data transmission between the first TA, the second TA and the CA running in the REE needs to be forwarded through the kernel, which is equivalent to realizing the data transmission between different execution environments through the kernel. In the case that the first TEE does not store a security key, the first TA can send the to-be-stored data to the second TA in the second TEE through the kernel, so that the second TA calculates the to-be-stored data by using the security key to obtain first authentication data, and obtains a first data packet according to the first authentication data and the to-be-stored data; the second TA sends the first data packet to a replay protection memory block (RPMB); and the RPMB stores the to-be-stored data in the first data packet by calculating the first data packet using the security key and storing the to-be-stored data in the first data packet in the case that the calculation is passed. That is, in an electronic device using at least two TEEs, the first TA running in the first TEE which does not store a security key can send the to-be-stored data to the second TA running in the second TEE which stores a security key through the kernel, and the second TA calculates the to-be-stored data by using the security key to obtain first authentication data, and obtains a first data packet according to the first authentication data and the to-be-stored data, and then sends the first data packet to the RPMB for storage through the kernel, so that the first TA running in the first TEE which does not store a security key can also store the to-be-stored data in the RPMB, which is equivalent to realizing the function that the application programs running in each TEE in the multi-TEE architecture can write data to the RPMB.
[0021] In some implementations of the first aspect, the RPMB stores the to-be-stored data in the first data packet, including:
[0022] The RPMB checks the first data packet based on the security key.
[0023] The RPMB stores the to-be-stored data in the first data packet in a case where the checking is passed.
[0024] In the embodiments of the present application, when the RPMB receives the first data packet, the first data packet can be checked by using the security key, and in a case where the checking is passed, the to-be-stored data is stored in the RPMB. That is to say, the data stored in the RPMB needs to be checked by the security key first, and then can be stored in the RPMB. In this way, the data of unknown sources can be effectively prevented from attacking the data stored in the RPMB, and the security of the data stored in the RPMB is improved.
[0025] In some implementations of the first aspect, the method further includes:
[0026] The RPMB sends response information to the second TA, the response information being used to indicate that the to-be-stored data has been stored in the RPBM.
[0027] In the embodiments of the present application, after the RPMB stores the to-be-stored data, the RPMB returns response information used to indicate that the to-be-stored data has been successfully stored to the second TA. After receiving the response information, the second TA does not need to send the first data packet to the RPMB again, and unnecessary data transmission between the second TA and the PRMB is avoided.
[0028] In some implementations of the first aspect, the method further includes:
[0029] The RPMB updates a count value in the RPMB based on the stored to-be-stored data, to obtain an updated count value.
[0030] It should be understood that the response information can include the updated count value, and the updated count value is a count value updated by the RPMB based on the stored to-be-stored data.
[0031] For example, the updated count value is obtained by adding 1 to the current count value after the RPMB stores the to-be-stored data.
[0032] In some implementations of the first aspect, the method further includes:
[0033] The second TA sends the response information to the first TA.
[0034] In embodiments of the present application, in a case where the RPMB returns response information to the second TA based on the stored data to be stored, the second TA further sends the received response information to the first TA, so that the first TA does not need to send the data to be stored to the second TA again after receiving the response information, thereby avoiding resource waste caused by unnecessary data transmission between the first TA and the second TA.
[0035] With reference to the first aspect, in some implementations of the first aspect, the second TA sends the response information to the first TA, including:
[0036] The second TA sends the response information to a kernel;
[0037] The kernel sends the response information to a CA running in a REE;
[0038] The CA sends the response information to the first TA.
[0039] With reference to the first aspect, in some implementations of the first aspect, the data to be stored is data obtained by the first TA invoking a first sensor.
[0040] With reference to the first aspect, in some implementations of the first aspect, the first sensor includes a fingerprint sensor.
[0041] With reference to the first aspect, in some implementations of the first aspect, the method further includes:
[0042] The CA running in the REE sends a fingerprint data acquisition request to the first TA in a case where a first operation is detected, the first operation being used to indicate acquisition of fingerprint data;
[0043] The first TA acquires fingerprint data by invoking the fingerprint sensor in response to the fingerprint data acquisition request, and obtains the data to be stored according to the fingerprint data.
[0044] In a second aspect, a data storage apparatus is provided, including units for performing any of the methods in the first aspect. The apparatus can be a server, a terminal device, or a chip in a terminal device. The apparatus can include an acquisition unit and a processing unit.
[0045] When the apparatus is a terminal device, the processing unit can be a processor, and the input unit can be a communication interface. The terminal device can further include a memory for storing computer program code, and when the processor executes the computer program code stored in the memory, the terminal device performs any of the methods in the first aspect.
[0046] When the device is a chip in a terminal device, the processing unit can be a processing unit inside the chip, and the input unit can be an output interface, a pin, a circuit, or the like; the chip can further include a memory, which can be a memory (for example, a register, a cache, or the like) inside the chip, or a memory (for example, a read-only memory, a random access memory, or the like) outside the chip; the memory is configured to store computer program code, and when the processor executes the computer program code stored in the memory, the chip is caused to execute any one of the methods in the first aspect.
[0047] In a possible implementation, the memory is configured to store computer program code; and the processor is configured to execute the computer program code stored in the memory, and when the computer program code stored in the memory is executed, the processor is configured to perform the following:
[0048] In a third aspect, a computer readable storage medium is provided, and the computer readable storage medium stores computer program code, and when the computer program code is run by a data storage device, the data storage device is caused to perform any one of the data storage methods in the first aspect.
[0049] In a fourth aspect, a computer program product is provided, and the computer program product includes computer program code, and when the computer program code is run by a data storage device, the data storage device is caused to perform any one of the data storage methods in the first aspect.
[0050] The data storage method provided in the embodiments of the present application is applied to an electronic device including at least two TEEs, the at least two TEEs including a first TEE and a second TEE, the first TEE being a TEE in which a security key is not stored, and the second TEE being a TEE in which a security key is stored, and the method includes: sending, by a first TA, to-be-stored data to a second TA, the first TA being a trusted application running on the first TEE, and the second TA being a trusted application running in the second TEE; performing, by the second TA, a calculation on the to-be-stored data by using the security key to obtain first authentication data, and obtaining a first data packet according to the first authentication data and the to-be-stored data; sending, by the second TA, the first data packet to a replay protection memory block (RPMB); and storing, by the RPMB, the to-be-stored data in the first data packet after performing a calculation authentication on the first data packet by using the security key and in a case where the calculation authentication is passed. That is, in the embodiments of the present application, since the security key is not stored in the first TEE, if the first TA running in the first TEE needs to store to-be-stored data in the RPMB, the first TA cannot obtain the security key to perform an authentication calculation on the to-be-stored data, so that the first TA cannot directly store the to-be-stored data in the RPMB. Meanwhile, since the security key is stored in the second TEE, the first TA in the first TEE can send the to-be-stored data to the second TA in the second TEE, so that the second TA performs an authentication calculation on the to-be-stored data by using the stored security key to obtain first authentication data, and generates a second data packet according to the first authentication data and the to-be-stored data, and the second TA can send the second data packet to the RPMB, so that the to-be-stored data in the first TEE in which the security key is not stored is stored in the RPMB. Thus, it is realized that any one of the multiple TEEs in the electronic device can store data in the RPMB. BRIEF DESCRIPTION OF DRAWINGS
[0051] Figure 1 FIG. 1 is a flowchart of an RPMB data writing process;
[0052] Figure 2 FIG. 1 is a schematic diagram of a hardware system of an electronic device suitable for the present application;
[0053] Figure 3 FIG. 1 is a schematic diagram of a software system of an electronic device suitable for the present application;
[0054] Figure 4 FIG. 1 is a schematic diagram of an application scenario provided by the embodiments of the present application;
[0055] Figure 5 FIG. 1 is a schematic diagram of an electronic device for data storage provided by the embodiments of the present application;
[0056] Figure 6 FIG. 1 is a flowchart of a data storage method provided by the embodiments of the present application;
[0057] Figure 7 FIG. 1 is a schematic diagram of an electronic device for data storage according to an embodiment of the present application;
[0058] Figure 8 FIG. 2 is a flow diagram of a data storage method according to an embodiment of the present application;
[0059] Figure 9 FIG. 3 is a schematic diagram of an electronic device for data storage according to an embodiment of the present application;
[0060] Figure 10 FIG. 4 is a flow diagram of a data storage method according to an embodiment of the present application;
[0061] Figure 11 FIG. 5 is a schematic diagram of a data format of a first data packet according to an embodiment of the present application;
[0062] Figure 12 FIG. 6 is a schematic diagram of an electronic device according to an embodiment of the present application;
[0063] Figure 13 FIG. 7 is a schematic diagram of an electronic device for data storage according to an embodiment of the present application. DETAILED DESCRIPTION
[0064] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; in this document, "and / or" is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0065] Hereinafter, the terms "first", "second", "third" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second", "third" can explicitly or implicitly include one or more of the features.
[0066] For ease of understanding, some examples are given below for reference in relation to the concepts of the embodiments of the present application.
[0067] 1. RPMB
[0068] RPMB refers to a separate physical partition in the memory, which is usually used to store data that has the need to prevent illegal tampering, such as public keys related to fingerprint payment on mobile phones, serial numbers, etc. Generally, RPMB will authenticate the write operation, but the read operation does not need to be authenticated.
[0069] It should be understood that in the process of producing electronic devices, a unique security key will be generated for each electronic device and burned into the One Time Programmable (OTP) area of the memory of the electronic device. The OTP area refers to an area that can only be burned once. At the same time, the Host of the electronic device will store the security key in a secure execution environment (for example, TEE). When the Host writes data to the RPMB, the RPMB can authenticate using the security key.
[0070] For example, the Host (trusted application TA in TEE) writes data to the Device (for example, UFS).
[0071] As shown in Figure 1 The Host sends a read count value Write Cnt request and a random number to the Device to obtain the count value Write Cnt in the Device. After receiving the read count value Write Cnt request, the Device performs HMAC calculation on the count value Write Cnt and the random number using the security key to generate a first MAC. Then the Device fills the Write Cnt, the random number and the first MAC into the RPMB data packet corresponding area, generates the RPMB data packet, and sends the RPMB data packet to the Host. When the Host receives the RPMB data packet, it performs HMAC calculation on the Write Cnt and the random number in the RPMB data packet using the security key to obtain a second MAC. It compares whether the first MAC and the second MAC are consistent, and in the case that the first MAC and the second MAC are consistent, it compares whether the random number sent by the Host to the Device and the random number in the RPMB data packet are consistent, and in the case that the random number sent by the Host to the Device and the random number in the RPMB data packet are consistent, it determines that the Write Cnt in the RPMB data packet is trusted.
[0072] Further, the Host performs HMAC calculation on the destination address of the data to be stored, the data to be stored and the Write Cnt by using the security key, obtains a third MAC, fills the third MAC into the MAC area in the RPMB data packet, obtains an updated RPMB data packet, and then sends the updated RPMB data packet to the Device. The Device receives the updated RPMB data packet, performs HMAC calculation on the destination address of the data to be stored, the data to be stored and the Write Cnt by using the security key, obtains a fourth MAC, compares the fourth MAC with the third MAC, compares the Write Cnt in the updated RPMB data packet with the Write Cnt in the Device in the case that the fourth MAC is consistent with the third MAC, and in the case that the Write Cnt in the updated RPMB data packet is consistent with the Write Cnt in the Device, stores the data to be stored in the updated RPMB data packet into the destination address corresponding to the data to be stored, and performs the increment operation on the Write Cnt in the Device, obtains an updated Write Cnt.
[0073] 2. Trusted execution environment (TEE)
[0074] The TEE refers to an independent secure running environment in a terminal device, and usually refers to a running environment logically isolated from a rich execution environment (REE). The TEE defines strict protection measures and can resist software attacks on the conventional REE side. Therefore, the TEE is usually used to process tasks with high security level.
[0075] 3. Rich execution environment (REE)
[0076] The REE usually refers to a general running environment on a terminal device, and is a running environment without specific security functions. For example, the Android system and the IOS system both belong to the REE.
[0077] The TEE and the REE are isolated from each other, and the REE cannot directly access the hardware and software resources of the TEE, but can only interact through authorized application programming interfaces.
[0078] 4. Trusted application (TA)
[0079] The TA usually refers to an application running on the TEE. The TA can provide security services for applications running outside the TEE.
[0080] 5. Client Application (CA)
[0081] CA typically refers to applications running on REE.
[0082] 6. Hypervisor module
[0083] The hypervisor module is an intermediate software layer running between the underlying physical server and the operating system. Through the hypervisor module, all physical devices on the electronic device, including disks and memory, can be accessed. The hypervisor module coordinates hardware resource access and provides protection between virtual machines. After the server starts, the hypervisor module loads the operating system of all virtual machine clients and allocates memory, disk, and network resources to the virtual machines. Based on the hypervisor mechanism, an electronic device can support multiple TEEs running simultaneously.
[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 ELO, the driver at EL1, the hypervisor module at EL2, and the ATF module at EL3.
[0086] The data storage method provided by the embodiments of the present application can be applied to an electronic device. Optionally, the electronic device includes a terminal device, which can also be referred to as a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The terminal device can be a mobile phone, a smart television, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiments of the present application do not limit the specific technology and specific device form of the terminal device.
[0087] Exemplarily, Figure 2 A structural schematic diagram of the electronic device 100 is shown. The electronic device 100 can 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, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 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 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light 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.
[0088] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0089] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors.
[0090] Among them, the controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals to complete the control of fetching instructions and executing instructions.
[0091] The memory in the processor 110 can also be provided for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. Avoiding repeated access reduces the waiting time of the processor 110, thus improving the efficiency of the system.
[0092] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application lock, fingerprint shooting, fingerprint answering, etc.
[0093] Optionally, the memory in the electronic device includes eMMC and universal file storage (UFS). Among them, the RPMB in the memory is usually used to store data with security requirements. When writing data into the RPMB, it needs to be encrypted by the pre-stored security key. The RPMB uses the security key stored thereon to verify the written data, and after the verification is passed, the written data is stored on the RPMB.
[0094] It should be noted that any electronic device mentioned in the embodiments of the present application can include more or less modules in the electronic device 100.
[0095] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiments of the present application take the Android system with a layered architecture as an example to exemplarily illustrate the software structure of the electronic device 100.
[0096] Figure 3 is a software structure block diagram of the electronic device 100 of the embodiments of the present application.
[0097] The layered architecture of the electronic device 100 divides the software into several layers, each layer has a clear role and division of labor. The 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 the system library, and the kernel layer.
[0098] The application layer can include a series of application packages.
[0099] As shown in Figure 3 , the application package can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
[0100] The application framework layer provides the application programming interface (API) and programming framework for the applications of the application layer. The application framework layer includes some pre-defined functions.
[0101] As shown in Figure 3 , the application framework layer can include window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0102] The window manager is used to manage the window program. The window manager can obtain the size of the display screen, judge whether there is a status bar, lock the screen, intercept the screen, etc.
[0103] The content provider is used to store and obtain data, and make the data accessible to the application. The data can include video, image, audio, dialed and received calls, browsing history and bookmarks, phonebook, etc.
[0104] The view system includes visual controls, such as controls that display text, controls that display pictures, and the like. The view system can be used to build an application. A display interface can be composed of one or more views. For example, a display interface that includes a short message notification icon can include a view that displays text and a view that displays a picture.
[0105] The telephony manager is used to provide the communication function of the electronic device 100. For example, the management of the call state (including the connection, hang-up, and the like).
[0106] The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and the like.
[0107] The notification manager enables the application to display notification information in the status bar, which can be used to convey a message of the notification type, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify the completion of the download, the message reminder, and the like. The notification manager can also be a notification that appears in the top status bar of the system in the form of a chart or a scrolling text, such as a notification of an application running in the background, and can also be a notification that appears on the screen in the form of a dialogue window. For example, the text information is prompted in the status bar, a prompt sound is emitted, the electronic device is vibrated, the indicator light flashes, and the like.
[0108] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0109] The core library includes two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.
[0110] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the java file of the application layer and the application framework layer into a binary file. The virtual machine is used to perform the management of the object life cycle, the stack management, the thread management, the security and exception management, and the garbage collection, and the like.
[0111] The system library can include a plurality of functional modules. For example: the surface manager, the media library, the three-dimensional graphics processing library (for example: OpenGL ES), the 2D graphics engine (for example: SGL), and the like.
[0112] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for a plurality of applications.
[0113] The media library supports multiple commonly used audio, video format playback and recording, and static image files, etc. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0114] The three-dimensional graphics processing library is used to implement three-dimensional graphics drawing, image rendering, synthesis, and layer processing, etc.
[0115] The 2D graphics engine is a drawing engine for 2D drawing.
[0116] The kernel layer is a layer between hardware and software. The kernel layer at least includes display drivers, camera drivers, audio drivers, sensor drivers, Wi-Fi drivers, etc.
[0117] It should be noted that the electronic device mentioned in the embodiments of the present application can include more or fewer modules in the above electronic device.
[0118] The application scenarios provided by the embodiments of the present application are described below in conjunction with the accompanying drawings.
[0119] With the continuous development of terminal technology, the multi-TEE architecture has become a common architecture. For example, as shown in Figure 4 The terminal device includes two TEEs, one REE, and an RPMB, which are a first TEE, a second TEE, an REE, and an RPMB, respectively. Among them, the first TEE does not store a security key, and the second TEE stores a security key. In the case that the first TA running in the first TEE needs to write data into the RPMB, the first TA running in the first TEE can send the to-be-stored data to the second TA running in the second TEE, and the second TA encrypts the to-be-stored data using the security key stored in the second TEE, and sends the encrypted data to the RPMB for storage.
[0120] Among them, the to-be-stored data can be data collected by the first TA calling the first sensor. For example, the first sensor is a fingerprint sensor, and the to-be-stored data can be fingerprint data collected by the first TA calling the fingerprint sensor.
[0121] Generally, fingerprint data is used for encryption and decryption in the terminal device, so the fingerprint data needs to be stored in a secure area, such as the RPMB. In the case that the first TA does not store a security key in the RPMB for verifying the data written into the RPMB, the data can be transmitted through the data channel between the first TEE, the second TEE, and the REE.
[0122] It should be understood that the above is an example of an application scenario, and does not limit the application scenarios of the present application in any way.
[0123] The application scenarios provided by the embodiments of the present application are described below in conjunction with the accompanying drawings. Figures 5 to 11The data storage method provided by the embodiment of the present application is described in detail.
[0124] The data storage method provided by the embodiment of the present application can be applied to an electronic device including at least two TEEs.
[0125] For example, as shown in Figure 5 , the electronic device includes a first TEE and a second TEE, the first TEE refers to a TEE that does not store a security key, and the second TEE refers to a TEE that stores a security key. A first TA running in the first TEE sends to-be-stored data to a second TA running in the second TEE, and the second TA performs encryption authentication on the to-be-stored data using the security key. The second TA sends the to-be-stored data and the first authentication data obtained after the encryption authentication to the RPMB.
[0126] The data storage method of the electronic device shown in Figure 6 is described in detail below. Figure 5 The data storage method of the electronic device shown in is described in detail below.
[0127] Figure 6 For the flowchart of the data storage method provided by an embodiment of the present application, as shown in Figure 6 , the method is applied to an electronic device as shown in Figure 5 . The method includes:
[0128] S101, the first TA sends to-be-stored data to the second TA.
[0129] It should be understood that when the electronic device is produced on the production line, the security key will be burned into the memory in the electronic device, and at the same time, the security key will be written into the TEE, so that the TEE can use the security key to encrypt the to-be-stored data when writing data to the RPMB. In the case where the electronic device includes at least two TEEs, in order to avoid the situation that multiple TEEs write data to the RPMB at the same time, causing the counter conflict, the security key will usually be written into only one TEE.
[0130] It should be understood that the security key can be stored in any one of the at least two TEEs.
[0131] For example, the at least two TEEs include a first TEE and a second TEE, wherein the first TEE refers to a TEE that does not store a security key, and the second TEE refers to a TEE that stores a security key.
[0132] It should be understood that in the case where the first TA running in the first TEE needs to write data to the RPMB, since the first TEE does not store the security key. Therefore, the first TA cannot use the security key to encrypt the to-be-stored data, and thus the first TA cannot directly send the to-be-stored data to the RPMB for storage.
[0133] The first TA can be a trusted application running in the first TEE.
[0134] In this case, the first TA can send the data to be stored to a second TA running in the second TEE.
[0135] The data to be stored can be data collected by the first TA on the first TEE.
[0136] For example, the first TA in the first TEE is an application that needs to encrypt and decrypt fingerprint data. The data to be stored can be fingerprint data collected by the first TA through a fingerprint collector.
[0137] For example, the first TA in the first TEE is an application that needs to encrypt and decrypt sound data. The data to be stored can be sound data collected by the first TA through a microphone.
[0138] For example, the first TA in the first TEE is an application that needs to encrypt and decrypt character password data. The data to be stored can be character data obtained by the first TA through receiving user click operation on the display screen.
[0139] For example, the first TA in the first TEE is an application that needs to encrypt and decrypt eyeprint data. The data to be stored can be eyeprint data collected by the first TA through a camera.
[0140] For example, the first TA in the first TEE is an application that needs to encrypt and decrypt face data. The data to be stored can be face data collected by the first TA through a camera.
[0141] For example, the first TA can also be an application that provides security services to the CA. The data to be stored can be password data sent by the CA to the first TA, including but not limited to the above-mentioned fingerprint data, sound data, character data, eyeprint data and face data.
[0142] Optionally, in the process of sending the data to be stored to the second TA, the first TA sends the data to be stored to a CA running in the REE, and the CA sends the data to be stored to the second TA.
[0143] The CA in the REE refers to a client application running in the REE.
[0144] In one possible case, the first TA in the first TEE can also send the data to be stored to the kernel first, and send the data to be stored to the CA in the REE through the kernel.
[0145] The second TA refers to a trusted application running in the second TEE.
[0146] In an example, the CA in the REE can send the to-be-stored data to the kernel, and the kernel can send the to-be-stored data to the second TA in the second TEE.
[0147] In an example, the second TA can perform calculation on the to-be-stored data by using the security key to obtain the first authentication data, and generate the first data packet according to the first authentication data and the to-be-stored data.
[0148] In an example, the second TA can perform encryption on the to-be-stored data by using the security key through a Hash-based Message Authentication Code (HMAC) to obtain the first authentication data.
[0149] In an example, the second TA can perform calculation on the to-be-stored data by using the security key through a Cipher Block Chaining-Message Authentication Code (CMAC) to obtain the first authentication data.
[0150] In an example, the second TA can send the first data packet to the RPMB through the kernel.
[0151] In an example, the second TA can send the first data packet to the kernel, and the kernel can send the first data packet to the RPMB.
[0152] In an example, the second TA can send the first data packet to the kernel, and the kernel can send the first data packet to the RPMB.
[0153] In an example, the RPMB can perform calculation authentication based on the first data packet, and store the to-be-stored data in the first data packet in the case of passing the authentication.
[0154] Optionally, the RPMB needs to use the security key to calculate the to-be-stored data to obtain second authentication data before storing the to-be-stored data, and determines that the first data packet authentication is passed in a case where the first authentication data and the second authentication data are same, and stores the to-be-stored data.
[0155] The data storage method provided in the embodiments of the present application is applied to an electronic device including at least two TEEs, the at least two TEEs including a first TEE and a second TEE, the first TEE being a TEE in which no security key is stored, and the second TEE being a TEE in which a security key is stored, and the method includes: a first TA sending to-be-stored data to a second TA, the first TA being a trusted application running on the first TEE, and the second TA being a trusted application running in the second TEE; the second TA using the security key to calculate the to-be-stored data to obtain first authentication data, and obtaining a first data packet according to the first authentication data and the to-be-stored data; the second TA sending the first data packet to a replay protection memory block (RPMB); and the RPMB storing the to-be-stored data in the first data packet after authenticating the first data packet using the security key and in a case where the authentication is passed. That is to say, in the electronic device using the at least two TEEs, the first TA running in the first TEE in which no security key is stored can send to-be-stored data to the second TA running in the second TEE in which the security key is stored, and the second TA uses the security key to calculate and authenticate the to-be-stored data to obtain first authentication data, and generates a first data packet according to the first authentication data and the to-be-stored data, so that the RPMB can use the security key to calculate and authenticate the first data packet after receiving the first data packet, and store the to-be-stored data in the first data packet in a case where the authentication is passed, which is equivalent to realizing the function that the applications running in each TEE in the multi-TEE architecture can write data to the RPMB.
[0156] In a possible case, the data transmission between the first TEE, the second TEE and the RPMB can be performed through a kernel and a CA running in a REE. Meanwhile, after the RPMB stores the encrypted data, the current count value can be increased by one to obtain an updated count value, and then the updated count value is returned to the first TEE and the second TEE, so that the first TEE or the second TEE determines that the to-be-stored data has been stored in the RPMB based on the response information, and thus the first TEE and the second TEE do not need to send data to the RPMB again, avoiding unnecessary data transmission of the first TEE, the second TEE, the kernel, the REE and the RPMB, and further avoiding resource waste. The embodiments shown in Figure 7 and Figure 8 will be described in detail below.
[0157] Exemplarily, the data storage method provided by the embodiment of the present application can be applied to the electronic device as shown in Figure 7 As shown in Figure 7 The electronic device includes a first TEE, a second TEE, a kernel, an REE and an RPMB. The first TEE refers to a TEE without storing a security key, and the second TEE refers to a TEE storing a security key. A first TA running in the first TEE sends to-be-stored data to a CA running in the REE, the CA sends the to-be-stored data to a second TA running in the second TEE, the second TA encrypts the to-be-stored data by using the security key to obtain encrypted data. The second TA sends the encrypted data to the kernel. The kernel sends the encrypted data to the RPMB. The RPMB stores the encrypted data.
[0158] The data storage method applied to the electronic device as shown in Figure 8 will be described in detail. Figure 7 The data storage method applied to the electronic device as shown in
[0159] Figure 8 A flowchart of the data storage method provided by an embodiment of the present application is shown in the figure. The method is applied to the electronic device as shown in Figure 7 As shown in Figure 8 The method includes the following steps.
[0160] S201, the first TA sends to-be-stored data to the kernel.
[0161] The first TA refers to a trusted application program running in the first TEE.
[0162] It should be understood that the kernel refers to a core component in the operating system, which is the main interface between the computer physical hardware and the processes running thereon. The kernel can include multiple modules.
[0163] Exemplarily, the kernel includes a TEE tz driving module, a storage device driving module, a Hypervisor module and an ATF module.
[0164] S202, the kernel sends the to-be-stored data to a CA running in the REE.
[0165] The CA running in the REE can refer to a TEE agent module,
[0166] Exemplarily, the CA running in the REE can include a first TEE agent CA and a second TEE agent CA.
[0167] S203, the CA sends the to-be-stored data to the kernel.
[0168] S204, the kernel sends the to-be-stored data to the second TA.
[0169] In the embodiments of the present application, in the process that the first TA sends the to-be-stored data to the second TA, the to-be-stored data is first sent to the CA running in the REE, and then the to-be-stored data is forwarded to the second TA through the CA. In this way, when the first TA sends the to-be-stored data to the second TA, the existing data channel between the REE and the first TEE and the data channel between the REE and the second TEE can be used, and it is not necessary to additionally establish a data channel between the first TEE and the second TEE. That is to say, by forwarding the to-be-stored data to the second TA through the CA running in the REE, the first TA can perform data transmission to the second TA through the existing data channel, and the unstable data transmission caused by newly establishing a data channel is avoided.
[0170] S205, the second TA calculates first authentication data from the to-be-stored data by using a security key, and generates a first data packet according to the first authentication data and the to-be-stored data.
[0171] S206, the second TA sends the first data packet to the kernel.
[0172] S207, the kernel sends the first data packet to the RPMB.
[0173] In the embodiments of the present application, the data transmission between the first TA, the second TA and the CA running in the REE needs to be forwarded through the kernel, which is equivalent to realizing the data transmission between different execution environments through the kernel. In the case that the first TEE does not store a security key, the first TA can send the to-be-stored data to the second TA in the second TEE through the kernel, so that the second TA calculates the to-be-stored data by using the security key to obtain first authentication data, and obtains a first data packet according to the first authentication data and the to-be-stored data; the second TA sends the first data packet to the replay protection memory block RPMB; the RPMB stores the to-be-stored data in the first data packet by calculating and authenticating the first data packet using the security key, and stores the to-be-stored data in the first data packet in the case that the authentication is passed. That is to say, in the electronic device using at least two TEEs, the first TA running in the first TEE which does not store a security key can send the to-be-stored data to the second TA running in the second TEE which stores a security key through the kernel, and calculate the to-be-stored data by using the security key through the second TA to obtain first authentication data, and obtain a first data packet according to the first authentication data and the to-be-stored data, and then send the first data packet to the RPMB for storage through the kernel, so that the first TA running in the first TEE which does not store a security key can also store the to-be-stored data in the RPMB, which is equivalent to realizing the function that the application programs running in each TEE in the multi-TEE architecture can write data to the RPMB.
[0174] S208, the RPMB verifies the first data packet by using the security key, and after the verification is passed, S209 is executed.
[0175] S209, the RPMB stores the to-be-stored data.
[0176] In the embodiments of the present application, when the RPMB receives the first data packet, the first data packet can be verified by using the security key, and in the case that the verification is passed, the to-be-stored data is stored in the RPMB, that is to say, the data stored in the RPMB needs to be verified by the security key first, and then stored in the RPMB, which can effectively avoid the attack of unknown source data on the data stored in the RPMB, and improve the security of the data stored in the RPMB.
[0177] S210, the RPMB sends response information to the kernel.
[0178] The response information is used to indicate that the to-be-stored data has been stored in the RPBM.
[0179] The response information can include an updated count value, which is a count value updated by the RPMB based on the stored data to be stored. For example, the updated count value is a count value obtained by the RPMB by adding 1 to the current count value after storing the data to be stored.
[0180] S211. The kernel sends the response information to a second TA running in the second TEE.
[0181] In an embodiment of the present application, after the RPMB stores the data to be stored, the RPMB also returns response information to the second TA, the response information indicating that the data to be stored has been successfully stored, so that the second TA does not need to send the first data packet to the RPMB again after receiving the response information, avoiding unnecessary data transmission between the second TA and the PRMB.
[0182] S212. The second TA sends the response information to the kernel.
[0183] S213. The kernel sends the response information to a CA running in the REE.
[0184] S214. The CA running in the REE sends the response information to the kernel.
[0185] S215. The kernel sends the response information to a first TA running in the first TEE.
[0186] In an embodiment of the present application, in the case where the RPMB returns response information to the second TA based on the stored data to be stored, the second TA also sends the received response information to the first TA, so that the first TA does not need to send the data to be stored to the second TA again after receiving the response information, avoiding resource waste caused by unnecessary data transmission between the first TA and the second TA.
[0187] In one possible case, the data to be stored can be data collected by a fingerprint sensor. In the case where the CA running in the Android system receives a fingerprint registration request initiated by a user, the CA sends the fingerprint registration request to a fingerprint TA (first TA) in the first TEE, the fingerprint TA invokes the fingerprint sensor based on the fingerprint registration request, collects fingerprint data, and sends the collected fingerprint data to the fingerprint TA. The following describes in detail how the fingerprint TA stores the fingerprint data collected by the fingerprint sensor into the RPMB. Figure 9 and Figure 10
[0188] It should be understood that the electronic device can be divided into four running levels, which are EL0, EL1, EL2 and EL3. Among them, the running level of the application program is EL0, the running level of the driver is EL1, the running level of the Hypervisor module is EL2, and the running level of the ATF module is EL3.
[0189] For example, the data storage method provided by the embodiment of the present application can be applied to the electronic device as shown in Figure 9 The fingerprint CA, the first TEE agent CA and the second TEE agent CA run in the Android. The fingerprint TA and the first RPMB service module run in the first TEE. The agent TA and the second RPMB service module run in the second TEE. The second RPMB service module stores the security key. It should be understood that the running levels of the fingerprint CA, the first TEE agent CA, the second TEE agent CA, the fingerprint TA, the first RPMB service module, the agent TA and the second RPMB service module are EL0. The storage device driver module, the second TEE tz driver module, the first TEE tz driver module, the Hypervisor module and the ATF module are included in the Kernel, wherein the running levels of the storage device driver module, the second TEE tz driver module and the first TEE tz driver module are EL1. The running level of the Hypervisor module is EL2. The running level of the ATF module is EL3. As shown in Figure 9 The Android (REE), the first TEE (first TEE) and the second TEE (second TEE) run in the electronic device, wherein the first TEE does not store the security key, and the second TEE stores the security key. The fingerprint CA running in the Android can send a fingerprint registration request to the fingerprint TA in the first TEE in the case of receiving a fingerprint registration operation. The fingerprint TA responds to the fingerprint registration request, calls the fingerprint sensor to collect fingerprint data, and then sends the fingerprint data to the agent TA running in the second TEE through the agent CA running in the Android, and then calculates and authenticates the fingerprint data through the agent TA to obtain first authentication data, and generates a first data packet according to the first authentication data and the to-be-stored data. The agent TA sends the first data packet to the RPMB through the Hypervisor module, the ATF module and the driver in the kernel.
[0190] The data storage method applied to the electronic device as shown in Figure 10 will be described in detail. Figure 9 The data storage method applied to the electronic device as shown in
[0191] Figure 10 The flowchart of another data storage method provided by the embodiment of the present application is shown in the figure. The method is applied to the electronic device as shown in Figure 9The electronic device comprises:
[0192] S301, in response to a fingerprint registration operation, a fingerprint CA running in Android (REE) sends a fingerprint registration request to a first TEE tz driver module in kernel.
[0193] S302, the first TEE tz driver module sends the fingerprint registration request to a Hypervisor module.
[0194] S303, the Hypervisor module sends the fingerprint registration request to a fingerprint TA (first TA) in a first TEE (first TEE).
[0195] S304, the fingerprint TA responds to the fingerprint registration request, calls a fingerprint sensor, and collects fingerprint data (to-be-stored data).
[0196] S305, the fingerprint TA sends the fingerprint data and an RPMB write request type to a first RPMB service module in the first TEE.
[0197] S306, the first RPMB service module in the first TEE encrypts the fingerprint data and the RPMB write request using a first security key to obtain first encrypted data, and adds an operation request type of a second TEE (second TEE) RPMB in the first encrypted data to generate a second data packet.
[0198] It should be understood that the first security key is a security key used for encryption and decryption in the first TEE and the second TEE, and is different from the security key of the RPMB. Since the fingerprint TA running in the first TEE needs to forward the fingerprint data to the proxy TA running in the second TEE through the CA running in the Android, in order to ensure the security of the fingerprint data in the CA running in the Android, the first security key can be used to encrypt the fingerprint data to ensure the security of the fingerprint data.
[0199] Optionally, the generated first data packet can further include an RPMB operation cmd id and an RPMB write cmd id, wherein the RPMB operation cmd id is used to indicate that the operation corresponding to the current data is an RPMB operation, so that the application program confirms that the operation corresponding to the fingerprint data in the first data packet is the RPMB operation based on the RPMB operation cmd id. The RPMB write cmd id is used to indicate that the operation corresponding to the current data is a write operation of the RPMB. When the RPMB device receives the first data packet, it can determine that the fingerprint data in the first data packet is the data written to the RPMB based on the RPMB write cmd id.
[0200] For example, the data format of the second data packet can be as followsFigure 11 The data shown includes RPMB operation cmd id, RPMB write cmd id, data amount of RPMB data, and RPMB data. The RPMB data can be fingerprint data.
[0201] Optionally, the generated second data packet can further include a VM id of the first TEE.
[0202] It should be understood that the Hypervisor module assigns a VM id to different virtual machines. The VM id of the first TEE is the VM id assigned to the first TEE by the Hypervisor module, which is used to represent the first TEE.
[0203] S307, the first RPMB service module in the first TEE sends the second data packet to the Hypervisor module in the kernel.
[0204] S308, the Hypervisor module sends the second data packet to the first TEE tz driver in the kernel.
[0205] S309, the first TEE tz driver module in the kernel sends the second data packet to the first TEE agent CA in Android.
[0206] S310, the first TEE agent CA sends the second data packet to the second TEE agent CA in Android.
[0207] S311, the second TEE agent CA in Android sends the second data packet to the second TEE tz driver module in the kernel.
[0208] S312, the second TEE tz driver module in the kernel sends the second data packet to the Hypervisor module in the kernel.
[0209] S313, the Hypervisor module sends the second data packet to the ATF module in the kernel according to the VM id in the second data packet.
[0210] S314, the ATF module sends the second data packet to the agent TA (second TA) running in the second TEE.
[0211] S315, the agent TA decrypts the first encrypted data in the second data packet using the first security key according to the type of the RPMB write request in the second data packet, to obtain the fingerprint data and the RPMB write request.
[0212] S316, the agent TA sends the decrypted fingerprint data and the RPMB write request to a second RPMB service module running in the second TEE.
[0213] S317, the second RPMB service module running in the second TEE generates a first data packet according to the fingerprint data and the RPMB write request.
[0214] Wherein, the second RPMB service module can use a second security key to perform authentication calculation on the fingerprint data to obtain first authentication data, and then generate the first data packet according to the first authentication data, the fingerprint data and the RPMB write request.
[0215] It should be understood that the second security key is a security key used by the RPMB to verify the storage of the RPMB data. Wherein, the first data packet is a data packet written to the RPMB.
[0216] S318, the second RPMB service module sends the first data packet to the ATF module.
[0217] S319, the ATF module sends the first data packet to the Hypervisor module.
[0218] S320, the Hypervisor module sends the first data packet to the second TEE tz drive module.
[0219] S321, the second TEE tz drive module sends the first data packet to the storage device drive module.
[0220] Exemplarily, the storage device drive module refers to an eMMC drive module.
[0221] Exemplarily, the storage device drive module refers to a UFS drive module.
[0222] S322, the storage device drive module sends the first data packet to the RPMB.
[0223] In the embodiment of the present application, the fingerprint TA running in the first TEE forwards the fingerprint data to the proxy TA running in the second TEE through the first TEE agent CA and the second TEE agent CA running in the Andriod, and then the proxy TA sends the fingerprint data to the second RPMB service module in the second TEE, so that the second RPMB service module storing the security key can perform authentication calculation on the fingerprint data to obtain first authentication data, and then generate a first data packet according to the first authentication data, the fingerprint data and the RPMB write request, and send the first data packet to the RPMB through the ATF module, the Hypervisor module, the second TEE tz driving module and the storage device driving module. The RPMB verifies the first data packet using the security key, and stores the fingerprint data in the first data packet in the case of passing the verification. In this way, the fingerprint TA in the first TEE without storing the security key can also store the fingerprint data in the RPMB through the above data channel, that is, the data storage method provided by the embodiment of the present application realizes the function that each application program running in each TEE in the multi-TEE architecture can write data to the RPMB.
[0224] It should be understood that, although each step in the flowchart in the above embodiment is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or sub-steps or stages of other steps.
[0225] Figure 12 A structural schematic diagram of an electronic device provided by the embodiment of the present application.
[0226] It should be understood that the electronic device can execute the data storage method shown in Figures 5 to 11 The electronic device includes an acquisition unit 610 and a processing unit 620.
[0227] The processing unit 620 is configured to control the first trusted application TA to send the to-be-stored data to the second trusted application TA, the first TA refers to a trusted application running on the first TEE, and the second TA refers to a trusted application running in the second TEE; the second TA performs authentication calculation on the to-be-stored data by using a security key to obtain first authentication data; the second TA obtains a first data packet according to the first authentication data and the to-be-stored data; the second TA sends the first data packet to the replay protection memory block RPMB; and the RPMB stores the to-be-stored data in the first data packet.
[0228] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the first TA to send the to-be-stored data to a client application CA running in a rich execution environment REE; and the CA sends the to-be-stored data to the second TA.
[0229] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the first TA to send the collected to-be-stored data to a kernel; and the kernel sends the to-be-stored data to the CA.
[0230] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the RPMB to verify the first data packet based on the security key; and the RPMB stores the to-be-stored data in the first data packet in a case where the verification is passed.
[0231] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the RPMB to send response information to the second TA, the response information being used to indicate that the to-be-stored data has been stored in the RPMB.
[0232] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the RPMB to update a count value in the RPMB based on the stored to-be-stored data to obtain an updated count value.
[0233] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the second TA to send the response information to the first TA.
[0234] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the second TA to send the response information to the kernel; the kernel sends the response information to the CA running in the REE; and the CA sends the response information to the first TA.
[0235] Optionally, as an embodiment, the to-be-stored data is data collected by the first TA calling a first sensor.
[0236] Optionally, as an embodiment, the first sensor includes a fingerprint sensor.
[0237] Optionally, as an embodiment, the processing unit 620 is specifically configured to control the CA running in the REE to send a fingerprint data acquisition request to the first TA in a case where a first operation is detected, the first operation being used to instruct to acquire fingerprint data; and the first TA is configured to collect fingerprint data by calling a fingerprint sensor in response to the fingerprint data acquisition request, and obtain to-be-stored data according to the fingerprint data.
[0238] The electronic device provided in the embodiment is used to execute the data storage method in the above embodiment, and has similar technical principles and technical effects, which are not described here again.
[0239] It should be noted that the electronic device is embodied in the form of a functional unit. The term "unit" herein can be implemented in the form of software and / or hardware, and is not specifically limited.
[0240] It can be understood that, in order to implement the above functions, the electronic device contains hardware and / or software modules corresponding to each function. The algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is implemented in hardware or computer software driven 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 combination with the embodiments. However, such implementation should not be considered beyond the scope of the present application.
[0241] The embodiments of the present application can divide the functional modules of the electronic device according to the above method examples, for example, each functional module can be divided according to each function, or two or more functions can be integrated in one module. It should be noted that the division of modules in the embodiments of the present application is illustrative, and is only a logical functional division. When actually implemented, another division method can be used. It should be noted that the names of the modules in the embodiments of the present application are illustrative, and the names of the modules are not limited when actually implemented.
[0242] For example, the "unit" can be a software program, a hardware circuit, or a combination of both, which implements the above functions. The hardware circuit can include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group processor) and a memory for executing one or more software or firmware programs, a combination logic circuit, and / or other suitable components supporting the described functions.
[0243] Therefore, the units of each example described in the embodiments of the present application can be implemented in electronic hardware, or in a combination of computer software and electronic hardware. Whether the 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 the present application.
[0244] Figure 13 A structural schematic diagram of an electronic device provided by the present application is shown. Figure 13 The dashed line in the figure indicates that the unit or the module is optional. The electronic device 700 can be used to implement the data storage method described in the method embodiments.
[0245] The electronic device 700 includes one or more processors 701, which can support the electronic device 700 to implement the data storage method in the method embodiments. The processor 701 can be a general-purpose processor or a special-purpose processor. For example, the 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 or transistor logic devices, or discrete hardware components.
[0246] The processor 701 can be used to control the electronic device 700, execute software programs, and process data of the software programs. The electronic device 700 can also include a communication unit 705 to implement input (reception) and output (transmission) of signals.
[0247] For example, the electronic device 700 can be a chip, the communication unit 705 can be an input and / or output circuit of the chip, or the communication unit 705 can be a communication interface of the chip, and the chip can be a component of a terminal device or other electronic device.
[0248] For another example, the electronic device 700 can be a terminal device, and the communication unit 705 can be a transceiver of the terminal device, or the communication unit 705 can be a transceiver circuit of the terminal device.
[0249] The electronic device 700 can include one or more memories 702 having programs 704 stored thereon, which can be run by the processor 701 to generate instructions 703 for the processor 701 to perform the impedance matching method described in the above method embodiments according to the instructions 703.
[0250] Optionally, the memory 702 can also store data. Optionally, the processor 701 can also read the data stored in the memory 702, which can be stored in the same storage address as the program 704, or can be stored in a different storage address from the program 704.
[0251] The processor 701 and the memory 702 can be separately arranged or integrated together, for example, integrated on a system on chip (SOC) of the terminal device.
[0252] Exemplarily, the memory 702 can be used to store the related program 704 of the data storage method provided in the embodiments of the present 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 the present application, including: a first trusted application TA sends to-be-stored data to a second trusted application TA, the first TA refers to a trusted application running on a first TEE, and the second TA refers to a trusted application running in a second TEE; the second TA performs authentication calculation on the to-be-stored data using a security key to obtain first authentication data; the second TA obtains a first data packet according to the first authentication data and the to-be-stored data; the second TA sends the first data packet to a replay protection memory block RPMB; and the RPMB stores the to-be-stored data in the first data packet.
[0253] The present application also provides a computer program product, which, when executed by the processor 701, implements the data storage method described in any of the method embodiments of the present application.
[0254] The computer program product can be stored in the memory 702, for example, the program 704, which is finally converted into an executable object file that can be executed by the processor 701 after preprocessing, compiling, assembling, and linking and other processing processes.
[0255] The present application also provides a computer readable storage medium having a computer program stored thereon, which, when executed by a computer, implements the data storage method described in any of the method embodiments of the present application. The computer program can be a high-level language program or an executable target program.
[0256] The computer-readable storage medium is, for example, the memory 702. The memory 702 can be a volatile memory or a nonvolatile memory, or the memory 702 can include both volatile and nonvolatile memory. The nonvolatile memory can be a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically EPROM (EEPROM), or a flash memory, among others. The volatile memory can be a random access memory (RAM), which is used as the external cache. By way of example, and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous dynamic RAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct rambus RAM (DR RAM), among others.
[0257] In this application, "at least one", "multiple", "plurality" mean one or more, unless otherwise indicated. "At least one of the following (a)" or the like means any combination of these items, including a single item (a) or a combination of multiple items (a). For example, at least one of a, b, or c can mean a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple.
[0258] It should be understood that the size of the sequence number of the above-mentioned processes in various embodiments of the present application does not mean the order of execution, and the execution order of the processes should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0259] Those skilled in the art can clearly understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed 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 the present application.
[0260] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
[0261] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic; for example, the division of the units is only a logical function division, and actual implementation can have another division manner; for example, a plurality of units or components can be combined or integrated into another system, or some features can be omitted or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0262] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e. they can be located in one place or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0263] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.
[0264] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A data storage method, characterized in that, The method is applied to an electronic device comprising at least two Trusted Execution Environments (TEEs), wherein the at least two Trusted Execution Environments (TEEs) include a first Trusted Execution Environment (TEE) and a second Trusted Execution Environment (TEE). The first Trusted Execution Environment (TEE) is a Trusted Execution Environment (TEE) that does not store a security key, and the second Trusted Execution Environment (TEE) is a Trusted Execution Environment (TEE) that stores the security key. The method includes: The first trusted application TA sends the data to be stored to the second trusted application TA. The first trusted application TA refers to a trusted application running on the first trusted execution environment TEE, and the second trusted application TA refers to a trusted application running in the second trusted execution environment TEE. The second trusted application TA uses the security key to perform authentication calculations on the data to be stored, and obtains the first authentication data; The second trusted application (TA) obtains the first data packet based on the first authentication data and the data to be stored; The second trusted application TA sends the first data packet to the replay protection memory block RPMB; The replay protection memory block (RPMB) stores the data to be stored in the first data packet.
2. The method according to claim 1, characterized in that, The first trusted application (TA) running in the first trusted execution environment (TEE) sends data to be stored to the second trusted application (TA) running in the second trusted execution environment (TEE), including: The first trusted application TA sends the data to be stored to the client application CA running in the rich execution environment REE; The client application CA sends the data to be stored to the second trusted application TA.
3. The method according to claim 2, characterized in that, The first trusted application TA sends the data to be stored to the client application CA running in the rich execution environment REE, including: The first trusted application TA sends the collected data to be stored to the kernel; The kernel sends the data to be stored to the client application CA.
4. The method according to any one of claims 1 to 3, characterized in that, The replay protection memory block (RPMB) stores the data to be stored in the first data packet, including: The Replay Protection Memory Block (RPMB) verifies the first data packet based on the security key; If the replay protection memory block (RPMB) passes the verification, it stores the data to be stored in the first data packet.
5. The method according to claim 4, characterized in that, The method further includes: The replay protection memory block RPMB sends a response message to the second trusted application TA, the response message indicating that the data to be stored has been stored in the replay protection memory block RPMB.
6. The method according to claim 5, characterized in that, The response information includes the updated count value, and also includes: The Replay Protection Memory Block (RPMB) updates the count value in the RPMB based on the stored data to be stored, thus obtaining the updated count value.
7. The method according to claim 5, characterized in that, The method further includes: The second trusted application TA sends the response information to the first trusted application TA.
8. The method according to claim 7, characterized in that, The second trusted application TA sends the response information to the first trusted application TA, including: The second trusted application (TA) sends the response information to the kernel. The kernel sends the response information to the client application CA running in the rich execution environment REE; The client application CA sends the response information to the first trusted application TA.
9. The method according to any one of claims 1 to 3, characterized in that, The data to be stored is the data collected by the first sensor by the first trusted application TA.
10. The method according to claim 9, characterized in that, The first sensor includes a fingerprint sensor.
11. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Upon detecting a first operation, the client application CA running in the rich execution environment REE sends a fingerprint data acquisition request to the first trusted application TA, whereby the first operation is used to instruct the acquisition of fingerprint data. In response to the fingerprint data acquisition request, the first trusted application TA calls the fingerprint sensor to collect fingerprint data and obtains the data to be stored based on the fingerprint data.
12. A chip, characterized in that, Includes a processor, which, when executing instructions, performs the method as described in any one of claims 1 to 11.
13. An electronic device, characterized in that, The electronic device includes a processor configured to be coupled to 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 11 according to the instructions.
14. 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 11.
Citation Information
Patent Citations
Data sharing between trusted execution environments
US20210173950A1
Method and system for protecting authentication credentials
WO2021018306A1