From 9328bbff521625e788396ef9c5b26b79e6d1a7cb Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Mon, 24 Nov 2014 12:55:29 -0800 Subject: vboot2: Add host lib function to create a vb2-style keyblock Also add vb2_common_desc() helper function to return the description for an object starting with a common struct header. And use the new host lib function to create the keyblock for verifying the firmware lib. Add tests for everything new. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I1fadb3e249e771a692cc69b23620c6ddd46a48ac Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/231721 Reviewed-by: Bill Richardson --- firmware/2lib/include/2common.h | 10 ++++++++++ firmware/2lib/include/2return_codes.h | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'firmware/2lib/include') diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index a0c82d3c..1ea3f9e2 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -183,6 +183,16 @@ int vb2_verify_member_inside(const void *parent, size_t parent_size, ptrdiff_t member_data_offset, size_t member_data_size); +/** + * Return the description of an object starting with a vb2_struct_common header. + * + * Does not sanity-check the buffer; merely returns the pointer. + * + * @param buf Pointer to common object + * @return A pointer to description or an empty string if none. + */ +const char *vb2_common_desc(const void *buf); + /** * Verify the common struct header is fully contained in its parent data * diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h index 8f5a5c51..7a59925a 100644 --- a/firmware/2lib/include/2return_codes.h +++ b/firmware/2lib/include/2return_codes.h @@ -599,6 +599,23 @@ enum vb2_return_code { /* Not enough buffer space to hold signature in vb2_sign_object() */ VB2_SIGN_OBJECT_OVERFLOW, + /********************************************************************** + * Errors generated by host library keyblock functions + */ + VB2_ERROR_HOST_KEYBLOCK = VB2_ERROR_HOST_BASE + 0x040000, + + /* Unable to determine signature sizes for vb2_create_keyblock() */ + VB2_KEYBLOCK_CREATE_SIG_SIZE, + + /* Unable to pack data key for vb2_create_keyblock() */ + VB2_KEYBLOCK_CREATE_DATA_KEY, + + /* Unable to allocate buffer in vb2_create_keyblock() */ + VB2_KEYBLOCK_CREATE_ALLOC, + + /* Unable to sign keyblock in vb2_create_keyblock() */ + VB2_KEYBLOCK_CREATE_SIGN, + /********************************************************************** * Highest non-zero error generated inside vboot library. Note that * error codes passed through vboot when it calls external APIs may -- cgit v1.2.1