Data storage method for mobile phone file system based on ternary tree NAT data structure
By adopting the encrypted storage method of ternary tree NAT data structure in the mobile phone file system, the problems of reduced data encryption storage performance and insufficient security in the existing technology are solved, and efficient and safe data storage and management are achieved, adapting to the needs of mobile devices. Resource limitations.
Patent Information
- Application Number
- CN202410903820.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-08
AI Technical Summary
Existing mobile phone file systems have problems with performance degradation, insufficient security, and complex key management in terms of data encryption storage. Especially in resource-constrained mobile device environments, this can easily lead to slow system response and risk of data leakage.
A file system data storage method based on the ternary tree NAT data structure is adopted. By constructing a data encryption scheme and using the structure of the NAT tree for data encryption and storage, efficient data storage and access is achieved, and the performance and security of the file system are improved.
It improves the efficiency of data storage and retrieval, enhances data security, ensures the efficiency of encryption and decryption, adapts to different data management needs, improves the flexibility and scalability of the system, and prevents unauthorized access.
Smart Images

Figure CN118445263B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of mobile phone encrypted data storage, and in particular to a mobile phone file system data storage method based on a ternary tree NAT data structure. Background Art
[0002] In the existing technology, mobile devices generally use file systems to manage data. Among them, file systems designed for flash memory, such as F2FS (Flash Friendly File System), have efficient data reading and writing performance. However, these technologies have shortcomings in data security and lack support for data encryption storage. This makes personal privacy and sensitive data in mobile devices vulnerable to unauthorized access and theft, which may lead to the leakage of users' personal privacy and data leakage incidents.
[0003] For data encryption storage, existing technologies provide a series of solutions, including symmetric encryption algorithms (such as AES), asymmetric encryption algorithms (such as RSA), hash algorithms (such as SHA-256), and key management systems. However, these technologies have many problems in practical applications. For example, the encrypted storage process may lead to performance degradation, insufficient security, and complex key management. Especially in resource-constrained environments such as mobile devices, encryption operations may consume a lot of computing resources, resulting in slower system response and reduced user experience. In addition, the implementation of encrypted storage may introduce new security vulnerabilities, such as errors in encryption algorithms or implementations, which may cause the system to be attacked by hackers or malicious attackers, leading to data leakage or damage. Summary of the invention
[0004] Based on this, it is necessary to provide a mobile phone file system data storage method based on a ternary tree NAT data structure that can improve the encrypted data storage efficiency and data storage security of the mobile phone file system in order to address the above technical problems.
[0005] A method for storing data in a mobile phone file system based on a ternary tree NAT data structure, the method comprising:
[0006] A data encryption scheme for the mobile phone file system is constructed based on the ternary tree NAT data structure, and data storage tasks are received according to the data encryption scheme.
[0007] Parse the data storage task to obtain the plaintext of the target data, the Node identifier, and the data block index.
[0008] Read the plaintext information of the NAT root node in the memory according to the Node identifier.
[0009] In the ternary tree NAT data structure, the target NAT leaf node that meets the identifier constraint rule is searched in sequence starting from the identifier of the NAT root node plain text information, the mapping relationship of the Node identifier is searched in the target NAT leaf node, the Node information tuple corresponding to the Node identifier is obtained, and the structure of the target Node is obtained from the disk according to the Node information tuple.
[0010] Encrypt the plaintext of the target data to obtain the ciphertext, store the ciphertext to the disk, and generate the ciphertext information tuple of the target data.
[0011] The ciphertext information tuple of the target data is placed in the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node.
[0012] The data encryption scheme is updated step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system can complete the storage of the target data.
[0013] A mobile phone file system data storage device based on a ternary tree NAT data structure, the device comprising:
[0014] A data storage task acquisition module is used to construct a data encryption scheme for the file system based on the ternary tree NAT data structure and receive data storage tasks according to the data encryption scheme;
[0015] The storage information acquisition module is used to parse the data storage task and obtain the plain text, Node identifier and data block index of the target data.
[0016] The root node plain text information acquisition module is used to read the NAT root node plain text information in the memory according to the Node identifier.
[0017] The target Node reading module is used to sequentially search for the target NAT leaf node that meets the identifier constraint rules in the ternary tree NAT data structure, starting from the identifier of the NAT root node plain text information, search for the mapping relationship of the Node identifier in the target NAT leaf node, obtain the Node information tuple corresponding to the Node identifier, and obtain the structure of the target Node from the disk according to the Node information tuple.
[0018] The first-level encryption module is used to encrypt the plain text of the target data, obtain the cipher text, store the cipher text in the disk, and generate the cipher text information tuple of the target data.
[0019] The secondary encryption module is used to put the ciphertext information tuple of the target data into the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node.
[0020] The data storage module is used to update the data encryption scheme step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system can complete the storage of the target data.
[0021] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0022] A data encryption scheme for the mobile phone file system is constructed based on the ternary tree NAT data structure, and data storage tasks are received according to the data encryption scheme.
[0023] Parse the data storage task to obtain the plaintext of the target data, the Node identifier, and the data block index.
[0024] Read the plaintext information of the NAT root node in the memory according to the Node identifier.
[0025] In the ternary tree NAT data structure, the target NAT leaf node that meets the identifier constraint rule is searched in sequence starting from the identifier of the NAT root node plain text information, the mapping relationship of the Node identifier is searched in the target NAT leaf node, the Node information tuple corresponding to the Node identifier is obtained, and the structure of the target Node is obtained from the disk according to the Node information tuple.
[0026] Encrypt the plaintext of the target data to obtain the ciphertext, store the ciphertext to the disk, and generate the ciphertext information tuple of the target data.
[0027] The ciphertext information tuple of the target data is placed in the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node.
[0028] The data encryption scheme is updated step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system can complete the storage of the target data.
[0029] The above-mentioned mobile phone file system data storage method based on the ternary tree NAT data structure can realize efficient data storage and access by adopting the ternary tree NAT data structure. The structure of the NAT tree makes the data organization more flexible, and the target data can be quickly located by the identifier, thereby improving the performance and efficiency of the file system. According to the Node identifier, starting from the root node of the NAT tree, the NAT nodes that meet the identifier constraint rules are sequentially searched to obtain the target Node corresponding to the Node identifier. The use of the ternary tree NAT data structure can improve the storage and retrieval efficiency of data, thereby improving the overall performance of the file system. Secondly, the ciphertext information tuple is stored in the target Node, which not only improves the security of the data, but also facilitates the management and maintenance of the ciphertext data. Such a design enables the file system to better adapt to different data management requirements and improves the flexibility and scalability of the system. Then, by secondary encryption of the target data, that is, while storing the ciphertext of the target data on the disk, the ciphertext information tuple is encrypted again in the target Node, thereby increasing the security of the data. Even if a part of the data is leaked, it is difficult for unauthorized users to obtain the true content of the data. In this way, the encrypted storage of data in the mobile phone file system can be realized, and the efficiency of encryption and decryption can be guaranteed while improving the security of the data storage process. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is an application scenario diagram of a mobile phone file system data storage method based on a ternary tree NAT data structure in one embodiment;
[0031] Figure 2 A schematic diagram of a flow chart of a method for storing data in a mobile phone file system based on a ternary tree NAT data structure in one embodiment;
[0032] Figure 3 A schematic diagram of a flow chart of a mobile phone file system data storage step based on a ternary tree NAT data structure in one embodiment;
[0033] Figure 4 A Crypt data structure in one embodiment;
[0034] Figure 5 The f2fs_inode encrypted data structure in one embodiment;
[0035] Figure 6 A direct_inode encrypted data structure in one embodiment;
[0036] Figure 7 A superblock encryption data structure in one embodiment;
[0037] Figure 8A structural block diagram of a mobile phone file system data storage device based on a ternary tree NAT data structure in one embodiment;
[0038] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0040] The mobile phone file system data storage method based on the ternary tree NAT data structure provided by the present invention can be applied to Figure 1 In the F2FS file system encryption scheme shown in the figure, the original data structure of F2FS exists in an encrypted form on the disk, and the data structure at the tail of the arrow stores the encryption information of the data structure pointed to by the arrow, including the key and the message verification code. The Node contains the encryption information of the directory entry and the data block. In the F2FS file system, the encryption information (key and message verification code) of the four data areas, namely the Check Point Data Area (CP), the Segment Information Table Data Area (SIT), the Node Address Table Data Area (NAT), and the Segment Summary Area (SSA), is placed in the super block, and the encrypted ciphertext is placed in the location where the plaintext was originally stored. In the super block, the key and the message verification code exist in the form of a Crypt structure. When the file system exits, the encrypted ciphertext is placed in the location where the plaintext was originally stored. Both directory entries and data blocks are stored in the data segment of the disk, and the original Node contains the physical addresses of the directory entries and data blocks. The corresponding directory entries and data blocks can be directly found through the Node. Therefore, the encryption information of the directory entries and data blocks is placed in the Node, thereby ensuring that the F2FS data query process remains basically unchanged. In addition, NAT saves the encryption information of the Node. In the F2FS file system, in order to avoid the snowball effect, the physical address of the Node can be found through NAT. Therefore, the encryption information of the Node is saved in NAT.
[0041] In one embodiment, Figure 2 As shown, a method for storing data in a mobile phone file system based on a ternary tree NAT data structure is provided. Figure 1 The encryption scheme of the F2FS file system in is used as an example to illustrate the encryption scheme, which includes the following steps:
[0042] Step 202: construct a data encryption scheme for the mobile phone file system based on the ternary tree NAT data structure, and receive a data storage task according to the data encryption scheme.
[0043] Step 204, parse the data storage task to obtain the plain text of the target data, the Node identifier and the data block index.
[0044] Step 206: Read the plain text information of the NAT root node in the memory according to the Node identifier.
[0045] Step 208, in the ternary tree NAT data structure, starting from the identifier of the plain text information of the NAT root node, sequentially search for the target NAT leaf node that meets the identifier constraint rule, search for the mapping relationship of the Node identifier in the target NAT leaf node, obtain the Node information tuple corresponding to the Node identifier, and obtain the structure of the target Node from the disk according to the Node information tuple.
[0046] Step 210, encrypt the plaintext of the target data to obtain ciphertext, store the ciphertext in the disk, and generate a ciphertext information tuple of the target data.
[0047] Step 212, the ciphertext information tuple of the target data is placed into the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node.
[0048] Step 214, updating the data encryption scheme step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system completes the storage of the target data.
[0049] Specifically, the original Node related information is updated according to the identifier of the target Node and the secondary information tuple, and the NAT node information is updated step by step. Based on the updated Node secondary information tuple, the relevant data in the NAT leaf node is updated.
[0050] Furthermore, the NAT node information is updated step by step, starting from the leaf node, and the current NAT node is re-encrypted in an iterative form to obtain an updated encrypted information tuple, and the encrypted information tuple is used to overwrite the relevant information in the parent node, and then the parent node is re-encrypted until it is updated to the NAT root node.
[0051] Furthermore, after exiting the mobile phone file system, the updated NAT root node information is placed in the metadata super block, and the metadata super block is encrypted by the user root key.
[0052] In the above-mentioned mobile phone file system data storage method based on the ternary tree NAT data structure, by adopting the ternary tree NAT data structure, the file system can realize efficient data storage and access. The structure of the NAT tree makes the data organization more flexible, and the target data can be quickly located by the identifier, thereby improving the performance and efficiency of the file system. According to the Node identifier, starting from the root node of the NAT tree, the NAT nodes that meet the identifier constraint rules are sequentially searched to obtain the target Node corresponding to the Node identifier. The use of the ternary tree NAT data structure can improve the storage and retrieval efficiency of data, thereby improving the overall performance of the file system. Secondly, the ciphertext information tuple is stored in the target Node, which not only improves the security of the data, but also facilitates the management and maintenance of the ciphertext data. Such a design enables the file system to better adapt to different data management requirements and improves the flexibility and scalability of the system. Then, by secondary encryption of the target data, that is, while storing the ciphertext of the target data on the disk, the ciphertext information tuple is encrypted again in the target Node, thereby increasing the security of the data. Even if a part of the data is leaked, it is difficult for unauthorized users to obtain the true content of the data. In this way, the encrypted storage of data in the mobile phone file system can be realized, and the efficiency of encryption and decryption can be guaranteed while improving the security of the data storage process.
[0053] In one embodiment, if Figure 3 As shown in the figure, a mobile phone file system data storage step based on a ternary tree NAT data structure is provided. Assuming that all data needs to be read from the disk as an example, the specific contents are as follows:
[0054] Step 1: Accept the data storage task and obtain the data plaintext data, the inode id to which it belongs, and the index of the data block.
[0055] Step 2: Get the plaintext information of the NAT root node (physical address, key, message authentication code) from the super block, and decrypt and read the NAT. Read the ciphertext of the NAT root node from the physical address, and decrypt and authenticate the NAT root node in combination with the key and message authentication code. This step is not required every time data is stored. When the file system is initialized, NAT can be initialized to read the NAT root node, or after the data is read for the first time, the NAT root node is not put into the disk, and the relevant information is saved in the memory, so that each subsequent storage can directly read the NAT root node in the memory.
[0056] Step 3: Use NAT to find the node-related information (physical address, key, message verification code) corresponding to the node id (the first search is the inode id). NAT is a tree structure. By comparing the node id with the nid in the non-leaf node, search from the root to the leaf node. Finally, the physical address, key and message verification code of the corresponding node can be locked and saved. Thus, relevant information can be obtained.
[0057] Step 4: Read the node and determine whether the index is in the current node. Based on the information obtained in step 3, read and decrypt the authentication node through the physical address, key, and message verification code. Then, according to the multi-level index mechanism in F2FS, determine whether the index of the data block to be stored is in the current node. If not, get the node id corresponding to the index and return to step 3. If it is, go to step 5.
[0058] Step 5: Encrypt the data data, put the ciphertext into the disk, and record the relevant information (physical address, key, message verification code). Put the corresponding physical address, key, and message verification code into the current node.
[0059] Step 6: Encrypt the node, put the ciphertext into the disk, and record the relevant information (physical address, key, message verification code). According to the ID of the current node, put the corresponding physical address, key, and message verification code into NAT.
[0060] Step 7: Put the modified NAT root node related information (physical address, key, message verification code) into the super block. After the data is stored, this step is usually not executed, and it will only be executed when the system exits.
[0061] In one of the embodiments, a data encryption framework is constructed in the mobile phone file system. The data encryption framework includes: a ternary tree NAT data structure, a metadata super block, and a Node data structure. The metadata super block is set in the previous data encryption link of the ternary tree NAT data structure, so that the metadata super block encrypts and saves the information tuple of the root node stored in the ternary tree NAT data structure through the root key. The Node data structure is set in the next data encryption link of the ternary tree NAT data structure, and the mapping relationship between the identifier of each Node in the Node data structure and the ciphertext information tuple is updated to the NAT leaf node of the ternary tree NAT data structure and then encrypted and saved. The data encryption framework stores the target ciphertext data according to the encrypted information tuple of the root node and the mapping relationship.
[0062] In one embodiment, the encryption interface provided by OpenSSL is used, and the encryption algorithm is AES128, so as to encrypt and authenticate each data written to the disk. In this embodiment, the length of the key and message authentication code is set to 16. For each encrypted data block, a key and message authentication code of the same size are used, so the key and message authentication code are encapsulated into a structure Crypt, such as Figure 4 As shown, it helps improve code readability.
[0063] In one embodiment, the Node data structure includes a direct Node and an indirect Node. The direct Node stores the index of the data block and the ciphertext information tuple of the data block. The indirect Node stores the identifier of the next level Node. The metadata super block includes: the physical address, key and message authentication code of the CP data area, the physical address, key and message authentication code of the SIT data area, the physical address, key and message authentication code of the SSA data area, and the physical address, key and message authentication code of the NAT root node.
[0064] It is worth noting that in the embodiment, the Node encryption data structure is in F2FS, and Node is divided into direct Node and indirect Node. Among them, there are two types of direct Node and one type of indirect Node, so there are three types of Node in total, namely f2fs_inode, direct_node, and indirect_node. In f2fs_inode and direct_node, the physical address of the data block is directly saved, so it is necessary to add the encryption information of each data block in these two nodes, that is, the Crypt structure in this embodiment. In the f2fs_inode structure, the number of addresses of the original saved data blocks is DEF_ADDRS_PER_INODE, so the number of newly added Crypt structures is also DEF_ADDRS_PER_INODE, and its specific structure is as follows Figure 5 In the direct_node structure, the number of addresses of the original saved data blocks is ADDRS_PER_BLOCK, so the number of newly added Crypt structures is also ADDRS_PER_BLOCK. Its specific structure is as follows Figure 6 As shown. In f2fs_inode and direct_node, the address and Crypt structure correspond one-to-one, that is, the address and Crypt at the same index correspond to the same data block. Since indirect_node stores the nid of the next level node and does not store the physical address, the indirect_node structure remains unchanged.
[0065] In addition, the encryption data structure of the super block in the embodiment adds encryption information (key and message verification code) of four data areas, CP, SIT, NAT, and SSA, into the super block. In the super block, the key and message verification code exist in the form of Crypt structure. When the file system exits, the encrypted ciphertext is placed in the location where the plaintext was originally stored, including Figure 7 The super block structure of the encrypted information is shown.
[0066] In one of the embodiments, a data encryption scheme of the F2FS file system is constructed based on the ternary tree NAT data structure, the Node data structure and the metadata super block, and a data storage task is received according to the data encryption scheme.
[0067] It is worth noting that, in this embodiment, a ternary tree that integrates the Merkle tree and the B+ tree is used to construct the NAT encryption data structure. The logical structure is a ternary tree (it can also be an N-fork number). The structure of non-leaf nodes is consistent, that is, they all contain two representations of nid, and three groups of physical addresses (pba), keys (key), and message verification codes (mac) values. The two nids of non-leaf nodes are used to distinguish the nid ranges of the three groups of child nodes they point to. The three groups of pba, key, and mac represent the physical addresses, keys, and message verification codes of the three child nodes, respectively. The leaf node contains multiple nid-> (pba, key, mac) mapping relationships. A leaf node is stored in the same physical block. NAT provides four external functions, namely NAT initialization, NAT disk placement, data query, and data writing. In the encryption scheme, a symmetric encryption algorithm and a message verification code mechanism are used to ensure both data security and data integrity. Therefore, when saving the encryption information of any data, it is necessary to record the key and the message verification code at the same time, and the plaintext is not stored on the disk. Instead, the ciphertext is stored in the plaintext location. In addition:
[0068] 1) Superblock encryption data structure: The superblock records the basic information of the F2FS file system, including the start address of each data area (Check Point (CP), Node Address Table (NAT), etc.), the size of each data area, etc. Here, in order to improve the security of the F2FS file system, the encryption information (key and message verification code) of the four data areas of the check point data area (CP), segment information table data area (SIT), node address table data area (NAT), and segment summary area data area (SSA) are placed in the superblock, and the encrypted ciphertext is placed in the location where the plaintext was originally stored. In the superblock, the key and message verification code exist in the form of a Crypt structure. When the file system exits, the encrypted ciphertext is placed in the location where the plaintext was originally stored.
[0069] 2) Node data structure: In the F2FS file system, nodes can be divided into direct nodes and indirect nodes according to whether the physical address of the data block is stored in the node. In direct nodes, since they store the physical address of the data block, in order to facilitate the search of encrypted information, the encryption information of each data block, namely the key and the message verification code, needs to be added to the direct node. However, in indirect nodes, since they store the ID (nid) of the next-level node, the encryption information of the next-level node is not stored in the indirect node. The physical address of the next-level node can be obtained by querying the nid in the NAT, so the encryption information of the next-level node is stored in the NAT.
[0070] In one embodiment, the ternary tree NAT encrypted data structure includes four functions: NAT initialization, NAT disk storage, NAT query data and NAT data writing. The specific steps of each function are as follows:
[0071] 1) NAT initialization: The first case: when the file system is first created, there is no NAT data on the disk. At this time, the entire NAT ternary tree needs to be constructed and all nodes except the root node need to be placed on the disk. This situation is relatively complicated, and the height of the NAT ternary tree needs to be designed according to the size of the file system. In this embodiment, the planned number of nodes is 1024, and each NAT leaf node contains 5 node information, so a ternary tree with a height of 6 is ultimately required. The tree height calculation method is shown in Formula 1, where num represents the number of nodes, leaf represents the number of node information that a single leaf node can store, and tree represents the number of branches of the tree. In this embodiment, num=1024, leaf=5, tree=3, that is:
[0072] ;
[0073] The construction of the ternary tree uses a backtracking algorithm to traverse the entire tree in a depth-first manner. After traversing a node, the node is encrypted, written to disk, and its encrypted information is written to the parent node.
[0074] The second case: when the file system is not created for the first time, that is, there is NAT data on the disk, in which case the address and encryption information of the NAT root node need to be read from the super block, and the NAT root node needs to be decrypted and loaded into the memory.
[0075] 2) NAT disk placement: NAT disk placement is called when the file system exits. It only requires placing the NAT root node in a preset location and placing the encrypted information of the NAT root node in the super block.
[0076] 3) NAT query data: To query data through NAT, you need to provide the node id. NAT searches from the NAT root node to the leaf nodes in sequence according to the node id. Finally, the node id is hit in the leaf node, and the storage address and encrypted information Crypt of the corresponding node are returned.
[0077] 4) NAT writes data: NAT writes data requiring node id and data. This is a two-step process. First, you need to find the location of the corresponding leaf node based on the node id, take out the leaf node, put the data to be written into the leaf node, then put the leaf node back to the location where it was taken out, and reverse the search path to change the encryption information of each node until the root node.
[0078] In one of the embodiments, in a ternary tree NAT data structure, according to the comparison result of the identifier of the NAT root node plain text information and the identifier of the non-leaf node in the ternary tree NAT data structure, the target NAT leaf node that meets the identifier constraint rule is searched in sequence from the root node to the leaf node, and the mapping relationship of the Node identifier is searched in the target NAT leaf node to obtain the Node information tuple corresponding to the Node identifier. According to the physical address of the Node information tuple, the target Node is addressed in the disk to obtain the target Node, and the key and message verification code of the Node information tuple are used to unlock the target Node to obtain the structure of the target Node.
[0079] In one embodiment, the physical address of the Node information tuple is used to address the disk. If the data block index of the target data is within the index storage range of the current Node, the current Node is the target Node, and the key and message verification code of the Node information tuple are used to unlock the target Node to obtain the structure of the target Node. Otherwise, according to the indirect Node identifier stored in the current Node, the ternary tree NAT data structure is iteratively searched to obtain the target Node corresponding to the data block index containing the target data in the Node index, and the key and message verification code of the Node information tuple are used to unlock the target Node to obtain the structure of the target Node.
[0080] In one embodiment, an encryption algorithm is used to encrypt the plain text of the target data to obtain ciphertext and encryption information. The encryption information includes: a ciphertext key and a ciphertext message verification code. According to the ciphertext and the encryption information, a storage area is applied to the disk for ciphertext storage to obtain a ciphertext physical address, and a ciphertext information tuple of the target data is generated according to the ciphertext physical address, the ciphertext key and the ciphertext message verification code.
[0081] In one of the embodiments, the ciphertext information tuple of the target data is written into the structure of the target Node. If the structure of the target Node contains a data block index and a ciphertext information tuple, the structure information of the target Node is updated according to the ciphertext information tuple. If the structure of the target Node does not contain a ciphertext information tuple, the data block index and the ciphertext information tuple are added to the structure of the target Node. After the ciphertext information tuple is written into the target Node, the system starts the data encryption scheme to perform secondary encryption storage on the target Node to obtain the secondary information tuple of the target Node. The secondary information tuple includes: a secondary physical address, a secondary key, and a secondary message verification code.
[0082] In one of the embodiments, the information of the original Node in the Node data structure is updated according to the identifier of the target Node and the secondary information tuple. The NAT leaf node information is updated in the ternary tree NAT data structure according to the updated information of the original Node, and each NAT node is updated in reverse iteration from the leaf node to the root node according to the updated NAT leaf node information to obtain an updated ternary tree NAT data structure. After exiting the mobile phone file system, the NAT root node information in the updated ternary tree NAT data structure is stored in the metadata super block, and the metadata super block is encrypted three times by the user root key so that the mobile phone file system completes the storage of the target data.
[0083] In one embodiment, data storage takes the creation of a folder as an example and accepts a data storage task. Create a node and generate inode id=2. Create a directory entry dentry and initialize it to obtain the index index=0 of the data block. Since the NAT root node is loaded when the file system is initialized, this step is skipped. Put the node information into NAT, and put the node and dentry into memory respectively for subsequent immediate reading. Since the node is not put into the disk at this time, no key and message verification code are generated. The data put into NAT at this time is only the logical address of the node (the logical address here is also equivalent to the physical address). Since index=0, it should obviously be put into the newly generated node. When the number of dentries cached in the memory reaches a certain upper limit, all the data in the memory needs to be put into the disk. At this time, it is necessary to encrypt the dentry data, put it into the disk, and record the relevant information (physical address, key, message verification code). Put this information into the associated node structure. When the number of nodes cached in the memory reaches a certain upper limit, all the data in the memory needs to be put into the disk. At this time, it is necessary to encrypt the node data, put it into the disk, and record the relevant information (physical address, key, message verification code). Put this information into the corresponding NAT structure. When the file system exits, the modified NAT root node needs to be put into the disk, and the relevant information (physical address, key, message verification code) needs to be recorded, and finally the relevant information needs to be put into the super block.
[0084] It should be understood that although Figure 2-Figure 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 3At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0085] In one embodiment, Figure 8 As shown, a mobile phone file system data storage device based on a ternary tree NAT data structure is provided, comprising: a data storage task acquisition module 802, a storage information acquisition module 804, a root node plaintext information acquisition module 806, a target Node reading module 808, a primary encryption module 810, a secondary encryption module 812 and a data storage module 814, wherein:
[0086] The data storage task acquisition module 802 is used to construct a data encryption scheme for the file system based on the ternary tree NAT data structure and receive a data storage task according to the data encryption scheme;
[0087] The storage information acquisition module 804 is used to parse the data storage task and obtain the plain text, Node identifier and data block index of the target data.
[0088] The root node plain text information acquisition module 806 is used to read the NAT root node plain text information in the memory according to the Node identifier.
[0089] The target Node reading module 808 is used to sequentially search for the target NAT leaf node that meets the identifier constraint rules in the ternary tree NAT data structure, starting from the identifier of the NAT root node plain text information, search for the mapping relationship of the Node identifier in the target NAT leaf node, obtain the Node information tuple corresponding to the Node identifier, and obtain the structure of the target Node from the disk according to the Node information tuple.
[0090] The first-level encryption module 810 is used to encrypt the plain text of the target data, obtain the ciphertext, store the ciphertext in the disk, and generate the ciphertext information tuple of the target data.
[0091] The secondary encryption module 812 is used to put the ciphertext information tuple of the target data into the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node.
[0092] The data storage module 814 is used to update the data encryption scheme level by level according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system can complete the storage of the target data.
[0093] For the specific definition of the mobile phone file system data storage device based on the ternary tree NAT data structure, please refer to the definition of the mobile phone file system data storage method based on the ternary tree NAT data structure in the above text, which will not be repeated here. Each module in the above-mentioned mobile phone file system data storage device based on the ternary tree NAT data structure can be fully or partially implemented by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0094] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a mobile phone file system data storage method based on a ternary tree NAT data structure is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0095] Those skilled in the art will understand that Figure 8-Figure 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0096] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0097] A data encryption scheme for the mobile phone file system is constructed based on the ternary tree NAT data structure, and a data storage task is received according to the data encryption scheme.
[0098] Parse the data storage task to obtain the plaintext of the target data, the Node identifier, and the data block index.
[0099] Read the plaintext information of the NAT root node in the memory according to the Node identifier.
[0100] In the ternary tree NAT data structure, the target NAT leaf node that meets the identifier constraint rule is searched in sequence starting from the identifier of the NAT root node plain text information, the mapping relationship of the Node identifier is searched in the target NAT leaf node, the Node information tuple corresponding to the Node identifier is obtained, and the structure of the target Node is obtained from the disk according to the Node information tuple.
[0101] The plain text of the target data is encrypted to obtain the cipher text, the cipher text is stored in the disk, and the cipher text information tuple of the target data is generated.
[0102] The ciphertext information tuple of the target data is placed in the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node.
[0103] The data encryption scheme is updated step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system can complete the storage of the target data.
[0104] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0105] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0106] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for storing data in a mobile phone file system based on a ternary tree NAT data structure, characterized in that: The method comprises: Constructing a data encryption framework in the mobile phone file system; the data encryption framework includes: a ternary tree NAT data structure, a metadata super block and a Node data structure; The metadata super block is set in the previous data encryption link of the ternary tree NAT data structure, so that the metadata super block encrypts and stores the information tuple stored in the root node of the ternary tree NAT data structure through the root key; The Node data structure is set in the next data encryption link of the ternary tree NAT data structure, and the mapping relationship between the identifier of each Node in the Node data structure and the ciphertext information tuple is updated to the NAT leaf node of the ternary tree NAT data structure and then encrypted and saved; The data encryption framework stores the target ciphertext data according to the encrypted information tuple of the root node and the mapping relationship; Building a data encryption scheme for the mobile phone file system based on the ternary tree NAT data structure, and receiving a data storage task according to the data encryption scheme; Parse the data storage task to obtain the plain text, Node identifier and data block index of the target data; Read the plaintext information of the NAT root node in the memory according to the Node identifier; In the ternary tree NAT data structure, starting from the identifier of the plain text information of the root node, sequentially search for the target NAT leaf node that meets the identifier constraint rule, search for the mapping relationship of the Node identifier in the target NAT leaf node, obtain the Node information tuple corresponding to the Node identifier, and obtain the structure of the target Node from the disk according to the Node information tuple; Encrypting the plaintext of the target data to obtain ciphertext, storing the ciphertext in the disk, and generating a ciphertext information tuple of the target data; Put the ciphertext information tuple of the target data into the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node; The data encryption scheme is updated step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system completes the storage of the target data.
2. The method according to claim 1, characterized in that The Node data structure includes: direct Node and indirect Node; wherein the direct Node stores the index of the data block and the ciphertext information tuple of the data block; the indirect Node stores the identifier of the next level Node; The metadata super block includes: the physical address, key and message authentication code of the CP data area, the physical address, key and message authentication code of the SIT data area, the physical address, key and message authentication code of the SSA data area, and the physical address, key and message authentication code of the NAT root node.
3. The method according to claim 1, characterized in that Building a data encryption scheme for the file system based on the ternary tree NAT data structure, and receiving a data storage task according to the data encryption scheme, including: A data encryption scheme for the F2FS file system is constructed based on the ternary tree NAT data structure, the Node data structure, and the metadata super block, and a data storage task is received according to the data encryption scheme.
4. The method according to claim 3, characterized in that In the ternary tree NAT data structure, starting from the identifier of the plain text information of the root node, sequentially searching for a target NAT leaf node that meets the identifier constraint rule, searching for a mapping relationship of the Node identifier in the target NAT leaf node, obtaining a Node information tuple corresponding to the Node identifier, and obtaining a structure of the target Node from the disk according to the Node information tuple, including: In the ternary tree NAT data structure, according to the comparison result of the identifier of the root node plaintext information and the identifier of the non-leaf node in the ternary tree NAT data structure, the target NAT leaf node that meets the identifier constraint rule is searched in sequence from the root node to the leaf node, and the mapping relationship of the Node identifier is searched in the target NAT leaf node to obtain the Node information tuple corresponding to the Node identifier; The target Node is obtained by addressing the disk according to the physical address of the Node information tuple, and the target Node is unlocked by using the key and message verification code of the Node information tuple to obtain the structure of the target Node.
5. The method according to claim 4, characterized in that According to the physical address of the Node information tuple, the target Node is addressed in the disk, and the target Node is unlocked by using the key and the message verification code of the Node information tuple to obtain the structure of the target Node, including: Addressing is performed in the disk according to the physical address of the Node information tuple. If the data block index of the target data is within the index storage range of the current Node, the current Node is the target Node. The target Node is unlocked using the key and message verification code of the Node information tuple to obtain the structure of the target Node. Otherwise, iterative search is performed in the ternary tree NAT data structure according to the indirect Node identifier stored in the current Node to obtain the target Node corresponding to the data block index of the target data in the Node index. The target Node is unlocked using the key and message verification code of the Node information tuple to obtain the structure of the target Node.
6. The method according to claim 5, characterized in that Encrypting the plaintext of the target data to obtain ciphertext, storing the ciphertext in the disk, and generating a ciphertext information tuple of the target data, including: The target data is encrypted using an encryption algorithm to obtain ciphertext and encrypted information; the encrypted information includes: a ciphertext key and a ciphertext message verification code; Apply for a storage area from the disk to store the ciphertext according to the ciphertext and the encryption information, obtain a ciphertext physical address, and generate a ciphertext information tuple of the target data according to the ciphertext physical address, the ciphertext key and the ciphertext message verification code.
7. The method according to claim 6, characterized in that The ciphertext information tuple of the target data is written into the structure of the target Node for secondary encryption to obtain the secondary information tuple of the target Node, including: Write the ciphertext information tuple of the target data into the structure of the target Node; if the structure of the target Node contains the data block index and the ciphertext information tuple, update the structure information of the target Node according to the ciphertext information tuple; if the structure of the target Node does not contain the ciphertext information tuple, add the data block index and the ciphertext information tuple to the structure of the target Node; After writing the ciphertext information tuple into the target Node, the system starts the data encryption scheme to perform secondary encryption storage on the target Node to obtain the secondary information tuple of the target Node; The secondary information tuple includes: a secondary physical address, a secondary key and a secondary message verification code.
8. The method according to claim 7, characterized in that The data encryption scheme is updated step by step according to the identifier of the target Node and the secondary information tuple, so that the mobile phone file system completes the storage of the target data, including: Update the information of the original Node in the Node data structure according to the identifier of the target Node and the secondary information tuple; Update NAT leaf node information in the ternary tree NAT data structure according to the updated information of the original Node, and update each NAT node in reverse iteration from the leaf node to the root node according to the updated NAT leaf node information to obtain the updated ternary tree NAT data structure; After exiting the mobile phone file system, the NAT root node information in the updated ternary tree NAT data structure is stored in the metadata super block, and the metadata super block is encrypted three times using the user root key so that the mobile phone file system completes the storage of the target data.
Citation Information
Patent Citations
Multi-version control method of memory file system
CN105868396A
Computing system including host and storage system
US20220221987A1
