summaryrefslogtreecommitdiff
path: root/firmware/2lib
diff options
context:
space:
mode:
authorMatt Delco <delco@google.com>2019-02-13 11:13:27 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-13 21:04:59 -0700
commit3bfaab121cbafbd5c6d57004df6784866b8de5de (patch)
treee23a950730e73515c31375bf0b4aba5724f67737 /firmware/2lib
parent98b9928b6aa2da5622cd84c5565a9debbf12be35 (diff)
downloadvboot-3bfaab121cbafbd5c6d57004df6784866b8de5de.tar.gz
vboot: changes to allow RW_LEGACY hash verification
This is largely a cherry-pick of CL:1133598 - Externalize vb2_digest_buffer function to vb2api_digest_buffer. - Change VbExLegacy()'s altfw_num parameter from int to enum so caller can specify which specific payload to run. BUG=b:124358784 BRANCH=None TEST=Local compile. Verified with subsequent change that legacy boot still works and new functionality can opt-in to and utilize payload verification. CQ-DEPEND=CL:1471053 Change-Id: I9700c2e38c3cfa255eeff72ce416295af9d076fb Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1471051 Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'firmware/2lib')
-rw-r--r--firmware/2lib/2api.c9
-rw-r--r--firmware/2lib/include/2api.h16
2 files changed, 25 insertions, 0 deletions
diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c
index c12a8051..707f2027 100644
--- a/firmware/2lib/2api.c
+++ b/firmware/2lib/2api.c
@@ -206,3 +206,12 @@ int vb2api_get_pcr_digest(struct vb2_context *ctx,
return VB2_SUCCESS;
}
+
+int vb2api_digest_buffer(const uint8_t *buf,
+ uint32_t size,
+ enum vb2_hash_algorithm hash_alg,
+ uint8_t *digest,
+ uint32_t digest_size)
+{
+ return vb2_digest_buffer(buf, size, hash_alg, digest, digest_size);
+}
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index f228fb30..d8349831 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -683,4 +683,20 @@ int vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size);
*/
int vb2ex_hwcrypto_digest_finalize(uint8_t *digest, uint32_t digest_size);
+/**
+ * Calculate the digest of a buffer and store the result.
+ *
+ * @param buf Data to hash
+ * @param size Length of data in bytes
+ * @param hash_alg Hash algorithm
+ * @param digest Destination for digest
+ * @param digest_size Length of digest buffer in bytes.
+ * @return VB2_SUCCESS, or non-zero on error.
+ */
+int vb2api_digest_buffer(const uint8_t *buf,
+ uint32_t size,
+ enum vb2_hash_algorithm hash_alg,
+ uint8_t *digest,
+ uint32_t digest_size);
+
#endif /* VBOOT_2_API_H_ */