Commit Graph

1086 Commits

Author SHA1 Message Date
Laukik Hase
251485a679 Merge branch 'feat/esp_tee_psa_exc_buf' into 'master'
feat(esp_tee): Disable the `MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS` option for TEE build

See merge request espressif/esp-idf!51960
2026-09-03 11:23:24 +05:30
Mahavir Jain
32df74b8af Merge branch 'fix/crt_bundle_cert_header_oob' into 'master'
Validate cert header extent before reading it in bundle check

See merge request espressif/esp-idf!51982
2026-09-02 13:41:47 +05:30
Laukik Hase
dc0fadf1d4 feat(esp_tee): Disable the MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS option for TEE build 2026-09-02 11:49:22 +05:30
Ashish Sharma
71e2df18ce feat(mbedtls): follow project performance optimization level by default 2026-09-01 19:07:27 +08:00
harshal.patil
8bbec50449 test(mbedtls): cover certificate extent checks in bundle bound checking
Add a bound-checking case for the two cert-extent rejections in
esp_crt_check_bundle(): a certificate whose declared name/key lengths
run past the end of the bundle, and a last certificate placed so close
to the end that its 4-byte header would straddle the bundle boundary.
2026-08-31 13:31:36 +08:00
harshal.patil
ed7153ef41 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-31 13:31:36 +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
Laukik Hase
427dc875b9 change(esp_tee): Force non-deterministic ECDSA signing for TEE secure storage keys 2026-08-28 10:20:55 +05:30
Laukik Hase
4812dbd2d8 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-08-28 10:20:54 +05:30
Ashish Sharma
49c9f7fb2a fix(mbedtls): reject an all-zero AES block output in the encrypt direction 2026-08-24 13:27:49 +08:00
harshal.patil
b85c05d556 test(mbedtls): fix in-place AES-CTR PSRAM test on targets without AES hardware
With MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS enabled, an in-place
psa_cipher_update() reaches the selected cipher implementation without
defensive buffer copies. The ESP AES PSA driver accepts an in-place
update of any length for CTR (PSA classifies CTR as a stream cipher, so
the driver's block_length is 1), but on targets without the AES
peripheral (e.g. ESP32-C61) the operation falls back to the mbedtls
builtin cipher layer, which rejects in-place updates whose length is
not a multiple of the block size (MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
surfacing as PSA_ERROR_INVALID_ARGUMENT).

Round the in-place test length down to a block multiple when
CONFIG_MBEDTLS_HARDWARE_AES is not set; partial-block PSRAM coverage is
retained through the separate-buffer alignment tests.
2026-08-20 18:46:09 +05:30
Mahavir Jain
dc73db9f18 Merge branch 'update/update_certs_bundle' into 'master'
Update esp_crt_bundle certificates

See merge request espressif/esp-idf!51768
2026-08-20 11:56:38 +05:30
morris
fe465ae1fe Merge branch 'fix/psram-ecc-mspi-dma-align' into 'master'
fix(mspi): handle PSRAM ECC DMA alignment across MSPI users

Closes IDF-15850, IDF-15910, and IDF-15700

See merge request espressif/esp-idf!49987
2026-08-20 11:51:46 +08:00
Mahavir Jain
b27a1cd318 Merge branch 'change/gen_crt_bundle_unify_output' into 'master'
change(mbedtls/crt_bundle): Unify gen_crt_bundle output with esp-pylib

Closes IDF-15331

See merge request espressif/esp-idf!51556
2026-08-19 19:38:29 +05:30
Mahavir Jain
ad59a903b7 Merge branch 'fix/esp32s2_aes_dma_psram_partial_block_hang' into 'master'
Avoid ESP32-S2 Crypto DMA stall on PSRAM output with partial blocks

See merge request espressif/esp-idf!51796
2026-08-19 19:29:59 +05:30
Espressif BOT
1004336f7a change(mbedtls/crt_bundle): Update esp_crt_bundle certificates 2026-08-19 17:08:51 +05:30
Pranav Sonawane
5d760b7a4a change(mbedtls/crt_bundle): Unify gen_crt_bundle output with esp-pylib
gen_crt_bundle.py now uses the shared esp-pylib library instead of its own
logging and argument parsing, so its messages look the same as the rest of
the ESP-IDF Python tools.
2026-08-19 16:22:57 +05:30
harshal.patil
95f1582f4b 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-19 11:27:52 +05:30
harshal.patil
6fe4f4f174 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 11:27:42 +05:30
Ashish Sharma
0a765b93e7 fix(mbedtls): use pointer-width types for dynamic buffer msg offsets 2026-08-19 12:25:12 +08:00
Ashish Sharma
732f7ca983 test(mbedtls): add test for unaligned multipart AES-GCM streaming 2026-08-19 12:25:12 +08:00
Ashish Sharma
e6ac065424 fix(mbedtls): preserve AES-GCM stream state across multipart updates 2026-08-19 12:25:12 +08:00
Ashish Sharma
23393e49bd fix(mbedtls): bound public-key coordinate copy in esp ecp_check_pubkey 2026-08-19 12:25:12 +08:00
Chen Jichang
e008f5a627 refactor(gdma): increase performance and optimize api 2026-08-17 17:02:06 +08:00
Chen Jichang
2b8029c775 feat(mspi): split dma and mspi alignment 2026-08-17 16:49:27 +08:00
Chen Jichang
e7a290a870 test(aes): add aes psram ecc test 2026-08-17 16:49:27 +08:00
Mahavir Jain
8c007f0e03 Merge branch 'feat/bootloader-mbedtls-split-final' into 'master'
feat(esp_image_verify): split image verification out of bootloader_support

Closes IDF-8577 and IDFGH-17033

See merge request espressif/esp-idf!48383
2026-08-13 08:45:58 +05:30
Mahavir Jain
6e49bfec02 Merge branch 'fix/crt-bundle-unaligned-reads' into 'master'
fix(mbedtls): read crt bundle byte-wise to avoid misaligned flash access

Closes IDF-16030

See merge request espressif/esp-idf!51600
2026-08-12 14:13:45 +05:30
Pranav Sonawane
d385023b85 fix(mbedtls): Raise error for certificate files with unsupported extension
gen_crt_bundle.py only parses files ending in .pem or .der, but silently
ignored anything else. A PEM certificate named e.g. ca.crt was skipped
without a word, and since the build invokes the script with -q, even the
"Successfully added 0 certificates" hint was suppressed. The build then
succeeded and embedded a bundle without the certificate, and the problem
only surfaced at runtime as a TLS verification failure.

A file passed directly via --input, which is what
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH points at, is now expected
to be a certificate: an unsupported extension raises an InputError and
fails the build with a message naming the file and the two accepted
extensions. Files found while scanning a directory keep being skipped,
as a certificate directory may legitimately contain other files, but a
warning is now printed unconditionally so it is visible in the build log.

Also document the requirement in the Kconfig help text and in the
esp_crt_bundle documentation.

Closes https://github.com/espressif/esp-idf/issues/18933
2026-08-12 09:59:28 +05:30
Mahavir Jain
9c3a553115 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-08-12 08:42:49 +05:30
Ashish Sharma
8589d9df25 fix(build): prepare dependents for bootloader_support dropping mbedtls
bootloader_support is about to stop pulling mbedtls (and app_update) into
every build graph, so components and apps that relied on those transitive
edges must own their dependencies

Closes https://github.com/espressif/esp-idf/issues/18072
Related https://github.com/espressif/esp-idf/issues/18778
2026-08-12 08:39:18 +05:30
Mahavir Jain
c9095b026f Merge branch 'feat/disable_constant_time_rsa_key_gen' into 'master'
fix(mbedtls): revert to non constant time rsa key gen

See merge request espressif/esp-idf!51026
2026-08-05 12:52:27 +05:30
Espressif BOT
8671276304 change(mbedtls/crt_bundle): Update esp_crt_bundle certificates 2026-07-31 10:09:00 +05:30
Ashish Sharma
be0df8c3ad fix(mbedtls): revert to non constant time rsa key gen 2026-07-30 13:39:35 +08:00
Ashish Sharma
e1e9c65e07 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-16 14:38:48 +08:00
Ashish Sharma
20ee0021e9 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-16 14:38:48 +08:00
Ashish Sharma
224902efc9 feat(mbedtls): update to version 4.1.1 2026-07-16 14:38:48 +08:00
Mahavir Jain
05250d7dd1 Merge branch 'feat/enable_cross_signed_cert_suppport_default' into 'master'
feat(mbedtls): enable cross signed certificate verification support by default

See merge request espressif/esp-idf!49905
2026-07-07 14:47:37 +05:30
morris
18f50fefa9 Merge branch 'feat/esp_macro_align_up_down' into 'master'
refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h

See merge request espressif/esp-idf!50335
2026-07-06 19:09:14 +08:00
Nilesh Kale
4eaa03abf5 Merge branch 'feat/enable_aes_gcm_support_for_esp32s31' into 'master'
feat: enable AES GCM support for ESP32-S31

Closes IDF-15529

See merge request espressif/esp-idf!47564
2026-07-06 17:35:39 +08:00
Ashish Sharma
5ea5256b96 feat(mbedtls): enable cross signed certificate verification support by default 2026-07-06 15:34:51 +08:00
nilesh.kale
ec6921b9df feat: enable AES GCM support for ESP32-S31 2026-07-06 11:51:05 +05:30
Ashish Sharma
f7b8db2f2f feat(espcoredump): migrate to esp sha256 implementation from mbedtls sha256 2026-07-06 11:11:12 +05:30
morris
651d6a283f refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h
Remove ~50 duplicate local definitions of ALIGN_UP/ALIGN_DOWN/ALIGN_UP_BY/
ALIGN_DOWN_BY across the codebase and replace them with canonical
ESP_ALIGN_UP/ESP_ALIGN_DOWN from esp_macros.h.
2026-07-06 13:36:06 +08:00
Ashish Sharma
7d9f061cc1 fix(mbedtls): fixes TLS1.3 server failing with dynamic buffer 2026-07-06 10:38:10 +05:30
Mahavir Jain
1e2b539c1c Merge branch 'bugfix/memory-safety-and-validation' into 'master'
fix(security): findings from project Vanessa

Closes SEC-1110, SEC-1115, SEC-1128, SEC-1144, SEC-763, SEC-1159, SEC-1058, SEC-609, SEC-1146, SEC-1163, SEC-1148, SEC-1176, SEC-1177, SEC-109, SEC-1156, SEC-1173, SEC-1174, SEC-1175, SEC-1117, SEC-1171, SEC-231, SEC-1182, SEC-1188, SEC-1157, SEC-328, and SEC-1131

See merge request espressif/esp-idf!50093
2026-07-03 23:26:21 +05:30
Sudeep Mohanty
26b24ee2fa Merge branch 'task/buildv2_full_pipeline' into 'master'
Enable full buildv2 pipeline

Closes IDF-14180

See merge request espressif/esp-idf!49668
2026-07-03 11:28:57 +02:00
Ashish Sharma
7842b5170f fix(esp_tee): fix DS-lock leak, intr-matrix OOB, calloc overflow, attestation leak 2026-07-03 17:20:49 +08:00
Ashish Sharma
7462e3c30a fix(mbedtls): validate crypto input lengths (TEE OOB, auth-bypass, overflows) 2026-07-03 17:19:05 +08:00
Laukik Hase
e7261f57f5 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-02 15:14:42 +05:30