vboot: Split partition and vblock verification from LoadKernel()

LoadKernel() was a big function which did everything from looping over
partitions on a drive to loading the data within them to calling the
low-level verification functions on that data.  Split it apart into more
manageable chunks.  This also reduces indentation of the inner parts of
the code, whic increases readability.

No outwardly-visible functionality changes.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: Iea79e70163f5d9f1a9d0d897e4a9bacc925a742d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404919
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
Randall Spangler
2016-10-25 10:00:27 -07:00
committed by chrome-bot
parent dfcacc87be
commit f182401b97
7 changed files with 550 additions and 472 deletions

View File

@@ -446,6 +446,48 @@ enum vb2_return_code {
/* Kernel preamble not loaded before calling vb2api_get_kernel_size() */
VB2_ERROR_API_GET_KERNEL_SIZE_PREAMBLE,
/* Unable to unpack kernel subkey in vb2_verify_vblock() */
VB2_ERROR_VBLOCK_KERNEL_SUBKEY,
/*
* Got a self-signed kernel in vb2_verify_vblock(), but need an
* officially signed one.
*/
VB2_ERROR_VBLOCK_SELF_SIGNED,
/* Invalid keyblock hash in vb2_verify_vblock() */
VB2_ERROR_VBLOCK_KEYBLOCK_HASH,
/* Invalid keyblock in vb2_verify_vblock() */
VB2_ERROR_VBLOCK_KEYBLOCK,
/* Wrong developer key hash in vb2_verify_vblock() */
VB2_ERROR_VBLOCK_DEV_KEY_HASH,
/* Work buffer too small in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_WORKBUF,
/* Unable to read vblock in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_READ_VBLOCK,
/* Unable to verify vblock in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_VERIFY_VBLOCK,
/* Kernel body offset too large in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_BODY_OFFSET,
/* Kernel body too big in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_BODY_SIZE,
/* Unable to read kernel body in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_READ_BODY,
/* Unable to unpack data key in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_DATA_KEY,
/* Unable to verify body in vb2_load_partition() */
VB2_ERROR_LOAD_PARTITION_VERIFY_BODY,
/**********************************************************************
* API-level errors
*/