Commit Graph

1055 Commits

Author SHA1 Message Date
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
Michael (XIAO Xufeng)
c1b218b640 Merge branch 'fix/mmap_cache_flash_wr' into 'master'
fix(mmap): fixed mmap read data wrong when flash being erased/written and cache not disabled

Closes IDFGH-14084

See merge request espressif/esp-idf!29804
2026-06-29 11:44:10 +08:00
Ashish Sharma
bc14daab3e fix(mbedtls): harden port layer to zeroize sensitive material 2026-06-23 11:15:01 +08:00
Kapil Gupta
fb14a3e7f4 Merge branch 'bugfix/mbedtls_rsa_base_reduction_hw_crt' into 'master'
fix(mbedlts): Enable hardware CRT for RSA-4096 via base reduction

Closes WIFIBUG-1789

See merge request espressif/esp-idf!49641
2026-06-21 09:59:18 +05:30
Kapil Gupta
66752f0942 fix(mbedtls): Fix cached Rinv size mismatch under private exponent blinding
Prevent signature verification failures on targets that do not round hardware words
to 16-word boundaries (e.g. ESP32-S3, ESP32-C6, and ESP32-P4), where exponent blinding
can cause `num_words` to vary between calls, leading to reuse of an incorrectly sized
cached `Rinv`.
2026-06-21 09:29:49 +05:30
Kapil Gupta
cf7a80aa01 fix(mbedtls): Enable hardware CRT for RSA-4096 via base reduction
Perform modulo reduction on the base before size checks to allow RSA-4096
CRT (2048-bit exponentiations) to use the hardware accelerator instead of
falling back to software. Fix input validation, negative zero sign issues,
and early memory cleanup paths in esp_mpi_exp_mod()
2026-06-21 09:29:37 +05:30
harshal.patil
d6f41cac35 feat(mbedtls/psa_esp_rsa_ds): Expose persistent key buffer format/parse helpers 2026-06-18 09:42:54 +05:30
harshal.patil
3494df8c85 feat(mbedtls): Support custom storage backend for persistent PSA keys 2026-06-18 09:37:15 +05:30
Mahavir Jain
bf51d194fe Merge branch 'update/update_cmn_crt_authorities_csv' into 'master'
Update common cert authorities csv

See merge request espressif/esp-idf!49372
2026-06-18 09:30:11 +05:30
Alexey Lapshin
e389f3e4df Merge branch 'feature/upgrade_toolchain_to_16.1.0_20260609' into 'master'
Upgrade GNU toolchain to 16.1.0_20260609

See merge request espressif/esp-idf!49523
2026-06-18 00:55:07 +04:00
Alexey Lapshin
4328dc28e2 fix(mbedtls): increase test limits 2026-06-17 17:24:24 +07:00
Xiao Xufeng
789ce684c9 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-06-16 01:00:43 +08:00
Ashish Sharma
e6f5f5ff63 fix(mbedtls/port): add additional hardening for PSA drivers 2026-06-15 16:10:09 +05:30
harshal.patil
9172417c13 fix(mbedtls/port): align ESP PSA hardware drivers with software references
Audited every esp_* PSA driver against its corresponding software driver in
mbedtls/library (psa_crypto_cipher.c, psa_crypto_aead.c, psa_crypto_mac.c,
psa_crypto_hash.c, psa_crypto_ecp.c, psa_crypto_rsa.c) and fixed gaps in
workflow ownership, error-path cleanup, sensitive-data wiping, and BAD_STATE
gating per the PSA Crypto API spec.

esp_aes (cipher): fix padding oracle in cipher_finish by replacing leaky
branches with mbedtls_ct_* primitives; abort wipes the driver-level ctx,
not just the inner mbedtls_aes_context; setup routes errors through abort.

esp_aes_gcm (AEAD): zeroize the 16-byte full_tag scratch; restore the
*output_length = finish_output_size assignment that the SW reference keeps
for future ciphers; NULL the inner ctx pointer after free in abort; gate
update/finish on a live ctx with PSA_ERROR_BAD_STATE.

esp_ecdsa: keep abort-at-exit in the one-shot wrappers so the stack-copy
of the hash (needed for little-endian byte order on HW) is wiped per
PSA spec 6.3.3, drop the over-defensive public-key qx/qy wipes that the
SW driver does not perform.

esp_cmac / esp_hmac_transparent / esp_hmac_opaque (MAC): make abort
idempotent, route setup errors through abort, gate update/finish/
verify_finish on PSA_ERROR_BAD_STATE, wipe M_last and intermediate hmac[]
buffers on completion or HW failure. HMAC opaque gains alg + computed
fields to mirror the SW psa_crypto_mac.c state machine. HMAC transparent
explicitly aborts the inner SHA context before reusing it for the outer
hash.

esp_sha: switch the per-op live indicator to (sha_ctx != NULL) so the
public esp_sha_operation_type_t enum keeps its original ordinal values;
free + NULL sha_ctx on every error path; gate update/finish/clone on a
live ctx; wipe per-algorithm core/parallel-engine scratch buffers
(W[], A[], state) on HW-engine failure.

esp_md5: replace bare memset in abort with mbedtls_platform_zeroize.

esp_rsa_ds: complete() no longer frees sig_buffer (abort owns that);
start() routes failures through abort; asymmetric_decrypt funnels all
cleanup through a single exit: label. RSA-DS utilities wipe the
decrypted-plaintext scratch on v15 / OAEP unpad failure.
2026-06-15 16:10:09 +05:30
Espressif BOT
cdff63e838 change(mbedtls/crt_bundle): Update esp_cmn_crt_bundle certificates 2026-06-10 10:10:43 +05:30
Aditya Patwardhan
5f8e7058a5 Merge branch 'fix/rsa_ds_driver_constant_time' into 'master'
Fix/rsa ds driver constant time

See merge request espressif/esp-idf!48678
2026-06-09 22:25:23 +05:30
Mahavir Jain
05c70c1fd4 Merge branch 'fix/ecdsa_ecc_hw_input_validation' into 'master'
Validate ECDSA signature range and harden ECC memory power-down

See merge request espressif/esp-idf!48958
2026-06-09 14:40:24 +05:30
harshal.patil
554cce6937 fix(mbedtls): validate ECDSA signature range and harden ECC memory power-down 2026-06-09 10:59:11 +05:30
Sudeep Mohanty
7c5fe924a5 fix(mbedtls): initialize SRCS variables in mbedtls/CMakeLists.txt BOOTLOADER_BUILD branch 2026-06-05 16:12:01 +02:00
Ashish Sharma
4c1422a02a fix(rsa_ds): make RSA-OAEP unpadding constant-time 2026-06-05 13:39:27 +08:00
Ashish Sharma
96f43bb049 fix(rsa_ds): make PKCS#1 v1.5 unpadding constant-time 2026-06-05 13:39:27 +08:00
harshal.patil
3cbd175d2b test(mbedtls/crt_bundle): Make weak-hash test self-contained
The "custom certificate bundle - weak hash" test relied on DigiCert
Global Root CA being present as a trust anchor in cacrt_all.pem (the
only SHA-1-self-signed root in the chain it loaded). The recent
cacrt_all.pem refresh moved that root to cacrt_deprecated.pem, so the
chain could no longer anchor and the test started failing.
2026-06-02 10:06:43 +05:30
Espressif BOT
7126a31b02 change(mbedtls/crt_bundle): Update esp_crt_bundle certificates 2026-06-02 10:06:43 +05:30