# Holds and modifies the state information held by binman
#
+import hashlib
import re
-from sets import Set
import os
import tools
use_fake_dtb = False
# Set of all device tree files references by images
-fdt_set = Set()
+fdt_set = set()
# Same as above, but excluding the main one
-fdt_subset = Set()
+fdt_subset = set()
# The DTB which contains the full image information
main_dtb = None
main_dtb = dtb
fdt_files.clear()
fdt_files['u-boot.dtb'] = dtb
- fdt_subset = Set()
+ fdt_subset = set()
if not use_fake_dtb:
for image in images.values():
fdt_subset.update(image.GetFdtSet())
"""
for n in GetUpdateNodes(node):
n.SetInt(prop, value)
+
+def CheckAddHashProp(node):
+ hash_node = node.FindNode('hash')
+ if hash_node:
+ algo = hash_node.props.get('algo')
+ if not algo:
+ return "Missing 'algo' property for hash node"
+ if algo.value == 'sha256':
+ size = 32
+ else:
+ return "Unknown hash algorithm '%s'" % algo
+ for n in GetUpdateNodes(hash_node):
+ n.AddEmptyProp('value', size)
+
+def CheckSetHashValue(node, get_data_func):
+ hash_node = node.FindNode('hash')
+ if hash_node:
+ algo = hash_node.props.get('algo').value
+ if algo == 'sha256':
+ m = hashlib.sha256()
+ m.update(get_data_func())
+ data = m.digest()
+ for n in GetUpdateNodes(hash_node):
+ n.SetData('value', data)