rboot: Add cryptographic digest support for OTA images & SHA256 example

This commit is contained in:
Angus Gratton 2016-03-23 19:44:27 +11:00
parent 03559de5cb
commit 53b2b50241
5 changed files with 88 additions and 6 deletions

View file

@ -144,6 +144,33 @@ uint32_t rboot_get_slot_offset(uint8_t slot);
**/
bool rboot_verify_image(uint32_t offset, uint32_t *image_length, const char **error_message);
/* @description Digest callback prototype, designed to be compatible with
mbedtls digest functions (SHA, MD5, etc.)
See the ota_basic example to see an example of calculating the
SHA256 digest of an OTA image.
*/
typedef void (*rboot_digest_update_fn)(void * ctx, void *data, size_t data_len);
/** @description Calculate a digest over the image at the offset specified
@note This function is actually a generic function that hashes SPI
flash contents, doesn't know anything about rboot image format. Use
rboot_verify_image to ensure a well-formed OTA image.
@param offset - Starting offset of image to hash (should be 4 byte aligned.)
@param image_length - Length of image to hash (should be 4 byte aligned.)
@param update_fn - Function to update digest (see rboot_digest_update_fn for details)
@param update_ctx - Context argument for digest update function.
@return True if digest completes successfully, false if digest function failed part way through
**/
bool rboot_digest_image(uint32_t offset, uint32_t image_length, rboot_digest_update_fn update_fn, void *update_ctx);
#ifdef __cplusplus
}
#endif