diff options
author | Julius Werner <jwerner@chromium.org> | 2020-01-23 14:52:59 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-28 02:32:08 +0000 |
commit | 0e97e25e85f0499e23b09a31a2c7116759f191d5 (patch) | |
tree | d990e6cc56eeab048a96de48cefdacc10e0c13b3 /firmware/2lib/2sha_utility.c | |
parent | f57ad98c29072624bf0977ab972201595efd2b38 (diff) | |
download | vboot-stabilize-12871.102.B.tar.gz |
2lib: Fix struct vb2_hash the way it was meant to bestabilize-quickfix-12871.27.Bstabilize-12871.91.Bstabilize-12871.65.Bstabilize-12871.57.Bstabilize-12871.253.Bstabilize-12871.24.Bstabilize-12871.103.Bstabilize-12871.102.Brelease-R81-12871.B
My goal in CL:1963614 was to write struct vb2_hash such that it can
match the exisiting binary representation of the CBFS hash attribute,
but no longer be dependent on endianness. Unfortunately I screwed up...
if you want to match the binary representation of a big-endian integer
for small numbers, the important byte you're interested in is the *last*
one, not the first.
Thankfully we still have time to fix the issue before this struct is
really used anywhere, so this patch does that and adds a test to double
check I got it right this time.
Also clarify comments about how vboot is allowed to use this struct a
bit to match the indended usage I'm planning in coreboot. In doing that
I realized that you actually don't want to make it easy to sizeof() the
|bytes| portion of the struct (because functions shouldn't rely on that
size anyway, they should only touch what's valid for a given hash
algorithm), so taking that out which also makes it a little more
comfortable to work with the struct.
BRANCH=none
BUG=none
TEST=make runtests
Change-Id: I7e1a19f36d75acb69e5d1bfa79700c9d878f9703
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2019952
Diffstat (limited to 'firmware/2lib/2sha_utility.c')
-rw-r--r-- | firmware/2lib/2sha_utility.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/firmware/2lib/2sha_utility.c b/firmware/2lib/2sha_utility.c index 8c6f4b80..378f4c8a 100644 --- a/firmware/2lib/2sha_utility.c +++ b/firmware/2lib/2sha_utility.c @@ -221,7 +221,7 @@ vb2_error_t vb2_hash_verify(const void *buf, uint32_t size, hash_buf, hash_size); if (rv) return rv; - if (memcmp(hash_buf, hash->bytes.raw, hash_size)) + if (memcmp(hash_buf, hash->raw, hash_size)) return VB2_ERROR_SHA_MISMATCH; else return VB2_SUCCESS; |