Skip to content

Commit 504847e

Browse files
nordic-mik7nordicjm
authored andcommitted
bootutil: Fix PureEdDSA when flash base is not 0x0
This commit introduces fix for PureEdDSA signature verification when the flash base address is not 0x0. The issue was that the flash base address was not taken into account when passing the image address to the signature verification function. Signed-off-by: Michal Kozikowski <[email protected]>
1 parent aa22913 commit 504847e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

boot/bootutil/src/image_validate.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ bootutil_img_validate(struct boot_loader_state *state,
227227
#endif
228228
int rc = 0;
229229
FIH_DECLARE(fih_rc, FIH_FAILURE);
230+
#if defined(MCUBOOT_SIGN_PURE)
231+
uintptr_t base = 0;
232+
#endif
230233
#ifdef MCUBOOT_HW_ROLLBACK_PROT
231234
fih_int security_cnt = fih_int_encode(INT_MAX);
232235
uint32_t img_security_cnt = 0;
@@ -388,11 +391,16 @@ bootutil_img_validate(struct boot_loader_state *state,
388391
FIH_CALL(bootutil_verify_sig, valid_signature, hash, sizeof(hash),
389392
buf, len, key_id);
390393
#else
394+
rc = flash_device_base(flash_area_get_device_id(fap), &base);
395+
if (rc != 0) {
396+
goto out;
397+
}
398+
391399
/* Directly check signature on the image, by using the mapping of
392400
* a device to memory. The pointer is beginning of image in flash,
393401
* so offset of area, the range is header + image + protected tlvs.
394402
*/
395-
FIH_CALL(bootutil_verify_img, valid_signature, (void *)flash_area_get_off(fap),
403+
FIH_CALL(bootutil_verify_img, valid_signature, (void *)(base + flash_area_get_off(fap)),
396404
hdr->ih_hdr_size + hdr->ih_img_size + hdr->ih_protect_tlv_size,
397405
buf, len, key_id);
398406
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Fixed issue in image_validate when `BOOT_SIGNATURE_TYPE_PURE` is enabled
2+
for platforms with NVM memory that does not start at 0x00.

0 commit comments

Comments
 (0)