change(security): disable Key Manager support on ESP32-C5/P4/S31

The Key Manager hardware peripheral in its current form needs further
design changes before it can be offered as a production feature.
Until a revised peripheral design is available, withdraw ESP-IDF
support for it on all Key Manager capable targets.
This commit is contained in:
harshal.patil
2026-07-21 11:58:12 +05:30
parent c80598ef7f
commit 516e849636
23 changed files with 41 additions and 45 deletions

View File

@@ -72,8 +72,11 @@ elseif(NOT BOOTLOADER_BUILD)
endif()
# Key Manager and HUK HAL (available in both bootloader and app builds)
if(CONFIG_SOC_KEY_MANAGER_SUPPORTED)
if(CONFIG_SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT)
list(APPEND srcs "key_mgr_hal.c")
endif()
if(CONFIG_SOC_HUK_SUPPORTED)
list(APPEND srcs "huk_hal.c")
endif()

View File

@@ -49,7 +49,7 @@ static void configure_ecdsa_periph(ecdsa_hal_config_t *conf)
key_mgr_hal_set_key_usage(ESP_KEY_MGR_ECDSA_KEY, ESP_KEY_MGR_USE_EFUSE_KEY);
#endif
}
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY
else {
if (!key_mgr_ll_is_supported()) {
HAL_ASSERT(false && "Key manager is not supported");

View File

@@ -13,7 +13,7 @@
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_HUK_SUPPORTED
#include <stdint.h>
#include <stdbool.h>

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -13,7 +13,7 @@
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_HUK_SUPPORTED
#include <stdint.h>
#include <stdbool.h>

View File

@@ -14,7 +14,7 @@
#include "esp_err.h"
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_HUK_SUPPORTED
esp_huk_state_t huk_hal_get_state(void)
{
return huk_ll_get_state();

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -7,7 +7,7 @@
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_HUK_SUPPORTED
#include "esp_assert.h"
#include "rom/km.h"

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -9,7 +9,7 @@
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
#include "hal/key_mgr_types.h"
#ifdef __cplusplus
@@ -138,4 +138,4 @@ void key_mgr_hal_set_date_info(const uint32_t date_info);
#ifdef __cplusplus
}
#endif
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */

View File

@@ -46,8 +46,11 @@ menu "Test App Configuration"
bool
default n if IDF_TARGET_ESP32P4 && ESP32P4_SELECTS_REV_LESS_V3
default y
depends on SOC_KEY_MANAGER_SUPPORTED
depends on SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
help
A hidden config to determine if the Key Manager tests should be included.
The tests build the esp_key_mgr driver from source so that the Key Manager
hardware stays covered by CI even on targets where IDF does not support
the Key Manager (SOC_KEY_MANAGER_SUPPORTED = 0).
endmenu

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,7 +8,6 @@
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#include "rom/ets_sys.h"
#include "esp_attr.h"
@@ -112,4 +111,3 @@ struct km_deploy_ops {
#if __cplusplus
}
#endif
#endif

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,7 +8,6 @@
#define _KM_H
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#include <stdint.h>
#include "soc/soc.h"
@@ -58,6 +57,5 @@ int esp_rom_km_huk_risk(void);
#ifdef __cplusplus
}
#endif
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#endif /* _KM_H */

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -7,7 +7,6 @@
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#include <stdint.h>
#include "esp_attr.h"
#include "ets_sys.h"
@@ -109,4 +108,3 @@ struct km_deploy_ops {
#if __cplusplus
}
#endif
#endif

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,7 +8,6 @@
#define _KM_H
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#include <stdint.h>
#include "soc/soc.h"
@@ -58,6 +57,5 @@ int esp_rom_km_huk_risk(void);
#ifdef __cplusplus
}
#endif
#endif
#endif /* _KM_H */

View File

@@ -48,7 +48,7 @@ elseif(esp_tee_build)
else() # BOOTLOADER_BUILD
list(APPEND srcs "src/esp_crypto_lock.c" "src/esp_crypto_periph_clk.c")
if(CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY)
if(CONFIG_SOC_KEY_MANAGER_SUPPORTED AND CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY)
list(APPEND srcs "src/esp_key_mgr.c")
endif()
endif()

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -122,7 +122,7 @@ void esp_crypto_ecdsa_lock_acquire(void);
void esp_crypto_ecdsa_lock_release(void);
#endif /* SOC_ECDSA_SUPPORTED */
#ifdef SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
/**
* @brief Acquire lock for Key Manager peripheral
*
@@ -134,7 +134,7 @@ void esp_crypto_key_manager_lock_acquire(void);
*
*/
void esp_crypto_key_manager_lock_release(void);
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */
#ifdef __cplusplus
}

View File

@@ -8,7 +8,7 @@
#include "esp_err.h"
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
#ifdef __cplusplus
extern "C" {

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -52,10 +52,10 @@ static _lock_t s_crypto_ecdsa_lock;
#endif /* SOC_ECDSA_USES_MPI */
#endif /* SOC_ECDSA_SUPPORTED */
#ifdef SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
/* Lock for Key Manager peripheral */
static _lock_t s_crypto_key_manager_lock;
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */
#ifdef SOC_HMAC_SUPPORTED
void esp_crypto_hmac_lock_acquire(void)
@@ -159,7 +159,7 @@ void esp_crypto_ecdsa_lock_release(void)
}
#endif /* SOC_ECDSA_SUPPORTED */
#ifdef SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
void esp_crypto_key_manager_lock_acquire(void)
{
_lock_acquire(&s_crypto_key_manager_lock);
@@ -169,7 +169,7 @@ void esp_crypto_key_manager_lock_release(void)
{
_lock_release(&s_crypto_key_manager_lock);
}
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */
#else /* NON_OS_BUILD */
#ifdef SOC_HMAC_SUPPORTED
void esp_crypto_hmac_lock_acquire(void) {}
@@ -213,9 +213,9 @@ void esp_crypto_ecdsa_lock_acquire(void) {}
void esp_crypto_ecdsa_lock_release(void) {}
#endif /* SOC_ECDSA_SUPPORTED */
#ifdef SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
void esp_crypto_key_manager_lock_acquire(void) {}
void esp_crypto_key_manager_lock_release(void) {}
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */
#endif /* !NON_OS_BUILD */

View File

@@ -31,7 +31,7 @@
#if SOC_ECDSA_SUPPORTED
#include "hal/ecdsa_ll.h"
#endif
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
#include "hal/key_mgr_ll.h"
#endif
/* Crypto DMA, shared between AES and SHA */
@@ -146,7 +146,7 @@ void esp_crypto_ecdsa_enable_periph_clk(bool enable)
}
#endif
#if SOC_KEY_MANAGER_SUPPORTED
#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT
void esp_crypto_key_mgr_enable_periph_clk(bool enable)
{
KEY_MANAGER_RCC_ATOMIC() {

View File

@@ -20,7 +20,6 @@
#include "hal/huk_hal.h"
#include "rom/key_mgr.h"
#if SOC_KEY_MANAGER_SUPPORTED
static const char *TAG = "esp_key_mgr";
ESP_STATIC_ASSERT(sizeof(esp_key_mgr_key_recovery_info_t) == sizeof(struct huk_key_block), "Size of esp_key_mgr_key_recovery_info_t should match huk_key_block (from ROM)");
@@ -1072,4 +1071,3 @@ cleanup:
esp_key_mgr_release_hardware(true);
return esp_ret;
}
#endif

View File

@@ -253,7 +253,7 @@ config SOC_RNG_SUPPORTED
config SOC_KEY_MANAGER_SUPPORTED
bool
default y
default n
config SOC_HUK_SUPPORTED
bool

View File

@@ -85,7 +85,7 @@
#define SOC_SPI_FLASH_SUPPORTED 1 // TODO: [ESP32C5] IDF-8715
#define SOC_ECDSA_SUPPORTED 1
#define SOC_RNG_SUPPORTED 1
#define SOC_KEY_MANAGER_SUPPORTED 1
#define SOC_KEY_MANAGER_SUPPORTED 0
#define SOC_HUK_SUPPORTED 1
#define SOC_MODEM_CLOCK_SUPPORTED 1
#define SOC_LIGHT_SLEEP_SUPPORTED 1

View File

@@ -217,7 +217,7 @@ config SOC_ECDSA_SUPPORTED
config SOC_KEY_MANAGER_SUPPORTED
bool
default y
default n
config SOC_HUK_SUPPORTED
bool

View File

@@ -76,7 +76,7 @@
#define SOC_ECC_SUPPORTED 1
#define SOC_ECC_EXTENDED_MODES_SUPPORTED 1
#define SOC_ECDSA_SUPPORTED 1
#define SOC_KEY_MANAGER_SUPPORTED 1
#define SOC_KEY_MANAGER_SUPPORTED 0
#define SOC_HUK_SUPPORTED 1
#define SOC_FLASH_ENC_SUPPORTED 1
#define SOC_SECURE_BOOT_SUPPORTED 1

View File

@@ -71,7 +71,7 @@ FATFS encryption example uses two additional partitions in the partition table.
> **Note:** This feature is only available on targets with the Key Manager peripheral: **ESP32-C5** and **ESP32-P4**.
On supported targets, the Flash Encryption key can be deployed into and managed by the [Key Manager](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c5/api-reference/peripherals/key_manager.html) peripheral instead of an eFuse block. This means the plaintext key material is never stored in eFuses, RAM, or flash - it is bound to the device's Hardware Unique Key (HUK) and accessible only to hardware peripherals.
On supported targets, the Flash Encryption key can be deployed into and managed by the [Key Manager](../../../docs/en/api-reference/peripherals/key_manager.rst) peripheral instead of an eFuse block. This means the plaintext key material is never stored in eFuses, RAM, or flash - it is bound to the device's Hardware Unique Key (HUK) and accessible only to hardware peripherals.
For the full workflow (key deployment, eFuse programming, and boot sequence), refer to the [Flash Encryption documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c5/security/flash-encryption.html).