vboot_api_kernel: Remove assumptions about EC-RW hash type and size
authorJulius Werner <jwerner@chromium.org>
Fri, 27 May 2016 20:27:18 +0000 (13:27 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Wed, 1 Jun 2016 05:15:49 +0000 (22:15 -0700)
commite1867d26a1379afa21144ff5de0406fbb6b492e8
tree03a39efd5a156b2a9c1041e0652122d27418300d
parent31d756465dbc53ff4dd19a332939a67a3bc55d49
vboot_api_kernel: Remove assumptions about EC-RW hash type and size

With newer PD chips and different update mechanisms, we can no longer
guarantee that the "hash" (really just a sort of version identifier) of
an EC-RW image will always be a SHA256. This patch removes any hardcoded
assumptions about that from vboot, and instead accepts any hash size
returned by VbExEcHashImage() and VbExEcGetExpectedImageHash().

It also removes the assumption that the hash can be regenerated by
running SHA256 over the full image returned by VbExEcGetExpectedImage().
We can thus no longer support VBERROR_EC_GET_EXPECTED_HASH_FROM_IMAGE,
which is fine since that functionality hasn't been needed for years and
there would be no reason why we might need it in the future. This also
allows simplifying the code flow of EcUpdateImage() a bit (since you can
really just return very early if you already figured out that you don't
need to update).

BRANCH=None
BUG=chrome-os-partner:53780
TEST=Tested software sync on Oak both after cold and warm boot.

Change-Id: I498f3d39085a38740734fff9f2d1a186a0801489
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/348001
Reviewed-by: Randall Spangler <rspangler@chromium.org>
firmware/lib/vboot_api_kernel.c
tests/vboot_api_kernel3_tests.c