bootloader_common: Fix esp_partition_get_sha256(), add unit tests

Regression in 438d513a95

Reported here: https://esp32.com/viewtopic.php?f=13&t=13250&p=52460
This commit is contained in:
Angus Gratton
2019-11-28 12:11:50 +11:00
committed by Angus Gratton
parent 2303dfaffc
commit 5139934767
3 changed files with 69 additions and 12 deletions

View File

@@ -229,18 +229,19 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
if (sha_handle != NULL) {
bootloader_sha256_finish(sha_handle, NULL);
}
if (data->image.hash_appended) {
const void *hash = bootloader_mmap(data->start_addr + data->image_len - HASH_LEN, HASH_LEN);
if (hash == NULL) {
err = ESP_FAIL;
goto err;
}
memcpy(data->image_digest, hash, HASH_LEN);
bootloader_munmap(hash);
}
sha_handle = NULL;
} // verify_sha
} //verify_sha
// Separately, if there's a hash appended to the image then copy it out to the data->image_digest field
if (data->image.hash_appended) {
const void *hash = bootloader_mmap(data->start_addr + data->image_len - HASH_LEN, HASH_LEN);
if (hash == NULL) {
err = ESP_FAIL;
goto err;
}
memcpy(data->image_digest, hash, HASH_LEN);
bootloader_munmap(hash);
}
} // do_verify
if (err != ESP_OK) {