diff --git a/components/bootloader_support/private_include/bootloader_console.h b/components/bootloader_support/private_include/bootloader_console.h index 64dd5f84047d..0fa8db5fe017 100644 --- a/components/bootloader_support/private_include/bootloader_console.h +++ b/components/bootloader_support/private_include/bootloader_console.h @@ -1,11 +1,15 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Initialize console output (UART or USB) */ @@ -21,3 +25,7 @@ void bootloader_console_deinit(void); * Only defined if USB CDC is used for console output. */ void bootloader_console_write_char_usb(char c); + +#ifdef __cplusplus +} +#endif diff --git a/components/bootloader_support/private_include/bootloader_init.h b/components/bootloader_support/private_include/bootloader_init.h index bbbfe42d29f7..724643703e1b 100644 --- a/components/bootloader_support/private_include/bootloader_init.h +++ b/components/bootloader_support/private_include/bootloader_init.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,10 @@ #include "esp_err.h" #include "esp_image_format.h" +#ifdef __cplusplus +extern "C" { +#endif + /**@{*/ /** * @brief labels from bootloader linker script: bootloader.ld @@ -49,3 +53,7 @@ void bootloader_print_banner(void); * ESP_FAIL - If the setting is not successful. */ esp_err_t bootloader_init(void); + +#ifdef __cplusplus +} +#endif diff --git a/components/bootloader_support/private_include/bootloader_sha.h b/components/bootloader_support/private_include/bootloader_sha.h index 99079faa04b1..143ba55863f5 100644 --- a/components/bootloader_support/private_include/bootloader_sha.h +++ b/components/bootloader_support/private_include/bootloader_sha.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,18 +8,29 @@ /* Provide a SHA256 API for bootloader_support code, that can be used from bootloader or app code. - This header is available to source code in the bootloader & bootloader_support components only. - Use mbedTLS APIs or include esp32/sha.h to calculate SHA256 in IDF apps. + This header is available to source code in the bootloader & + bootloader_support components only. Use mbedTLS APIs or include esp32/sha.h + to calculate SHA256 in IDF apps. */ +#include "esp_err.h" #include #include -#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif typedef void *bootloader_sha256_handle_t; bootloader_sha256_handle_t bootloader_sha256_start(void); -void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len); +void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, + size_t data_len); + +void bootloader_sha256_finish(bootloader_sha256_handle_t handle, + uint8_t *digest); -void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest); +#ifdef __cplusplus +} +#endif diff --git a/components/bootloader_support/private_include/bootloader_signature.h b/components/bootloader_support/private_include/bootloader_signature.h index 3582db606474..dab09990ecff 100644 --- a/components/bootloader_support/private_include/bootloader_signature.h +++ b/components/bootloader_support/private_include/bootloader_signature.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,34 +27,55 @@ #include "esp32p4/rom/secure_boot.h" #endif +#ifdef __cplusplus +extern "C" { +#endif + #if !CONFIG_IDF_TARGET_ESP32 || CONFIG_ESP32_REV_MIN_FULL >= 300 #if CONFIG_SECURE_BOOT_V2_ENABLED || CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT /** @brief Verify the secure boot signature block for Secure Boot V2. * - * Performs RSA-PSS or ECDSA verification of the SHA-256 image based on the public key - * in the signature block, compared against the public key digest stored in efuse. + * Performs RSA-PSS or ECDSA verification of the SHA-256 image based on the + * public key in the signature block, compared against the public key digest + * stored in efuse. * - * Similar to esp_secure_boot_verify_signature(), but can be used when the digest is precalculated. + * Similar to esp_secure_boot_verify_signature(), but can be used when the + * digest is precalculated. * @param sig_block Pointer to signature block data * @param image_digest Pointer to 32 byte buffer holding SHA-256 hash. - * @param verified_digest Pointer to 32 byte buffer that will receive verified digest if verification completes. (Used during bootloader implementation only, result is invalid otherwise.) + * @param verified_digest Pointer to 32 byte buffer that will receive verified + * digest if verification completes. (Used during bootloader implementation + * only, result is invalid otherwise.) * */ -esp_err_t esp_secure_boot_verify_sbv2_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest); +esp_err_t esp_secure_boot_verify_sbv2_signature_block( + const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, + uint8_t *verified_digest); -/** @brief Legacy function to verify RSA secure boot signature block for Secure Boot V2. +/** @brief Legacy function to verify RSA secure boot signature block for Secure + * Boot V2. * - * @note This is kept for backward compatibility. It internally calls esp_secure_boot_verify_sbv2_signature_block. + * @note This is kept for backward compatibility. It internally calls + * esp_secure_boot_verify_sbv2_signature_block. * * @param sig_block Pointer to RSA signature block data * @param image_digest Pointer to 32 byte buffer holding SHA-256 hash. - * @param verified_digest Pointer to 32 byte buffer that will receive verified digest if verification completes. (Used during bootloader implementation only, result is invalid otherwise.) + * @param verified_digest Pointer to 32 byte buffer that will receive verified + * digest if verification completes. (Used during bootloader implementation + * only, result is invalid otherwise.) * */ -esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest); +esp_err_t esp_secure_boot_verify_rsa_signature_block( + const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, + uint8_t *verified_digest); -#endif /* CONFIG_SECURE_BOOT_V2_ENABLED || CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT */ +#endif /* CONFIG_SECURE_BOOT_V2_ENABLED || \ + CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT */ + +#endif +#ifdef __cplusplus +} #endif diff --git a/components/bootloader_support/private_include/bootloader_soc.h b/components/bootloader_support/private_include/bootloader_soc.h index a7414fd3f374..8b95742f74ab 100644 --- a/components/bootloader_support/private_include/bootloader_soc.h +++ b/components/bootloader_support/private_include/bootloader_soc.h @@ -1,10 +1,15 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once +#ifdef __cplusplus +extern "C" +{ +#endif + /** * @brief Configure analog super WDT reset * @@ -25,3 +30,7 @@ void bootloader_ana_bod_reset_config(bool enable); * @param enable Boolean to enable or disable clock glitch reset */ void bootloader_ana_clock_glitch_reset_config(bool enable); + +#ifdef __cplusplus +} +#endif diff --git a/components/bootloader_support/private_include/bootloader_utility.h b/components/bootloader_support/private_include/bootloader_utility.h index 77d4a9eee075..af3e66ac7996 100644 --- a/components/bootloader_support/private_include/bootloader_utility.h +++ b/components/bootloader_support/private_include/bootloader_utility.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,11 @@ #include "esp_image_format.h" #include "bootloader_config.h" +#ifdef __cplusplus +extern "C" +{ +#endif + /** * @brief Load partition table. * @@ -120,3 +125,7 @@ void bootloader_debug_buffer(const void *buffer, size_t length, const char *labe * @return ESP_OK if secure boot digest is generated successfully. */ esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest); + +#ifdef __cplusplus +} +#endif