feat(esp_image_verify): split image verification out of bootloader_support

This commit is contained in:
Ashish Sharma
2026-07-08 15:54:40 +08:00
committed by Mahavir Jain
parent b912691fcd
commit e7af5c69d9
54 changed files with 650 additions and 520 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2018-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -153,8 +153,13 @@ void bootloader_configure_spi_pins(int drv);
* - ESP_ERR_NO_MEM: Cannot allocate memory for sha256 operation.
* - ESP_ERR_IMAGE_INVALID: App partition doesn't contain a valid app image.
* - ESP_FAIL: An allocation error occurred.
*
* @deprecated Use esp_partition_get_sha256() from the esp_partition component instead.
* Requires the esp_image_verify component in the build; otherwise
* calls fail at link time with an undefined reference.
*/
esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t size, int type, uint8_t *out_sha_256);
esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t size, int type, uint8_t *out_sha_256)
__attribute__((deprecated("Use esp_partition_get_sha256() from the esp_partition component instead")));
/**
* @brief Returns the number of active otadata.

View File

@@ -0,0 +1,48 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_err.h"
#include "soc/soc_caps.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Generates the SHA-256 digest of flash contents between offset and offset+length.
*
* Reads in MMU-sized chunks, so it handles images larger than the MMU window
* (3.2 MB / 50 pages of 64 KB).
*
* @param[in] flash_offset Byte offset in flash.
* @param[in] len Length of data in bytes.
* @param[out] digest 32-byte buffer for the resulting SHA-256 digest.
*
* @return ESP_OK on success; ESP_ERR_NO_MEM if allocation fails.
*
* @note Defined in the esp_image_verify component; calling it in builds without
* that component fails at link time with an undefined reference.
*/
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest);
#if SOC_SHA_SUPPORT_SHA384 && SOC_ECDSA_SUPPORT_CURVE_P384
/** @brief Generates the SHA-384 digest of flash contents between offset and offset+length.
*
* @param[in] flash_offset Byte offset in flash.
* @param[in] len Length of data in bytes.
* @param[out] digest 48-byte buffer for the resulting SHA-384 digest.
*
* @return ESP_OK on success; ESP_ERR_NO_MEM if allocation fails.
*
* @note Defined in the esp_image_verify component; calling it in builds without
* that component fails at link time with an undefined reference.
*/
esp_err_t bootloader_sha384_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -312,6 +312,16 @@ typedef struct {
*/
void esp_secure_boot_init_checks(void);
/**
* @brief Run the on-update signature-block check for app-side secure boot.
*
* @important This function is invoked by esp_secure_boot_init_checks() during app
* startup when CONFIG_SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT is configured with
* V2 RSA or ECDSA schemes. It verifies that the running app's signature blocks
* are intact so future OTA updates can be verified.
*/
void esp_secure_boot_check_signature_on_update(void);
#if !BOOTLOADER_BUILD && (CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME)
/** @brief Scan the current running app for signature blocks