Ternary tree NAT data structure construction method, device, equipment and medium
By constructing a ternary tree NAT data structure, the deficiencies in data security of mobile phone file systems are solved, data encryption and efficient storage are achieved, data security and performance are improved, and data tampering and rollback attacks are prevented.
Patent Information
- Application Number
- CN202410904013.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-07-08
AI Technical Summary
Existing mobile phone file systems such as F2FS have deficiencies in data security, especially the lack of encryption functions, which results in reduced data performance and low security, and existing encryption solutions such as stacked encryption and fscrypt lead to reduced memory space utilization. and program compatibility issues.
Using the ternary tree NAT data structure, by building a data encrypted ternary tree NAT data structure, including non-leaf nodes and leaf nodes, using identifiers and information tuples for data encryption, ensuring the privacy and integrity of the data, and in the metadata Root node information is stored in the super block to achieve safe storage and fast retrieval of data.
It improves data security and performance, prevents rollback attacks, ensures data stability and reliability, and avoids the risk of data being decrypted and tampered with, while maintaining the efficiency of the file system.
Smart Images

Figure CN118445258B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of mobile phone data structure construction, and in particular to a ternary tree NAT data structure construction method, device, equipment and medium. Background Art
[0002] The mobile phone file system is directly related to data storage and plays an important role in data security. The file system manages the storage method of data on the disk. An excellent file system can greatly maximize the performance of the disk, thereby meeting the performance requirements of users. The F2FS (Flash Friendly File System) file system is a file system designed specifically for mobile phone flash memory. It is friendly to mobile phone storage media and has extremely high data read and write performance. However, F2FS does not have data encryption function, that is, in terms of data security, F2FS cannot meet user needs.
[0003] Designing a mobile phone file system encryption scheme is an important means to ensure the security of mobile phone data. At present, combined with the encryption subsystem, the encryption of the mobile phone file system can also be achieved to a certain extent. For example, on the mobile phone file system, adding a stacked encrypted file system can achieve file-level encryption, but the stacked encrypted file system has a separate cache page, which will lead to reduced memory space utilization. And due to the encrypted file name structure, it will cause program compatibility issues. In addition, the fscrypt encryption subsystem can also achieve file-level encryption, support transparent encryption of files and directories, and provide encryption support for the mobile phone file system. However, due to file-level encryption, there is no friendly design for the mobile phone file system, which leads to the problem of reduced performance and low security of the mobile phone file system. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, equipment and medium for constructing a ternary tree NAT data structure that can improve data security and effectiveness in response to the above technical problems.
[0005] A method for constructing a ternary tree NAT data structure, the method comprising:
[0006] Construct a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes: non-leaf nodes and leaf nodes.
[0007] Constructing a non-leaf node data structure of the NAT node. The non-leaf node data structure includes: a first identifier, a second identifier, and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0008] Construct the leaf node data structure of the NAT node. The leaf node data structure includes: several Node identifiers and Node information tuples.
[0009] An identifier constraint condition is constructed based on the first identifier and the second identifier.
[0010] When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint.
[0011] When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node.
[0012] When the NAT node is a root node, the information tuple of the root node is stored in a pre-built metadata super block.
[0013] In one embodiment, it also includes: constructing a root node for data encryption, the root node writes the identifiers and information tuples of the child nodes of the root node into a memory in the order of completion of backtracking, and obtains a ternary tree NAT data structure. The information tuple includes: a physical address, a key, and a message verification code.
[0014] In one embodiment, it also includes: if several Node identifiers in the leaf node are all smaller than the first identifier of the non-leaf node, the leaf node is the first child node of the non-leaf node. If several Node identifiers are all larger than the first identifier and smaller than the second identifier, the leaf node is the second child node of the non-leaf node. If several Node identifiers are all larger than the second identifier, the leaf node is the third child node of the non-leaf node.
[0015] In one embodiment, if the first identifier and the second identifier of the non-leaf node are both smaller than the first identifier of the parent node of the non-leaf node, the non-leaf node is the first child node of the parent node. If the first identifier and the second identifier are both greater than the first identifier of the parent node and less than the second identifier of the parent node, the non-leaf node is the second child node of the parent node. If the first identifier and the second identifier are both greater than the second identifier of the parent node, the non-leaf node is the third child node of the parent node.
[0016] In one embodiment, it also includes: constructing a data encryption scheme of the F2FS file system according to the ternary tree NAT data structure, the Node data structure and the metadata super block, and storing the information tuple of the target NAT node according to the data encryption scheme. 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.
[0017] In one of the embodiments, it also includes: in the ternary tree NAT data structure, querying the plaintext information stored in the data area of the target NAT subnode according to the identifier constraint condition and the information tuple of the target NAT subnode.
[0018] In one embodiment, the method further includes: a non-leaf node searches in a ternary tree NAT data structure according to the first identifier and the second identifier to obtain an information tuple of a target NAT child node. A data block address of the target NAT child node in a NAT data area is determined according to a physical address of the information tuple of the target NAT child node, and plain text information of the target NAT child node is obtained through a key and a message verification code of the information tuple of the target NAT child node.
[0019] A device for constructing a ternary tree NAT data structure, the device comprising:
[0020] The tree structure building module is used to build a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes non-leaf nodes and leaf nodes.
[0021] The non-leaf node construction module is used to construct a non-leaf node data structure of a NAT node. The non-leaf node data structure includes: a first identifier, a second identifier and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0022] The leaf node construction module is used to construct the leaf node data structure of the NAT node. The leaf node data structure includes: a number of Node identifiers and Node information tuples.
[0023] The identifier constraint condition building module is used to build the identifier constraint condition according to the first identifier and the second identifier.
[0024] The leaf node connection module is used to connect the identifier of the leaf node with the non-leaf node according to the identifier constraint condition.
[0025] The non-leaf node connection module is used for connecting the non-leaf node to the parent node according to the identifier constraint condition of the parent node of the non-leaf node when the NAT node is a non-leaf node.
[0026] The root node information interaction module is used to save the information tuple of the root node in a pre-built metadata super block when the NAT node is the root node.
[0027] 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:
[0028] Construct a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes: non-leaf nodes and leaf nodes.
[0029] Constructing a non-leaf node data structure of the NAT node. The non-leaf node data structure includes: a first identifier, a second identifier, and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0030] Construct the leaf node data structure of the NAT node. The leaf node data structure includes: several Node identifiers and Node information tuples.
[0031] An identifier constraint condition is constructed based on the first identifier and the second identifier.
[0032] When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint.
[0033] When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node.
[0034] When the NAT node is a root node, the information tuple of the root node is stored in a pre-built metadata super block.
[0035] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0036] Construct a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes: non-leaf nodes and leaf nodes.
[0037] Constructing a non-leaf node data structure of the NAT node. The non-leaf node data structure includes: a first identifier, a second identifier, and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0038] Construct the leaf node data structure of the NAT node. The leaf node data structure includes: several Node identifiers and Node information tuples.
[0039] An identifier constraint condition is constructed based on the first identifier and the second identifier.
[0040] When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint.
[0041] When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node.
[0042] When the NAT node is a root node, the information tuple of the root node is stored in a pre-built metadata super block.
[0043] The above-mentioned three-fork tree NAT data structure construction method, device, equipment and medium, first, need to create a root node, which is the starting node of the entire three-fork tree NAT data structure. For each NAT node, it is necessary to determine its identifier and information tuple. The identifier is usually a number, which can be compared in size to identify the search direction in the NAT node. The information tuple consists of a physical address, a key and a message verification code. Among them, the key and the message verification code are used to encrypt the NAT node to ensure the security of the data. Secondly, for each non-leaf node, it is necessary to set a first identifier and a second identifier, which are used to determine the range of identifiers in its child nodes. The non-leaf node also needs to store three groups of NAT child node information tuples. For the leaf node, it is necessary to determine its parent node (i.e., non-leaf node) and the mapping relationship between several Node identifiers and Node information tuples. The Node identifier is an attribute of the Node structure in the file system, which is used to identify the Node structure. The difference is that the information tuple in the leaf node is for the Node structure, while the information tuple in the non-leaf node is for the NAT node. The establishment of the leaf node needs to rely on the existence and organizational structure of the parent node to ensure the correct storage and retrieval of data. When creating a metadata superblock, the root node's related information needs to be stored in it. Such an encryption structure ensures the privacy and integrity of the data, making it difficult to decrypt and tamper with the data even if it is obtained. It can also effectively prevent rollback attacks, improve data security, and quickly locate and restore data, ensuring the stability and reliability of encrypted data. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is an application scenario diagram of a method for constructing a ternary tree NAT data structure in an embodiment;
[0045] Figure 2 A schematic diagram of a flow chart of a method for constructing a ternary tree NAT data structure in one embodiment;
[0046] Figure 3 Schematic diagram of NAT data structure in one embodiment; Figure 3 (a) is the logical structure of NAT data. Figure 3 (b) The physical structure of NAT data;
[0047] Figure 4 is an encrypted data structure of a super block in one embodiment;
[0048] Figure 5 A structural block diagram of a device for constructing a ternary tree NAT data structure in one embodiment;
[0049] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0050] 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.
[0051] The ternary tree NAT data structure construction method provided by the present invention can be applied to Figure 1 In the F2FS file system encryption scheme shown in FIG. 1 , 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 directory entry and the data block are both stored in the data segment of the disk, and the original Node contains the physical address of the directory entry and the data block. The corresponding directory entry and data block can be directly found through the Node. Therefore, the encryption information of the directory entry and the data block 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.
[0052] In one embodiment, Figure 2 As shown, a method for constructing a ternary tree NAT data structure is provided, and the method is applied to 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:
[0053] Step 202: construct a ternary tree NAT (Node Address Table) data structure for data encryption.
[0054] The ternary tree NAT data structure includes: non-leaf nodes and leaf nodes.
[0055] Step 204: construct a non-leaf node data structure of the NAT node.
[0056] The non-leaf node data structure includes: a first identifier, a second identifier and three groups of NAT child node information tuples, and the identifier is composed of numbers.
[0057] Step 206: construct a leaf node data structure of the NAT node.
[0058] The leaf node data structure includes: a mapping relationship between several Node identifiers and Node information tuples.
[0059] Step 208: construct an identifier constraint condition according to the first identifier and the second identifier.
[0060] The identifier constraint condition includes: for a leaf node in a NAT data structure, its identifier is constrained by the first identifier and the second identifier in its parent node. The identifier is composed of a number. If the leaf node is the first child node of its parent node, then several Node identifiers in the leaf node are smaller than the first identifier of its parent node. If the leaf node is the second child node of its parent node, then several Node identifiers of the leaf node are between the first identifier and the second identifier of its parent node. If the leaf node is the third child node of its parent node, then several Node identifiers of the leaf node are larger than the second identifier of its parent node.
[0061] It also includes: for a non-leaf node in the NAT data structure, its first identifier is smaller than the second identifier. If the non-leaf node has a parent node, the size of its first identifier and the second identifier is constrained by the first identifier and the second identifier of the parent node, and the constraint rules are the same as the Node identifier constraints in the leaf node. The corresponding child node can be found according to the identifier relationship and the information tuple of the NAT child node.
[0062] Step 210: When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint condition.
[0063] Step 212: When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node.
[0064] Step 214: When the NAT node is a root node, the information tuple of the root node is stored in a pre-built metadata super block.
[0065] In the above-mentioned three-fork tree NAT data structure construction method, first, it is necessary to create a root node, which is the starting node of the entire three-fork tree NAT data structure. For each NAT node, its identifier and information tuple need to be determined. The identifier is usually a number, which can be compared in size to identify the search direction in the NAT node. The information tuple consists of a physical address, a key and a message verification code. Among them, the key and the message verification code are used to encrypt the NAT node to ensure the security of the data. Secondly, for each non-leaf node, it is necessary to set a first identifier and a second identifier, which are used to determine the range of identifiers in its child nodes. Non-leaf nodes also need to store three groups of NAT child node information tuples. For leaf nodes, it is necessary to determine the mapping relationship between its parent node (i.e., non-leaf node) and several Node identifiers and Node information tuples. The Node identifier is an attribute of the Node structure in the file system, which is used to identify the Node structure. The difference is that the information tuple in the leaf node is for the Node structure, while the information tuple in the non-leaf node is for the NAT node. The establishment of a leaf node needs to rely on the existence and organizational structure of the parent node to ensure the correct storage and retrieval of data. When creating a metadata superblock, the root node's related information needs to be stored in it. Such an encryption structure ensures the privacy and integrity of the data, making it difficult to decrypt and tamper with the data even if it is obtained. It can also effectively prevent rollback attacks, improve data security, and quickly locate and restore data, ensuring the stability and reliability of encrypted data.
[0066] In one embodiment, a root node for data encryption is constructed, and the root node writes the identifiers and information tuples of the child nodes of the root node into a memory in the order of completion of backtracking to obtain a ternary tree NAT data structure. The information tuple includes: a physical address, a key, and a message verification code.
[0067] In one embodiment, if several Node identifiers in a leaf node are all smaller than the first identifier of a non-leaf node, the leaf node is the first child node of the non-leaf node. If several Node identifiers are all larger than the first identifier and smaller than the second identifier, the leaf node is the second child node of the non-leaf node. If several Node identifiers are all larger than the second identifier, the leaf node is the third child node of the non-leaf node.
[0068] In one embodiment, if the first identifier and the second identifier of the non-leaf node are both smaller than the first identifier of the parent node of the non-leaf node, the non-leaf node is the first child node of the parent node. If the first identifier and the second identifier are both greater than the first identifier of the parent node and less than the second identifier of the parent node, the non-leaf node is the second child node of the parent node. If the first identifier and the second identifier are both greater than the second identifier of the parent node, the non-leaf node is the third child node of the parent node.
[0069] In one embodiment, 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 the information tuple of the target NAT node is stored according to the data encryption scheme. 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.
[0070] It is worth noting that in the encryption scheme, symmetric encryption algorithms and message authentication code mechanisms 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 message authentication code at the same time, and the plain text is not stored on the disk, but the cipher text is stored in the location of the plain text. In addition:
[0071] 1) Super block encryption data structure: The super block structure containing encryption information is as follows Figure 4 As shown, the basic information of the F2FS file system is recorded in the super block, 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 Check Point (CP), Segment Information Table (SIT), Node Address Table (NAT), and Segment Summary Area (SSA) are 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 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.
[0072] 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.
[0073] In one of the embodiments, in the ternary tree NAT data structure, the plaintext information stored in the data area of the target NAT subnode is queried according to the identifier constraint and the information tuple of the target NAT subnode.
[0074] In one embodiment, the non-leaf node searches three-way in the ternary tree NAT data structure according to the first identifier and the second identifier to obtain the information tuple of the target NAT child node. The data block address of the target NAT child node in the NAT data area is determined according to the physical address of the information tuple of the target NAT child node, and the plain text information of the target NAT child node is obtained through the key and message verification code of the information tuple of the target NAT child node.
[0075] It is worth noting that if Figure 3 As shown, a NAT encryption data structure is provided, wherein: Figure 3 (a) is the logical structure of NAT, which is a ternary tree (can also be an N-ary tree). The structure of non-leaf nodes is the same, that is, they all contain two identifiers nid (Node ID) and three groups of information tuples (physical address, key, message verification code). The two nids of non-leaf nodes are used to distinguish the nid ranges of the three groups of child nodes they point to. Leaf nodes contain mappings from multiple nids to information tuples (physical address, key, message verification code). A leaf node is stored in the same physical block. Figure 3 (b) shows the physical structure of NAT storage and disk. When constructing NAT for the first time, a backtracking algorithm is used, starting from the root node and using depth-first construction. The corresponding nodes are written to the disk in the order in which the backtracking is completed. When changing the data in NAT, the in-place change method is used to overwrite the original value.
[0076] In one of the embodiments, the metadata superblock is encrypted by a pre-set administrator key.
[0077] In one of the embodiments, the encryption information of the metadata super block is stored in the root key of the F2FS file system for encryption protection.
[0078] It should be understood that although Figure 2 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 At 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.
[0079] In one embodiment, Figure 5 As shown, a three-tree NAT data structure construction device is provided, including: a tree structure construction module 502, a non-leaf node construction module 504, a leaf node construction module 506, an identifier constraint condition construction module 508, a leaf node connection module 510, a non-leaf node connection module 512 and a root node information interaction module 514, wherein:
[0080] The tree structure building module 502 is used to build a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes non-leaf nodes and leaf nodes.
[0081] The non-leaf node construction module 504 is used to construct a non-leaf node data structure of the NAT node. The non-leaf node data structure includes: a first identifier, a second identifier and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0082] The leaf node construction module 506 is used to construct the leaf node data structure of the NAT node. The leaf node data structure includes: a plurality of Node identifiers and Node information tuples.
[0083] The identifier constraint condition building module 508 is used to build an identifier constraint condition according to the first identifier and the second identifier.
[0084] The leaf node connection module 510 is used to connect the identifier of the leaf node with the non-leaf node according to the identifier constraint condition.
[0085] The non-leaf node connection module 512 is used for connecting the non-leaf node to the parent node according to the identifier constraint condition of the parent node of the non-leaf node when the NAT node is a non-leaf node.
[0086] The root node information interaction module 514 is used to save the information tuple of the root node in a pre-built metadata super block when the NAT node is the root node.
[0087] The specific definition of the ternary tree NAT data structure construction device can be found in the definition of the ternary tree NAT data structure construction method mentioned above, which will not be repeated here. Each module in the above-mentioned ternary tree NAT data structure device can be implemented in whole or in part 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 in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0088] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 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 method for constructing 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.
[0089] Those skilled in the art will understand that Figure 5-6 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.
[0090] 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:
[0091] Construct a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes: non-leaf nodes and leaf nodes.
[0092] Constructing a non-leaf node data structure of the NAT node. The non-leaf node data structure includes: a first identifier, a second identifier, and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0093] Construct the leaf node data structure of the NAT node. The leaf node data structure includes: several Node identifiers and Node information tuples.
[0094] An identifier constraint condition is constructed based on the first identifier and the second identifier.
[0095] When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint.
[0096] When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node.
[0097] When the NAT node is a root node, the information tuple of the root node is stored in a pre-built metadata super block.
[0098] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0099] Construct a ternary tree NAT data structure for data encryption. The ternary tree NAT data structure includes: non-leaf nodes and leaf nodes.
[0100] Constructing a non-leaf node data structure of the NAT node. The non-leaf node data structure includes: a first identifier, a second identifier, and three groups of NAT child node information tuples, wherein the first identifier is smaller than the second identifier.
[0101] Construct the leaf node data structure of the NAT node. The leaf node data structure includes: several Node identifiers and Node information tuples.
[0102] An identifier constraint condition is constructed based on the first identifier and the second identifier.
[0103] When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint.
[0104] When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node.
[0105] When the NAT node is a root node, the information tuple of the root node is stored in a pre-built metadata super block.
[0106] 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).
[0107] The technical features of the above embodiments may be arbitrarily combined. 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.
[0108] 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 constructing a ternary tree NAT data structure, characterized in that: The method comprises: Constructing a ternary tree NAT data structure for data encryption; the ternary tree NAT data structure includes: non-leaf nodes and leaf nodes; Constructing a non-leaf node data structure of a NAT node; the non-leaf node data structure comprises: a first identifier, a second identifier and information tuples of three groups of NAT child nodes, wherein the first identifier is smaller than the second identifier; Constructing a leaf node data structure of the NAT node; the leaf node data structure includes: a plurality of Node identifiers and Node information tuples; An identifier constraint condition is constructed according to the first identifier and the second identifier; if several Node identifiers in the leaf node are all smaller than the first identifier of the non-leaf node, the leaf node is the first child node of the non-leaf node; if the several Node identifiers are all larger than the first identifier and smaller than the second identifier, the leaf node is the second child node of the non-leaf node; if the several Node identifiers are all larger than the second identifier, the leaf node is the third child node of the non-leaf node; When the NAT node is a leaf node, the identifier of the leaf node is connected to the non-leaf node according to the identifier constraint condition; When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to an identifier constraint condition of the parent node of the non-leaf node; When the NAT node is a root node, the information tuple of the root node is saved in a pre-constructed metadata super block; a data encryption scheme of the F2FS file system is constructed according to the ternary tree NAT data structure, the Node data structure and the metadata super block, and the information tuple of the target NAT node is stored according to the data encryption scheme; 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.
2. The method according to claim 1, characterized in that Construct a ternary tree NAT data structure for data encryption, including: Constructing a root node for data encryption, wherein the root node writes identifiers and information tuples of child nodes of the root node into a memory in the order in which the backtracking is completed, to obtain a ternary tree NAT data structure; The information tuple includes: a physical address, a key and a message verification code.
3. The method according to claim 1, characterized in that When the NAT node is a non-leaf node, the non-leaf node is connected to the parent node according to the identifier constraint of the parent node of the non-leaf node, including: If the first identifier and the second identifier of the non-leaf node are both smaller than the first identifier of the parent node of the non-leaf node, then the non-leaf node is the first child node of the parent node; If the first identifier and the second identifier are both greater than the first identifier of the parent node and less than the second identifier of the parent node, the non-leaf node is the second child node of the parent node; If the first identifier and the second identifier are both greater than the second identifier of the parent node, the non-leaf node is the third child node of the parent node.
4. The method according to claim 3, characterized in that After building a data encryption scheme for the F2FS file system according to the ternary tree NAT data structure, the Node data structure, and the metadata super block, and storing the information tuple of the target NAT node according to the data encryption scheme, the method further includes: In the ternary tree NAT data structure, the plaintext information stored in the data area of the target NAT subnode is queried according to the identifier constraint condition and the information tuple of the target NAT subnode.
5. The method according to claim 4, characterized in that In the ternary tree NAT data structure, querying the plaintext information stored in the data area of the target NAT subnode according to the identifier constraint and the information tuple of the target NAT subnode includes: The non-leaf node searches in the ternary tree NAT data structure according to the first identifier and the second identifier to obtain an information tuple of a target NAT child node; The data block address of the target NAT subnode in the NAT data area is determined according to the physical address of the information tuple of the target NAT subnode, and the plaintext information of the target NAT subnode is obtained through the key and message verification code of the information tuple of the target NAT subnode.
6. A device for constructing a ternary tree NAT data structure, characterized in that: The device comprises: A tree structure building module, used to build a ternary tree NAT data structure for data encryption; the ternary tree NAT data structure includes non-leaf nodes and leaf nodes; A non-leaf node construction module, used to construct a non-leaf node data structure of a NAT node; the non-leaf node data structure includes: a first identifier, a second identifier and three groups of information tuples of NAT child nodes, wherein the first identifier is smaller than the second identifier; A leaf node construction module, used to construct a leaf node data structure of the NAT node; the leaf node data structure includes: a plurality of Node identifiers and Node information tuples; An identifier constraint construction module, used to construct an identifier constraint based on the first identifier and the second identifier; if several Node identifiers in the leaf node are all smaller than the first identifier of the non-leaf node, then the leaf node is the first child node of the non-leaf node; if the several Node identifiers are all larger than the first identifier and smaller than the second identifier, then the leaf node is the second child node of the non-leaf node; if the several Node identifiers are all larger than the second identifier, then the leaf node is the third child node of the non-leaf node; A leaf node connection module, used for connecting the identifier of the leaf node with the non-leaf node according to the identifier constraint condition; A non-leaf node connection module, used for connecting the non-leaf node to the parent node according to the identifier constraint of the parent node of the non-leaf node when the NAT node is a non-leaf node; A root node information interaction module is used to save the information tuple of the root node in a pre-constructed metadata super block when the NAT node is a root node; construct a data encryption scheme for the F2FS file system according to the ternary tree NAT data structure, the Node data structure and the metadata super block, and store the information tuple of the target NAT node according to the data encryption scheme; the metadata super block includes: the physical address, key and message verification code of the CP data area; the physical address, key and message verification code of the SIT data area; the physical address, key and message verification code of the SSA data area and the physical address, key and message verification code of the NAT root node.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
