[go: up one dir, main page]

CN105138478A - Memory integrity protection method employing unbalanced hash tree mode - Google Patents

Memory integrity protection method employing unbalanced hash tree mode Download PDF

Info

Publication number
CN105138478A
CN105138478A CN201510451102.XA CN201510451102A CN105138478A CN 105138478 A CN105138478 A CN 105138478A CN 201510451102 A CN201510451102 A CN 201510451102A CN 105138478 A CN105138478 A CN 105138478A
Authority
CN
China
Prior art keywords
data
tree
counter
block
data block
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201510451102.XA
Other languages
Chinese (zh)
Other versions
CN105138478B (en
Inventor
张国印
郭振华
姚念民
石翠华
吴艳霞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Harbin Engineering University
Original Assignee
Harbin Engineering University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Harbin Engineering University filed Critical Harbin Engineering University
Priority to CN201510451102.XA priority Critical patent/CN105138478B/en
Publication of CN105138478A publication Critical patent/CN105138478A/en
Application granted granted Critical
Publication of CN105138478B publication Critical patent/CN105138478B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Storage Device Security (AREA)

Abstract

The invention relates to the field of memory integrity checking, in particular to a memory integrity protection method employing an unbalanced hash tree mode. The memory integrity protection method comprises the following steps: (1) initialization; (2) building of the unbalanced hash tree; (3) writing operation; and (4) reading operation. According to the method, the check cost is lower than that of an ordinary balanced binary tree in general; and the performance of the method is not higher than the check cost of the ordinary balanced binary tree and is the same as the check cost of the ordinary balanced binary tree even if in the worst case. The path length during data authentication is shortened on the whole.

Description

一种非平衡哈希树的存储器完整性保护方法A Memory Integrity Protection Method for Unbalanced Hash Tree

技术领域 technical field

本发明涉及的是内存完整性校验领域,具体为一种非平衡哈希树的存储器完整性保护方法。 The invention relates to the field of memory integrity verification, in particular to a memory integrity protection method of an unbalanced hash tree.

技术背景 technical background

随着科技的发展,计算机的应用越来越普及,由于计算机处理的数据会涉及很多的机密,因此,保证计算机在处理这些数据的安全成了当前研究的热点。数据的安全性包括机密性和完整性。在这里本发明只涉及如何确保数据的完整性。攻击者可以对总线上流动的数据进行欺骗、重组、重放攻击。完整性保护就是要保证能够检测到攻击者对数据所实施的恶意篡改行为,如硬件搭载攻击。重点在于保护信息使之免受重放攻击。重放攻击是指攻击者把以前存储在某个地址单元中的数据替换现在的数据。目前防范重放攻击主要通过使用树形校验机制。根据认证单元采用的方法与构建树过程的不同,又可分为MerkleTree、并行校验树PATtree和TEC-Tree三种方案。 With the development of science and technology, the application of computers is becoming more and more popular. Since the data processed by computers will involve a lot of confidentiality, ensuring the security of these data processed by computers has become a current research focus. Data security includes confidentiality and integrity. Here the invention only concerns how to ensure the integrity of the data. Attackers can perform spoofing, reassembly, and replay attacks on the data flowing on the bus. Integrity protection is to ensure that malicious tampering of data by attackers, such as hardware piggyback attacks, can be detected. The focus is on protecting information from replay attacks. Replay attack means that the attacker replaces the data previously stored in a certain address unit with the current data. At present, the defense against replay attacks is mainly through the use of tree verification mechanisms. According to the method used by the authentication unit and the tree construction process, it can be divided into three schemes: MerkleTree, parallel verification tree PATtree and TEC-Tree.

MerkleTree又称HashTree,是一种最早用于完整性校验的树机制。由Merkle在1980年提出主要用于公钥系统中的有效计算问题。Blum等人修改后将其用于存储器内容的完整性校验中。它通过对内存数据块进行迭代哈希计算建立一棵树,在CPU上保存根结点从而可以确保数据的完整性,尤其是可以抵抗重放攻击。缺点是数据块更新时不能并行计算,因此延迟比较大。针对这个缺点提出了并行校验树PAT,由于该方法每次进行哈希计算时都对应一个随机数,高层结点的计算不直接依赖于低层结点,上层结点通过将子结点的随机数连接后计算MAC,因此它实现了数据更新时的并行计算。但是MerkleTree和PAT树只能够保证数据的完整性,即它们的完整性保护和机密性保护方案是分开的,针对这个缺点提出了TEC-Tree,它通过往数据中添加冗余数据,在保证数据完整性的同时也保证了数据的机密性。 MerkleTree, also known as HashTree, is a tree mechanism that was first used for integrity verification. It was proposed by Merkle in 1980 and is mainly used for efficient calculation problems in public key systems. Blum et al. modified it for use in integrity checking of memory contents. It builds a tree by performing iterative hash calculation on memory data blocks, and saves the root node on the CPU to ensure data integrity, especially to resist replay attacks. The disadvantage is that data block updates cannot be calculated in parallel, so the delay is relatively large. Aiming at this shortcoming, a parallel verification tree PAT is proposed. Since this method corresponds to a random number every time the hash calculation is performed, the calculation of the high-level nodes does not directly depend on the low-level nodes. The upper-level nodes pass the random number of the sub-nodes The MAC is calculated after the number of connections, so it realizes the parallel calculation when the data is updated. However, MerkleTree and PAT trees can only guarantee the integrity of data, that is, their integrity protection and confidentiality protection schemes are separated. To address this shortcoming, TEC-Tree is proposed, which adds redundant data to the data to ensure data integrity. Integrity also ensures data confidentiality.

这三种树的一个共同的特点是它们建立的树都是平衡树,所有数据块的校验路径长度都相同。虽然已经提出了缓存哈希树CHTree,把MerkleTree的部分上层结点保存在缓存中,这种方法虽然能够有效缩短校验长度,但是访问频率高的和访问频率低的数据块的校验路径长度依然相同,因此平均看来数据块进行哈希计算时延迟仍然很大。 A common feature of these three trees is that the trees they build are all balanced trees, and the check path lengths of all data blocks are the same. Although a cache hash tree CHTree has been proposed, which saves some upper-level nodes of the MerkleTree in the cache, although this method can effectively shorten the verification length, the verification path length of data blocks with high access frequency and low access frequency Still the same, so on average the block is still hashed with a lot of latency.

发明内容 Contents of the invention

本发明的目的在于提供一种缩短树中叶子节点的平均校验路径长度的非平衡哈希树的存储器完整性保护方法。 The purpose of the present invention is to provide a memory integrity protection method of an unbalanced hash tree which shortens the average check path length of the leaf nodes in the tree.

本发明的目的是这样实现的: The purpose of the present invention is achieved like this:

(1)初始化 (1) Initialization

(1.1)把内存分成相同大小的数据块data_block[i],每个数据块有一个计数器counter[i]来记录对该数据块的读/写次数;初始时,counter[i]=0,当处理器读写数据块data_block[i]时,计数器值counter[i]=counter[i]+1;数据块结构采用3链表式: (1.1) Divide the memory into data blocks data_block[i] of the same size, and each data block has a counter counter[i] to record the number of read/write times of the data block; initially, counter[i]=0, when When the processor reads and writes the data block data_block[i], the counter value counter[i]=counter[i]+1; the data block structure adopts 3 linked lists:

(1.2)设置一个定时器Time;当定时器到达设定的时间后,构建一棵非平衡二叉树,同时把所有数据块data_block的计数器counter全部清零,重新计数; (1.2) Set a timer Time; when the timer reaches the set time, build an unbalanced binary tree, and simultaneously clear the counters of all data blocks data_block to zero, and recount;

(2)构建非平衡二叉树 (2) Build an unbalanced binary tree

(2.1)把内存中n个数据块的读/写次数作为权值,则得到n个权值{w1,w2,w3,w4,w5,……wn},每个权值构成一棵只有根节点的树Ti,则得到有n棵树的集合F={T1,T2,T3,T4,T5,……Tn}; (2.1) Taking the read/write times of n data blocks in the memory as weights, n weights {w 1 ,w 2 ,w 3 ,w 4 ,w 5 ,...w n } are obtained, and each weight Values constitute a tree T i with only root nodes, then get a collection of n trees F={T 1 , T 2 , T 3 , T 4 , T 5 ,...T n };

(2.2)从集合F中选取权值最小的两棵树Ti和Tj,作为左右孩子构建一棵新的树T,新树T节点的权值为两个孩子节点权值之和;从集合F中删除Ti和Tj,并把树T加入集合F中; (2.2) Select two trees T i and T j with the smallest weight from the set F, and construct a new tree T as the left and right children. The weight of the new tree T node is the sum of the weights of the two child nodes; Delete T i and T j from the set F, and add the tree T to the set F;

(2.3)重复步骤(2.2),直到集合F中只剩下一棵树; (2.3) Repeat step (2.2) until only one tree remains in the set F;

(3)写操作 (3) Write operation

(3.1)当CPU向内存写入数据块data_block[i]时,更新计数器counter[i]=counter[i]+1; (3.1) When the CPU writes the data block data_block[i] to the memory, update the counter counter[i]=counter[i]+1;

(3.2)找到数据块data_block[i]的相应叶子节点的指针; (3.2) Find the pointer of the corresponding leaf node of the data block data_block[i];

(3.3)连接数据块和兄弟结点所对应的数据块,重新计算数据块连接之后的哈希值hash,更新父节点的哈希值,重复(3.1)—(3.3)直到根节点; (3.3) Connect the data block and the data block corresponding to the brother node, recalculate the hash value hash after the data block connection, update the hash value of the parent node, repeat (3.1)—(3.3) until the root node;

(3.4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,写操作结束; (3.4) Check whether the timer Time reaches the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the write operation ends;

(4)读操作 (4) Read operation

(4.1)当CPU读内存数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1; (4.1) When the CPU reads the memory data block data_block[i], update its counter counter[i]=counter[i]+1;

(4.2)找到数据块data_block[i]的相应叶子节点的指针; (4.2) Find the pointer of the corresponding leaf node of the data block data_block[i];

(4.3)连接数据块和兄弟结点所对应的数据块,然后计算数据块连接之后的哈希值hash,把哈希结果与父节点的哈希值进行比较,重复这个过程直到根节点,如果最后计算的根节点的哈希值与CPU中存储的根节点的哈希值相同,则说明数据是正确的,没有被篡改,CPU可以使用数据;反之,则说明数据被篡改,发出警报; (4.3) Connect the data block and the data block corresponding to the sibling node, then calculate the hash value hash after the data block connection, compare the hash result with the hash value of the parent node, repeat this process until the root node, if The hash value of the root node calculated at the end is the same as the hash value of the root node stored in the CPU, which means that the data is correct and has not been tampered with, and the CPU can use the data; otherwise, it means that the data has been tampered with and an alarm is issued;

(4.4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,读操作结束。 (4.4) Check whether the timer Time reaches the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the read operation ends.

本发明的有益效果在于: The beneficial effects of the present invention are:

本发明从整体上缩短了数据认证时的路径长度。 The present invention shortens the path length during data authentication as a whole.

在构建非平衡二叉树的过程中,会出现3种情况,第一种是附图1中列举的一般情况,在这种情况下,已经证明,本文的方法比普通的平衡二叉树平均校验长度小。除一般情况外,在构建非平衡二叉树的过程中还会出现两种极端情况,分别是: In the process of building an unbalanced binary tree, there will be three situations. The first is the general situation listed in Figure 1. In this case, it has been proved that the method in this paper is smaller than the average check length of an ordinary balanced binary tree. . In addition to the general situation, there are two extreme situations in the process of building an unbalanced binary tree, namely:

(1)构建的树和原先的平衡二叉树相同。这种情况下它们的校验代价相同。 (1) The constructed tree is the same as the original balanced binary tree. In this case their verification costs are the same.

(2)构建的非平衡二叉树是单支二叉树。在这种情况下非平衡二叉树的校验代价要小于普通平衡二叉树的校验代价。 (2) The unbalanced binary tree constructed is a single branch binary tree. In this case, the verification cost of an unbalanced binary tree is lower than that of an ordinary balanced binary tree.

综上所述,本方法在一般情况下,校验代价要低于普通的平衡二叉树的校验代价,即使在最坏情况下,本方法的性能也不会高于普通的平衡二叉树的校验代价,而是与它的校验代价相同。 In summary, under normal circumstances, the verification cost of this method is lower than that of ordinary balanced binary trees. Even in the worst case, the performance of this method will not be higher than that of ordinary balanced binary trees. The cost is the same as its verification cost.

附图说明 Description of drawings

图1为平衡二叉树和非平衡二叉树。 Figure 1 shows a balanced binary tree and an unbalanced binary tree.

图2为构建非平衡二叉树步骤。 Figure 2 shows the steps of building an unbalanced binary tree.

图3为向内存中写入数据步骤。 Figure 3 shows the steps of writing data into the memory.

图4为从内存中读数据步骤。 Figure 4 shows the steps of reading data from memory.

具体实施方式 Detailed ways

下面结合附图对本发明做进一步描述。 The present invention will be further described below in conjunction with the accompanying drawings.

本发明涉及的是内存完整性校验领域,是一种基于局部性原理的非平衡哈希树的存储器完整性保护方法。为了防止重放攻击,目前大多采用树结构保护数据的完整性。目前使用的树都是平衡N叉树,所有的叶子节点在树中的层次都相同,即所有数据块的校验路径长度是相同的。根据程序的局部性原理,在一段时间内某些数据访问频率高,某一些数据访问频率低。因此本发明对哈希树进行改进,建立一棵非平衡二叉树,使那些访问频率高的节点离根节点近,使那些访问频率低的节点离根节点远。这样访问频率高的数据块校验路径短,访问频率低的数据块校验路径长。从整体上来缩短校验路径,减少延迟。 The invention relates to the field of memory integrity verification, and relates to a memory integrity protection method of an unbalanced hash tree based on the principle of locality. In order to prevent replay attacks, tree structures are currently used to protect data integrity. The trees currently used are all balanced N-ary trees, and all leaf nodes are at the same level in the tree, that is, the check path lengths of all data blocks are the same. According to the locality principle of the program, some data access frequency is high and some data access frequency is low within a period of time. Therefore, the present invention improves the hash tree and establishes an unbalanced binary tree, so that those nodes with high access frequency are close to the root node, and those nodes with low access frequency are far away from the root node. In this way, the verification path of data blocks with high access frequency is short, and the verification path of data blocks with low access frequency is long. On the whole, the verification path is shortened and the delay is reduced.

为了缩短树中叶子节点的平均校验路径长度,本发明提出一种非平衡哈希树的存储器完整性保护方法。根据程序的局部性原理,内存中的数据在一段时间内的访问频率是不相同的,有些数据的访问频率要高,有些数据的访问频率要低。因此,本发明提出的方法是建立一棵非平衡二叉树,把那些最近访问频率很高的数据块放在离根节点近的地方,相反,那些不经常使用到的数据块放在离根节点远的地方。缩短数据块的平均校验路径长度。如附图1所示(其中叶子节点上的数字为访问次数)。 In order to shorten the average check path length of the leaf nodes in the tree, the invention proposes a memory integrity protection method of the unbalanced hash tree. According to the principle of program locality, the access frequency of data in the memory is different within a period of time. Some data access frequency is higher, and some data access frequency is lower. Therefore, the method proposed by the present invention is to build an unbalanced binary tree, and place those data blocks with high frequency of recent access near the root node, on the contrary, those data blocks that are not frequently used are placed far away from the root node. The place. Reduce the average checksum path length of data blocks. As shown in Figure 1 (the number on the leaf node is the number of visits).

本发明把内存划分成相同大小的数据块data_block[i],并且为每个数据块都设置一个计数器counter[i],用来记录对数据块的读/写次数。在内存中存储数据块的同时存储相应的叶子节点的指针,叶子节点为数据块的哈希值。设置一个定时器Time,当定时器Time到达设定时间后,以内存数据块的哈希值作为叶子节点构建非平衡哈希树,每次移动叶子节点时,要改变相应叶子节点的指针,并且在CPU中保留该哈希树的根节点,用于完整性校验。 The present invention divides the memory into data blocks data_block[i] of the same size, and sets a counter counter[i] for each data block to record the times of reading/writing to the data block. While storing the data block in the memory, store the pointer of the corresponding leaf node, and the leaf node is the hash value of the data block. Set a timer Time, when the timer Time reaches the set time, build an unbalanced hash tree with the hash value of the memory data block as the leaf node, and change the pointer of the corresponding leaf node every time the leaf node is moved, and The root node of the hash tree is reserved in the CPU for integrity verification.

构建非平衡哈希树的具体操作如下: The specific operation of building an unbalanced hash tree is as follows:

(1)把内存中n个数据块的读/写次数作为权值,则得到n个权值{w1,w2,w3,w4,w5,……wn},每个权值构成一棵只有根节点的树Ti,则得到有n棵树的集合F={T1,T2,T3,T4,T5,……Tn}。 (1) Taking the read/write times of n data blocks in the memory as weights, n weights {w 1 ,w 2 ,w 3 ,w 4 ,w 5 ,...w n } are obtained, and each weight Values constitute a tree T i with only root nodes, then get a set F={T 1 , T 2 , T 3 , T 4 , T 5 ,...T n } with n trees.

(2)从集合F中选取权值最小的两棵树Ti和Tj,以它们作为左右孩子构建一棵新的树T,新树T节点的权值为两个孩子节点权值之和。从集合F中删除Ti和Tj,并把树T加入集合F中。 (2) Select two trees T i and T j with the smallest weight from the set F, and use them as the left and right children to construct a new tree T. The weight of the new tree T node is the sum of the weights of the two child nodes . Delete T i and T j from set F, and add tree T to set F.

(3)重复步骤(2),直到集合F中只剩下一棵树。 (3) Repeat step (2) until there is only one tree left in the set F.

当处理器向内存中写入数据块data_block[i]时,更新数据块的访问次数counter[i]和整个哈希树。具体的操作如下: When the processor writes the data block data_block[i] into the memory, the access count counter[i] of the data block and the entire hash tree are updated. The specific operation is as follows:

(1)当CPU向内存写入数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1。 (1) When the CPU writes the data block data_block[i] into the memory, it updates its counter counter[i]=counter[i]+1.

(2)然后找到数据块data_block[i]的相应叶子节点的指针。 (2) Then find the pointer of the corresponding leaf node of the data block data_block[i].

(3)连接数据块和兄弟结点所对应的数据块,重新计算数据块连接之后的哈希值hash,更新父节点的哈希值,重复这个过程直到根节点。 (3) Connect the data block and the data block corresponding to the brother node, recalculate the hash value hash after the data block connection, update the hash value of the parent node, and repeat this process until the root node.

(4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,写操作结束。 (4) Check whether the timer Time reaches the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the write operation ends.

当处理器从内存中读数据块data_block[i]时,更新它的计数器counter[i],同时对数据进行完整性检验。具体的操作如下: When the processor reads the data block data_block[i] from the memory, it updates its counter counter[i], and at the same time checks the integrity of the data. The specific operation is as follows:

(1)当CPU读内存数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1。 (1) When the CPU reads the memory data block data_block[i], it updates its counter counter[i]=counter[i]+1.

(2)然后找到数据块data_block[i]的相应叶子节点的指针。 (2) Then find the pointer of the corresponding leaf node of the data block data_block[i].

(3)连接数据块和兄弟结点所对应的数据块,然后计算数据块连接之后的哈希值hash,把哈希结果与父节点的哈希值进行比较,重复这个过程直到根节点,如果最后计算的根节点的哈希值与CPU中存储的根节点的哈希值相同,则说明数据是正确的,没有被篡改,CPU可以使用数据;反之,则说明数据被篡改,发出警报。 (3) Connect the data block and the data block corresponding to the sibling node, then calculate the hash value hash after the data block connection, compare the hash result with the hash value of the parent node, repeat this process until the root node, if The hash value of the root node calculated at the end is the same as the hash value of the root node stored in the CPU, which means that the data is correct and has not been tampered with, and the CPU can use the data; otherwise, it means that the data has been tampered with and an alarm is issued.

(4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,读操作结束。 (4) Check whether the timer Time has reached the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the read operation ends.

使用树的带权校验长度(树中所有叶子节点的带权校验长度之和)作为性能比较的标准,用WPL表示,即其中权值wi为每个叶子节点的读/写次数,li为叶子节点的校验长度,即路径上分支数目。n为节点的数目。 Use the weighted check length of the tree (the sum of the weighted check lengths of all leaf nodes in the tree) as the standard for performance comparison, expressed in WPL, that is The weight w i is the read/write times of each leaf node, and l i is the check length of the leaf node, that is, the number of branches on the path. n is the number of nodes.

根据数据块的读写频率,而不是读写次数来重建哈希树。 The hash tree is rebuilt according to the read and write frequency of data blocks, not the number of reads and writes.

在介绍本发明的内容前先给出以下定义: Before introducing the content of the present invention, the following definitions are provided:

权值:数据块的读/写次数,用w表示。 Weight: the number of read/write times of the data block, represented by w.

节点的带权校验长度:从节点到树根节点之间的校验长度与节点上权的乘积,用WPL表示,即WPLi=wi*IiThe weighted check length of a node: the product of the check length from the node to the root node of the tree and the weight on the node, represented by WPL, that is, WPL i =w i *I i .

树的带权校验长度:树中所有叶子节点的带权校验长度之和,用WPL表示,即 W P L = Σ i = 1 i = n w i * l i . The weighted check length of the tree: the sum of the weighted check lengths of all leaf nodes in the tree, expressed in WPL, that is W P L = Σ i = 1 i = no w i * l i .

把内存划分成相同大小的数据块data_block[i],并且为每个数据块都设置一个计数器counter[i],用来记录对数据块的读/写次数。在内存中存储数据块的同时存储相应的叶子节点的指针,叶子节点为数据块的哈希值。设置一个定时器Time,当定时器Time到达设定时间后,以内存数据块的哈希值作为叶子节点构建非平衡哈希树,每次移动叶子节点时,要改变相应叶子节点的指针,并且在CPU中保留该哈希树的根节点,用于完整性校验。 Divide the memory into data blocks data_block[i] of the same size, and set a counter counter[i] for each data block to record the number of read/write times for the data block. While storing the data block in the memory, store the pointer of the corresponding leaf node, and the leaf node is the hash value of the data block. Set a timer Time, when the timer Time reaches the set time, build an unbalanced hash tree with the hash value of the memory data block as the leaf node, and change the pointer of the corresponding leaf node every time the leaf node is moved, and The root node of the hash tree is reserved in the CPU for integrity verification.

构建非平衡哈希树时,根据给定的n个权值{w1,w2,w3,w4,w5,……wn},每次从中间选出两个权值最小的数据块,把它们作为二叉树的左右子树,父节点的权值为孩子节点权值的和,同时把选出的这两个权值最小的节点删除,把新生成的这棵二叉树作为新的树加入到上述集合中。重复上述过程,直到只有一棵树为止。 When constructing an unbalanced hash tree, according to the given n weights {w 1 ,w 2 ,w 3 ,w 4 ,w 5 ,…w n }, select two weights with the smallest weight from the middle each time Data blocks, as the left and right subtrees of the binary tree, the weight of the parent node is the sum of the weights of the child nodes, and at the same time delete the two selected nodes with the smallest weight, and use the newly generated binary tree as a new Trees are added to the above set. Repeat the above process until there is only one tree.

通过以下过程实现内存完整性校验方法: The memory integrity verification method is implemented through the following process:

1)初始化 1) Initialization

(1)把内存分成相同大小的数据块data_block[i],每个数据块有一个计数器counter[i]来记录对该数据块的读/写次数。初始时,counter[i]=0,当处理器读写数据块data_block[i]时,它的计数器值counter[i]=counter[i]+1。 (1) Divide the memory into data blocks of the same size data_block[i], and each data block has a counter counter[i] to record the number of read/write times of the data block. Initially, counter[i]=0, when the processor reads and writes the data block data_block[i], its counter value counter[i]=counter[i]+1.

(2)数据结构采用3链表式,如下所示: (2) The data structure adopts 3 linked lists, as follows:

Node node

{ {

longintcounter;//读/写次数,作为数据块的权值 longintcounter; //Read/write times, as the weight of the data block

longinthash;//哈希值 longinthash; // hash value

Structnode*lchild;//左孩子 Structnode *lchild; // left child

Structnode*rchild;//右孩子 Structnode *rchild; //right child

Structnode*parent;//父节点 Structnode*parent;//parent node

}node; } node;

(3)设置一个定时器Time。当定时器到达设定的时间后,构建一棵非平衡二叉树,同时把所有数据块data_block的计数器counter全部清零,使它们重新计数。 (3) Set up a timer Time. When the timer reaches the set time, build an unbalanced binary tree, and at the same time clear the counters of all data blocks data_block to make them count again.

2)构建非平衡二叉树 2) Build an unbalanced binary tree

处理器构建非平衡二叉树的流程如附图2所示,具体操作如下: The process for the processor to build an unbalanced binary tree is shown in Figure 2, and the specific operations are as follows:

(1)把内存中n个数据块的读/写次数作为权值,则得到n个权值{w1,w2,w3,w4,w5,……wn},每个权值构成一棵只有根节点的树Ti,则得到有n棵树的集合F={T1,T2,T3,T4,T5,……Tn}。 (1) Taking the read/write times of n data blocks in the memory as weights, n weights {w 1 ,w 2 ,w 3 ,w 4 ,w 5 ,...w n } are obtained, and each weight Values constitute a tree T i with only root nodes, then get a set F={T 1 , T 2 , T 3 , T 4 , T 5 ,...T n } with n trees.

(2)从集合F中选取权值最小的两棵树Ti和Tj,以它们作为左右孩子构建一棵新的树T,新树T节点的权值为两个孩子节点权值之和。从集合F中删除Ti和Tj,并把树T加入集合F中。 (2) Select two trees T i and T j with the smallest weight from the set F, and use them as the left and right children to construct a new tree T. The weight of the new tree T node is the sum of the weights of the two child nodes . Delete T i and T j from set F, and add tree T to set F.

(3)重复步骤(2),直到集合F中只剩下一棵树。 (3) Repeat step (2) until there is only one tree left in the set F.

3)写操作 3) Write operation

当处理器向内存中写入数据块data_block[i]时,更新数据块的访问次数counter[i]和整个哈希树。处理器对存储器进行写操作的流程如附图3所示,具体的操作如下: When the processor writes the data block data_block[i] into the memory, the access count counter[i] of the data block and the entire hash tree are updated. The process for the processor to write to the memory is shown in Figure 3, and the specific operations are as follows:

(1)当CPU向内存写入数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1。 (1) When the CPU writes the data block data_block[i] into the memory, it updates its counter counter[i]=counter[i]+1.

(2)然后找到数据块data_block[i]的相应叶子节点的指针。 (2) Then find the pointer of the corresponding leaf node of the data block data_block[i].

(3)连接数据块和兄弟结点所对应的数据块,重新计算数据块连接之后的哈希值hash,更新父节点的哈希值,重复这个过程直到根节点。 (3) Connect the data block and the data block corresponding to the brother node, recalculate the hash value hash after the data block connection, update the hash value of the parent node, and repeat this process until the root node.

(4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,写操作结束。 (4) Check whether the timer Time reaches the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the write operation ends.

4)读操作 4) Read operation

当处理器从内存中读数据块data_block[i]时,更新它的计数器counter[i],同时对数据进行完整性检验。处理器对存储器进行读操作的流程如附图4所示,具体的操作如下: When the processor reads the data block data_block[i] from the memory, it updates its counter counter[i], and at the same time checks the integrity of the data. The process for the processor to read the memory is shown in Figure 4, and the specific operations are as follows:

(1)当CPU读内存数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1。 (1) When the CPU reads the memory data block data_block[i], it updates its counter counter[i]=counter[i]+1.

(2)然后找到数据块data_block[i]的相应叶子节点的指针。 (2) Then find the pointer of the corresponding leaf node of the data block data_block[i].

(3)连接数据块和兄弟结点所对应的数据块,然后计算数据块连接之后的哈希值hash,把哈希结果与父节点的哈希值进行比较,重复这个过程直到根节点,如果最后计算的根节点的哈希值与CPU中存储的根节点的哈希值相同,则说明数据是正确的,没有被篡改,CPU可以使用数据;反之,则说明数据被篡改,发出警报。 (3) Connect the data block and the data block corresponding to the sibling node, then calculate the hash value hash after the data block connection, compare the hash result with the hash value of the parent node, repeat this process until the root node, if The hash value of the root node calculated at the end is the same as the hash value of the root node stored in the CPU, which means that the data is correct and has not been tampered with, and the CPU can use the data; otherwise, it means that the data has been tampered with and an alarm is issued.

(4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,读操作结束。 (4) Check whether the timer Time has reached the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the read operation ends.

下面是本发明的具体实施内容: Below is the concrete implementation content of the present invention:

本发明内容使用模拟器SimpleScalartool实现本发明所提出的算法内容,下面分别介绍每一个步骤算法的具体实施伪代码。 The content of the present invention uses the simulator SimpleScalartool to realize the content of the algorithm proposed by the present invention, and the specific implementation pseudocode of each step algorithm is introduced respectively below.

1、构建非平衡二叉树 1. Build an unbalanced binary tree

处理器构建非平衡二叉树的流程如附图2所示,具体操作如下: The process for the processor to build an unbalanced binary tree is shown in Figure 2, and the specific operations are as follows:

(1)把内存中n个数据块的读/写次数作为权值,则得到n个权值{w1,w2,w3,w4,w5,……wn},每个权值构成一棵只有根节点的树Ti,则得到有n棵树的集合F={T1,T2,T3,T4,T5,……Tn}。 (1) Taking the read/write times of n data blocks in the memory as weights, n weights {w 1 ,w 2 ,w 3 ,w 4 ,w 5 ,...w n } are obtained, and each weight Values constitute a tree T i with only root nodes, then get a set F={T 1 , T 2 , T 3 , T 4 , T 5 ,...T n } with n trees.

(2)从集合F中选取权值最小的两棵树Ti和Tj,以它们作为左右孩子构建一棵新的树T,新树T节点的权值为两个孩子节点权值之和。从集合F中删除Ti和Tj,树T加入集合F中。 (2) Select two trees T i and T j with the smallest weight from the set F, and use them as the left and right children to construct a new tree T. The weight of the new tree T node is the sum of the weights of the two child nodes . Delete T i and T j from set F, and tree T is added to set F.

(3)重复步骤(2),直到集合F中只剩下一棵树。 (3) Repeat step (2) until there is only one tree left in the set F.

构建非平衡二叉树的具体实施代码如算法1所示。 The specific implementation code for building an unbalanced binary tree is shown in Algorithm 1.

2、向内存中写入数据 2. Write data to memory

当处理器向内存中写入数据块data_block[i]时,更新数据块的访问次数counter[i]和整个哈希树。处理器对存储器进行写操作的流程如附图3所示,具体的操作如下: When the processor writes the data block data_block[i] into the memory, the access count counter[i] of the data block and the entire hash tree are updated. The process for the processor to write to the memory is shown in Figure 3, and the specific operations are as follows:

(1)当CPU向内存写入数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1。 (1) When the CPU writes the data block data_block[i] into the memory, it updates its counter counter[i]=counter[i]+1.

(2)然后找到数据块data_block[i]的相应叶子节点的指针。 (2) Then find the pointer of the corresponding leaf node of the data block data_block[i].

(3)把这个数据块和兄弟结点所对应的数据块进行连接,重新计算数据块连接之后的的哈希值hash,更新父节点的哈希值,重复这个过程直到根节点。 (3) Connect this data block with the data block corresponding to the brother node, recalculate the hash value hash after the data block connection, update the hash value of the parent node, and repeat this process until the root node.

(4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,写操作结束。 (4) Check whether the timer Time reaches the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the write operation ends.

向内存中写入一个数据块时的具体实施过程如算法2所示。 The specific implementation process when writing a data block into the memory is shown in Algorithm 2.

3、从内存中读数据 3. Read data from memory

当处理器从内存中读数据块data_block[i]时,更新它的计数器counter[i],同时对数据进行完整性检验。处理器对存储器进行读操作的流程如附图4所示,具体的操作如下: When the processor reads the data block data_block[i] from the memory, it updates its counter counter[i], and at the same time checks the integrity of the data. The process for the processor to read the memory is shown in Figure 4, and the specific operations are as follows:

(1)当CPU从内存中读数据块data_block[i]时,更新它的计数器counter[i]=counter[i]+1。 (1) When the CPU reads the data block data_block[i] from the memory, it updates its counter counter[i]=counter[i]+1.

(2)然后找到数据块data_block[i]的相应叶子节点的指针。 (2) Then find the pointer of the corresponding leaf node of the data block data_block[i].

(3)把这个数据块和兄弟结点所对应的数据块进行连接,然后计算数据块连接之后的的哈希值hash,把哈希结果与父节点的哈希值进行比较,重复这个过程直到根节点,如果最后计算后的根节点的哈希值与CPU上存储的根节点的哈希结果相同,则说明数据是正确的,没有被篡改,CPU可以使用数据;反之,则说明数据被篡改,发出警报。 (3) Connect this data block with the data block corresponding to the sibling node, then calculate the hash value hash after the data block connection, compare the hash result with the hash value of the parent node, and repeat this process until Root node, if the calculated hash value of the root node is the same as the hash result of the root node stored on the CPU, it means that the data is correct and has not been tampered with, and the CPU can use the data; otherwise, it means that the data has been tampered with ,Alert.

(4)检查定时器Time是否到达设定时间,如果已经到达设定时间,则重新建立非平衡哈希树,否则,读操作结束。 (4) Check whether the timer Time has reached the set time, if it has reached the set time, re-establish the unbalanced hash tree, otherwise, the read operation ends.

从内存中读取一个数据块时的具体实施过程如算法3所示。 The specific implementation process when reading a data block from memory is shown in Algorithm 3.

.

Claims (1)

1. a memory integrity protection method for non-equilibrium Hash tree, is characterized in that, comprises the steps:
(1) initialization
(1.1) internal memory is divided into the data block data_block [i] of formed objects, each data block has a counter counter [i] to record read/write number of times to this data block; Time initial, counter [i]=0, when processor reads and writes data block data_block [i], Counter Value counter [i]=counter [i]+1; Block data structure adopts 3 linked list type:
(1.2) a timer Time is set; After timer arrives the time of setting, build a non-equilibrium binary tree, the counter counter of all data block data_block is all reset simultaneously, again count;
(2) non-equilibrium binary tree is built
(2.1) using the read/write number of times of the data block of n in internal memory as weights, then obtain n weights { w 1, w 2, w 3, w 4, w 5... w n, each weights form the tree T that is only had root node i, then the set F={T of n tree is obtained 1, T 2, T 3, T 4, T 5... T n;
(2.2) from set F, choose two tree T that weights are minimum iand T j, build a new tree T as left and right child, the weights of new tree T node are two child nodes weights sums; T is deleted from set F iand T j, and tree T is added in set F;
(2.3) step (2.2) is repeated, until only remaining one tree in set F;
(3) write operation
(3.1) when CPU is to internal memory writing data blocks data_block [i], refresh counter counter [i]=counter [i]+1;
(3.2) pointer of the respective leaves child node of data block data_block [i] is found;
(3.3) connection data block and the data block corresponding to sibling, recalculates the cryptographic hash hash after data block connects, upgrades the cryptographic hash of father node, repeats (3.1)-(3.3) until root node;
(3.4) check whether timer Time arrives setting-up time, if arrive setting-up time, then re-establish non-equilibrium Hash tree, otherwise write operation terminates;
(4) read operation
(4.1) as CPU rdma read data block data_block [i], its counter counter [i]=counter [i]+1 is upgraded;
(4.2) pointer of the respective leaves child node of data block data_block [i] is found;
(4.3) connection data block and the data block corresponding to sibling, then the cryptographic hash hash after data block connects is calculated, the cryptographic hash of Hash result and father node is compared, repeat this process until root node, if the cryptographic hash of the last root node calculated is identical with the cryptographic hash of the root node stored in CPU, then illustrate that data are correct, are not tampered, CPU can usage data; Otherwise, then illustrate that data are tampered, and give the alarm;
(4.4) check whether timer Time arrives setting-up time, if arrive setting-up time, then re-establish non-equilibrium Hash tree, otherwise read operation terminates.
CN201510451102.XA 2015-07-28 2015-07-28 A kind of memory integrity protection method of non-equilibrium Hash tree Expired - Fee Related CN105138478B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510451102.XA CN105138478B (en) 2015-07-28 2015-07-28 A kind of memory integrity protection method of non-equilibrium Hash tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510451102.XA CN105138478B (en) 2015-07-28 2015-07-28 A kind of memory integrity protection method of non-equilibrium Hash tree

Publications (2)

Publication Number Publication Date
CN105138478A true CN105138478A (en) 2015-12-09
CN105138478B CN105138478B (en) 2018-10-26

Family

ID=54723831

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510451102.XA Expired - Fee Related CN105138478B (en) 2015-07-28 2015-07-28 A kind of memory integrity protection method of non-equilibrium Hash tree

Country Status (1)

Country Link
CN (1) CN105138478B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108595980A (en) * 2018-05-02 2018-09-28 广州品唯软件有限公司 A method and device for protecting commodity traceability information
CN109428822A (en) * 2017-09-01 2019-03-05 华为技术有限公司 A kind of Name Lookup method and the network equipment
CN109445763A (en) * 2018-10-25 2019-03-08 长沙新弘软件有限公司 A kind of non-equilibrium binary tree building method calculated based on two points of boundary values
CN109495446A (en) * 2018-10-02 2019-03-19 复旦大学 Order-preserving Encryption Algorithm based on balanced sorting tree storage organization
CN111164934A (en) * 2017-08-07 2020-05-15 西门子股份公司 Pruning of certified trees
CN111373388A (en) * 2017-12-28 2020-07-03 卓普网盘股份有限公司 Efficiently propagating differentiated values
CN111898164A (en) * 2020-07-02 2020-11-06 武汉纺织大学 A Data Integrity Audit Method Supporting Tag Blockchain Storage and Query
CN112651054A (en) * 2020-12-30 2021-04-13 海光信息技术股份有限公司 Memory data integrity protection method and device and electronic equipment
CN113111391A (en) * 2021-04-09 2021-07-13 支付宝(杭州)信息技术有限公司 Method for memory integrity protection and memory controller
CN115936698A (en) * 2022-08-25 2023-04-07 国网智能电网研究院有限公司 A method and system for joint distributed trustworthy reference value management

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP4213053A4 (en) 2020-09-30 2023-11-01 Huawei Technologies Co., Ltd. RESOURCE ALLOCATION METHOD AND APPARATUS, AND STORAGE MEDIUM

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070233982A1 (en) * 2006-03-28 2007-10-04 Xuemin Chen System and method for memory data protection with secure pad memory
CN101853190A (en) * 2010-06-04 2010-10-06 华中科技大学 A Data Integrity Verification Method Applicable to Embedded Processor
CN101976322A (en) * 2010-11-11 2011-02-16 清华大学 Safety metadata management method based on integrality checking

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070233982A1 (en) * 2006-03-28 2007-10-04 Xuemin Chen System and method for memory data protection with secure pad memory
CN101853190A (en) * 2010-06-04 2010-10-06 华中科技大学 A Data Integrity Verification Method Applicable to Embedded Processor
CN101976322A (en) * 2010-11-11 2011-02-16 清华大学 Safety metadata management method based on integrality checking

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
马海峰等: "《非对称hash树存储器完整性保护方法》", 《小型微型计算机系统》 *

Cited By (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111164934A (en) * 2017-08-07 2020-05-15 西门子股份公司 Pruning of certified trees
CN109428822A (en) * 2017-09-01 2019-03-05 华为技术有限公司 A kind of Name Lookup method and the network equipment
US12169505B2 (en) 2017-12-28 2024-12-17 Dropbox, Inc. Updating a local tree for a client synchronization service
CN111373388B (en) * 2017-12-28 2024-03-15 卓普网盘股份有限公司 Methods and devices for effectively communicating differentiated values
US11669544B2 (en) 2017-12-28 2023-06-06 Dropbox, Inc. Allocation and reassignment of unique identifiers for synchronization of content items
CN111373388A (en) * 2017-12-28 2020-07-03 卓普网盘股份有限公司 Efficiently propagating differentiated values
US11657067B2 (en) 2017-12-28 2023-05-23 Dropbox Inc. Updating a remote tree for a client synchronization service
US11836151B2 (en) 2017-12-28 2023-12-05 Dropbox, Inc. Synchronizing symbolic links
US11704336B2 (en) 2017-12-28 2023-07-18 Dropbox, Inc. Efficient filename storage and retrieval
US12135733B2 (en) 2017-12-28 2024-11-05 Dropbox, Inc. File journal interface for synchronizing content
US12061623B2 (en) 2017-12-28 2024-08-13 Dropbox, Inc. Selective synchronization of content items in a content management system
CN108595980B (en) * 2018-05-02 2023-01-24 广州品唯软件有限公司 Method and device for protecting commodity traceability information
CN108595980A (en) * 2018-05-02 2018-09-28 广州品唯软件有限公司 A method and device for protecting commodity traceability information
CN109495446A (en) * 2018-10-02 2019-03-19 复旦大学 Order-preserving Encryption Algorithm based on balanced sorting tree storage organization
CN109495446B (en) * 2018-10-02 2020-12-22 复旦大学 Order-preserving encryption algorithm based on balanced sorting tree storage structure
CN109445763B (en) * 2018-10-25 2022-02-01 长沙新弘软件有限公司 Unbalanced binary tree construction method based on binary boundary value calculation
CN109445763A (en) * 2018-10-25 2019-03-08 长沙新弘软件有限公司 A kind of non-equilibrium binary tree building method calculated based on two points of boundary values
CN111898164A (en) * 2020-07-02 2020-11-06 武汉纺织大学 A Data Integrity Audit Method Supporting Tag Blockchain Storage and Query
CN111898164B (en) * 2020-07-02 2024-03-29 武汉纺织大学 Data integrity auditing method supporting label block chain storage and query
CN112651054B (en) * 2020-12-30 2022-10-14 海光信息技术股份有限公司 Memory data integrity protection method and device and electronic equipment
CN112651054A (en) * 2020-12-30 2021-04-13 海光信息技术股份有限公司 Memory data integrity protection method and device and electronic equipment
CN113111391B (en) * 2021-04-09 2022-07-08 支付宝(杭州)信息技术有限公司 Method for memory integrity protection and memory controller
CN113111391A (en) * 2021-04-09 2021-07-13 支付宝(杭州)信息技术有限公司 Method for memory integrity protection and memory controller
CN115936698A (en) * 2022-08-25 2023-04-07 国网智能电网研究院有限公司 A method and system for joint distributed trustworthy reference value management

Also Published As

Publication number Publication date
CN105138478B (en) 2018-10-26

Similar Documents

Publication Publication Date Title
CN105138478B (en) A kind of memory integrity protection method of non-equilibrium Hash tree
CN111030822B (en) Method and system for protecting firmware, and computer readable medium
CN101853190B (en) Data integrity verification method suitable for embedded processor
CN105022968B (en) A kind of integrity checking method of internal storage data
CN110647503A (en) A distributed storage method and device
CN110120942B (en) Security policy rule matching method and device, firewall equipment and medium
US8706701B1 (en) Scalable cloud file system with efficient integrity checks
US11171774B2 (en) System for synchronizing a cryptographic key state through a blockchain
US9270698B2 (en) Filter for network intrusion and virus detection
Ren et al. Integrity verification for path oblivious-ram
CN105069379B (en) It is a kind of based on the memory integrity protection method for writing counter
TW201823988A (en) Block data checking method and device
WO2019226297A1 (en) Edit transactions for blockchains
CN111641496B (en) Blockchain data update method, device, equipment, system and readable storage medium
WO2019160128A1 (en) Method for validating transaction in blockchain network and node for configuring same network
CN112989405A (en) A trusted storage method, device, device and storage medium for data storage
WO2014079282A1 (en) Method and apparatus for storing and verifying redeem code
CN114968323A (en) A Differential Upgrade Method Based on National Secret Algorithm
CN102156759B (en) Binary tree parallel inquiry method and device
CN107705208A (en) A kind of digital asset processing method and system based on Hash tree
KR102416336B1 (en) Device, method, system and computer readable storage medium for managing blockchain
CN115730933A (en) Data processing method, device and equipment based on block chain and storage medium
CN101355428B (en) A Method for Protecting Data Integrity Using Incremental Verification
CN107402959A (en) URL matching process, URL matching units and storage medium
CN117614601A (en) Method to realize layer 2 network convolution, layer 2 network and prover

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20181026