Skip to content

Commit 6cfb1ef

Browse files
committed
[nrf fromlist] 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. Upstream PR #: 2414 Signed-off-by: Michal Kozikowski <[email protected]>
1 parent 4bfb139 commit 6cfb1ef

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
@@ -544,6 +544,9 @@ bootutil_img_validate(struct boot_loader_state *state,
544544
#endif
545545
int rc = 0;
546546
FIH_DECLARE(fih_rc, FIH_FAILURE);
547+
#if defined(MCUBOOT_SIGN_PURE)
548+
uintptr_t base = 0;
549+
#endif
547550
#ifdef MCUBOOT_HW_ROLLBACK_PROT
548551
fih_int security_cnt = fih_int_encode(INT_MAX);
549552
uint32_t img_security_cnt = 0;
@@ -788,11 +791,16 @@ bootutil_img_validate(struct boot_loader_state *state,
788791
FIH_CALL(bootutil_verify_sig, valid_signature, hash, sizeof(hash),
789792
buf, len, key_id);
790793
#else
794+
rc = flash_device_base(flash_area_get_device_id(fap), &base);
795+
if (rc != 0) {
796+
goto out;
797+
}
798+
791799
/* Directly check signature on the image, by using the mapping of
792800
* a device to memory. The pointer is beginning of image in flash,
793801
* so offset of area, the range is header + image + protected tlvs.
794802
*/
795-
FIH_CALL(bootutil_verify_img, valid_signature, (void *)flash_area_get_off(fap),
803+
FIH_CALL(bootutil_verify_img, valid_signature, (void *)(base + flash_area_get_off(fap)),
796804
hdr->ih_hdr_size + hdr->ih_img_size + hdr->ih_protect_tlv_size,
797805
buf, len, key_id);
798806
#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)