diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/2lib/2gbb.c | 124 | ||||
-rw-r--r-- | firmware/2lib/include/2api.h | 17 | ||||
-rw-r--r-- | firmware/2lib/include/2common.h | 1 | ||||
-rw-r--r-- | firmware/2lib/include/2constants.h | 3 | ||||
-rw-r--r-- | firmware/2lib/include/2gbb.h | 48 | ||||
-rw-r--r-- | firmware/2lib/include/2return_codes.h | 8 | ||||
-rw-r--r-- | firmware/include/gbb_access.h | 58 | ||||
-rw-r--r-- | firmware/lib/region-init.c | 91 | ||||
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 17 | ||||
-rw-r--r-- | firmware/lib/vboot_display.c | 59 | ||||
-rw-r--r-- | firmware/lib/vboot_kernel.c | 20 | ||||
-rw-r--r-- | firmware/lib/vboot_ui.c | 1 | ||||
-rw-r--r-- | firmware/lib/vboot_ui_menu.c | 1 | ||||
-rw-r--r-- | firmware/lib20/include/vb2_common.h | 3 |
14 files changed, 257 insertions, 194 deletions
diff --git a/firmware/2lib/2gbb.c b/firmware/2lib/2gbb.c new file mode 100644 index 00000000..75eed57e --- /dev/null +++ b/firmware/2lib/2gbb.c @@ -0,0 +1,124 @@ +/* Copyright 2019 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * GBB accessor functions. + */ + +#include "2common.h" +#include "2misc.h" + +static int vb2_gbb_read_key(struct vb2_context *ctx, + uint32_t offset, + uint32_t *size, + struct vb2_packed_key **keyp, + struct vb2_workbuf *wb) +{ + struct vb2_workbuf wblocal = *wb; + int rv; + + /* Check offset and size. */ + if (offset < sizeof(struct vb2_gbb_header)) + return VB2_ERROR_GBB_INVALID; + if (*size < sizeof(**keyp)) + return VB2_ERROR_GBB_INVALID; + + /* GBB header might be padded. Retrieve the vb2_packed_key + header so we can find out what the real size is. */ + *keyp = vb2_workbuf_alloc(&wblocal, sizeof(**keyp)); + if (!*keyp) + return VB2_ERROR_GBB_WORKBUF; + rv = vb2ex_read_resource(ctx, VB2_RES_GBB, offset, *keyp, + sizeof(**keyp)); + if (rv) + return rv; + + rv = vb2_verify_packed_key_inside(*keyp, *size, *keyp); + if (rv) + return rv; + + /* Deal with a zero-size key (used in testing). */ + *size = (*keyp)->key_offset + (*keyp)->key_size; + if (*size < sizeof(**keyp)) + *size = sizeof(**keyp); + + /* Now that we know the real size of the key, retrieve the key + data, and write it on the workbuf, directly after vb2_packed_key. */ + *keyp = vb2_workbuf_realloc(&wblocal, sizeof(**keyp), *size); + if (!*keyp) + return VB2_ERROR_GBB_WORKBUF; + + rv = vb2ex_read_resource(ctx, VB2_RES_GBB, + offset + sizeof(**keyp), + (void *)*keyp + sizeof(**keyp), + *size - sizeof(**keyp)); + if (!rv) + *wb = wblocal; + return rv; +} + +int vb2_gbb_read_root_key(struct vb2_context *ctx, + struct vb2_packed_key **keyp, + uint32_t *size, + struct vb2_workbuf *wb) +{ + struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); + uint32_t size_in = gbb->rootkey_size; + int ret = vb2_gbb_read_key(ctx, gbb->rootkey_offset, + &size_in, keyp, wb); + if (size) + *size = size_in; + return ret; +} + +int vb2_gbb_read_recovery_key(struct vb2_context *ctx, + struct vb2_packed_key **keyp, + uint32_t *size, + struct vb2_workbuf *wb) +{ + struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); + uint32_t size_in = gbb->recovery_key_size; + int ret = vb2_gbb_read_key(ctx, gbb->recovery_key_offset, + &size_in, keyp, wb); + if (size) + *size = size_in; + return ret; +} + +int vb2api_gbb_read_hwid(struct vb2_context *ctx, + char *hwid, + uint32_t *size) +{ + struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); + uint32_t i; + int ret; + + if (gbb->hwid_size == 0) { + VB2_DEBUG("invalid HWID size %d\n", gbb->hwid_size); + return VB2_ERROR_GBB_INVALID; + } + + if (*size > VB2_GBB_HWID_MAX_SIZE) + *size = VB2_GBB_HWID_MAX_SIZE; + if (*size > gbb->hwid_size) + *size = gbb->hwid_size; + + ret = vb2ex_read_resource(ctx, VB2_RES_GBB, gbb->hwid_offset, + hwid, *size); + if (ret) { + VB2_DEBUG("read resource failure: %d\n", ret); + return ret; + } + + /* Count HWID size, and ensure that it fits in the given buffer. */ + for (i = 0; i < *size; i++) { + if (hwid[i] == '\0') { + *size = i + 1; + break; + } + } + if (hwid[*size - 1] != '\0') + return VB2_ERROR_INVALID_PARAMETER; + + return VB2_SUCCESS; +} diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index e7964e28..341517d9 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -643,6 +643,23 @@ int vb2api_verify_kernel_data(struct vb2_context *ctx, */ int vb2api_kernel_phase3(struct vb2_context *ctx); +/** + * Read the hardware ID from the GBB, and store it onto the given buffer. + * + * @param ctx Vboot context. + * @param hwid Buffer to store HWID, which will be null-terminated. + * @param size Maximum size of HWID including null terminator. HWID + * length may not exceed 256 (VB2_GBB_HWID_MAX_SIZE), so + * this value is suggested. If size is too small, then + * VB2_ERROR_INVALID_PARAMETER is returned. Actual size + * of the output HWID string is returned in this pointer, + * also including null terminator. + * @return VB2_SUCCESS, or error code on error. + */ +int vb2api_gbb_read_hwid(struct vb2_context *ctx, + char *hwid, + uint32_t *size); + /*****************************************************************************/ /* APIs provided by the caller to verified boot */ diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index be8a4ec5..81f56df5 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -9,6 +9,7 @@ #define VBOOT_REFERENCE_VBOOT_2COMMON_H_ #include "2api.h" +#include "2gbb.h" #include "2return_codes.h" #include "2sha.h" #include "2struct.h" diff --git a/firmware/2lib/include/2constants.h b/firmware/2lib/include/2constants.h index 81d1cc56..ef772ef6 100644 --- a/firmware/2lib/include/2constants.h +++ b/firmware/2lib/include/2constants.h @@ -64,4 +64,7 @@ * macro for us we'll be safe and use that. */ #define VB2_WORKBUF_ALIGN __BIGGEST_ALIGNMENT__ +/* Maximum length of a HWID in bytes, counting terminating null. */ +#define VB2_GBB_HWID_MAX_SIZE 256 + #endif /* VBOOT_REFERENCE_2CONSTANTS_H_ */ diff --git a/firmware/2lib/include/2gbb.h b/firmware/2lib/include/2gbb.h new file mode 100644 index 00000000..6ad0eb3b --- /dev/null +++ b/firmware/2lib/include/2gbb.h @@ -0,0 +1,48 @@ +/* Copyright 2019 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * GBB accessor functions. + */ + +#ifndef VBOOT_REFERENCE_VBOOT_2GBB_H_ +#define VBOOT_REFERENCE_VBOOT_2GBB_H_ + +#include "2common.h" + +struct vb2_packed_key; +struct vb2_workbuf; + +/** + * Read the root key from the GBB, and store it onto the given workbuf. + * + * @param ctx Vboot context. + * @param keyp Returns a pointer to the key. The caller may discard + * workbuf state if it wants to free the key. + * @param size If pointer is non-NULL, returns the total size of key, + * including data. + * @param wb Workbuf for data storage. + * @return VB2_SUCCESS, or error code on error. + */ +int vb2_gbb_read_root_key(struct vb2_context *ctx, + struct vb2_packed_key **keyp, + uint32_t *size, + struct vb2_workbuf *wb); + +/** + * Read the recovery key from the GBB, and store it onto the given workbuf. + * + * @param ctx Vboot context. + * @param keyp Returns a pointer to the key. The caller may discard + * workbuf state if it wants to free the key. + * @param size If pointer is non-NULL, returns the total size of key, + * including data. + * @param wb Workbuf for data storage. + * @return VB2_SUCCESS, or error code on error. + */ +int vb2_gbb_read_recovery_key(struct vb2_context *ctx, + struct vb2_packed_key **keyp, + uint32_t *size, + struct vb2_workbuf *wb); + +#endif /* VBOOT_REFERENCE_VBOOT_2GBB_H_ */ diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h index 5992806d..15ec97f6 100644 --- a/firmware/2lib/include/2return_codes.h +++ b/firmware/2lib/include/2return_codes.h @@ -361,7 +361,7 @@ enum vb2_return_code { /* Work buffer unaligned in vb2_init_context() */ VB2_ERROR_INITCTX_WORKBUF_ALIGN, - /* Work buffer too small in vb2_fw_parse_gbb() */ + /* Work buffer too small in GBB-related function */ VB2_ERROR_GBB_WORKBUF, /* Bad magic number in vb2_read_gbb_header() */ @@ -503,6 +503,12 @@ enum vb2_return_code { /* Bad magic number in vb2_shared_data structure */ VB2_ERROR_SHARED_DATA_MAGIC, + /* Some part of GBB data is invalid */ + VB2_ERROR_GBB_INVALID, + + /* Invalid parameter */ + VB2_ERROR_INVALID_PARAMETER, + /********************************************************************** * API-level errors */ diff --git a/firmware/include/gbb_access.h b/firmware/include/gbb_access.h deleted file mode 100644 index 09a88fa0..00000000 --- a/firmware/include/gbb_access.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Access to portions of the GBB using the region API. - */ - -#ifndef VBOOT_REFERENCE_GBB_ACCESS_H_ -#define VBOOT_REFERENCE_GBB_ACCESS_H_ - -#include "vboot_api.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct vb2_context; -struct VbPublicKey; - -/** - * Read the root key from the GBB - * - * @param ctx Vboot context - * @param keyp Returns a pointer to the key. The caller must call - * free() on the key when finished with it. - * @return VBERROR_... error, VBERROR_SUCCESS on success, - */ -VbError_t VbGbbReadRootKey(struct vb2_context *ctx, - struct VbPublicKey **keyp); - -/** - * Read the recovery key from the GBB - * - * @param ctx Vboot context - * @param keyp Returns a pointer to the key. The caller must call - * free() on the key when finished with it. - * @return VBERROR_... error, VBERROR_SUCCESS on success, - */ -VbError_t VbGbbReadRecoveryKey(struct vb2_context *ctx, - struct VbPublicKey **keyp); - -/** - * Read the hardware ID from the GBB - * - * @param ctx Vboot context - * @param hwid Place to put HWID, which will be null-terminated - * @param max_size Maximum size of HWID including terminated null - * character (suggest 256). If this size is too small - * then VBERROR_INVALID_PARAMETER is returned. - * @return VBERROR_... error, VBERROR_SUCCESS on success, - */ -VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid, uint32_t max_size); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/firmware/lib/region-init.c b/firmware/lib/region-init.c deleted file mode 100644 index 9e3c2bc3..00000000 --- a/firmware/lib/region-init.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * High-level firmware API for loading and verifying rewritable firmware. - * (Firmware portion) - */ - -#include "2sysincludes.h" -#include "2common.h" -#include "2misc.h" - -#include "sysincludes.h" -#include "gbb_access.h" -#include "load_kernel_fw.h" -#include "utility.h" -#include "vboot_api.h" -#include "vboot_struct.h" - -static VbError_t VbGbbReadData(struct vb2_context *ctx, - uint32_t offset, uint32_t size, void *buf) -{ - if (vb2ex_read_resource(ctx, VB2_RES_GBB, offset, buf, size)) - return VBERROR_INVALID_GBB; - return VBERROR_SUCCESS; -} - -VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid, uint32_t max_size) -{ - struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); - - if (!max_size) - return VBERROR_INVALID_PARAMETER; - *hwid = '\0'; - StrnAppend(hwid, "{INVALID}", max_size); - if (!ctx) - return VBERROR_INVALID_GBB; - - if (0 == gbb->hwid_size) { - VB2_DEBUG("VbHWID(): invalid hwid size\n"); - return VBERROR_SUCCESS; /* oddly enough! */ - } - - if (gbb->hwid_size > max_size) { - VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n"); - return VBERROR_INVALID_PARAMETER; - } - - return VbGbbReadData(ctx, gbb->hwid_offset, - gbb->hwid_size, hwid); -} - -static VbError_t VbGbbReadKey(struct vb2_context *ctx, uint32_t offset, - VbPublicKey **keyp) -{ - VbPublicKey hdr, *key; - VbError_t ret; - uint32_t size; - - ret = VbGbbReadData(ctx, offset, sizeof(VbPublicKey), &hdr); - if (ret) - return ret; - - /* Deal with a zero-size key (used in testing) */ - size = hdr.key_offset + hdr.key_size; - if (size < sizeof(hdr)) - size = sizeof(hdr); - key = malloc(size); - ret = VbGbbReadData(ctx, offset, size, key); - if (ret) { - free(key); - return ret; - } - - *keyp = key; - return VBERROR_SUCCESS; -} - -VbError_t VbGbbReadRootKey(struct vb2_context *ctx, VbPublicKey **keyp) -{ - struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); - - return VbGbbReadKey(ctx, gbb->rootkey_offset, keyp); -} - -VbError_t VbGbbReadRecoveryKey(struct vb2_context *ctx, VbPublicKey **keyp) -{ - struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); - - return VbGbbReadKey(ctx, gbb->recovery_key_offset, keyp); -} diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 35f33813..bde6f82e 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -13,7 +13,6 @@ #include "2nvstorage.h" #include "2rsa.h" #include "ec_sync.h" -#include "gbb_access.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "utility.h" @@ -463,7 +462,7 @@ VbError_t VbVerifyMemoryBootImage( VbSelectAndLoadKernelParams *kparams, void *boot_image, size_t image_size) { - VbPublicKey* kernel_subkey = NULL; + struct vb2_packed_key *kernel_subkey = NULL; uint8_t *kbuf; VbKeyBlockHeader *key_block; VbKernelPreambleHeader *preamble; @@ -473,6 +472,9 @@ VbError_t VbVerifyMemoryBootImage( uint32_t allow_fastboot_full_cap = 0; struct vb2_workbuf wb; + /* Allocate work buffer */ + vb2_workbuf_from_ctx(ctx, &wb); + VbError_t retval = vb2_kernel_setup(ctx, shared, kparams); if (retval) goto fail; @@ -508,7 +510,8 @@ VbError_t VbVerifyMemoryBootImage( hash_only = 1; } else { /* Get recovery key. */ - retval = VbGbbReadRecoveryKey(ctx, &kernel_subkey); + retval = vb2_gbb_read_recovery_key(ctx, &kernel_subkey, + NULL, &wb); if (VBERROR_SUCCESS != retval) { VB2_DEBUG("Gbb Read Recovery key failed.\n"); goto fail; @@ -518,9 +521,6 @@ VbError_t VbVerifyMemoryBootImage( /* If we fail at any step, retval returned would be invalid kernel. */ retval = VBERROR_INVALID_KERNEL_FOUND; - /* Allocate work buffer */ - vb2_workbuf_from_ctx(ctx, &wb); - /* Verify the key block. */ key_block = (VbKeyBlockHeader *)kbuf; struct vb2_keyblock *keyblock2 = (struct vb2_keyblock *)kbuf; @@ -531,8 +531,7 @@ VbError_t VbVerifyMemoryBootImage( /* Unpack kernel subkey */ struct vb2_public_key kernel_subkey2; if (VB2_SUCCESS != - vb2_unpack_key(&kernel_subkey2, - (struct vb2_packed_key *)kernel_subkey)) { + vb2_unpack_key(&kernel_subkey2, kernel_subkey)) { VB2_DEBUG("Unable to unpack kernel subkey\n"); goto fail; } @@ -609,8 +608,6 @@ VbError_t VbVerifyMemoryBootImage( fail: vb2_kernel_cleanup(ctx); - if (NULL != kernel_subkey) - free(kernel_subkey); return retval; } diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c index 1f80a651..6ef692f7 100644 --- a/firmware/lib/vboot_display.c +++ b/firmware/lib/vboot_display.c @@ -12,7 +12,6 @@ #include "2misc.h" #include "2nvstorage.h" #include "2sha.h" -#include "gbb_access.h" #include "utility.h" #include "vboot_api.h" #include "vboot_common.h" @@ -274,19 +273,27 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx) { struct vb2_shared_data *sd = vb2_get_sd(ctx); struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); + struct vb2_workbuf wb; VbSharedDataHeader *shared = sd->vbsd; char buf[DEBUG_INFO_SIZE] = ""; char sha1sum[VB2_SHA1_DIGEST_SIZE * 2 + 1]; - char hwid[256]; uint32_t used = 0; - VbPublicKey *key; - VbError_t ret; + int ret; uint32_t i; + vb2_workbuf_from_ctx(ctx, &wb); + /* Add hardware ID */ - VbGbbReadHWID(ctx, hwid, sizeof(hwid)); - used += StrnAppend(buf + used, "HWID: ", DEBUG_INFO_SIZE - used); - used += StrnAppend(buf + used, hwid, DEBUG_INFO_SIZE - used); + { + char hwid[VB2_GBB_HWID_MAX_SIZE]; + uint32_t size = sizeof(hwid); + ret = vb2api_gbb_read_hwid(ctx, hwid, &size); + if (ret) + strcpy(hwid, "{INVALID}"); + used += StrnAppend(buf + used, "HWID: ", + DEBUG_INFO_SIZE - used); + used += StrnAppend(buf + used, hwid, DEBUG_INFO_SIZE - used); + } /* Add recovery reason and subcode */ i = vb2_nv_get(ctx, VB2_NV_RECOVERY_SUBCODE); @@ -359,24 +366,30 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx) gbb->flags, 16, 8); /* Add sha1sum for Root & Recovery keys */ - ret = VbGbbReadRootKey(ctx, &key); - if (!ret) { - FillInSha1Sum(sha1sum, key); - free(key); - used += StrnAppend(buf + used, "\ngbb.rootkey: ", - DEBUG_INFO_SIZE - used); - used += StrnAppend(buf + used, sha1sum, - DEBUG_INFO_SIZE - used); + { + struct vb2_packed_key *key; + struct vb2_workbuf wblocal = wb; + ret = vb2_gbb_read_root_key(ctx, &key, NULL, &wblocal); + if (!ret) { + FillInSha1Sum(sha1sum, (VbPublicKey *)key); + used += StrnAppend(buf + used, "\ngbb.rootkey: ", + DEBUG_INFO_SIZE - used); + used += StrnAppend(buf + used, sha1sum, + DEBUG_INFO_SIZE - used); + } } - ret = VbGbbReadRecoveryKey(ctx, &key); - if (!ret) { - FillInSha1Sum(sha1sum, key); - free(key); - used += StrnAppend(buf + used, "\ngbb.recovery_key: ", - DEBUG_INFO_SIZE - used); - used += StrnAppend(buf + used, sha1sum, - DEBUG_INFO_SIZE - used); + { + struct vb2_packed_key *key; + struct vb2_workbuf wblocal = wb; + ret = vb2_gbb_read_recovery_key(ctx, &key, NULL, &wblocal); + if (!ret) { + FillInSha1Sum(sha1sum, (VbPublicKey *)key); + used += StrnAppend(buf + used, "\ngbb.recovery_key: ", + DEBUG_INFO_SIZE - used); + used += StrnAppend(buf + used, sha1sum, + DEBUG_INFO_SIZE - used); + } } /* If we're in dev-mode, show the kernel subkey that we expect, too. */ diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 7195bdb0..741890e4 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -16,7 +16,6 @@ #include "2sha.h" #include "cgptlib.h" #include "cgptlib_internal.h" -#include "gbb_access.h" #include "gpt_misc.h" #include "load_kernel_fw.h" #include "rollback_index.h" @@ -309,6 +308,7 @@ enum vb2_load_partition_flags { * @param params Load-kernel parameters * @param min_version Minimum kernel version from TPM * @param shpart Destination for verification results + * @param wb Workbuf for data storage * @return VB2_SUCCESS, or non-zero error code. */ static int vb2_load_partition(struct vb2_context *ctx, @@ -317,10 +317,10 @@ static int vb2_load_partition(struct vb2_context *ctx, uint32_t flags, LoadKernelParams *params, uint32_t min_version, - VbSharedDataKernelPart *shpart) + VbSharedDataKernelPart *shpart, + struct vb2_workbuf *wb) { - struct vb2_workbuf wblocal; - vb2_workbuf_from_ctx(ctx, &wblocal); + struct vb2_workbuf wblocal = *wb; /* Allocate kernel header buffer in workbuf */ uint8_t *kbuf = vb2_workbuf_alloc(&wblocal, KBUF_SIZE); @@ -429,6 +429,7 @@ static int vb2_load_partition(struct vb2_context *ctx, VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) { struct vb2_shared_data *sd = vb2_get_sd(ctx); + struct vb2_workbuf wb; VbSharedDataHeader *shared = sd->vbsd; VbSharedDataKernelCall *shcall = NULL; struct vb2_packed_key *recovery_key = NULL; @@ -438,6 +439,8 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) VbError_t retval = VBERROR_UNKNOWN; int recovery = VB2_RECOVERY_LK_UNSPECIFIED; + vb2_workbuf_from_ctx(ctx, &wb); + /* Clear output params in case we fail */ params->partition_number = 0; params->bootloader_address = 0; @@ -461,8 +464,8 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) struct vb2_packed_key *kernel_subkey; if (kBootRecovery == shcall->boot_mode) { /* Use the recovery key to verify the kernel */ - retval = VbGbbReadRecoveryKey(ctx, - (VbPublicKey **)&recovery_key); + retval = vb2_gbb_read_recovery_key(ctx, &recovery_key, + NULL, &wb); if (VBERROR_SUCCESS != retval) goto load_kernel_exit; kernel_subkey = recovery_key; @@ -547,7 +550,8 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params) lpflags, params, shared->kernel_version_tpm, - shpart); + shpart, + &wb); VbExStreamClose(stream); if (rv != VB2_SUCCESS) { @@ -656,8 +660,6 @@ load_kernel_exit: VBERROR_SUCCESS != retval ? recovery : VB2_RECOVERY_NOT_REQUESTED); - free(recovery_key); - shcall->return_code = (uint8_t)retval; return retval; } diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c index 7fc7a307..8a990047 100644 --- a/firmware/lib/vboot_ui.c +++ b/firmware/lib/vboot_ui.c @@ -13,7 +13,6 @@ #include "2nvstorage.h" #include "2rsa.h" #include "ec_sync.h" -#include "gbb_access.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "tlcl.h" diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 3fdf77cb..c3268d1e 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -11,7 +11,6 @@ #include "2nvstorage.h" #include "2rsa.h" #include "ec_sync.h" -#include "gbb_access.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "utility.h" diff --git a/firmware/lib20/include/vb2_common.h b/firmware/lib20/include/vb2_common.h index 4cb0e5a5..2f70d544 100644 --- a/firmware/lib20/include/vb2_common.h +++ b/firmware/lib20/include/vb2_common.h @@ -13,8 +13,11 @@ #include "2return_codes.h" #include "2sha.h" #include "2struct.h" +#include "2sysincludes.h" #include "vb2_struct.h" +struct vb2_public_key; + /* * Helper functions to get data pointed to by a public key or signature. */ |