Commit Graph
1077 Commits
Author SHA1 Message Date
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
Aditya Patwardhan b5023d4343 Merge branch 'feature/unified_priv_key_interface_across_idf' into 'master'
feat(esp-tls): Added a PSA driver for Secure Element

See merge request espressif/esp-idf!44987
2026-07-02 11:00:42 +05:30
Sudeep Mohanty b3951f4013 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-01 13:17:25 +02:00
Mahavir Jain 1c5aa1c5cb Merge branch 'fix/aes_dma_psram_encrypted_mem_s31' into 'master'
fix(mbedtls/aes): Fix AES-DMA over encrypted PSRAM on ESP32-S31

See merge request espressif/esp-idf!49935
2026-07-01 12:16:13 +05:30
Aditya Patwardhan ed6f697ea8 docs(esp-tls): clarify caller owns the PSA key in esp_key_config_t 2026-06-29 19:20:23 +05:30
Aditya Patwardhan 08b567ef3b 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
2026-06-29 19:20:22 +05:30
Aditya Patwardhan 1c20f525b4 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
2026-06-29 19:20:07 +05:30
Mahavir Jain 1ec9740baf Merge branch 'fix/harden_mbedtls_port_layer' into 'master'
fix(mbedtls): harden port layer to zeroize sensitive material

Closes SEC-395

See merge request espressif/esp-idf!49693
2026-06-29 18:45:17 +05:30
harshal.patil 9707272cda test(mbedtls): move AES test vectors to a dedicated header 2026-06-29 15:56:09 +05:30
harshal.patil 6d45a3ae06 fix(mbedtls/aes): Fix AES-DMA over encrypted PSRAM on ESP32-S31
esp_crypto_shared_gdma_done() polled the AXI RX raw interrupt status
(in_done) but never cleared it, so after the first transfer the set bit
made every subsequent call return immediately without waiting.
2026-06-29 15:56:09 +05:30