Commit Graph

70 Commits

Author SHA1 Message Date
harshal.patil
950c9b1c38 fix(esp_security): cover the crypto reset coupling in the driver locks
A peripheral's reset also resets the ones it occupies, so a lock has to cover
both. Gate the ECDSA MPI lock on SOC_ECDSA_USES_MPI rather than the runtime
ecdsa_ll_is_mpi_required() and set that capability on C5, lock the Key Manager
path in esp_key_mgr.c, clean HMAC after its reset, and enable DS before the
primitives its reset covers.
2026-09-08 19:47:32 +05:30
radek.tandler
da41d31a14 fix(esp_security): Stop ECDSA and Key Manager resets from corrupting concurrent crypto
ECDSA enable pulses a reset that also holds SHA in reset, and SHA shares
its DMA with AES. Key Manager enable pulses a reset that also covers the
XTS-AES flash encryption key-usage selector. Neither path was serialized
against those victims, so a hardware ECDSA/HMAC/DS operation could
corrupt a concurrent SHA/AES transfer or an in-flight encrypted flash
read.

- Take the SHA/AES lock inside esp_crypto_ecdsa_lock_acquire(), before
  MPI, matching the DS lock order (sha_aes < mpi)
- Add esp_crypto_key_mgr_enable_periph_clk_no_reset() and switch ECDSA,
  HMAC and DS to it; they only need the key-usage selector writable
- Hold esp_crypto_key_manager_lock across those clock enable/disable
  pairs so selector writes stay serialized without resetting KM
2026-09-08 19:46:19 +05:30
Laukik Hase
f241c77737 fix(esp_tee): Snapshot input arguments in TEE memory before secure service execution 2026-09-04 10:34:49 +05:30
Ashish Sharma
28268f348c fix(esp_security): don't reset DS peripheral in esp_hmac_calculate
esp_hmac_calculate() enabled and reset the Digital Signature (DS)
peripheral, but HMAC has no dependency on DS (the dependency runs the
other way: a DS operation uses HMAC/SHA).

The DS peripheral drives the RSA (MPI) accelerator internally, so pulsing
the DS reset also resets the RSA datapath. This coupling exists on every
target that has the DS peripheral: the MPI reset routine itself clears the
DS reset "otherwise RSA is held in reset".

esp_hmac_calculate() holds only the HMAC and SHA/AES locks, not the MPI
lock, so it can corrupt a concurrent RSA/MPI operation. On multi-core
targets (e.g. ESP32-P4, ESP32-S31, ESP32-S3) an HMAC on one core resets an
RSA op running on another core; on single-core targets (e.g. ESP32-C5) the
same corruption happens when an HMAC preempts an in-flight RSA op. The
result is a wrong RSA result or a crash in the computation.

Remove the DS peripheral enable/reset from the HMAC path. SHA, which HMAC
depends on, is enabled independently, so the HMAC output is unchanged.
This also drops a few redundant register writes.
2026-08-31 10:56:56 +08:00
harshal.patil
6459793edd 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.
2026-08-21 11:47:41 +05:30
harshal.patil
024de60208 fix(esp_common/esp_fault): make ESP_FAULT_ASSERT survive optimization
ESP_FAULT_ASSERT(C) was silently deleted by the optimizer when C is a cached
flag/status already proven by a preceding `if (!C) return/goto`: the compiler
folds C to a constant and drops all three checks, removing the fault-injection
protection with no warning.
2026-06-22 11:20:04 +05:30
harshal.patil
fcb5e51c6d fix(esp_security): Add more validation checks 2026-05-15 00:13:34 +05:30
harshal.patil
8b2e942e4e change(esp_key_mgr): Store key_len field in the key_info
- Update the Key Manager key types to be generic
- Define a new enum to determine the length of the keys
- Refactor the Key Manager driver support generic key types and key lengths
- Also store key deployment mode in the key recovery info
2026-05-15 00:13:34 +05:30
harshal.patil
acd9cf6271 fix(esp_security/esp_key_mgr): Fix missed error codes and some cleanup 2026-05-15 00:13:30 +05:30
harshal.patil
e0211edf0e fix(esp_security): Enable ECC clock while using the Key Manager's ECDH key deployment mode 2026-05-05 13:37:00 +05:30
harshal.patil
52a8c04bd6 test(esp_security): Update the Key Manager test to support ESP32-P4 2026-04-28 21:27:40 +05:30
harshal.patil
beaa37a2e6 fix(esp_security): guard key manager APIs against unsupported chip revs
On ESP32-P4 rev < 3.0, Key Manager is software-disabled, but the public
esp_key_mgr.h APIs had no runtime check.
Calls using HMAC/DS/PSRAM key types fell through to
HAL_ASSERT("Unsupported ...") paths in key_mgr_ll.h. Gate
each public API with key_mgr_ll_is_supported() and return
ESP_ERR_NOT_SUPPORTED cleanly instead.
2026-04-28 15:02:40 +05:30
harshal.patil
8f9b860131 fix(esp_security): Fixes incorrect key manager configuration for ESP32-P4 rev < 3 2026-04-28 14:55:51 +05:30
harshal.patil
9c86e8bdc1 fix(esp_security): Enable Key Manager clocks even for efuse key operations
The Key Manager holds a key usage register, thus, the Key Manager peripheral
clock must be enabled even for efuses-based key operations to route the
crypto operations to correctly to the efuses (default is Key Manager)
2026-04-06 18:36:17 +05:30
harshal.patil
8dafc3b75f feat(esp32p4): Support newer Key Manager key sources for ESP32-P4 V3 2026-04-06 18:11:43 +05:30
Xiao Xufeng
07cc2c7d3b fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption
This reverts commit 7145fc9558.
2026-02-06 11:44:52 +08:00
Xiao Xufeng
343fbafafe Revert "fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption"
This reverts commit cca0ac8c56.
2026-01-15 23:52:41 +08:00
Xiao Xufeng
08f5f0d66b fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption
This reverts commit 7145fc9558.
2025-12-24 02:31:57 +08:00
Xiao Xufeng
187f43a3bb Revert "fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption"
This reverts commit 3c5d2e6b58.
2025-12-17 03:33:30 +08:00
armando
cdff2570c7 ci(p4): disable p4 rev3 invalid tests temporarily 2025-11-20 11:33:36 +08:00
Jiang Jiang Jian
376f396e20 Merge branch 'bugfix/esp32c5_encrypted_flash_write_v5.5' into 'release/v5.5'
fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption (v5.5)

See merge request espressif/esp-idf!43326
2025-11-17 15:02:40 +08:00
Mahavir Jain
3fd00b4d80 fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption
Encrypted flash write operation sometimes result in random corruption in
certain bytes. Root cause points to sudden current surge due to involvement of
encryption block overwhelming LDO supply. More details will be provided
in the ESP32-C5 SoC Errata document.

This fix limits the CPU clock to 160MHz for flash encryption enabled
case. Failing encrypted flash write tests could successfully pass in
this configuration. Going ahead, a dynamic clock adjustment in flash
driver will be considered to mitigate this issue.
2025-11-13 13:26:06 +05:30
harshal.patil
6ea63548d4 fix(esp_security): Set WR_DIS_SECURE_BOOT_SHA384_EN by default when
Flash Encryption Release mode is enabled and Secure Boot P384 scheme not is enabled.
2025-11-11 17:53:04 +05:30
harshal.patil
7b57a1cd16 fix(esp_security): Fix undefined efuse build failure in case of ESP32-P4
- The `wr_dis` efuse bit corresponding to `SECURE_BOOT_SHA384_EN` is absent in P4
2025-11-11 17:53:04 +05:30
Mahavir Jain
042f29dd66 Merge branch 'fix/change_write_protection_bit_of_shared_security_efuses_v5.5' into 'release/v5.5'
Reorder write protection bits of some shared security efuses (v5.5)

See merge request espressif/esp-idf!42033
2025-10-15 09:38:59 +05:30
harshal.patil
6ab5a2f883 fix(esp_security): Configure the Key Manager to use XTS-AES efuse key by-default 2025-10-13 10:40:50 +05:30
harshal.patil
70a8b4d842 fix(bootloader_support): Reorder write disabling ECDSA_CURVE_MODE 2025-10-13 10:40:16 +05:30
harshal.patil
d902072d80 fix(bootloader_support): Reorder write protection bits of some shared security efuses 2025-10-13 10:40:16 +05:30
harshal.patil
ae7d7542e0 fix(esp_key_mgr): Fix incorrect key manager state management 2025-09-12 17:26:27 +05:30
harshal.patil
f6f15bf91a change(mbedtls/ecdsa): The ECDSA module of ESP32-H2 ECO5 does not use MPI module 2025-08-13 18:53:19 +05:30
Jiang Jiang Jian
3c39b32195 Chip/support esp32c61 v5.5 2025-07-22 12:21:36 +08:00
nilesh.kale
c65858287a feat: enabled secure boot support esp32h21 2025-04-25 17:48:25 +05:30
Laukik Hase
fc4802c0d6 feat(esp_tee): Protect the HMAC and DS peripherals from REE access 2025-04-16 19:19:04 +05:30
Laukik Hase
1c4969bc47 feat(esp_security): Add a TEE-specific crypto lock layer with stub implementations 2025-04-16 19:19:03 +05:30
nilesh.kale
aae4bfb6f3 feat: enable ecdsa support for esp32h21
This commit enabled suppot for ECDSA peripheral in ESP32H21.
2025-04-14 10:26:46 +05:30
Laukik Hase
bd314c2460 refactor(esp_tee): Update the SHA clock configuration service call 2025-04-04 10:31:28 +05:30
Laukik Hase
3e95020c59 refactor(esp_security): Introduce dedicated APIs for crypto clock configuration 2025-04-04 10:31:27 +05:30
Mahavir Jain
ce7ec7f19f Merge branch 'feature/enable_hmac_and_ds_support_for_esp32h21' into 'master'
feat: enabled hmac and ds support in esp32h21

Closes IDF-11495 and IDF-11497

See merge request espressif/esp-idf!37085
2025-03-21 17:23:46 +08:00
Chen Jichang
45ba78940f feat(esp32h4): finnal introduce hello world 2025-03-19 18:48:41 +08:00
nilesh.kale
f794eb9b2d feat: enabled hmac and ds support in esp32h21
This commit enables support for HMAC and DS in ESP32H21
2025-03-13 10:23:11 +05:30
igor.udot
daf2d31008 test: format all test scripts 2025-03-05 12:08:48 +08:00
Chen Jichang
6f83f39dce feat(esp32h4): introduce target esp32h4(stage 1) 2025-02-08 17:07:44 +08:00
laokaiyao
9269b785f8 refactor(ecdsa): rely on efuse to get chip revision 2025-01-24 11:50:17 +08:00
Aditya Patwardhan
d8d9ba3dc2 fix(soc): Fixed ECDSA register compatibility 2025-01-24 11:50:17 +08:00
Aditya Patwardhan
bef2a72ecb fix(hal): Make the ECDSA countermeasure dynamically applicable
This commit makes the ECDSA countermeasure dynamically applicable
    across different revisions of the ESP32H2 SoC.
2025-01-24 11:50:17 +08:00
Mahavir Jain
6875cbf022 feat(ecc): enable ECC constant time mode for ESP32-H2 ECO5 2025-01-24 11:50:17 +08:00
Gao Xu
54f501a2fc Merge branch 'feat/h21_introduce_step8' into 'master'
feat(esp32h21): introduce hello world to ESP32H21 (stage8)

See merge request espressif/esp-idf!35874
2024-12-31 10:39:21 +08:00
gaoxu
25731d0c1e feat(esp32h21): finnal introduce hello world support 2024-12-30 20:14:40 +08:00
Marek Fiala
2c814ef2fa feat(tools): Enforce utf-8 encoding with open() function 2024-12-27 17:12:21 +08:00
gaoxu
64bbb53b8f feat(esp32h21): introduce target esp32h21(stage 1) 2024-11-12 15:42:27 +08:00