Commit Graph

129 Commits

Author SHA1 Message Date
Mahavir Jain
0d1b945b16 Merge branch 'fix/fix_clk_tree_abba_deadlock' into 'master'
fix(esp32s31): break clk_tree and deadlock with PERIPH_RCC

Closes PM-871

See merge request espressif/esp-idf!52621
2026-09-13 16:40:51 +05:30
Mahavir Jain
957618d083 Merge branch 'fix/buildv2_fault_assert_opt_check' into 'master'
fix(esp_security): use EXECUTABLE in fault_assert_opt_check

See merge request espressif/esp-idf!52640
2026-09-11 09:53:36 +05:30
Jiang Jiang Jian
342dd1f9c4 Merge branch 'feat/esp_idf_h4_clk_tree_management' into 'master'
Feat/esp idf h4 h21 clk tree management

Closes PM-858 and PM-653

See merge request espressif/esp-idf!50653
2026-09-11 10:38:04 +08:00
Sudeep Mohanty
671713d66f fix(esp_security): use EXECUTABLE in fault_assert_opt_check
The post-build check named the executable target directly, which does not exist
under Build system v2. Query the EXECUTABLE build property instead.
2026-09-09 10:53:14 +02:00
wuzhenghui
b72f7a91ce fix(esp32s31): break clk_tree and RCC ABBA deadlock
Keep gated-clk refcnt under s_clk_tree_spinlock only, and call
esp_crypto_common_clk_enable outside PERIPH_RCC so crypto (RCC→clk_tree)
and modem (clk_tree→RCC) cannot deadlock on periph_spinlock

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 14:34:07 +08:00
harshal.patil
de3a510a18 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 14:03:50 +05:30
radek.tandler
ce27a6e7e0 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 14:03:50 +05:30
Ashish Sharma
0eabc80893 feat(sha): add the esp_sm3 API 2026-09-04 14:26:23 +08:00
wuzhenghui
2a5ab24ec4 change(esp_security): select crypto clock source before enable on s31 2026-09-01 16:53:39 +08:00
Laukik Hase
1fbeea3393 fix(esp_tee): Snapshot input arguments in TEE memory before secure service execution 2026-08-28 10:20:55 +05:30
hebinglin
53adc12692 feat(esp_security): make esp32h4 esp32h21 on-demand crypto clock management optional 2026-08-27 23:16:00 +08:00
Ashish Sharma
34799be7b9 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-20 18:52:58 +08:00
Wu Zheng Hui
aac7f7ea47 Merge branch 'feat/support_esp32s31_clock_tree_management' into 'master'
feat: support esp32s31 clock tree management

Closes PM-630

See merge request espressif/esp-idf!48934
2026-07-24 20:11:45 +08:00
harshal.patil
a7b29bfda9 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-07-22 19:58:23 +05:30
wuzhenghui
09253d3f48 feat(esp_security): make esp32s31 on-demand crypto clock management optional 2026-07-22 16:32:46 +08:00
wuzhenghui
a04dc898db feat(esp_security): support s31 security clock management 2026-07-22 16:32:45 +08:00
nilesh.kale
fe18ed97dd feat: added call to aquire clock source for H4 and H21 AES crypto 2026-07-06 10:12:35 +05:30
Mahavir Jain
625ee1abb7 Merge branch 'fix/harden_esp_security' into 'master'
fix(esp_security): harden crypto peripheral error handling

Closes SEC-236, SEC-351, SEC-352, SEC-353, SEC-355, SEC-356, and SEC-357

See merge request espressif/esp-idf!49828
2026-07-03 09:11:33 +05:30
Aditya Patwardhan
36090b7161 feat(esp-tls): Add unified private key interface via esp_key_config_t
Add ESP_KEY_SOURCE_BUFFER and ESP_KEY_SOURCE_PSA key sources so all
hardware backends (DS, ECDSA, secure element) are accessed via PSA
key IDs through a single esp_tls_cfg_t.client_key field.
2026-06-25 11:31:37 +05:30
Ashish Sharma
1b8a365f16 fix(esp_security): harden crypto peripheral error handling 2026-06-19 18:27:22 +08:00
harshal.patil
6b417e9d47 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-17 16:45:29 +05:30
wuzhenghui
69d548c8d1 feat(esp_security): suppoer s31 security clock management 2026-06-10 21:20:04 +08:00
Guillaume Souchere
33e774397c Merge branch 'feat/error-code-registration' into 'master'
feat(esp_common): implement composable error code registration via link-time arrays

Closes IDF-15105 and IDF-15486

See merge request espressif/esp-idf!46125
2026-06-01 09:40:37 +02:00
Guillaume Souchere
d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00
nilesh.kale
fe257f699e feat: enable Secure Boot, Flash Encryption and Key Manager support for S31 2026-05-26 12:57:34 +08:00
nilesh.kale
34e24e1ed3 fix: disable Key Manager and ECDSA TRNG tests for S31 temporarily 2026-05-20 10:17:34 +05:30
nilesh.kale
a530aab0a6 feat: enable key manager and HUK support for S31 2026-05-20 10:17:34 +05:30
Aditya Patwardhan
e9a9091b59 feat(hal): add HMAC and Digital Signature support for esp32s31
Co-authored-by: Nilesh Kale <nilesh.kale@espressif.com>
2026-05-20 10:17:34 +05:30
Chen Jichang
645ff40cde ci(esp32h4): enable ci target test 2026-05-11 16:48:58 +08:00
muhaidong
14e964c0fa fix(esp_security): fix ECDH1 key manager multi-stage helper 2026-05-11 12:03:17 +05:30
Mahavir Jain
bc8db060f1 Merge branch 'feat/key_manager_ecdh1_key_deployment_mode' into 'master'
Key Manager ECDH1 key deployment mode

Closes IDF-15582

See merge request espressif/esp-idf!47988
2026-05-11 09:03:10 +05:30
harshal.patil
9aba184c43 feat(esp_security): add ECDH1 deployment mode to Key Manager driver 2026-04-30 09:29:40 +05:30
harshal.patil
c9366ac4b5 fix(esp_security): Fix the flipped key info slot when deploying a Key Manager-based key 2026-04-30 09:17:38 +05:30
harshal.patil
8ce8d8919b fix(esp_security): Enable ECC clock while using the Key Manager's ECDH key deployment mode 2026-04-30 09:17:31 +05:30
harshal.patil
8bfc4f7255 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-27 15:18:34 +05:30
Mahavir Jain
80116d4e07 Merge branch 'feat/add_hmac_support_for_esp32h4' into 'master'
feat: added support for HMAC in ESP32H4

Closes IDF-12257

See merge request espressif/esp-idf!44647
2026-04-15 15:18:03 +05:30
Aditya Patwardhan
bfd3e191bc feat: enable AES, SHA, RSA and ECC support for ESP32S31
Co-authored-by: Nilesh Kale <nilesh.kale@espressif.com>
2026-04-13 10:20:44 +05:30
nilesh.kale
b3243dc6de feat: enable HMAC peripheral support for ESP32-H4 2026-04-09 14:29:57 +05:30
Harshal Patil
876b9581bd Merge branch 'fix/enable_key_mgr_clk_for_efuse_key_ops' into 'master'
Enable Key Manager clock even for efuses-based key operations

See merge request espressif/esp-idf!46740
2026-03-25 21:37:53 +05:30
hebinglin
474d89b4c2 fix(clk): update H21 ECO1 to use 64MHz clock for mspi 2026-03-25 15:38:49 +08:00
harshal.patil
28736a81fa 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-03-25 10:38:44 +05:30
harshal.patil
ccc48c3980 fix(esp_security): Fixes incorrect key manager configuration for ESP32-P4 rev < 3 2026-03-24 15:23:23 +05:30
harshal.patil
398d9ea9cd fix(esp_security): Add more validation checks 2026-03-20 11:15:23 +05:30
harshal.patil
0db717b9ec feat(esp_ds): Support using the AES key used by DS peripheral for encrypting params 2026-03-20 11:15:23 +05:30
harshal.patil
5f647c0ba3 docs(key-manager): Add Key-Manager peripheral related documentation 2026-03-18 16:27:39 +05:30
wuzhenghui
51cca0a88f feat(esp_hw_support): support clock tree management for esp32p4 2026-03-04 20:10:54 +08:00
nilesh.kale
0fd1a4c9f8 test(esp_security): re-enable crypto drivers test app for ESP32P4
Also remove common_components dep for security-related tests
2026-02-10 17:48:55 +05:30
harshal.patil
6964de6f45 test(esp_security): Update the Key Manager test to support ESP32-P4 2026-02-10 17:48:52 +05:30
Xiao Xufeng
0a6c922059 fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption
This reverts commit 7145fc9558.
2026-01-28 11:15:30 +05:30
igor.udot
4c26ab876b ci: update build-test-rules to use common_components 2026-01-23 10:14:09 +08:00