rboot: Add cryptographic digest support for OTA images & SHA256 example
This commit is contained in:
parent
03559de5cb
commit
53b2b50241
5 changed files with 88 additions and 6 deletions
|
@ -355,6 +355,20 @@ bool rboot_verify_image(uint32_t initial_offset, uint32_t *image_length, const c
|
|||
return false;
|
||||
}
|
||||
|
||||
bool rboot_digest_image(uint32_t offset, uint32_t image_length, rboot_digest_update_fn update_fn, void *update_ctx)
|
||||
{
|
||||
uint8_t buf[32] __attribute__((aligned(4)));
|
||||
for(int i = 0; i < image_length; i += sizeof(buf)) {
|
||||
if(sdk_spi_flash_read(offset+i, buf, sizeof(buf)))
|
||||
return false;
|
||||
uint32_t digest_len = sizeof(buf);
|
||||
if(i + digest_len > image_length)
|
||||
digest_len = image_length - i;
|
||||
update_fn(update_ctx, buf, digest_len);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue