Add a new type of blob for the EC hash.
A new vboot API allows us to precompute the EC hash and pass it in instead of
having to load, verify and hash the EC on each boot. This new blob type lets
us put the hash into the image as data. The hash is calculated with hashlib
like the "hash" property which is added to the device tree.
BUG=chrome-os-partner:17606
TEST=Built depthcharge with this new blob type and verified that the EC hash
was retrieved correctly.
BRANCH=None
Change-Id: I3a17a054e2f12fe720d3e41ad3d0d7e33ec7024a
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/42724
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Reviewed-by: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index 7bd0036..b4420be 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -17,6 +17,7 @@
"""
import glob
+import hashlib
import os
import re
@@ -928,6 +929,13 @@
elif blob_type in ['ecrw', 'ecbin']:
pack.AddProperty('ecrw', self.ecrw_fname)
pack.AddProperty('ecbin', self.ecrw_fname)
+ elif blob_type == 'ecrwhash':
+ ec_hash_file = os.path.join(self._tools.outdir, 'ec_hash.bin')
+ ecrw = self._tools.ReadFile(self.ecrw_fname)
+ hasher = hashlib.sha256()
+ hasher.update(ecrw)
+ self._tools.WriteFile(ec_hash_file, hasher.digest())
+ pack.AddProperty(blob_type, ec_hash_file)
elif blob_type == 'ecro':
# crosbug.com/p/13143
# We cannot have an fmap in the EC image since there can be only one,