Skip to content

Commit b9710fd

Browse files
committed
x86 Measured boot: re-calculate hash before extending PCR
F/233
1 parent 572e7d5 commit b9710fd

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/boot_x86_fsp.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,23 @@ static void jump_into_wolfboot(void)
257257
/* The image needs to be already verified */
258258
int wolfBoot_image_measure(uint8_t *image)
259259
{
260-
uint16_t hash_len;
261-
uint8_t *hash;
260+
struct wolfBoot_image img;
261+
int ret;
262262

263-
hash_len = wolfBoot_find_header(image + IMAGE_HEADER_OFFSET,
264-
WOLFBOOT_SHA_HDR, &hash);
265-
wolfBoot_print_hexstr(hash, hash_len, 0);
266-
return wolfBoot_tpm2_extend(WOLFBOOT_MEASURED_PCR_A, hash, __LINE__);
263+
memset(&img, 0, sizeof(img));
264+
ret = wolfBoot_open_image_address(&img, image);
265+
if (ret != 0) {
266+
return ret;
267+
}
268+
269+
ret = wolfBoot_verify_integrity(&img);
270+
if (ret != 0 || img.sha_hash == NULL) {
271+
return -1;
272+
}
273+
274+
wolfBoot_print_hexstr(img.sha_hash, WOLFBOOT_SHA_DIGEST_SIZE, 0);
275+
return wolfBoot_tpm2_extend(WOLFBOOT_MEASURED_PCR_A, img.sha_hash,
276+
__LINE__);
267277
}
268278
#endif /* WOLFBOOT_MEASURED_BOOT */
269279

0 commit comments

Comments
 (0)