-
Notifications
You must be signed in to change notification settings - Fork 146
oneshot hash build option #736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -973,8 +973,7 @@ static int header_sha256(wc_Sha256 *sha256_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint8_t *stored_sha, *end_sha; | ||||||||||||||||||||||||||||||||
| uint16_t stored_sha_len; | ||||||||||||||||||||||||||||||||
| uint8_t *p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| uint8_t* p; | ||||||||||||||||||||||||||||||||
| if (!img) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -988,13 +987,22 @@ static int header_sha256(wc_Sha256 *sha256_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| wc_InitSha256(sha256_ctx); | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [High] Hash context resource leak on ONESHOT error path in header_sha functions* In all three The pre-existing error returns at lines 978 and 983 are safe because they occur before the init call. The non-ONESHOT path has no such early return after init — the This is especially concerning when Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| end_sha = stored_sha - (2 * sizeof(uint16_t)); /* Subtract 2 Type + 2 Len */ | ||||||||||||||||||||||||||||||||
| while (p < end_sha) { | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (end_sha - p < blksz) | ||||||||||||||||||||||||||||||||
| blksz = end_sha - p; | ||||||||||||||||||||||||||||||||
| wc_Sha256Update(sha256_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| p += blksz; | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [Low] Behavioral difference between ONESHOT and non-ONESHOT when end_sha <= p In the non-ONESHOT path, when While the ONESHOT behavior is arguably more correct (this condition indicates a corrupt header), the inconsistency means the same malformed image would pass verification without ONESHOT but fail with ONESHOT enabled. This could cause confusion during testing or field deployment when switching between the two modes. Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| if (end_sha <= p) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_Sha256Update(sha256_ctx, p, (word32)(end_sha - p)); | ||||||||||||||||||||||||||||||||
bigbrett marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| while (p < end_sha) { | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (end_sha - p < blksz) | ||||||||||||||||||||||||||||||||
| blksz = end_sha - p; | ||||||||||||||||||||||||||||||||
| wc_Sha256Update(sha256_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| p += blksz; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -1007,23 +1015,31 @@ static int header_sha256(wc_Sha256 *sha256_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| static int image_sha256(struct wolfBoot_image *img, uint8_t *hash) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint32_t position = 0; | ||||||||||||||||||||||||||||||||
| uint8_t *p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| wc_Sha256 sha256_ctx; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (header_sha256(&sha256_ctx, img) != 0) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||
| p = get_sha_block(img, position); | ||||||||||||||||||||||||||||||||
| if (p == NULL) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (position + blksz > img->fw_size) | ||||||||||||||||||||||||||||||||
| blksz = img->fw_size - position; | ||||||||||||||||||||||||||||||||
| wc_Sha256Update(&sha256_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| position += blksz; | ||||||||||||||||||||||||||||||||
| } while(position < img->fw_size); | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [High] Hash context resource leak on ONESHOT fw_base NULL check in image_sha functions* In This leaks the hash context resources. For HSM-backed crypto, this leaks a hardware session. Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| if (img->fw_base == NULL) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_Sha256Update(&sha256_ctx, img->fw_base, img->fw_size); | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint32_t position = 0; | ||||||||||||||||||||||||||||||||
| uint8_t* p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||
| p = get_sha_block(img, position); | ||||||||||||||||||||||||||||||||
| if (p == NULL) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (position + blksz > img->fw_size) | ||||||||||||||||||||||||||||||||
| blksz = img->fw_size - position; | ||||||||||||||||||||||||||||||||
| wc_Sha256Update(&sha256_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| position += blksz; | ||||||||||||||||||||||||||||||||
| } while (position < img->fw_size); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| wc_Sha256Final(&sha256_ctx, hash); | ||||||||||||||||||||||||||||||||
| wc_Sha256Free(&sha256_ctx); | ||||||||||||||||||||||||||||||||
|
|
@@ -1064,8 +1080,7 @@ static int header_sha384(wc_Sha384 *sha384_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint16_t stored_sha_len; | ||||||||||||||||||||||||||||||||
| uint8_t *stored_sha, *end_sha; | ||||||||||||||||||||||||||||||||
| uint8_t *p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| uint8_t* p; | ||||||||||||||||||||||||||||||||
| if (!img) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -1079,13 +1094,22 @@ static int header_sha384(wc_Sha384 *sha384_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| wc_InitSha384(sha384_ctx); | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| end_sha = stored_sha - (2 * sizeof(uint16_t)); /* Subtract 2 Type + 2 Len */ | ||||||||||||||||||||||||||||||||
bigbrett marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| while (p < end_sha) { | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (end_sha - p < blksz) | ||||||||||||||||||||||||||||||||
| blksz = end_sha - p; | ||||||||||||||||||||||||||||||||
| wc_Sha384Update(sha384_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| p += blksz; | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
| if (end_sha <= p) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_Sha384Update(sha384_ctx, p, (word32)(end_sha - p)); | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| while (p < end_sha) { | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (end_sha - p < blksz) | ||||||||||||||||||||||||||||||||
| blksz = end_sha - p; | ||||||||||||||||||||||||||||||||
| wc_Sha384Update(sha384_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| p += blksz; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -1101,23 +1125,31 @@ static int header_sha384(wc_Sha384 *sha384_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| static int image_sha384(struct wolfBoot_image *img, uint8_t *hash) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint32_t position = 0; | ||||||||||||||||||||||||||||||||
| uint8_t *p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| wc_Sha384 sha384_ctx; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (header_sha384(&sha384_ctx, img) != 0) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||
| p = get_sha_block(img, position); | ||||||||||||||||||||||||||||||||
| if (p == NULL) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (position + blksz > img->fw_size) | ||||||||||||||||||||||||||||||||
| blksz = img->fw_size - position; | ||||||||||||||||||||||||||||||||
| wc_Sha384Update(&sha384_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| position += blksz; | ||||||||||||||||||||||||||||||||
| } while(position < img->fw_size); | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
| if (img->fw_base == NULL) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_Sha384Update(&sha384_ctx, img->fw_base, img->fw_size); | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint32_t position = 0; | ||||||||||||||||||||||||||||||||
| uint8_t* p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||
| p = get_sha_block(img, position); | ||||||||||||||||||||||||||||||||
| if (p == NULL) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (position + blksz > img->fw_size) | ||||||||||||||||||||||||||||||||
| blksz = img->fw_size - position; | ||||||||||||||||||||||||||||||||
| wc_Sha384Update(&sha384_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| position += blksz; | ||||||||||||||||||||||||||||||||
| } while (position < img->fw_size); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| wc_Sha384Final(&sha384_ctx, hash); | ||||||||||||||||||||||||||||||||
| wc_Sha384Free(&sha384_ctx); | ||||||||||||||||||||||||||||||||
|
|
@@ -1164,8 +1196,7 @@ static int header_sha3_384(wc_Sha3 *sha3_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint16_t stored_sha_len; | ||||||||||||||||||||||||||||||||
| uint8_t *stored_sha, *end_sha; | ||||||||||||||||||||||||||||||||
| uint8_t *p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| uint8_t* p; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (!img) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
|
|
@@ -1176,13 +1207,22 @@ static int header_sha3_384(wc_Sha3 *sha3_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_InitSha3_384(sha3_ctx, NULL, INVALID_DEVID); | ||||||||||||||||||||||||||||||||
| end_sha = stored_sha - (2 * sizeof(uint16_t)); /* Subtract 2 Type + 2 Len */ | ||||||||||||||||||||||||||||||||
bigbrett marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| while (p < end_sha) { | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (end_sha - p < blksz) | ||||||||||||||||||||||||||||||||
| blksz = end_sha - p; | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Update(sha3_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| p += blksz; | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
| if (end_sha <= p) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Update(sha3_ctx, p, (word32)(end_sha - p)); | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| while (p < end_sha) { | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (end_sha - p < blksz) | ||||||||||||||||||||||||||||||||
| blksz = end_sha - p; | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Update(sha3_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| p += blksz; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -1197,23 +1237,31 @@ static int header_sha3_384(wc_Sha3 *sha3_ctx, struct wolfBoot_image *img) | |||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| static int image_sha3_384(struct wolfBoot_image *img, uint8_t *hash) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint8_t *p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| uint32_t position = 0; | ||||||||||||||||||||||||||||||||
| wc_Sha3 sha3_ctx; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (header_sha3_384(&sha3_ctx, img) != 0) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||
| p = get_sha_block(img, position); | ||||||||||||||||||||||||||||||||
| if (p == NULL) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (position + blksz > img->fw_size) | ||||||||||||||||||||||||||||||||
| blksz = img->fw_size - position; | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Update(&sha3_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| position += blksz; | ||||||||||||||||||||||||||||||||
| } while(position < img->fw_size); | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
| if (img->fw_base == NULL) | ||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Update(&sha3_ctx, img->fw_base, img->fw_size); | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| uint8_t* p; | ||||||||||||||||||||||||||||||||
| int blksz; | ||||||||||||||||||||||||||||||||
| uint32_t position = 0; | ||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||
| p = get_sha_block(img, position); | ||||||||||||||||||||||||||||||||
| if (p == NULL) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| blksz = WOLFBOOT_SHA_BLOCK_SIZE; | ||||||||||||||||||||||||||||||||
| if (position + blksz > img->fw_size) | ||||||||||||||||||||||||||||||||
| blksz = img->fw_size - position; | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Update(&sha3_ctx, p, blksz); | ||||||||||||||||||||||||||||||||
| position += blksz; | ||||||||||||||||||||||||||||||||
| } while (position < img->fw_size); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| wc_Sha3_384_Final(&sha3_ctx, hash); | ||||||||||||||||||||||||||||||||
| wc_Sha3_384_Free(&sha3_ctx); | ||||||||||||||||||||||||||||||||
|
|
@@ -1728,6 +1776,10 @@ static int update_hash_flash_fwimg(wolfBoot_hash_t* ctx, | |||||||||||||||||||||||||||||||
| struct wolfBoot_image* img, uint32_t offset, | ||||||||||||||||||||||||||||||||
| uint32_t size) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
bigbrett marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [Medium] Missing NULL and bounds checks in update_hash_flash_fwimg ONESHOT path The ONESHOT path in
The callers in Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| update_hash(ctx, img->fw_base + offset, size); | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| uint32_t current_offset = offset; | ||||||||||||||||||||||||||||||||
| uint32_t remaining_size = size; | ||||||||||||||||||||||||||||||||
| uint8_t read_buf[WOLFBOOT_SHA_BLOCK_SIZE] XALIGNED_STACK(4); /* Use local buffer */ | ||||||||||||||||||||||||||||||||
|
|
@@ -1750,6 +1802,7 @@ static int update_hash_flash_fwimg(wolfBoot_hash_t* ctx, | |||||||||||||||||||||||||||||||
| current_offset += read_size; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||
|
|
@@ -1759,6 +1812,11 @@ static int update_hash_flash_fwimg(wolfBoot_hash_t* ctx, | |||||||||||||||||||||||||||||||
| static int update_hash_flash_addr(wolfBoot_hash_t* ctx, uintptr_t addr, | ||||||||||||||||||||||||||||||||
| uint32_t size, int src_ext) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| #ifdef WOLFBOOT_IMG_HASH_ONESHOT | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [Medium] update_hash_flash_addr ONESHOT path silently ignores src_ext flag The ONESHOT path in The caller at line 1988-1989 passes Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||
| (void)src_ext; | ||||||||||||||||||||||||||||||||
| update_hash(ctx, (uint8_t*)addr, size); | ||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
bigbrett marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||
| uint8_t buffer[WOLFBOOT_SHA_BLOCK_SIZE] XALIGNED_STACK(4); | ||||||||||||||||||||||||||||||||
| uint32_t remaining_size = size; | ||||||||||||||||||||||||||||||||
| uintptr_t current_addr = addr; | ||||||||||||||||||||||||||||||||
|
|
@@ -1783,6 +1841,7 @@ static int update_hash_flash_addr(wolfBoot_hash_t* ctx, uintptr_t addr, | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| int wolfBoot_check_flash_image_elf(uint8_t part, unsigned long* entry_out) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.