vboot: Add vb2_unpack_key_buffer

Previously, vb2_unpack_key() actually unpacked a key buffer.  Callers
that had a vb2_packed_key had to typecast it back to a uint8_t buffer to
unpack it.  Rename vb2_unpack_key() to vb2_unpack_key_buffer(), and make
vb2_unpack_key() unpack a vb2_packed_key.

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

Change-Id: I9ee38a819c59cc58a72ead78cf5ddf3d0f301ae7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400906
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
Randall Spangler
2016-10-18 15:09:21 -07:00
parent 559a110f33
commit 6e3931d1f6
24 changed files with 101 additions and 98 deletions

View File

@@ -78,7 +78,7 @@ int vb2_verify_packed_key_inside(const void *parent,
const struct vb2_packed_key *key);
/**
* Unpack a vboot1-format key for use in verification
* Unpack a vboot1-format key buffer for use in verification
*
* The elements of the unpacked key will point into the source buffer, so don't
* free the source buffer until you're done with the key.
@@ -88,9 +88,23 @@ int vb2_verify_packed_key_inside(const void *parent,
* @param size Size of buffer in bytes
* @return VB2_SUCCESS, or non-zero error code if error.
*/
int vb2_unpack_key_buffer(struct vb2_public_key *key,
const uint8_t *buf,
uint32_t size);
/**
* Unpack a vboot1-format key for use in verification
*
* The elements of the unpacked key will point into the source packed key, so
* don't free the source until you're done with the public key.
*
* @param key Destintion for unpacked key
* @param packed_key Source packed key
* @param size Size of buffer in bytes
* @return VB2_SUCCESS, or non-zero error code if error.
*/
int vb2_unpack_key(struct vb2_public_key *key,
const uint8_t *buf,
uint32_t size);
const struct vb2_packed_key *packed_key);
/**
* Verify a signature against an expected hash digest.