Skip to content

Commit 5aa5366

Browse files
committed
fix(bootloader_support): Reorder write disabling ECDSA_CURVE_MODE
1 parent d6c1184 commit 5aa5366

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

components/bootloader_support/src/esp32h2/secure_boot_secure_features.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ esp_err_t esp_secure_boot_enable_secure_features(void)
3737
ESP_LOGW(TAG, "UART ROM Download mode kept enabled - SECURITY COMPROMISED");
3838
#endif
3939

40-
#ifdef SOC_ECDSA_P192_CURVE_DEFAULT_DISABLED
41-
if (ecdsa_ll_is_configurable_curve_supported()) {
42-
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_ECDSA_CURVE_MODE);
43-
}
44-
#endif
45-
4640
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
4741
ESP_LOGI(TAG, "Disable hardware & software JTAG...");
4842
esp_efuse_write_field_bit(ESP_EFUSE_DIS_PAD_JTAG);

components/bootloader_support/src/esp32h21/secure_boot_secure_features.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ esp_err_t esp_secure_boot_enable_secure_features(void)
3636
ESP_LOGW(TAG, "UART ROM Download mode kept enabled - SECURITY COMPROMISED");
3737
#endif
3838

39-
#ifdef SOC_ECDSA_P192_CURVE_DEFAULT_DISABLED
40-
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_ECDSA_CURVE_MODE);
41-
#endif
42-
4339
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
4440
ESP_LOGI(TAG, "Disable hardware & software JTAG...");
4541
esp_efuse_write_field_bit(ESP_EFUSE_DIS_PAD_JTAG);

components/esp_security/src/init.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "hal/key_mgr_ll.h"
2323
#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */
2424

25+
#if SOC_ECDSA_P192_CURVE_DEFAULT_DISABLED
26+
#include "hal/ecdsa_ll.h"
27+
#endif /* SOC_ECDSA_P192_CURVE_DEFAULT_DISABLED */
28+
2529
__attribute__((unused)) static const char *TAG = "esp_security";
2630

2731
static void esp_key_mgr_init(void)
@@ -73,6 +77,18 @@ ESP_SYSTEM_INIT_FN(esp_security_init, SECONDARY, BIT(0), 103)
7377
#endif
7478

7579
#if CONFIG_SECURE_BOOT_V2_ENABLED
80+
// H2, H21
81+
#if SOC_ECDSA_P192_CURVE_DEFAULT_DISABLED
82+
// Also write protects the ECDSA_CURVE_MODE efuse bit.
83+
if (ecdsa_ll_is_configurable_curve_supported()) {
84+
err = esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_ECDSA_CURVE_MODE);
85+
if (err != ESP_OK) {
86+
ESP_LOGE(TAG, "Failed to write protect the ECDSA_CURVE_MODE efuse bit.");
87+
return err;
88+
}
89+
}
90+
#endif
91+
7692
#if !CONFIG_SECURE_BOOT_SKIP_WRITE_PROTECTION_SCA
7793
// C5
7894
#if SOC_ECDSA_SUPPORT_CURVE_P384 && !CONFIG_SECURE_BOOT_ECDSA_KEY_LEN_384_BITS

docs/en/security/security-features-enablement-workflows.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ In this workflow we shall use ``espsecure`` tool to generate signing keys and us
500500
:SOC_EFUSE_DIS_USB_JTAG: - ``DIS_USB_JTAG``: Disable USB switch to JTAG.
501501
:SOC_EFUSE_DIS_PAD_JTAG: - ``DIS_PAD_JTAG``: Disable JTAG permanently.
502502
:SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS: - ``SECURE_BOOT_AGGRESSIVE_REVOKE``: Aggressive revocation of key digests, see :ref:`secure-boot-v2-aggressive-key-revocation` for more details.
503+
:SOC_ECDSA_P192_CURVE_DEFAULT_DISABLED: - ``WR_DIS_ECDSA_CURVE_MODE``: Disable writing to the ECDSA curve mode eFuse bit (As this write protection bit is shared with ECC_FORCE_CONST_TIME, it is recommended to write protect this bit only after configuring the ECC_FORCE_CONST_TIME efuse).
503504
:SOC_ECDSA_SUPPORT_CURVE_P384: - ``WR_DIS_SECURE_BOOT_SHA384_EN``: Disable writing to the SHA-384 secure boot eFuse bit (As this write protection bit is shared with XTS_DPA_PSEUDO_LEVEL and ECC_FORCE_CONST_TIME, it is recommended to write protect this bit only after configuring all the other shared efuses).
504505

505506
The respective eFuses can be burned by running:

0 commit comments

Comments
 (0)