Commit Graph
95 Commits
Author SHA1 Message Date
Ashish Sharma cecbc54c04 fix(esp_tee): fixes double panic when ESP-TEE panics 2026-07-09 11:59:23 +05:30
Ashish Sharma cdedde2fea fix(esp_tee): release SHA held by HMAC after crypto peripheral reset 2026-07-09 11:58:48 +05:30
Laukik Hase 2ad7cb65c6 fix(esp_tee): Add additional input validation checks for TEE service calls 2026-07-09 11:56:01 +05:30
Laukik Hase cf817f6a65 fix(esp_tee): Avoid crypto peripherals reset with esp_restart() from REE
- Reset the crypto peripherals during TEE initialization
2026-07-09 11:56:01 +05:30
Laukik Hase d39a11ace7 fix(esp_tee): Prevent TEE from dispatching the REE heap poisoning callback 2026-07-09 11:56:00 +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
Jiang Jiang Jian 87c540da31 Merge branch 'fix/disable_secure_boot_v2_ecdsa_v5.5' into 'release/v5.5'
Fix/disable secure boot v2 ecdsa (v5.5)

See merge request espressif/esp-idf!49472
2026-06-17 12:00:48 +08:00
harshal.patil faa70e9cd0 fix(esp_tee): Reset crypto peripherals before the panic-induced reset 2026-06-12 16:54:33 +05:30
Aditya Patwardhan 66156479d2 change(secure_boot): mark ECDSA based Secure Boot V2 as insecure on affected SoCs
ECDSA based Secure Boot V2 is not functional for certain input vectors on
ESP32-C5/C61/H2/P4 and on the preview targets ESP32-H4/H21. RSA based Secure
Boot V2 is the recommended scheme where the SoC supports it. This issue will be
fixed in a future hardware ECO revision; more details will be shared through the
hardware errata document.

A new hidden Kconfig option SECURE_BOOT_V2_ECDSA_INSECURE marks the affected
mass-production SoCs (ESP32-C5/C61/H2/P4). On these SoCs, when hardware Secure
Boot V2 is enabled, the ECDSA (V2) signing scheme is no longer offered by
default; it must be turned on explicitly via SECURE_BOOT_V2_FORCE_ENABLE_ECDSA
under "Allow potentially insecure options" (CONFIG_SECURE_BOOT_INSECURE). App
signing without hardware Secure Boot is not affected. Note that ESP32-C61 has no
RSA based Secure Boot V2, so it has no Secure Boot scheme enabled by default.

The preview targets ESP32-H4 and ESP32-H21 mark ECDSA Secure Boot V2 as not
supported in their SoC capabilities instead of using the option above. As
ESP32-H4 has no other Secure Boot V2 scheme, Secure Boot is disabled entirely on
it; ESP32-H21 retains RSA based Secure Boot V2.

The security documentation keeps the ECDSA Secure Boot V2 content visible and
adds a warning describing the limitation (including that ECDSA Secure Boot V2 on
ESP32-C61 is not recommended for production). CI apps that exercise ECDSA Secure
Boot V2 on the affected SoCs set CONFIG_SECURE_BOOT_V2_FORCE_ENABLE_ECDSA
accordingly.
2026-06-10 08:08:07 +05:30
Laukik Hase b471faf803 fix(esp_tee): Harden the TEE secure services against REE manipulation
- `bootloader_flash_execute_command_common`: whitelist the flash command
   opcodes the REE actually uses; reject the rest
- `spi_flash_hal_* services`: a forged `host->driver` could hijack TEE
   control flow since the HAL dispatches through it, so swap
   `host->driver` to a TEE-rodata vtable around each HAL call
- Deny partition table and bootloader writes by default and permit
  bootloader writes only when explicitly enabled via
  `CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED` option
- Protect the TEE-assigned interrupt pin configuration against REE
- Validate nested DS context pointers in start/finish_sign and bound
  the result copy to the SoC max signature size
- Fix the stack usage in service dispatcher argument parsing
2026-06-09 16:20:38 +05:30
Alexey Lapshin 610be5330f fix(esp_tee): fix buffer overflow 2026-06-05 12:25:35 +07:00
Aditya Patwardhan 6f79e8ed4a Merge branch 'feat/esp_tee_backports_v5.5' into 'release/v5.5'
feat(esp_tee): Feature/fixes backports to `release/v5.5`

See merge request espressif/esp-idf!48496
2026-05-28 11:00:10 +05:30
Laukik Hase 2c38c285cf feat(esp_tee): Clear out all sensitive buffers explicitly after TEE crypto operations 2026-05-26 11:44:47 +05:30
Laukik Hase a88716153b feat(esp_tee): Add some required fields in the attestation token
- Chip ID from the ROM
- Device MAC address from eFuse BLK1
- Device Optional Unique ID from eFuse BLK2
2026-05-26 11:34:06 +05:30
Xiao Xufeng be62da6ca4 fix(mspi): fixed possible boot failure in some builds when psram is enabled
A typical scenario is: when XIP on PSRAM enabled, compiler optimization level is Os. Under certain binary layout, boot hangs and backtrace points to `esp_sleep_config_gpio_isolate`.

The root cause is that, during PSRAM initialization, it calls esp_gpio_reserve, which happens to place before the reported function. However, after call, there is no barrier before the clock adjustment in `mspi_timing_enter_low_speed_mode`. The clock gets changed when the cache is still fetching data, resulting in the corrupted data in the end of the cache line.

This commits add spi_flash_disable_cache as a barrier to make sure the cache transactions is finished before the clock switch.
2026-05-19 23:55:01 +08:00
Laukik Hase 1df6b857ac fix(esp_hw_support): Add PMP entry for LP peripherals region on P4 v3+ 2026-05-08 12:43:26 +05:30
harshal.patil 8121f66ec3 feat(cpu_region_protect): Extend PMP memprot for ESP32-P4 V3 2026-05-08 12:43:26 +05:30
Aditya Patwardhan dcb758a30b fix(esp_tee): prevent validation clobbering and deref-before-check
TEE secure-service handlers had two bugs letting REE bypass
pointer-region validation:

1. valid_addr = instead of valid_addr &= in AEAD encrypt/decrypt
   and DS sign handlers, clobbering prior failed checks.
   Impact: REE writes to TEE DRAM via DS signature output, or reads
   TEE DRAM via AEAD output.

2. data->rsa_length dereferenced before data is validated in DS sign
   and DS start_sign handlers.

Fix: use &= for subsequent checks, add early return after initial
data pointer check in DS handlers.
2026-04-30 10:18:00 +05:30
Fu Hanxi 8a9c2cbeb1 tests: change wifi tests expect timeout to 60
- wifi_router
- wifi_ap
- wifi_high_traffic
2026-04-22 09:22:20 +02:00
Laukik Hase afd14ab113 change(esp_tee): Move the internal memory secure service call table to IRAM
- Using PMA, the TEE IRAM is marked as R/X while TEE DRAM is marked as R/W.
  Moving the internal memory secure service call table from DRAM to IRAM
  makes it immutable.
2026-04-14 10:12:26 +05:30
Laukik Hase eebabaff2f fix(esp_tee): Add missing input validation checks for TEE service calls
- MULTI_HEAP_ASSERT for TEE now aborts on failure, instead of ignoring the condition
- Prevent potential TEE OTA write bounds overflow
2026-04-09 16:34:21 +05:30
Laukik Hase 221f0e7c23 ci(esp_tee): Enable heap tracing for the tee_test_fw test-app 2026-03-31 11:09:35 +05:30
Laukik Hase 7d4436028d ci(esp_tee): Optimize the TEE pytest script 2026-03-31 11:09:30 +05:30
Alexey Gerenkov 0c7eac2565 Merge branch 'feature/picolibc_v5.5' into 'release/v5.5'
feat(build): add Picolibc support (v5.5)

See merge request espressif/esp-idf!44108
2026-02-26 18:12:58 +08:00
Laukik Hase 7b3e2b82bb fix(esp_tee): Prevent IV reuse in the TEE secure storage AES-GCM service 2026-02-05 13:45:21 +05:30
Alexey Lapshin 7dd7edabaa fix(esp_tee): build esp_tee only with CONFIG_LIBC_NEWLIB to reduce size 2026-02-02 12:27:27 +07:00
Laukik Hase a45758dede ci(esp_tee): Remove incorrect error checks for TEE flash protection tests
- Also fixed coverity issue from TEE secure storage
2025-11-06 17:20:04 +05:30
Laukik Hase 6bfea8fef8 feat(esp_tee): Enable MSPI tuning for Flash and PSRAM 2025-10-27 11:17:07 +05:30
Laukik Hase 06ba6bb4b4 fix(esp_tee): Use HAL APIs instead of ROM APIs for SPI flash service calls
Currently, REE SPI flash HAL operations are routed as service calls to TEE,
but the TEE implementation incorrectly uses ROM APIs instead of HAL APIs.
This leads to issues and is not the recommended approach.
2025-10-27 11:17:05 +05:30
Mahavir Jain e054d168c1 Merge branch 'fix/c5_tee_sram_prot_v5.5' into 'release/v5.5'
fix(esp_tee): Split TEE SRAM as I/DRAM for ESP32-C5 with PMA (v5.5)

See merge request espressif/esp-idf!42680
2025-10-21 17:25:15 +05:30
Laukik Hase c6168500b9 fix(esp_tee): Sync TEE-REE intr thresholds during service calls from critical sections
- Previously, only the U-mode interrupt threshold was raised in REE critical sections,
  leaving M-mode at the lowest level.
- As a result, when a service call transitioned to M-mode, all interrupts were still
  allowed to fire, including those that should have been masked.
2025-10-17 19:35:55 +05:30
Laukik Hase 2d494c5df6 feat(esp_tee): Reclaim unused TEE IRAM memory as heap
- Changed the default TEE code placement to use the flash
  text section instead of IRAM text, making it consistent
  with the default data placement.
2025-10-17 10:41:55 +05:30
Laukik Hase 1d563150b0 fix(esp_tee): Split TEE SRAM as I/DRAM for ESP32-C5 with PMA 2025-10-17 10:40:08 +05:30
Laukik Hase 50d2ecd93f refactor(esp_tee): Remove the spi_flash_erase_chip service call
- Also fix coverity bug from TEE HMAC-PBKDF2 routine
2025-10-14 10:12:36 +05:30
Laukik Hase 73d0dadd6b fix(esp_tee): Correct flash operation bound checks to handle all overlap cases
- Ensure bound checks correctly handle all scenarios, including
  when a requested operation's (SPI0/1) range fully contains the
  TEE-protected region.
- Disable delegation of INTWDT timeout and Cache error interrupts as they reset
  the device after the panic handler
2025-10-14 10:12:28 +05:30
Laukik Hase 22fe84bf91 ci(esp_tee): Disable the TEE test-apps for ESP32-C5 temporarily 2025-10-14 10:12:13 +05:30
Laukik Hase 78737a757a feat(esp_tee): Added support for PBKDF2-based (HMAC) ECDSA signing 2025-10-14 10:12:13 +05:30
Laukik Hase d49055e307 fix(esp_tee): Skip taking the service call mutex when in critical sections
- Fixes INT_WDT timeouts with mmap operations
- Add test-case for verifying parallel service calls
2025-10-14 10:12:12 +05:30
Laukik Hase 26014bb404 feat(esp_tee): ASM routine fixes and improvements
- Fix incorrect setting in the edge interrupt acknowledgement API
- Avoid executing the service call dispatcher in the U-mode ecall,
  rather execute `mret` to jump it
- Avoid `t1` register corruption when processing `ecall`
- Switch back to the bootloader stack from TEE stack after the
  execution of the entire TEE initialization routine
2025-10-14 10:12:12 +05:30
Laukik Hase 4aafa4d11b feat(esp_tee): Miscellaneous fixes and updates
- Rename `tee_test_fw` app configs for better CI tracking
- Decrease the lower bound of TEE I/DRAM config options
- Trim the TEE test-apps build
- Improve the TEE/REE OTA pytest script with additional checks
- Fix build issues when `tee_sec_storage`/`tee_ota_ops` are a
  a part of the project build but ESP-TEE is disabled
2025-10-14 10:12:12 +05:30
Laukik Hase 9e487873c9 ci(esp_tee): Enable the TEE test-apps for ESP32-C5 2025-10-14 10:12:11 +05:30
Laukik Hase 12ab50dc54 ci(esp_tee): Refactor the ESP-TEE test-cases
- Improve the interrupt-related test cases
- Fix potential issues in the task-switching test
  during secure service calls
2025-10-14 10:12:11 +05:30
Laukik Hase 1815e2e4f2 feat(esp_tee): Support for ESP32-C5 - the esp_tee component 2025-10-14 10:12:10 +05:30
Jiang Jiang Jian 3c39b32195 Chip/support esp32c61 v5.5 2025-07-22 12:21:36 +08:00
harshal.patil 5210e576d5 feat(mbedtls/sha): New API for setting SHA mode 2025-06-18 16:46:39 +05:30
Laukik Hase d482206483 ci(esp_tee): Enable the tee_test_fw test app for ESP32-H2 2025-05-21 10:06:17 +05:30
Laukik Hase eca7c7296c feat(esp_tee): Support for ESP32-H2 - the esp_tee component 2025-05-21 10:06:16 +05:30
Laukik Hase c16fc04c2d docs(esp_tee): Revise TEE secure storage and related documentation 2025-05-04 18:22:22 +05:30
Laukik Hase 033397b877 fix(esp_tee): Add standard newlib function stubs to resolve build warnings
- Disable C++ exceptions for TEE build to reduce flash footprint
2025-05-04 18:03:30 +05:30
Laukik Hase 3bb3f9362e refactor(esp_tee): Update TEE secure storage examples and test-apps 2025-05-04 18:03:30 +05:30