Commit Graph

1065 Commits

Author SHA1 Message Date
wuzhenghui
4166ee869d test(mbedtls): smoke-test crypto HW after PD_TOP lightsleep
Add a mbedtls_ut case that enters TOP PD light sleep then runs minimal
AES/SHA/MPI/ECC/ECDSA ops, catching crypto modules left unusable after wake.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 17:13:29 +08:00
Chen Jichang
8cb3743b7c ci(esp32h4): disable h4 build and target test on unsupported release branch 2026-09-07 15:48:11 +08:00
Jiang Jiang Jian
27892e5e12 Merge branch 'fix/tee_reentrant_svc_and_non_det_sign_v6.1' into 'release/v6.1'
feat(esp_tee): Backports to v6.1

See merge request espressif/esp-idf!52291
2026-09-04 23:17:06 +08:00
morris
28a4aaa1db Merge branch 'fix/psram-ecc-mspi-dma-align_v6.1' into 'release/v6.1'
fix(mspi): handle PSRAM ECC DMA alignment across MSPI users (v6.1)

See merge request espressif/esp-idf!52363
2026-09-04 18:48:05 +08:00
Mahavir Jain
19e1a190fa Merge branch 'feat/enable_cross_signed_cert_suppport_default_v6.1' into 'release/v6.1'
feat(mbedtls): enable cross signed certificate verification support by default (v6.1)

See merge request espressif/esp-idf!50534
2026-09-04 13:32:49 +05:30
Jiang Jiang Jian
76838eb605 Merge branch 'fix/mbedtls_gcm_multipart_and_ecp_pubkey_v6.1' into 'release/v6.1'
Fix/mbedTLS port layer security fixes (394, 1214, 1206) (v6.1)

See merge request espressif/esp-idf!52194
2026-09-04 16:00:34 +08:00
Mahavir Jain
156d8938f1 Merge branch 'fix/crt-bundle-unaligned-reads_v6.1' into 'release/v6.1'
fix(mbedtls): read crt bundle byte-wise to avoid misaligned flash access (v6.1)

See merge request espressif/esp-idf!51723
2026-09-04 11:00:13 +05:30
Laukik Hase
f8d0bae631 feat(esp_tee): Disable the MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS option for TEE build 2026-09-04 10:20:21 +05:30
Laukik Hase
4057fcda2d fix(esp_tee): Snapshot input arguments in TEE memory before secure service execution 2026-09-04 10:20:21 +05:30
Laukik Hase
02bf7ea021 change(esp_tee): Force non-deterministic ECDSA signing for TEE secure storage keys 2026-09-04 10:20:20 +05:30
Laukik Hase
bc6b8f7fa5 feat(esp_tee): Use CTR-DRBG for assisting random number generation in TEE
- For ESP-TEE, fault-assert in `esp_random()` if the RNG is held in a
  freeze state
2026-09-04 10:20:20 +05:30
Mahavir Jain
e44c357a02 fix(mbedtls): read crt bundle byte-wise to avoid misaligned flash access
The offset table and the per-cert length fields of the certificate
bundle were read through uint16_t*/uint32_t* casts, which compile to
halfword/word loads at addresses with no alignment guarantee: bundles
supplied via esp_crt_bundle_set() can start anywhere, and cert entries
are byte-packed, so their 16-bit fields land at arbitrary offsets.

On chips with SOC_CPU_MISALIGNED_ACCESS_ON_PMP_MISMATCH_ISSUE (DIG-694:
ESP32-C6/H2/H21) a misaligned load from memory-mapped flash can take a
spurious "Load access fault" when it sits within two instructions of an
access to a differently-permissioned region, observed as a crash in
esp_crt_check_bundle()/CA callback during TLS handshakes with a bundle
that happened to be placed at an odd address.
2026-09-04 11:51:56 +08:00
Chen Jichang
bd2d64bffb refactor(gdma): increase performance and optimize api 2026-09-03 19:09:30 +08:00
Chen Jichang
305d434bda feat(mspi): split dma and mspi alignment 2026-09-03 19:09:30 +08:00
Chen Jichang
ef4387144e test(aes): add aes psram ecc test 2026-09-03 19:09:30 +08:00
Ashish Sharma
bcf41920e2 fix(mbedtls): reject an all-zero AES block output in the encrypt direction 2026-09-03 16:10:29 +08:00
Ashish Sharma
9c72f7a642 fix(mbedtls): use pointer-width types for dynamic buffer msg offsets 2026-09-03 16:09:57 +08:00
Ashish Sharma
94e538c2dc test(mbedtls): add test for unaligned multipart AES-GCM streaming 2026-09-03 16:09:57 +08:00
Ashish Sharma
613469ffe7 fix(mbedtls): preserve AES-GCM stream state across multipart updates 2026-09-03 16:09:57 +08:00
Ashish Sharma
0ffb8daf92 fix(mbedtls): bound public-key coordinate copy in esp ecp_check_pubkey 2026-09-03 16:09:57 +08:00
Ashish Sharma
b508d7bf9b feat(mbedtls): enable cross signed certificate verification support by default 2026-09-02 13:58:29 +05:30
harshal.patil
bffba12969 fix(mbedtls): validate cert header extent before reading it in bundle check
esp_crt_check_bundle() read the 4-byte certificate header (name_len,
key_len) via esp_crt_get_len() after only checking that the cert's
start offset lies inside the bundle, so a crafted bundle whose first
or last certificate starts within the final 3 bytes caused a transient
out-of-bounds read of up to 3 bytes before the extent check rejected
it. Require the whole header to lie inside the bundle before reading
it.
2026-08-28 21:48:26 +05:30
Mahavir Jain
7be5451cd6 Merge branch 'fix/harden_mbedtls_port_layer_v6.1' into 'release/v6.1'
fix(mbedtls): harden port layer to zeroize sensitive material (v6.1)

See merge request espressif/esp-idf!50315
2026-08-27 12:30:19 +05:30
Mahavir Jain
7b18822f6d Merge branch 'fix/esp32s2_aes_dma_psram_partial_block_hang_v6.1' into 'release/v6.1'
Avoid ESP32-S2 Crypto DMA stall on PSRAM output with partial blocks (v6.1)

See merge request espressif/esp-idf!51874
2026-08-27 12:28:47 +05:30
harshal.patil
e5d9a7f1a5 test(mbedtls): add partial-block PSRAM coverage for AES and AES-GCM
Extend the CTR test data length to 6433 bytes so the trailing partial
block is exercised with external RAM buffers (which stalls the ESP32-S2
Crypto DMA on an unfixed driver), and add AES-GCM PSRAM tests verified
against internal RAM references.
2026-08-21 10:30:05 +05:30
harshal.patil
da744fe061 fix(mbedtls/aes): fix ESP32-S2 Crypto DMA stall on PSRAM output with partial blocks
The ESP32-S2 Crypto DMA in-channel stalls silently when a receive
descriptor list transitions from external to internal RAM. The AES
driver hits this when a PSRAM-output operation has a trailing partial
block, as the internal stream descriptor is linked after the external
RAM data descriptors.

- esp_aes_process_dma(): process the block-aligned part and the partial
  block as two separate DMA operations, keeping each descriptor list
  uniform
- crypto_dma_ll_reset(): also reset the in-channel (per the TRM receive
  reset sequence), otherwise stale state from a preceding external-RAM
  operation corrupts the next operation's output

The GCM DMA path is unaffected; it never operates on PSRAM buffers.
2026-08-19 13:26:27 +05:30
Ashish Sharma
27e5155ce3 fix(mbedtls): revert to non constant time rsa key gen 2026-07-21 16:24:06 +08:00
Ashish Sharma
844403b5b9 test(mbedtls): add PSA RSA key generation test
The test only runs with MBEDTLS_CONSTANT_TIME_PRIME_GEN disabled:
with the constant-time prime generation that is now the default,
RSA-2048 key generation takes over a minute on most targets (~86 s on
ESP32-S3), exceeding the test timeout and starving the task watchdog.
2026-07-20 17:17:04 +08:00
Ashish Sharma
3321e2adf8 feat(mbedtls): add option to choose constant-time prime generation
mbedtls 4.1.1 made the small-factor test in prime generation
constant-time (a CT GCD against the product of primes up to 997, run
for every prime candidate). This makes RSA key generation roughly ten
times slower on ESP chips and starves the idle task since the software
GCD never yields, tripping the task watchdog.

Add MBEDTLS_CONSTANT_TIME_PRIME_GEN under the new "Security hardening"
menu, default y so the upstream constant-time behavior ships as the
secure default. When disabled, esp_config.h defines
MBEDTLS_MPI_PRIME_SIEVE_VARIABLE_TIME and mbedtls uses the pre-3.6.7
variable-time trial division, restoring key generation performance on
devices where no untrusted co-resident code could time key generation.
2026-07-20 17:17:04 +08:00
Ashish Sharma
ad19b932da feat(mbedtls): update to version 4.1.1 2026-07-20 17:17:04 +08:00
Jiang Jiang Jian
a43c51681a Merge branch 'task/buildv2_full_pipeline_v6.1' into 'release/v6.1'
Enable full buildv2 pipeline (v6.1)

See merge request espressif/esp-idf!50351
2026-07-17 18:20:09 +08:00
Ashish Sharma
4173ed018a fix(mbedtls): harden port layer to zeroize sensitive material 2026-07-17 17:14:10 +08:00
Jiang Jiang Jian
947e534927 Merge branch 'fix/mmap_cache_flash_wr_v6.1' into 'release/v6.1'
fix(mmap): fixed mmap read data wrong when flash being erased/written and cache not disabled (v6.1)

See merge request espressif/esp-idf!50117
2026-07-17 10:30:14 +08:00
Aditya Patwardhan
9dc17f98b0 Merge branch 'backport/44987_v6.1' into 'release/v6.1'
feat(esp-tls): Added a PSA driver for Secure Element (backport v6.1)

See merge request espressif/esp-idf!50334
2026-07-16 15:37:49 +05:30
Xiao Xufeng
3e8389cc31 fix(mmap): fixed some API read wrong data via mmap when flash being erased/written while XIP on PSRAM
Before:

The cache won't be disabled when XIP on psram. But during flash
erasing/programming, read data will be courrupt.

When XIP in psram is enabled, the image is not mapped to the cache so
usually there will be no flash access. The only way to read from flash
is via the driver or use mmap. The driver has protection during erasing,
while th mmap region not.

Now:

Mmap APIs provide a flag to make mmap->unmap region mutually exclusive
to flash erase/programming when XIP from psram. SPI Flash write APIs
will benefit from this. When the flag is used, no concurrent access to
mapped region will happen while writing; otherwise the cache will be
disable to avoid data corruption.

Most ESP-IDF APIs calls mmap with this flag. As for users calling
mmap-like APIs directly, they can choose whether to enable this by a
flag.

Closes https://github.com/espressif/esp-idf/issues/14897
2026-07-15 18:57:08 +08:00
Ashish Sharma
8d8068aee3 fix(esp_tee): fix DS-lock leak, intr-matrix OOB, calloc overflow, attestation leak 2026-07-13 14:40:44 +08:00
Ashish Sharma
e4304fab76 fix(mbedtls): validate crypto input lengths (TEE OOB, auth-bypass, overflows) 2026-07-13 14:40:44 +08:00
Laukik Hase
87a5664883 ci(esp_tee): Fix tee_cli_app build failure due to heap size overflow
- Also fix the `unused variable` warning while builing the PSA
  AES tests with `tee_test_fw` app
2026-07-10 10:30:02 +05:30
Mahavir Jain
f0fbd9d9fa Merge branch 'fix/tls1_3_dynamic_buffer_server_crash_v6.1' into 'release/v6.1'
fix(mbedtls): fixes TLS1.3 server failing with dynamic buffer (v6.1)

See merge request espressif/esp-idf!50386
2026-07-10 09:38:26 +05:30
nilesh.kale
c9e90831b8 feat: enable AES GCM support for ESP32-S31 2026-07-06 15:08:38 +05:30
Ashish Sharma
8ca83a0fa9 fix(mbedtls): fixes TLS1.3 server failing with dynamic buffer 2026-07-06 15:18:23 +08:00
Sudeep Mohanty
0a89c2e432 fix(test_apps): override config defaults unused by these tests
These tests enable features they do not use -- the VFS console, Wi-Fi task core pinning, and
the DS peripheral -- which shift memory layout, interrupt allocation, and peripheral access
enough to fail them. Override the unused options in each test's sdkconfig and ignore the
resulting unknown-symbol build warnings.
2026-07-03 19:18:42 +02:00
Jiang Jiang Jian
a6f24da33e Merge branch 'bugfix/mbedtls_rsa_base_reduction_hw_crt_v6.1' into 'release/v6.1'
fix(mbedlts): Enable hardware CRT for RSA-4096 via base reduction (v6.1)

See merge request espressif/esp-idf!49849
2026-07-03 21:42:10 +08:00
Mahavir Jain
0362f806e1 Merge branch 'feat/psa_its_custom_backend_v6.1' into 'release/v6.1'
Support custom storage backend for persistent PSA keys (v6.1)

See merge request espressif/esp-idf!49151
2026-07-03 11:34:23 +05:30
Mahavir Jain
40974f42a3 Merge branch 'fix/aes_dma_psram_encrypted_mem_s31_v6.1' into 'release/v6.1'
fix(mbedtls/aes): Fix AES-DMA over encrypted PSRAM on ESP32-S31 (v6.1)

See merge request espressif/esp-idf!50252
2026-07-03 08:45:02 +05:30
harshal.patil
b5d53b87ef feat(mbedtls/psa_esp_rsa_ds): Expose persistent key buffer format/parse helpers 2026-07-02 16:00:23 +05:30
harshal.patil
6634a0b620 feat(mbedtls): Support custom storage backend for persistent PSA keys 2026-07-02 16:00:23 +05:30
Aditya Patwardhan
49d1a84c0b docs(esp-tls): clarify caller owns the PSA key in esp_key_config_t
(cherry picked from commit ed6f697ea8)
2026-07-02 11:41:49 +05:30
Aditya Patwardhan
72b2e4f4fd fix(esp-tls): address MR review comments for SE PSA driver
- esp_tls_mbedtls: require cert when PSA-backed server/client key is set
- esp_tls_mbedtls: drop redundant pk_init/x509_crt_init (calloc handles it)
- psa SE driver: copy callbacks/opaque_key by value (no lifetime coupling)
- psa SE driver: replace atomic CAS with simple null check on register
- psa SE driver: use sig_len from sign callback with bounds validation
- psa SE driver: validate pubkey_len returned by export_pubkey callback
- psa SE driver: check hash sub-alg in RSA PKCS1V15 branch of validate_request
- psa SE driver: align secure_element_register_callbacks doc with value-copy impl
- esp_https_server: initialize server_key in HTTPD_SSL_CONFIG_DEFAULT
- mbedtls: move SECURE_ELEMENT_DRIVER_ENABLED to esp_config.h for parity
  with ESP_ECDSA_DRIVER_ENABLED; drop target_compile_definitions
- docs: fix esp_tls_cfg_t -> esp_http_client_config_t cross-reference
- docs: check psa_import_key() status in ESP-TLS PSA example
- hints/error_output: point at CONFIG_MBEDTLS_SECURE_ELEMENT_DRIVER_ENABLED

(cherry picked from commit 08b567ef3b)
2026-07-02 11:41:49 +05:30
Aditya Patwardhan
a35e056816 feat(mbedtls): Add PSA Crypto driver for external secure elements
Add generic secure element PSA driver with runtime callback registration.
Consolidate Kconfig into single MBEDTLS_SECURE_ELEMENT_DRIVER_ENABLED option.

Closes https://github.com/espressif/esp-idf/issues/18388

(cherry picked from commit 1c20f525b4)
2026-07-02 11:41:48 +05:30