Skip to content

[nrf fromlist] bootutil: Fix PureEdDSA when flash base is not 0x0 #492

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion boot/bootutil/src/image_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ bootutil_img_validate(struct boot_loader_state *state,
#endif
int rc = 0;
FIH_DECLARE(fih_rc, FIH_FAILURE);
#if defined(MCUBOOT_SIGN_PURE)
uintptr_t base = 0;
#endif
#ifdef MCUBOOT_HW_ROLLBACK_PROT
fih_int security_cnt = fih_int_encode(INT_MAX);
uint32_t img_security_cnt = 0;
Expand Down Expand Up @@ -788,11 +791,16 @@ bootutil_img_validate(struct boot_loader_state *state,
FIH_CALL(bootutil_verify_sig, valid_signature, hash, sizeof(hash),
buf, len, key_id);
#else
rc = flash_device_base(flash_area_get_device_id(fap), &base);
if (rc != 0) {
goto out;
}

/* Directly check signature on the image, by using the mapping of
* a device to memory. The pointer is beginning of image in flash,
* so offset of area, the range is header + image + protected tlvs.
*/
FIH_CALL(bootutil_verify_img, valid_signature, (void *)flash_area_get_off(fap),
FIH_CALL(bootutil_verify_img, valid_signature, (void *)(base + flash_area_get_off(fap)),
hdr->ih_hdr_size + hdr->ih_img_size + hdr->ih_protect_tlv_size,
buf, len, key_id);
#endif
Expand Down
2 changes: 1 addition & 1 deletion boot/zephyr/flash_map_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);

#elif (defined(CONFIG_SOC_SERIES_NRF54HX) && DT_HAS_CHOSEN(zephyr_flash))

#define FLASH_DEVICE_ID SPI_FLASH_0_ID
#define FLASH_DEVICE_ID SOC_FLASH_0_ID
#define FLASH_DEVICE_BASE CONFIG_FLASH_BASE_ADDRESS
#define FLASH_DEVICE_NODE DT_CHOSEN(zephyr_flash)

Expand Down
2 changes: 2 additions & 0 deletions docs/release-notes.d/fix-pure-eddsa-base-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed issue in image_validate when `BOOT_SIGNATURE_TYPE_PURE` is enabled
for platforms with NVM memory that does not start at 0x00.
Loading