diff options
-rw-r--r-- | firmware/2lib/include/2return_codes.h | 13 | ||||
-rw-r--r-- | firmware/lib/include/vboot_common.h | 29 | ||||
-rw-r--r-- | firmware/lib/vboot_common.c | 17 | ||||
-rw-r--r-- | firmware/lib/vboot_common_init.c | 2 | ||||
-rw-r--r-- | tests/vboot_common_tests.c | 8 |
5 files changed, 24 insertions, 45 deletions
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h index fa0ed3b7..49ee50ab 100644 --- a/firmware/2lib/include/2return_codes.h +++ b/firmware/2lib/include/2return_codes.h @@ -37,6 +37,19 @@ enum vb2_return_code { VB2_ERROR_MOCK, /********************************************************************** + * ancient pre-vboot1 errors + * TODO: deprecate these once they have all moved over to vboot2 style + */ + /* Invalid public key passed to a signature verficiation function. */ + VBOOT_PUBLIC_KEY_INVALID = 4, + /* Preamble internal structure is invalid */ + VBOOT_PREAMBLE_INVALID = 5, + /* Shared data is invalid. */ + VBOOT_SHARED_DATA_INVALID = 7, + /* Kernel Preamble does not contain flags */ + VBOOT_KERNEL_PREAMBLE_NO_FLAGS = 8, + + /********************************************************************** * vboot1-style errors * TODO: deprecate these once they have all moved over to vboot2 style */ diff --git a/firmware/lib/include/vboot_common.h b/firmware/lib/include/vboot_common.h index ce7fbdfa..a0d07d89 100644 --- a/firmware/lib/include/vboot_common.h +++ b/firmware/lib/include/vboot_common.h @@ -12,29 +12,6 @@ #include "2struct.h" #include "vboot_struct.h" -/* Error Codes for all common functions. */ -enum { - VBOOT_SUCCESS = 0, - /* Keyblock internal structure is invalid, or not a keyblock */ - VBOOT_KEYBLOCK_INVALID, - /* Keyblock signature check failed */ - VBOOT_KEYBLOCK_SIGNATURE, - /* Keyblock hash check failed */ - VBOOT_KEYBLOCK_HASH, - /* Invalid public key passed to a signature verficiation function. */ - VBOOT_PUBLIC_KEY_INVALID, - /* Preamble internal structure is invalid */ - VBOOT_PREAMBLE_INVALID, - /* Preamble signature check failed */ - VBOOT_PREAMBLE_SIGNATURE, - /* Shared data is invalid. */ - VBOOT_SHARED_DATA_INVALID, - /* Kernel Preamble does not contain flags */ - VBOOT_KERNEL_PREAMBLE_NO_FLAGS, - VBOOT_ERROR_MAX, -}; -extern const char *kVbootErrors[VBOOT_ERROR_MAX]; - /* * Helper functions to get data pointed to by a public key or signature. */ @@ -75,7 +52,7 @@ int PublicKeyCopy(struct vb2_packed_key *dest, * >= 2.1. If given a header 2.0 or lower, will set address and size to 0 (this * is not considered an error). * - * Returns VBOOT_SUCCESS if successful. + * Returns VB2_SUCCESS if successful. */ vb2_error_t VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble, uint64_t *vmlinuz_header_address, @@ -86,14 +63,14 @@ vb2_error_t VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble, * Kernel Preamble Header version >=2.2. If give a header of 2.1 or lower, it * will return VBOOT_KERNEL_PREAMBLE_NO_FLAGS. * - * Returns VBOOT_SUCCESS if version is >=2.2. + * Returns VB2_SUCCESS if version is >=2.2. */ vb2_error_t VbKernelHasFlags(const VbKernelPreambleHeader *preamble); /** * Verify that the Vmlinuz Header is contained inside of the kernel blob. * - * Returns VBOOT_SUCCESS or VBOOT_PREAMBLE_INVALID on error + * Returns VB2_SUCCESS or VBOOT_PREAMBLE_INVALID on error */ vb2_error_t VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size, uint64_t header, uint64_t header_size); diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c index f8b0a955..d6e0c41d 100644 --- a/firmware/lib/vboot_common.c +++ b/firmware/lib/vboot_common.c @@ -15,17 +15,6 @@ #include "vboot_api.h" #include "vboot_common.h" -const char *kVbootErrors[VBOOT_ERROR_MAX] = { - "Success.", - "Keyblock invalid.", - "Keyblock signature failed.", - "Keyblock hash failed.", - "Public key invalid.", - "Preamble invalid.", - "Preamble signature check failed.", - "Shared data invalid." -}; - /* Helper functions to get data pointed to by a public key or signature. */ uint8_t *GetPublicKeyData(struct vb2_packed_key *key) @@ -106,13 +95,13 @@ vb2_error_t VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble, *vmlinuz_header_address = preamble->vmlinuz_header_address; *vmlinuz_header_size = preamble->vmlinuz_header_size; } - return VBOOT_SUCCESS; + return VB2_SUCCESS; } vb2_error_t VbKernelHasFlags(const VbKernelPreambleHeader *preamble) { if (preamble->header_version_minor > 1) - return VBOOT_SUCCESS; + return VB2_SUCCESS; return VBOOT_KERNEL_PREAMBLE_NO_FLAGS; } @@ -128,7 +117,7 @@ vb2_error_t VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size, if (end + header_size > kblob_size) return VBOOT_PREAMBLE_INVALID; - return VBOOT_SUCCESS; + return VB2_SUCCESS; } uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size) diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c index 00a201b6..b370fa3a 100644 --- a/firmware/lib/vboot_common_init.c +++ b/firmware/lib/vboot_common_init.c @@ -41,5 +41,5 @@ vb2_error_t VbSharedDataInit(VbSharedDataHeader *header, uint64_t size) header->firmware_index = 0xFF; /* Success */ - return VBOOT_SUCCESS; + return VB2_SUCCESS; } diff --git a/tests/vboot_common_tests.c b/tests/vboot_common_tests.c index 1869556b..49f2f2b9 100644 --- a/tests/vboot_common_tests.c +++ b/tests/vboot_common_tests.c @@ -88,18 +88,18 @@ static void VbSharedDataTest(void) uint8_t buf[VB_SHARED_DATA_MIN_SIZE + 1]; VbSharedDataHeader* d = (VbSharedDataHeader*)buf; - TEST_NEQ(VBOOT_SUCCESS, + TEST_NEQ(VB2_SUCCESS, VbSharedDataInit(d, sizeof(VbSharedDataHeader) - 1), "VbSharedDataInit too small"); - TEST_NEQ(VBOOT_SUCCESS, + TEST_NEQ(VB2_SUCCESS, VbSharedDataInit(d, VB_SHARED_DATA_MIN_SIZE - 1), "VbSharedDataInit too small 2"); - TEST_NEQ(VBOOT_SUCCESS, + TEST_NEQ(VB2_SUCCESS, VbSharedDataInit(NULL, VB_SHARED_DATA_MIN_SIZE), "VbSharedDataInit null"); memset(buf, 0x68, sizeof(buf)); - TEST_EQ(VBOOT_SUCCESS, VbSharedDataInit(d, VB_SHARED_DATA_MIN_SIZE), + TEST_EQ(VB2_SUCCESS, VbSharedDataInit(d, VB_SHARED_DATA_MIN_SIZE), "VbSharedDataInit"); /* Check fields that should have been initialized */ |