Integrity verification method and system for persistent memory
By using the combination of Merkel tree and SGX region in NVMM, persistent memory data is encrypted and hashed, which solves the problem of data integrity verification in NVMM, and takes into account both data security and performance, preventing External attacks and tampering.
Patent Information
- Application Number
- CN202411586675.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-01-17
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN119323061A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of persistent memory technology, and more specifically to a method and system for verifying the integrity of a persistent memory. Background Art
[0002] Non-volatile memory (NVMM) has the advantages of high capacity, low cost, byte addressing, and data retention after power failure, but it also faces the risk of data residual attack and data tampering attack. In order to ensure data security and integrity, NVMM needs to combine memory encryption and integrity verification technology.
[0003] Existing NVMM persistence technology focuses on performance, but ignores the persistence of security metadata, resulting in the inability to ensure security. In addition, the current NVMM security and persistence technology does not distinguish between persistent and non-persistent memory areas, resulting in the inability to balance performance and security.
[0004] Therefore, how to verify the integrity of data in persistent memory and prevent external attacks and tampering is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0005] In view of this, the present invention provides a method and system for integrity verification of persistent memory, which solves the problems existing in the background technology.
[0006] In order to achieve the above object, the present invention provides the following technical solutions:
[0007] A method for verifying the integrity of persistent memory includes the following steps:
[0008] S1: Preprocess the data in persistent memory and build a Merkle tree based on the hash value of the data;
[0009] S2: Initialize the SGX area and load the Merkle tree into the SGX area;
[0010] S3: According to the path verification mechanism of the Merkle tree, the hash value from the leaf node to the root node corresponding to the data block to be verified is compared with the hash value of the known Merkle tree to verify the integrity of the data in the persistent memory.
[0011] Optionally, the preprocessing operation in S1 is to encrypt the data in the persistent memory using the XTS-AES mode encryption algorithm, which specifically includes the following steps:
[0012] Select an encryption algorithm suitable for persistent memory and generate a strong random key;
[0013] Divide the data into fixed-size data blocks, and encrypt each data block using the AES algorithm in XTS mode;
[0014] Write the encrypted data back to persistent memory and store the key and initialization vector;
[0015] When access to the data is required, the encrypted data is decrypted using the same key and initialization vector.
[0016] Optionally, the preprocessing operation in S1 is: divide the data in the persistent memory into blocks according to the data type and application requirements, and independently encrypt, hash and access control each data block; wherein the size of the data block is determined based on the requirement of balancing data access efficiency and persistent memory usage efficiency.
[0017] Optionally, the preprocessing operation in S1 also includes: selecting a compression algorithm suitable for data characteristics to compress the data in the persistent memory, and performing redundancy processing on the data in the persistent memory based on a redundancy strategy.
[0018] Optionally, the construction of the Merkle tree in S1 specifically includes the following steps:
[0019] Calculate the hash value of each data block according to the hash function, and use the hash value of each data block as the leaf node of the Merkle tree;
[0020] The hash values of adjacent leaf nodes are concatenated into a new string, and the hash function is applied to the new string again to obtain the hash value of the upper parent node. The calculation is recursively performed until the root node of the Merkle tree is formed.
[0021] Optionally, initializing the SGX area in S2, that is, initializing the verification logic and data structure in the SGX area, specifically includes the following steps:
[0022] Create an EDL file to define the enclave interface;
[0023] Write initialization verification logic and data structures inside the enclave;
[0024] Call the initialization function at the enclave entry point;
[0025] Create an enclave in the Host application and call the enclave's initialization function.
[0026] Optionally, verify the integrity of the data in the persistent memory in S3, including the following steps:
[0027] When the integrity of the data in persistent memory needs to be verified, the root node of the Merkle tree is read from the SGX area;
[0028] According to the verification request, read the data block to be verified from the persistent memory and calculate the hash value;
[0029] Using the Merkle tree's path verification mechanism, starting from the leaf node, the hash value is verified layer by layer until the root node is reached;
[0030] Compare the hash value in the verification process with the hash value on the Merkle tree to see if they match, and verify the integrity of the data in the persistent memory.
[0031] Optionally, the path verification mechanism of the Merkle tree is the inverse process of building the Merkle tree, which specifically includes the following steps:
[0032] Get the verification path from the leaf node corresponding to the data block to be verified to the root node of the Merkle tree;
[0033] Starting from the bottom of the verification path, the hash value of the data block to be verified is combined with the hash value of the corresponding sibling node to calculate the hash value of the two;
[0034] Use the hash value calculated in the previous step to continue upward and combine it with the hash value of the next sibling node in the verification path to calculate the hash, and repeat this process until the root node of the Merkle tree is reached;
[0035] The last calculated hash value is compared with the known Merkle tree root hash value. If the two are the same, the integrity verification of the data block is successful. Otherwise, the data block has been tampered with.
[0036] A system using any one of the above methods for verifying the integrity of persistent memory comprises:
[0037] Persistent memory, used to store data to be verified;
[0038] The SGX zone contains the verification logic and data structures used to protect critical data and perform integrity verification;
[0039] Processor, which is used to perform tasks such as data preprocessing, hash calculation, Merkle tree construction, and integrity verification.
[0040] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a method and system for integrity verification of persistent memory, which has the following beneficial effects:
[0041] The present invention utilizes the data structure characteristics of the Merkle tree and combines the security isolation capability of the SGX area to realize the integrity verification of the data in the persistent memory; by constructing the Merkle tree, the hash value of the data is used as the node of the tree to form a compact representation of the data and an efficient verification mechanism; at the same time, the SGX area is used to protect key data and verification logic to prevent external attacks and tampering. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0043] Figure 1 A flowchart of the integrity verification method for persistent memory provided by the present invention. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] The embodiment of the present invention discloses a method for verifying the integrity of a persistent memory. Figure 1 As shown, the following steps are included:
[0046] S1: Preprocess the data in persistent memory and build a Merkle tree based on the hash value of the data;
[0047] S2: Initialize the SGX area and load the Merkle tree into the SGX area;
[0048] S3: According to the path verification mechanism of the Merkle tree, the hash value from the leaf node to the root node corresponding to the data block to be verified is compared with the hash value of the known Merkle tree to verify the integrity of the data in the persistent memory.
[0049] Furthermore, the preprocessing operation in S1 is to encrypt the data in the persistent memory using the XTS-AES mode encryption algorithm, which specifically includes the following steps:
[0050] Select an encryption algorithm suitable for persistent memory (for example, AES-256-XTS) and generate a strong random key to ensure secure storage and transmission of the key;
[0051] Divide the data into fixed-size data blocks, and encrypt each data block using the AES algorithm in XTS mode;
[0052] Write the encrypted data back to persistent memory and store the key and initialization vector;
[0053] When access to the data is required, the encrypted data is decrypted using the same key and initialization vector.
[0054] Furthermore, the preprocessing operation in S1 is: divide the data in the persistent memory into blocks according to the data type and application requirements, and independently encrypt, hash and access control each data block; wherein the size of the data block is determined based on the requirement of balancing data access efficiency and persistent memory usage efficiency.
[0055] Furthermore, the preprocessing operations in S1 also include: (1) selecting a compression algorithm suitable for data characteristics (for example, LZ4, Zstd, etc.) to compress the data in the persistent memory, thereby reducing the use of storage space and improving transmission efficiency; (2) performing redundant processing on the data in the persistent memory based on a redundancy strategy (for example, RAID or replicated data blocks) to improve data reliability.
[0056] Furthermore, the construction of the Merkle tree in S1 specifically includes the following steps:
[0057] Calculate the hash value of each data block according to the hash function (for example, SHA-256), and use the hash value of each data block as the leaf node of the Merkle tree;
[0058] The hash values of adjacent leaf nodes are concatenated into a new string, and the hash function is applied to the new string again to obtain the hash value of the upper parent node. The calculation is recursively performed until the root node of the Merkle tree is formed.
[0059] Specifically, the calculation of hash values is usually based on a hash function, which is an algorithm that converts an input (or "message") into a fixed-length output, which is the hash value. There is a set of algorithms inside the hash function that converts the input data into a hash value. These algorithms are used to ensure that even a small change in the input will result in a very different output hash value (avalanche effect).
[0060] Furthermore, the initialization of the SGX area in S2, that is, initializing the necessary verification logic and data structure in the SGX area, specifically includes the following steps:
[0061] Define EDL file: Create an EDL file to define the enclave interface;
[0062] Write enclave code: Write initialization verification logic and data structure inside the enclave;
[0063] Call the initialization function at the enclave entry point;
[0064] Create an enclave in the Host application and call the enclave's initialization function.
[0065] After completing the SGX area initialization, the root node of the Merkle tree and other necessary verification information are loaded into the SGX area to ensure its security and isolation.
[0066] Furthermore, verifying the integrity of data in the persistent memory in S3 specifically includes the following steps:
[0067] When the integrity of the data in persistent memory needs to be verified, the root node of the Merkle tree is read from the SGX area;
[0068] According to the verification request, read the data block to be verified from the persistent memory and calculate the hash value;
[0069] Using the Merkle tree's path verification mechanism, starting from the leaf node, the hash value is verified layer by layer until the root node is reached;
[0070] Compare the hash value in the verification process with the hash value on the Merkle tree to see if they match, and verify the integrity of the data in the persistent memory.
[0071] Furthermore, the path verification mechanism of the Merkle tree is the inverse process of constructing the Merkle tree, which specifically includes the following steps:
[0072] Get the verification path from the leaf node corresponding to the data block to be verified to the root node of the Merkle tree, which usually includes a series of hash values corresponding to the sibling nodes on the path from the leaf node to the root node;
[0073] Starting from the bottom of the verification path, the hash value of the data block to be verified is combined with the hash value of the corresponding sibling node to calculate the hash value of the two;
[0074] Use the hash value calculated in the previous step to continue upward and combine it with the hash value of the next sibling node in the verification path to calculate the hash, and repeat this process until the root node of the Merkle tree is reached;
[0075] The last calculated hash value is compared with the known Merkle tree root hash value. If the two are the same, the integrity verification of the data block is successful. Otherwise, the data block has been tampered with.
[0076] and Figure 1 Corresponding to the method described above, an embodiment of the present invention further provides an integrity verification system for persistent memory, for verifying Figure 1 The specific implementation of the method in the embodiment of the present invention is a persistent memory-oriented integrity verification system which can be applied to a computer terminal or various mobile devices, and specifically includes:
[0077] Persistent memory, used to store data to be verified;
[0078] The SGX zone contains the verification logic and data structures used to protect critical data and perform integrity verification;
[0079] Processor, which is used to perform tasks such as data preprocessing, hash calculation, Merkle tree construction, and integrity verification.
[0080] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0081] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for integrity verification of persistent memory, characterized in that: The following steps are involved: S1: Preprocess the data in persistent memory and build a Merkle tree based on the hash value of the data; S2: Initialize the SGX area and load the Merkle tree into the SGX area; S3: According to the path verification mechanism of the Merkle tree, the hash value from the leaf node to the root node corresponding to the data block to be verified is compared with the hash value of the known Merkle tree to verify the integrity of the data in the persistent memory.
2. The method for integrity verification of persistent memory according to claim 1, characterized in that: The preprocessing operation in S1 is to encrypt the data in the persistent memory using the XTS-AES mode encryption algorithm, which specifically includes the following steps: Select an encryption algorithm suitable for persistent memory and generate a strong random key; Divide the data into fixed-size data blocks, and encrypt each data block using the AES algorithm in XTS mode; Write the encrypted data back to persistent memory and store the key and initialization vector; When access to the data is required, the encrypted data is decrypted using the same key and initialization vector.
3. The method for integrity verification of persistent memory according to claim 1, characterized in that: The preprocessing operation in S1 is: divide the data in the persistent memory into blocks according to the data type and application requirements, and encrypt, hash and access control each data block independently; the size of the data block is determined based on the requirement of balancing data access efficiency and persistent memory usage efficiency.
4. The method for integrity verification of persistent memory according to claim 1, characterized in that: The preprocessing operation in S1 also includes: selecting a compression algorithm suitable for data characteristics to compress the data in the persistent memory, and performing redundancy processing on the data in the persistent memory based on a redundancy strategy.
5. The method for integrity verification of persistent memory according to claim 3, characterized in that: The construction of the Merkle tree in S1 specifically includes the following steps: Calculate the hash value of each data block according to the hash function, and use the hash value of each data block as the leaf node of the Merkle tree; The hash values of adjacent leaf nodes are concatenated into a new string, and the hash function is applied to the new string again to obtain the hash value of the upper parent node. The calculation is recursively performed until the root node of the Merkle tree is formed.
6. The method for integrity verification of persistent memory according to claim 1, characterized in that: Initializing the SGX area in S2, that is, initializing the verification logic and data structure in the SGX area, specifically includes the following steps: Create an EDL file to define the enclave interface; Write initialization verification logic and data structures inside the enclave; Call the initialization function at the enclave entry point; Create an enclave in the Host application and call the enclave's initialization function.
7. The method for integrity verification of persistent memory according to claim 1, characterized in that: Verifying the integrity of data in persistent memory in S3 includes the following steps: When the integrity of the data in persistent memory needs to be verified, the root node of the Merkle tree is read from the SGX area; According to the verification request, read the data block to be verified from the persistent memory and calculate the hash value; Using the Merkle tree's path verification mechanism, starting from the leaf node, the hash value is verified layer by layer until the root node is reached; Compare the hash value in the verification process with the hash value on the Merkle tree to see if they match, and verify the integrity of the data in the persistent memory.
8. The method for integrity verification of persistent memory according to claim 1, characterized in that: The path verification mechanism of the Merkle tree is the reverse process of building the Merkle tree, which includes the following steps: Get the verification path from the leaf node corresponding to the data block to be verified to the root node of the Merkle tree; Starting from the bottom of the verification path, the hash value of the data block to be verified is combined with the hash value of the corresponding sibling node to calculate the hash value of the two; Use the hash value calculated in the previous step to continue upward and combine it with the hash value of the next sibling node in the verification path to calculate the hash, and repeat this process until the root node of the Merkle tree is reached; The last calculated hash value is compared with the known Merkle tree root hash value. If the two are the same, the integrity verification of the data block is successful. Otherwise, the data block has been tampered with.
9. A system using the method for integrity verification of persistent memory as described in any one of claims 1 to 8, characterized in that: include: Persistent memory, used to store data to be verified; The SGX zone contains the verification logic and data structures used to protect critical data and perform integrity verification; Processor, which is used to perform tasks such as data preprocessing, hash calculation, Merkle tree construction, and integrity verification.
Citation Information
Patent Citations
Hash tree memory integrity protection method of variable length storage block
CN101894079A
Verifying method and device for SSME (Secure Service Management Entity) module
CN106845279A
Secure NVM system and data recovery method after crash thereof
CN111079201A
Method for memory integrity protection and memory controller
CN113111391A
File verification method and device, equipment and storage medium
CN115840730A
Cited By
Data incremental backup restoration method and system based on Merkel tree
CN120029826A
A Merkle tree-based incremental backup and restore method and system
CN120029826B
Distributed data storage security protection system
CN120974550A
Media evidence obtaining verification method based on ring verification
CN121727871A
A media forensics verification method based on ring verification
CN121727871B