summaryrefslogtreecommitdiff
path: root/firmware/2lib/2api.c
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-07-06 09:01:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-06 23:00:44 -0700
commitcd341a0cd7d698b816b55a0f6e2e9ae9aeeea3bb (patch)
tree3823f9aa2975bc68128cb5c849676d7edb41dbc5 /firmware/2lib/2api.c
parent452973e5f45014162c273e13ad973d38f58404b0 (diff)
downloadvboot-cd341a0cd7d698b816b55a0f6e2e9ae9aeeea3bb.tar.gz
vb2api: pad digest buffers if they are larger than digest sizes
Extending tpm PCRs in case of TPM2 requires 32 bit values, some digests pre-calculated in vboot source code are 20 bytes in size. To make sure that PCR extension is consistent, pad remaining buffer space when a 20 byte digest is returned in a 32 byte buffer. BRANCH=none BUG=chrome-os-partner:50645 TEST=did not verify much, made sure that PCR extension commands triggered by coreboot succeed. Change-Id: Ib16bdf782f18a6106eadb4b880cd1e67b56ad6db Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358175 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'firmware/2lib/2api.c')
-rw-r--r--firmware/2lib/2api.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c
index 059cb6c2..c12a8051 100644
--- a/firmware/2lib/2api.c
+++ b/firmware/2lib/2api.c
@@ -199,6 +199,9 @@ int vb2api_get_pcr_digest(struct vb2_context *ctx,
return VB2_ERROR_API_PCR_DIGEST_BUF;
memcpy(dest, digest, digest_size);
+ if (digest_size < *dest_size)
+ memset(dest + digest_size, 0, *dest_size - digest_size);
+
*dest_size = digest_size;
return VB2_SUCCESS;