Processing method and electronic equipment

By using a first-in-first-out file system to manage RPMB in a TEE environment, the problem of RPMB storage space exhaustion is solved, ensuring device security and data integrity, and preventing device failure and data loss caused by insufficient storage space.

CN114792016BActive Publication Date: 2025-09-19LENOVO (BEIJING) LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210334158.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-30
Publication Date
2025-09-19
Estimated Expiration
2042-03-30

AI Technical Summary

Technical Problem

Frequent use of RPMB leads to rapid depletion of storage space. Existing technologies lack effective storage management, resulting in reduced device security. In particular, OTA updates may fail, affecting the normal operation of the device and the security of user data.

Method used

RPMB is managed using a first-in-first-out file system in the TEE environment. By creating a target queue and data indexing mechanism, storage space utilization is optimized to ensure that recorded data is written and eliminated according to the first-in-first-out principle, avoiding storage space being full.

Benefits of technology

It realizes the continuous writing of recorded data in RPMB to prevent insufficient storage space, improve the security level of the device, and prevent illegal intrusion and data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114792016B_ABST
    Figure CN114792016B_ABST
Patent Text Reader

Abstract

The present application provides a processing method, the method comprising: a trusted application in a trusted execution environment (TEE) responding to an operation request from a general-purpose operating system; the trusted application obtaining recorded data, the recorded data being data corresponding to the trusted application's response to the operation request from the general-purpose operating system; the trusted application storing the recorded data in a replay protection memory (RPMB) of the trusted execution environment based on a first-in-first-out file system. The present application also provides an electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to data storage technology, and more particularly to a processing method and electronic device. Background Art

[0002] Replay Protected Memory RPMB (Replay Protected Memory) is a separate partition integrated into the embedded multimedia memory card EMMC (Embeded MultiMedia Card) or the universal flash storage UFS (Universal Flash Storage). It is a secure storage area that can safely store keys, certificates, personal privacy data, fingerprint templates, etc. All storage and reading actions of this partition must be subject to key authentication. Currently, this partition is mainly accessed after encryption within the data security system (Trustzone). Due to the frequent use of RPMB, the historical information of related security information operations in RPMB has become longer and longer, making it easy for the storage space of RPMB to be filled up. Since Trustzone currently lacks data storage management for RPMB, after the storage space of RPMB is full, new security information data can no longer be written to RPMB, resulting in a significant decrease in the security of the device. Summary of the Invention

[0003] In view of this, embodiments of the present application hope to provide a processing method and electronic device.

[0004] To achieve the above objectives, the technical solution of this application is implemented as follows:

[0005] According to one aspect of the present application, a processing method is provided, comprising:

[0006] The trusted application (TA) in the trusted execution environment (TEE) responds to the operation request of the general operating system;

[0007] The trusted application obtains record data, where the record data is data corresponding to the operation request of the general operating system in response to the trusted application;

[0008] The trusted application stores the recorded data in a replay protected memory (RPMB) of the trusted execution environment based on a first-in-first-out file system.

[0009] In the above solution, the trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system, including:

[0010] Determining a target queue corresponding to the trusted application;

[0011] If each data element in the target queue is not empty, the record data is written into the data element in the target queue that is the first to be written with data.

[0012] In the above solution, the trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system, including:

[0013] The data index of each data element in the target queue is modified, wherein the data element to which data is first written is the latest data element.

[0014] In the above solution, the trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system, including:

[0015] querying whether the data elements in the target queue are empty in a first data element order based on the target queue;

[0016] If a data element in the target queue is empty, the record data is written into the empty data element in the target queue.

[0017] In the above solution, the trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system, including:

[0018] Creating the target queue, wherein the target queue includes queue depth information and size information of each data element;

[0019] A storage area is allocated for the target queue in the replay protection memory RPMB.

[0020] In the above solution, allocating a storage area for the target queue in the replay protection memory RPMB includes:

[0021] Based on the target queue, search for free storage blocks starting from the starting block in the RPMB in a block list manner;

[0022] If the free space size of the free storage block exceeds the data size corresponding to the target queue, the free storage block is split into a first block and a second block based on the target queue; wherein the first block is used as the target block for carrying the target queue.

[0023] In the above solution, the trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system, and further includes:

[0024] Deleting the target queue corresponding to the trusted application;

[0025] Reclaim the target block corresponding to the target queue.

[0026] In the above solution, the trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system, and further includes:

[0027] Determining target data in a target queue corresponding to the trusted application based on a creation timestamp of each data element, wherein the creation time of the target data is the closest to the current time among all data elements in the target queue;

[0028] authenticating an operation request of the general operating system based on the target data;

[0029] If the authentication is successful, the record data corresponding to the operation request is stored in the target queue.

[0030] According to another aspect of the present application, an electronic device is provided, including:

[0031] A response unit, configured to respond to an operation request of a general operating system based on a trusted application in a trusted execution environment (TEE);

[0032] an acquiring unit, configured to acquire record data based on the trusted application, wherein the record data is data corresponding to an operation request obtained by the trusted application in response to the general operating system;

[0033] A storage unit is used to store the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system.

[0034] According to another aspect of the present application, an electronic device is provided, comprising: a processor and a memory for storing a computer program capable of running on the processor,

[0035] Wherein, when the processor is used to run the computer program, it executes the method steps of any one of the above-mentioned processing methods.

[0036] The processing method and electronic device provided in this application store the recorded data of general applications in the rich execution environment (REE) in the RPMB of the TEE through a first-in-first-out file system. Due to the mechanism of the first-in-first-out system, the recorded data of general applications can be continuously written into the RPMB without worrying about the storage space of the RPMB being full, thereby improving the security level of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 This is a schematic diagram of the process implementation of the processing method in this application Figure 1 ;

[0038] Figure 2 This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 1 ;

[0039] Figure 3 This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 2 ;

[0040] Figure 4A This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 3 ;

[0041] Figure 4B This is a fourth schematic diagram of the architecture of the first-in-first-out file system in this application;

[0042] Figure 4C This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 5 ;

[0043] Figure 5 This is a schematic diagram of the process implementation of the processing method in this application Figure 2 ;

[0044] Figure 6 This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 6 ;

[0045] Figure 7 Schematic diagram of the structure of the electronic device in this application Figure 1 ;

[0046] Figure 8 This is a schematic diagram of the structure of the electronic device in this application Figure 2 . DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. Unless there is a conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. The steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. In addition, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in an order different from that here.

[0048] As mentioned above, due to the frequent use of RPMB, the operation records of relevant security information in RPMB will become longer and longer. Since the Trustzone running in TEE lacks storage management of data in RPMB, or some applications are interrupted when using the operation sequence of RPMB (for example, some APPs are forcibly killed), the relevant historical information and data are not effectively recovered, resulting in the gradual reduction of the remaining space of RPMB. Even after the remaining space of RPMB is used up, the user is unaware. Because even after the operation of a certain application is completed, many encrypted operations still return correctly, but the security is greatly reduced. The more dangerous problem is that when our mobile phones are downloading services through over-the-air technology (OTA), some keys forcibly require the protection of RPMB. If the RPMB space is insufficient, the OTA will fail, and the user will no longer be able to successfully start the phone, which will not only lead to data loss for the user, but also damage the brand image of the device. By adopting the technical solution provided in the embodiment of the present application, the record data of the general application in the REE is stored in the RPMB through the first-in-first-out file system in the TEE environment. The record data of the general application can be continuously written into the RPMB without worrying about the storage space of the RPMB being full, thereby improving the security level of the device.

[0049] The technical solution of the present application is further elaborated in detail below with reference to the accompanying drawings and specific embodiments.

[0050] Figure 1 This is a schematic diagram of the data processing method in this application. Figure 1 ,like Figure 1 Shown, including:

[0051] Step 101: A trusted application in a trusted execution environment (TEE) responds to an operation request from a general operating system.

[0052] Step 102: The trusted application in the trusted execution environment (TEE) responds to the operation request of the general operating system.

[0053] Step 103: The trusted application stores the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system.

[0054] Here, the method can be applied to various electronic devices, including but not limited to mobile phones, personal computers, servers, watches, all-in-one machines, etc. Among them, the electronic device has two operating systems, one operating system runs in TEE, which can be called a secure operating system, for providing security feature functions and ensuring that sensitive operations (such as fingerprint recognition, password processing, data encryption and decryption, security authentication, virtual payment, etc.) are performed in a trusted environment to ensure the security of information. The other operating system runs in REE, which can be called a general operating system (such as Android operating system, OS operating system, etc.), under which a variety of applications including third-party applications can be run (such as mobile wallet applications, version applications, fingerprint recognition applications, facial recognition applications, etc.). Here, the trusted operating system and the general operating system are logically isolated from each other. Among them, the security level of the operating system running in TEE is higher than that of the operating system running in REE.

[0055] Here, the application running in the TEE environment is usually referred to as TA, and the application running in the REE environment is usually referred to as CA (Client Application). The CA in the REE environment can exchange data with the TA in the TEE environment through a specific REE communication interface.

[0056] In this application, the electronic device also runs a first-in-first-out file system in the TEE environment, through which the storage space of the RPMB in the TEE can be managed.

[0057] In this application, the architecture of the FIFO file system can be divided into three parts: a directory structure, a data structure, and a supernode. A supernode can refer to data stored at a fixed data address (either a data tag or a data link). The data tag or data link stored at the data address can be used to find the corresponding directory structure, and the data tag or data link in the directory structure can be used to find the corresponding data structure. In other words, the supernode can be the root of a tree, the directory structure can be the branches, and the data structure can be the leaves on the branches.

[0058] In this application, the super element in the first-in-first-out file system can be stored at the starting address of the RPMB. The structure of the super element can be as follows:

[0059] a. MAGIC CODE 64 bits: used as the logo of the super node, for example, ascII: "rpmbfifo";

[0060] b.Directory: used to store the address of the first directory node of the directory structure. The data size can be 64 bits.

[0061] c. Filesystem size: represents the total size of the RPMB area, which can be 64 bits;

[0062] d.Filesystem Free Space: used to indicate the remaining space size of the file system, such as 64 bits.

[0063] In this application, the directory structure (Data Directory) in the first-in-first-out file system is composed of directory nodes. The structure of each directory node can be as follows:

[0064] a.Type: This field stores the data type. The data size can be 32 bits. Of the 16 bits H, 8 bits H represent directory nodes or data nodes, and 8 bits L represent: 1) root nodes; 2) leaf nodes; 3) intermediate nodes. If the current node is a leaf node, 16 bits L represent the depth of the current node. Here, H represents the data height, and L represents the data length.

[0065] b.Name

[256] : used to store the node name, byte array type;

[0066] c.Parent*: used to store the parent node address of the current node. The data storage size can be 64 bits.

[0067] d.Child*: used to store the child node address of the current node. The data storage size can be 64 bits. If the current directory node is a leaf node, the pointer points to the data head node;

[0068] e.Sibling*: used to store the neighbor node addresses of the current node. The data storage size can be 64 bits.

[0069] Figure 2 This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 1 ,like Figure 2 As shown:

[0070] It includes a super node 21, a directory structure 22, and a data structure 23. The directory structure 22 includes multiple directory nodes 221, and the data structure 23 includes multiple data nodes 231. When the data in the super node 21 is marked as fifo 1, the directory node fifo 1 can be found through the super node dev; if the data in the directory node fifo 1 is marked as data node data 1, the data node data 1 can be found through the directory node fifo 1, so that the TA can read the recorded data in the data node data 1.

[0071] Here, the FIFO file system may also provide a data interface, through which the TA can search for target data in the FIFO file system according to the target path (eg Figure 3 shown).

[0072] Figure 3 This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 2 ,like Figure 3 As shown:

[0073] TA can first find the super node dev in the first-in-first-out file system according to the data path (such as / dev / fifo / data1), and then find the directory structure fifo according to the data tag in the super node dev, and then find the data structure data1 according to the data tag in the directory structure fifo, so as to read the historical record data corresponding to the data structure data1.

[0074] Here, the historical record data corresponding to the data structure data1 is a first-in-first-out target queue created by TA in the first-in-first-out file system. The target queue has corresponding queue depth information and the size of each data element in the queue file is the same.

[0075] In this application, the first-in-first-out file system can only be accessed by the TA in the TEE environment, and cannot be accessed by the CA in the REE environment. If the CA in the REE environment wants to access the target data in the RPMB, it can only be achieved through the TA in the TEE environment.

[0076] In this application, when the TA in the TEE environment stores recorded data in the RPMB for the first time, it can create a first-in-first-out queue (i.e., a target queue) with its own depth in the first-in-first-out file system based on preset data parameters. The first-in-first-out file system can allocate an idle storage block corresponding to the data parameter in the RPMB for the target queue based on the data parameter of the target queue. The idle storage block is used to carry the target queue. Here, the data parameter includes but is not limited to queue depth information characterizing the target queue and size information of each data element in the target queue.

[0077] For example, the queue depth information representation of the target queue created by the TA request is 10 operation records, and the data element size information corresponding to each operation record is 1000 bytes. Then the size of the free storage block allocated by the first-in-first-out system for the target queue in the RPBM is the depth of 10 operation records, and the data element size corresponding to each operation record is 1000 bytes. When the TA writes the record data in the target queue according to the free space management policy of the target queue, the data size of the record data is the same as the size information of each data element in the target queue. And it can ensure that the TA can always write data in the RPMB without causing the problem of write failure.

[0078] In this application, the first-in-first-out file system can be implemented in the firmware of EMMC or UFS in the TEE environment. By managing the storage space of RPMB in the TEE environment through the first-in-first-out file system, the problem of data writing failure caused by RPMB being full can be avoided, thereby improving the security level of electronic equipment and preventing illegal intrusion and data loss or damage.

[0079] Here, when RPMB has no data written into it (i.e., in the initial state), the storage space of the entire RPMB can be represented by three blocks: the starting block, the first free block, and the ending block, wherein the storage size of the first free block is the total storage size of RPMB (e.g., Figure 4A As shown). When the FIFO file system allocates storage blocks for the target queue in the RPBM based on the data parameters of the target queue, it can search for free storage blocks corresponding to the target queue starting from the starting block of the RPMB in a block list manner, and then the TA can store the record data in the free storage blocks corresponding to the target queue.

[0080] Figure 4A This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 3 ,like Figure 4A As shown,

[0081] The storage space of RPMB is divided into: a starting block 41, a first free block 42 and an ending block 43. When TA creates a target queue in a first-in-first-out system based on data parameters, the first-in-first-out system can query the free blocks starting from the starting block 41 based on the data parameters (depth and data element size) of the target queue. If the first free block 42 is queried, a storage block of corresponding size is allocated to the target queue from the starting address of the first free block 42.

[0082] Figure 4B This is a schematic diagram of the structure of the first-in-first-out file system in this application, as shown in FIG. Figure 4B As shown, when the FIFO system allocates corresponding free storage blocks for the target queue in the RPMB based on the data parameters (depth and data element size) of the target queue, it must query the free storage blocks starting from the starting block 41 of the RPMB each time. If the first free block 42 is found, a free block (storage block) 421 of the corresponding size is allocated to the target queue starting from the starting address of the first free block 42 to carry the target queue, and the remaining free blocks in the first free block 42 can be called the second free block 422. When the FIFO file system allocates storage blocks for the target queue in the RPMB next time, it can allocate free blocks of the corresponding size for the target queue from the second free block 422 with the second free block 422 as the starting address.

[0083] In the present application, the FIFO file system can also use a linked list block splitting method to manage the storage space of the RPMB. If the free space size of the free storage block corresponding to the target queue found by the FIFO file system in the RPBM exceeds the data size corresponding to the target queue, the FIFO file system can also split the free storage block into a first block and a second block based on the data parameters of the target queue; wherein the first block is used as the target block for carrying the target queue, and the second block is recycled.

[0084] Here, when the first-in-first-out file system reclaims the second block, it can also sort the free blocks in the RPMB in ascending order according to the size of each free block to form a block list, and manage the storage space of the RPMB through the block list.

[0085] For example, if TA1 requires the queue A to be created with a queue depth of 10 operations, each operation of 1000 bytes, the FIFO system will allocate a free block of 1000 bytes, the size of 10 operations, to Queue A in the RPMB for the target queue. If TA2 requires the queue B to be created with a queue depth of 5 operations, each operation of 800 bytes, the FIFO system will allocate a free block of 800 bytes, the size of 5 operations, to Queue B in the RPMB for the target queue. If TA1 requires the deletion of the operation data in Queue A, the FIFO system will delete all the data in Queue A (not deleting the data of a specific operation), reclaim Block A corresponding to Queue A, and arrange Block A in the corresponding position of the RPMB according to the size of each free block in the RPMB (for example, if Block A is the smallest block among all the free blocks, Block A will be arranged at the starting position of the first free block in the RPMB). If TA3 requires the queue depth of queue C to be created to be 10 operations, and each operation is 1000 bytes, since the size of block A in RPMB is equal to the data size of queue C, the first-in-first-out system can directly allocate block A in RPMB to queue C; if TA3 requires the queue depth of queue C to be created to be 4 operations, and each operation is 500 bytes, since block A in RPMB can meet the data size of queue C, the first-in-first-out file system can allocate block A in RPMB to queue C. Since the size of block A is larger than the data size of queue C, the first-in-first-out file system can also divide block A into a first block and a second block according to the data parameters of queue C, wherein the first block serves as the target block for carrying queue C and recycles the second block.

[0086] In this application, when the FIFO file system uses the linked list block splitting method to manage the storage space of the RPMB, the structure of each linked list element can be as follows:

[0087] Next: Indicates the next free block. For example, the data storage size can be 64 bits.

[0088] Size: Indicates the size of the current free block. For example, the data storage size can be 32 bits.

[0089] Here, when there are no storage blocks for the reclaimed queue in the RPMB, the addresses of the storage blocks in the RPMB are all continuous (for example, blocks 1-10). When the RPMB allocates storage blocks for the target queue created by the TA, for example, it first allocates storage block 1, then allocates storage block 2, and then allocates storage block 3. When the target queue corresponding to storage block 1 is deleted, the RPMB can reclaim storage block 1. However, since the addresses of the storage blocks in the RPBM are all continuous, it has currently been allocated to storage block 4, leaving storage blocks 4-10. Therefore, when the RPBM reclaims storage block 1, storage block 1 can only exist alone and cannot be merged with the remaining free storage blocks 4-10 in the RPMB. In addition, since the storage size of storage block 1 is smaller than the other free storage blocks in the RPMB, storage block 1 can only be placed at the starting position of the first free block of the RPMB, that is, the storage block list in the RPMB is represented as: storage block 1, storage blocks 4-10.

[0090] In this application, if the CA in the REE environment sends a deletion request to the TA through the REE communication interface, the TA can delete the corresponding target queue in the first-in-first-out file system in response to the deletion request (here, it does not delete a certain historical record data in the queue, but deletes the entire queue). Then the first-in-first-out file system can recycle the target block corresponding to the target queue and rearrange it in ascending order according to the size of each free block in the RPMB. In this way, the storage space of the queue can be released to the RPMB.

[0091] Figure 4C This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 5 ,like Figure 4C As shown,

[0092] There are currently two free blocks in the RPMB, one of which is 16KB in size and the other is 32KB in size. When the block used by the queue is reclaimed by the FIFO file system, since the size of the block used by the queue is 16KB, the size of the block used by the queue is smaller than the 32KB free block in the RPMB, so after sorting the free blocks in the RPMB in ascending order, we get Figure 4C Here, since the free block 1 and free block 2 are of equal size, the block used by the queue can also be used as free block 1.

[0093] In this application, when the TA stores record data in the RPMB of the TEE based on the first-in-first-out file system, it can also determine the target queue corresponding to the TA in the first-in-first-out system according to the data path (this is for the scenario where the target queue has already been created). Then, based on the target queue, it queries whether the data elements in the target queue are empty in the order of the first data element. If there is an empty data element in the target queue, the record data is written to the empty data element in the target queue.

[0094] Here, the data path is sent to the TA by the FIFO file system when the TA creates a target queue in the FIFO file system.

[0095] Here, each data element in the queue corresponds to a record data (including but not limited to operation type, creation timestamp and other information). Each data element represents the space occupied by a record data, and the number of such data elements in the queue is the queue depth of the target queue.

[0096] For example, the queue depth of the target queue is 10, which means that the number of data elements in the target queue is 10. And the size of each data element is equal, for example, 10KB.

[0097] In the present application, if each data element in the target queue is not empty (ie, the written record data has reached the queue depth), the TA may write the record data into the data element in the target queue that is the first to be written.

[0098] Here, when the TA writes the record data into the data element of the target queue to which data is first written, the TA overwrites the data element of the target queue to which data is first written with the current record data.

[0099] For example, the queue depth of the target queue is 10, and each data element is a FIFO data node of 16B. When data A0, A1, A2...An of a size of 16B are continuously written, when n is equal to 10, it means that the current queue depth is full, then the data index of each data element in the target queue is modified so that the current element pointer points to A0, so that when TA writes record data of a size of 16B, the current record data is written to the data element (A0) in the target queue. In this way, the first recorded data (A0) written will be automatically eliminated, and the first data written in the data element (A0) becomes the latest data.

[0100] The present application can modify the data index of each data element in the target queue by means of a pointer in a first-in-first-out file system. When the data index in the target queue is not empty, the data element pointer usually points to the next empty data element, so that when the TA writes record data in RPMB, the record data can directly write the next empty data element. When each data element in the target queue is not empty, the data element pointer can be modified so that the data element pointer points to the data element that first writes data in the target queue, so that when the TA writes record data in RPMB, the record data can directly write the data element that first writes data, to overwrite the historical data of the data element that first writes data. The data element pointer is then modified so that the data element pointer points to the next data element to be eliminated. When the TA writes record data in RPMB next time, the next record data can directly be written into the next data element to be eliminated.

[0101] Here, when the queue depth is not full, the data element pointer always points to the next empty data element. When the queue depth overflows, the first-out system is adopted, and the data element pointer always points to the next data element to be eliminated (i.e., the first written data). In this way, when the queue depth overflows, the current record data is written to the data element of the first written data according to the data element pointed to by the data element pointer, which can enable the RPMB to continuously write data without causing write failures due to full storage space.

[0102] Figure 5 This is a schematic diagram of the process implementation of the processing method in this application Figure 2 ,like Figure 5 As shown, the method includes:

[0103] Step 501, determine whether the data element header is empty; if so, execute step 506; if not, execute step 502;

[0104] Step 502, find the next data element;

[0105] Here, the next data element can be determined in sequence;

[0106] Step 503, determine whether the next data element is empty; if so, execute step 506; if not, execute step 504;

[0107] Step 504, determine whether all data elements are occupied; if so, execute step 505; if not, execute step 502;

[0108] Step 505, reuse the first data element;

[0109] Here, when all data elements are used, we select the data element that is first written to fill, and the first data element that is reused described here is the data element that is first written to fill;

[0110] Step 506, filling in the missing data elements;

[0111] Here, when a data element is empty, the data element is an idle data element; when all data elements are occupied, the data element is the first data element to be written. Filling a vacant data element means writing the record data to be written into the vacant data element.

[0112] Step 507, point the element pointer to the first data element;

[0113] Here, each time you write record data, you need to modify the element index through the element pointer so that the element pointer always points to the data element to be used. When a data element is empty, the data element to be used is the currently empty data element; when all data elements are occupied, the data element to be used is the data element that first wrote data.

[0114] In this way, through the management strategy of the RPMB storage space of the first-in-first-out file system provided in this application, TA can always write record data to RPMB without the problem of write failure, thereby improving the security level of electronic equipment and preventing losses to the equipment caused by illegal intrusion by illegal personnel.

[0115] In this application, the data structure (Data Element) in the first-in-first-out file system is composed of data nodes. The structure of each data node is as follows:

[0116] a.type: Used to store the data type. The data storage size can be 32 bits. Of the 16 bits H, 8 bits H represent data nodes or directory nodes, and 8 bits L represent: 1) head nodes; 2) intermediate nodes; 3) free nodes. 16 bits L are used for extension. Here, H represents the data height, and L represents the data length.

[0117] b.prev*: used to store the parent node address of the current node. The data storage size can be 64 bits. If the current node is the head node, the parent node is the directory node.

[0118] c.next*: used to store the child node address of the current node. The data storage size can be 64 bits. If the current node is the last node, the node is empty (NIL);

[0119] d.length: used to store the data length of the current node. The data storage size can be 32 bits, indicating the size of the subsequent data area. All data nodes in the same group (the same list) have the same data length.

[0120] e.data: used to store the data of the current node.

[0121] Figure 6 This is a schematic diagram of the architecture of the first-in-first-out file system in this application Figure 6 , Figure 6 is Figure 2 Based on the data structure, the data nodes in the data structure are further described. Figure 2 The similarities will not be repeated here.

[0122] like Figure 6 As shown:

[0123] The record data in the data node data 1 is presented through a first-in-first-out queue file. There are 1-N data elements in the first-in-first-out queue, where N is the queue depth of the first-in-first-out queue, and each data element has the same size.

[0124] Here, there can be two element pointers in the first-in-first-out queue: element pointer A points to the previous data element, and element pointer B points to the next data element. If the current node is the head node, element pointer A can point to the parent node, the target node, such as data 1. If the current node is the end node, element pointer B points to null.

[0125] like Figure 6 As shown, when TA stores record data in the target queue through the interface provided by the first-in-first-out file system, it can first determine whether the data element data body 1 is empty. If the data element data body 1 is empty, the current record data is written into the data element data body 1. If the data element data body 1 is not empty, the data element data body 2 is determined; if the data element data body n in the current queue is occupied, the current record data is written into the data element data body 1 to overwrite the data originally written in the data element data body 1.

[0126] In this application, when a TA reads data from a first-in-first-out file system, it can also determine the target data in the target queue corresponding to the TA based on the creation timestamp of the data in each data element, where the creation time of the target data is the closest to the current time among all the data elements in the target queue. The TA can then authenticate an operation request from a general-purpose operating system based on this target data; if authentication is successful, the recorded data corresponding to the current operation request is stored in the target queue. If authentication fails, the current operation request is rejected, and the recorded data corresponding to the current operation request is not stored in the target queue.

[0127] In this application, the interface provided by the first-in-first-out file system can be as follows:

[0128] Mkdir parameters:

[0129] const char*path: represents the data path, such as / dev / fifo / .

[0130] Here, the interface will create one or more new directory nodes and connect the nodes in series in the correct way. If the corresponding node already exists, an error code will be returned.

[0131] open parameters:

[0132] const char*path: represents the data path, such as / dev / fifo / finger1

[0133] rd_rw: Indicates opening in read-only mode or in read-write mode. If the data does not exist, a new data node is created.

[0134] Depth: indicates the queue depth, which is used to indicate the maximum number of data nodes that can be stored;

[0135] element_size: indicates the length of data stored in each data node.

[0136] If the data path doesn't exist, the API creates data nodes corresponding to the specified depth, pre-allocating space for each data node with the length specified by element_size. If the creation or opening is successful, the address of the corresponding leaf directory node is returned; otherwise, 0 is returned.

[0137] close parameter:

[0138] handler: corresponds to the return value of the open interface;

[0139] Get parameters:

[0140] handler: corresponds to the return value of the open interface;

[0141] *depth: indicates the depth of the data element corresponding to the handler;

[0142] *element_size: indicates the size of the element corresponding to the handler.

[0143] Write parameters:

[0144] handler: corresponds to the return value of the open interface;

[0145] element_data: indicates the data element data that needs to be written;

[0146] length: indicates the length of the element data to be written. This length must be consistent with the element_size element size created by the handler in open, otherwise failure is returned.

[0147] This interface operates on the linked list of element data in a FIFO manner. When it finds the appropriate element data, it checks whether the written length is consistent with the data length of the current element data. If they are consistent, it modifies the data directly. Then, if necessary, it modifies the corresponding pointer to complete the operation and returns the actual written length.

[0148] peek parameters:

[0149] handler: represents the data handle returned by the open operation;

[0150] element_data: indicates the return data writing parameter;

[0151] element_size: indicates the length of the returned data. This length must be less than or equal to the length of the data element created during open. Otherwise, 0 is returned.

[0152] index: This parameter indicates the depth of the target data element currently being read. 0 indicates reading the last written data element; -1 indicates reading the earliest written data element; 1, 2, 3... indicate the data element of the corresponding depth.

[0153] flush parameters:

[0154] handler: represents the data handle returned by the open operation;

[0155] Here, this interface is used to clear all data elements corresponding to the handler, and the status of all data elements will be set to idle.

[0156] delete parameters:

[0157] handler: represents the data handle returned by the open operation;

[0158] Here, this interface is used to delete all directory nodes (directory elements) and data nodes (data elements) corresponding to the handler.

[0159] For example, in one implementation scenario, when a version update application in a REE environment updates the system version, the version update application can send a version update operation request to the TA corresponding to the version update application in the TEE environment via the REE communication interface. After receiving the version update operation request sent by the version update application, the TA can obtain version information A (such as the version number) corresponding to the version update application from the corresponding first-in-first-out queue through the data interface provided by the first-in-first-out file system, and match this version information A with the version information B corresponding to the operation request. If the matching result indicates that version information A and version information B are different, it indicates that the operation request failed verification and may be an illegal operation request, and the version update application is denied from executing the system version update. If the matching result indicates that version information A and version information B are the same, it indicates that the operation request successfully verified and is a legal operation request, and the version update application is allowed to execute the system version update. Then, after the operation request is successfully verified, the TA can record the operation information corresponding to the operation request, such as the system version number and update timestamp, to obtain the recorded data corresponding to the operation request, and store the recorded data in the first-in-first-out queue. In this way, through the free space management strategy of the PRMB of the first-in-first-out file system, TA can always write data in the RPMB without causing the problem of write failure.

[0160] For example, in another implementation scenario, APP1 in the REE environment receives a fingerprint creation request from the user. APP1 sends the fingerprint creation request to the corresponding APP2 in the TEE environment through the REE communication interface. APP2 receives the fingerprint creation request and calls the interface of the first-in-first-out file system to create a target queue. The encrypted operating system in the TEE environment can be divided into an encrypted file part and an RPMB storage part. The encrypted file part can write the created fingerprint on its own internal file system after encryption, and at the same time, it will store the version number of the currently written fingerprint template, the time of fingerprint generation, and the hash value of the file in the RPMB. Here, the data in the encrypted file part can be accessed by the APP in the REE environment, but the APP in the REE environment can only obtain the data in the encrypted file part and cannot decrypt the data. If the data needs to be decrypted, it needs to be implemented through the TA in the TEE. That is to say, after someone obtains the fingerprint template from the encrypted file part of system B in the TEE environment through system A in the REE environment, if the fingerprint template is modified, it is not feasible to access the modified fingerprint file in the TEE through the normal path. Because when APP2 in the TEE reads the fingerprint file, it will compare the version number, generation time, and hash value in the fingerprint file with the version number, generation time, and hash value stored in the RPMB of the first-in-first-out file system. If they do not match, the user will be denied access.

[0161] Here, the FIFO file system can also directly store the encrypted data body in the RPMB, such as directly storing fingerprint body data and facial body data in the RPBM, and the fingerprint body data and facial body data can be one or more. When the TA writes the latest encrypted data body in the target queue, the FIFO file system can determine whether the number of bodies in the target queue has reached the maximum number of bodies allowed by the queue depth. If the maximum number of bodies allowed by the queue depth has been reached, the currently written encrypted data body is written to the location of the first written encrypted data body to overwrite the first written encrypted data body.

[0162] Here, the FIFO file system can also store abstract entities in the RPMB, such as encrypted data or payment applications such as mobile wallets. When storing the operation records of abstract entities, the processing flow is the same as that for fingerprints and system versions. Please refer to the relevant description and will not be repeated here.

[0163] The processing method and electronic device provided in the present application store the recorded data of general applications in the rich execution environment (REE) in the RPMB of the TEE through a first-in-first-out file system. Due to the management mechanism of the free space of the RPMB by the first-in-first-out system, the TA can continuously write the recorded data of the general application into the RPMB without worrying about the problem of the storage space of the RPMB being full, thereby improving the security level of the device.

[0164] Figure 7 Schematic diagram of the structure of the electronic device in this application Figure 1 ,like Figure 7 Shown, including:

[0165] A response unit 701 is configured to respond to an operation request of a general operating system based on a trusted application in a trusted execution environment (TEE);

[0166] An acquiring unit 702 is configured to acquire record data based on the trusted application, where the record data is data corresponding to the trusted application responding to an operation request of the general operating system;

[0167] The storage unit 703 is used to store the recorded data in the replay protection memory RPMB of the trusted execution environment based on a first-in-first-out file system.

[0168] In a preferred embodiment, the electronic device further comprises:

[0169] A determining unit 704 is configured to determine a target queue corresponding to the trusted application;

[0170] The storage unit 703 is specifically configured to write the record data into the data element in the target queue that is the first to be written with data when each data element in the target queue is not empty.

[0171] In a preferred embodiment, the electronic device further comprises:

[0172] The modifying unit 705 is configured to modify the data index of each data element in the target queue, wherein the data element to which data is first written is the latest data element.

[0173] In a preferred embodiment, the electronic device further comprises:

[0174] A query unit 706 is configured to query whether the data elements in the target queue are empty based on the target queue in a first data element order;

[0175] The storage unit 703 is specifically configured to write the record data into the empty data element in the target queue when there is an empty data element in the target queue.

[0176] In a preferred embodiment, the electronic device further comprises:

[0177] A creating unit 707 is configured to create the target queue, wherein the target queue includes queue depth information and size information of each data element;

[0178] The allocating unit 708 is configured to allocate a storage area for the target queue in the replay protection memory RPMB.

[0179] In a preferred embodiment, the electronic device further comprises: a splitting unit 709;

[0180] Specifically, the query unit 706 is further configured to search for free storage blocks based on the target queue and starting from a starting block in the RPMB in a block list manner;

[0181] If the free space size of the idle storage block exceeds the data size corresponding to the target queue, the splitting unit 709 is triggered so that the splitting unit 709 splits the idle storage block into a first block and a second block based on the target queue; wherein the first block is used as the target block for carrying the target queue.

[0182] In a preferred embodiment, the electronic device further comprises: a deletion unit 710 and a recycling unit 711;

[0183] The deleting unit 710 is configured to delete the target queue corresponding to the trusted application;

[0184] The recycling unit 711 is configured to recycle the target block corresponding to the target queue.

[0185] In a preferred embodiment, the determining unit 704 is further configured to determine the target data in the target queue corresponding to the trusted application based on the creation timestamp of each data element, wherein the creation time of the target data is the closest to the current time among all the data elements in the target queue;

[0186] an authentication unit 712, configured to authenticate an operation request of the general operating system based on the target data;

[0187] The storage unit 703 is further configured to store the record data corresponding to the operation request in the target queue if the authentication is successful.

[0188] It should be noted that the electronic device provided in the above embodiment, when performing data processing, is illustrated only by the division of the above-mentioned program modules. In actual applications, the above-mentioned processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the above-described processing. In addition, the electronic device provided in the above embodiment and the processing method embodiment provided above are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0189] An embodiment of the present application further provides an electronic device, the electronic device comprising: a processor and a memory for storing a computer program that can be run on the processor,

[0190] Wherein, when the processor is used to run the computer program, it executes any one of the method steps in the above-mentioned processing method.

[0191] Figure 8 This is a schematic diagram of the structure of the electronic device in this application Figure 2 The electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, an information transceiver, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like. Figure 8 The electronic device 800 shown includes: at least one processor 801, a memory 802, at least one network interface 804, and a user interface 803. The various components in the electronic device 800 are coupled together via a bus system 805. It is understood that the bus system 805 is used to achieve connection and communication between these components. In addition to including a data bus, the bus system 805 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the bus system 805 is not described in detail. Figure 8 Various buses are labeled as bus system 805.

[0192] The user interface 803 may include a display, a keyboard, a mouse, a trackball, a click wheel, keys, buttons, a touch pad or a touch screen.

[0193] It is understood that memory 802 can be volatile memory or non-volatile memory, or can include both volatile and non-volatile memory. 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), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disk, or compact disc read-only memory (CD-ROM); magnetic surface memory can be magnetic disk memory or tape memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 802 described in the embodiments of the present application is intended to include, but is not limited to, these and any other suitable types of memories.

[0194] The memory 802 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device 800. Examples of these data include: any computer program for operating on the electronic device 800, such as an operating system 8021 and an application 8022; contact data; phone book data; messages; pictures; audio, etc. Among them, the operating system 8021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 8022 can include various applications, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. The program that implements the method of the embodiment of the present application can be included in the application 8022.

[0195] The methods disclosed in the above embodiments of the present application can be applied to the processor 801 or implemented by the processor 801. The processor 801 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the hardware integrated logic circuit in the processor 801 or by instructions in the form of software. The above processor 801 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 801 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 802. The processor 801 reads the information in the memory 802 and completes the steps of the above method in combination with its hardware.

[0196] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.

[0197] In an exemplary embodiment, the present application also provides a computer-readable storage medium, such as a memory 802 including a computer program. The computer program can be executed by a processor 801 of an electronic device 800 to perform the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface mount storage, optical disk, or CD-ROM; or various devices including any one or any combination of the aforementioned memories, such as a mobile phone, computer, tablet device, personal digital assistant, etc.

[0198] A computer-readable storage medium stores a computer program, which, when executed by a processor, executes any one of the steps in the above-mentioned processing method.

[0199] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0200] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0201] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0202] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0203] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0204] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A treatment method, comprising: Trusted applications in the trusted execution environment (TEE) respond to operation requests from the general operating system. The trusted application obtains record data, where the record data is data corresponding to the operation request of the general operating system in response to the trusted application; Determining a target queue corresponding to the trusted application in a replay protected memory RPMB of the trusted execution environment; Based on the target queue, starting from the starting block in the RPMB in a block list manner, searching for free storage blocks; the free storage blocks include storage blocks corresponding to the queues whose data are all deleted; If the free space size of the free storage block exceeds the data size corresponding to the target queue, splitting the free storage block into a first block and a second block based on the target queue; using the first block as a target block for carrying the target queue; The trusted application stores the record data in the target block based on a first-in-first-out file system.

2. The method according to claim 1, wherein The trusted application stores the recorded data in the target block based on a first-in-first-out file system, including: If each data element in the target queue is not empty, the recorded data is written into the data element of the target block of the target queue that is the first to be written with data.

3. The method according to claim 2, wherein: The trusted application stores the recorded data in the target block based on a first-in-first-out file system, including: The data index of each data element in the target queue is modified, wherein the data element to which data is first written is the latest data element.

4. The method according to claim 2, wherein: The trusted application stores the recorded data in the target block based on a first-in-first-out file system, including: querying whether the data elements in the target queue are empty in a first data element order based on the target queue; If a data element in the target queue is empty, the record data is written into the empty data element in the target block of the target queue.

5. The method according to claim 1, wherein The determining of the target queue corresponding to the trusted application comprises: The target queue is created, where the target queue includes queue depth information and size information of each data element.

6. The method according to claim 1, wherein The trusted application stores the recorded data in the target block based on a first-in-first-out file system, further comprising: Deleting the target queue corresponding to the trusted application; Reclaim the target block corresponding to the target queue.

7. The method according to claim 1, wherein The trusted application stores the recorded data in the target block based on a first-in-first-out file system, further comprising: Determining target data in a target queue corresponding to the trusted application based on a creation timestamp of each data element, wherein the creation time of the target data is the closest to the current time among all data elements in the target queue; authenticating an operation request of the general operating system based on the target data; If the authentication is successful, the record data corresponding to the operation request is stored in the target block of the target queue.

8. An electronic device comprising: A response unit, configured to respond to an operation request of a general operating system based on a trusted application in a trusted execution environment (TEE); an acquiring unit, configured to acquire record data based on the trusted application, wherein the record data is data corresponding to an operation request obtained by the trusted application in response to the general operating system; A storage unit, configured to determine a target queue corresponding to the trusted application in a replay protected memory RPMB of the trusted execution environment; Based on the target queue, starting from the starting block in the RPMB in a block list manner, searching for free storage blocks; the free storage blocks include storage blocks corresponding to the queues whose data are all deleted; If the free space size of the free storage block exceeds the data size corresponding to the target queue, splitting the free storage block into a first block and a second block based on the target queue; using the first block as a target block for carrying the target queue; The trusted application stores the record data in the target block based on a first-in-first-out file system.

9. An electronic device comprising: a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, it executes the method steps described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and apparatus for accessing storage space

    CN105447406A

  • Method for loading a file into ram in an electronic apparatus and associated electronic apparatus

    CN105574414A