Commit Graph

309 Commits

Author SHA1 Message Date
Ashish Sharma
06f2672046 fix(esp-tls): correct return codes and harden TLS 1.3 ticket handling 2026-08-06 13:52:21 +08:00
Eric Wang
850d652f00 feat(esp-tls): add opt-in TCP_NODELAY (CONFIG_ESP_TLS_ENABLE_TCP_NODELAY)
Latency-sensitive small-message protocols (notably MQTT: PUBLISH/PUBACK/
PINGREQ) suffer when Nagle's algorithm interacts with the peer's
delayed-ACK: a small write is withheld until the prior segment is ACKed
while the peer holds that ACK up to ~40-200 ms, stalling each small write
until the delayed-ACK timer fires.

Add CONFIG_ESP_TLS_ENABLE_TCP_NODELAY (default n). When enabled,
esp_tls_set_socket_options() sets TCP_NODELAY on the connection socket
alongside the existing SO_*TIMEO / keepalive options, so small records go
out immediately. Non-fatal (a latency hint), so a failure only warns.
Off by default: no behavior change for existing users.

Signed-off-by: Eric Wang <eric@rwx.one>
2026-07-20 14:27:04 -07:00
Aditya Patwardhan
8fe74703bc fix(esp-tls): Keep deprecated use_secure_element field for compatibility
Restore the use_secure_element field in esp_tls_cfg_t, esp_tls_cfg_server_t
and httpd_ssl_config_t, and esp_transport_ssl_use_secure_element(), as
deprecated no-ops so that existing code keeps compiling. Setting them now
fails at runtime with ESP_ERR_NOT_SUPPORTED, as the feature is accessed
via the esp_key_config_t interface. To be removed in the next major release.
2026-07-15 12:40:55 +05:30
Ashish Sharma
b065c38286 fix(esp-tls): reject NULL host/url in plain-TCP and async HTTP connect 2026-07-03 17:19:05 +08:00
Ashish Sharma
6d1beb1f23 fix(esp-tls): guard against NULL PSK hint to prevent crash 2026-07-03 11:34:59 +08:00
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
5f1074045f fix(esp-tls): update secure element build hint for PSA integration 2026-06-29 19:20:23 +05:30
Aditya Patwardhan
7cdd0b5960 fix(esp-tls): track opaque PSA key ownership and cover the secure-element path
Replace the key-lifetime check with explicit ownership tracking so a
caller-supplied volatile PSA key is also preserved on cleanup, and drop the
DS/HARDWARE_ECDSA compile guard so the ESP_KEY_SOURCE_PSA path is released on
pure secure-element builds.
2026-06-29 19:20:23 +05:30
Mike Szczys
f68cfbf8d4 fix(esp-tls): only destroy volatile keys in DS/ECDSA cleanup
The DS/ECDSA cleanup added in 8cb64703 is intended for volatile PSA keys
created internally by the DS and ECDSA peripheral paths. Ensure that
during the cleanup, PSA_KEY_LIFETIME_IS_VOLATILE() is checked to avoid
destroying keys the user has added persistently to PSA.

This resolves an issue in the next commit (adding support for
clientkey_psa_id) where a user passes a PSA key id that is then silently
destroyed if CONFIG_ESP_TLS_USE_DS_PERIPHERAL or
CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN happen to be defined.

Signed-off-by: Mike Szczys <michael.szczys@canonical.com>
(cherry picked from commit da51d69013)
2026-06-29 19:20:22 +05:30
Aditya Patwardhan
b7f53c3868 fix(esp-tls): correct test_apps README to match manifest target restriction
.build-test-rules.yml restricts esp-tls test_apps to esp32c3 only.
Commit 19a544203b9 accidentally expanded the README to all targets.
2026-06-29 19:20:22 +05:30
Aditya Patwardhan
005072c87e fix(esp-tls): call mbedtls_pk_init before mbedtls_pk_wrap_psa in PSA key paths
Per mbedTLS API contract, mbedtls_pk_context must be explicitly initialized
with mbedtls_pk_init() before calling mbedtls_pk_wrap_psa(). Add the missing
init calls for both the server_key and client_key PSA-backed key code paths.
2026-06-29 19:20:22 +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
36090b7161 feat(esp-tls): Add unified private key interface via esp_key_config_t
Add ESP_KEY_SOURCE_BUFFER and ESP_KEY_SOURCE_PSA key sources so all
hardware backends (DS, ECDSA, secure element) are accessed via PSA
key IDs through a single esp_tls_cfg_t.client_key field.
2026-06-25 11:31:37 +05:30
Mahavir Jain
da6dfc30e9 Merge branch 'feat/adds_ds_qemu_test' into 'master'
feat: adds mutual auth example

Closes IDF-2681

See merge request espressif/esp-idf!45641
2026-06-04 20:43:00 +05:30
Ashish Sharma
8cb64703ff fix(esp-tls): fixes DS peripheral use case with tf-psa-crypto 1.1 2026-05-29 11:58:46 +08:00
Guillaume Souchere
d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00
Aditya Patwardhan
4540181c62 fix(esp-tls): clarify skip_common_name and warn when SNI is disabled
The skip_common_name flag was named for the legacy CN field but actually
suppresses the entire mbedtls_ssl_set_hostname() call -- disabling
hostname matching against CN/SAN AND Server Name Indication. Update the
doxygen to describe the real effect, and emit a per-call WARN inside the
SNI-disable branch so debug-only use does not slip into production
unnoticed.
2026-05-25 21:58:18 +05:30
Aditya Patwardhan
c5f20937bd fix(esp-tls): close CA-verification bypass during session resumption
The session-resumption else-if in set_client_config() short-circuited
the CA verification chain when only client_session was supplied. Remove
the branch so session-only configs fall through to the normal error /
skip-verify path; resumption no longer silently disables CA validation.
2026-05-25 21:58:18 +05:30
Ashish Sharma
306639c690 fix(esp-tls): replace deprecated pk_ctx with PSA equivalent 2026-04-30 18:02:06 +08:00
Aditya Patwardhan
fd551a3618 Merge branch 'fix/esp_tls_check_tls_conn_before_read_write' into 'master'
Fix/esp tls check tls conn before read write

Closes IDF-15501

See merge request espressif/esp-idf!47068
2026-04-13 12:03:45 +05:30
Guillaume Souchere
e7cf8cd3cb fix(mbedtls): fix undefined esp_mbedtls_mem_calloc/free at link time
platform.c (compiled into the 'builtin' archive) calls
esp_mbedtls_mem_calloc and esp_mbedtls_mem_free directly by name via
the MBEDTLS_PLATFORM_STD_CALLOC/FREE macros in esp_config.h.
Previously, esp_mem.c was compiled into the 'tfpsacrypto' archive, which
appears after 'builtin' in the link command, causing the linker to fail
with undefined reference errors when 'builtin' was processed first.

Moving esp_mem.c into 'builtin' to assure that the function used by
esp_mbedtls_mem_calloc and esp_mbedtls_mem_free are available when
pltform.c is linked.
2026-04-09 10:51:21 +02:00
Ashish Sharma
f3238ec7d5 feat(esp_tls): extends esp-tls test apps 2026-04-09 14:09:31 +08:00
Ashish Sharma
25c0c9da24 fix(esp_tls): check tls connection finished before read/write operation 2026-04-09 14:09:31 +08:00
harshal.patil
48e7d44ce1 fix(esp-tls): Remove the legacy use_km_key option 2026-03-20 11:15:23 +05:30
Evgeny Torbin
d0f062c018 ci: remove unused test cases 2026-03-12 12:02:10 +01:00
harshal.patil
b5550281b9 change(mbedtls): Change the ESP-DS-RSA key lifetime name to include the VOLATILE keyword 2026-03-06 15:00:38 +05:30
Mahavir Jain
a5d7fb3a41 Merge branch 'fix/fix_dynamic_buffer_with_tls1_3' into 'master'
fix: fixes failing dynamic buffer tests

Closes IDFCI-5130

See merge request espressif/esp-idf!45150
2026-03-05 18:35:32 +05:30
harshal.patil
aa63487d9f feat(mbedtls/esp_rsa_ds): Introduce ESP-RSA DS opaque key context 2026-03-03 18:36:18 +05:30
Ashish Sharma
20a6888b41 feat(esp-tls): adds per ssl context state management 2026-03-03 11:21:56 +08:00
Sudeep Mohanty
53243675d4 fix(esp-tls): Fixed linux build for Build System v2
For Build System v2 on linux target, lwip dependency and ESP_TLS_WITH_LWIP
definition must be conditional on CONFIG_LWIP_ENABLE rather than checking
BUILD_COMPONENTS. v2 uses configuration-driven dependencies.
2026-02-18 09:58:05 +01:00
Marek Fiala
eb0086ef7f change: Moved esp-tls hint to component specific hints.yml file 2026-02-13 15:59:31 +08:00
Ashish Sharma
b3e1c03d97 fix(mbedtls): revert struct member name change esp_rsa_ds_data to esp_ds_data 2026-02-06 17:33:17 +08:00
Mahavir Jain
3a7d385ea4 Merge branch 'feat/add_opaque_ds_driver' into 'master'
feat: adds PSA opaque DS driver support

See merge request espressif/esp-idf!45008
2026-02-06 12:41:58 +05:30
Ashish Sharma
6f5b078ed6 feat: adds DS Sign capabilities for ESP32S2 2026-02-05 10:12:25 +08:00
Ashish Sharma
e06a7dd791 feat: adds new Kconfig variable for DS peripheral 2026-02-05 10:12:25 +08:00
Ashish Sharma
1d185a6548 feat: adds PSA DS driver support 2026-02-05 10:12:25 +08:00
Aditya Patwardhan
e1810e6bfd feat(esp-tls): Add crypto callbacks to custom TLS stack interface
Added crypto_sha1 and crypto_base64_encode callbacks to esp_tls_stack_ops_t
to allow custom TLS stacks to provide implementations for esp_crypto_* APIs.
2026-02-04 18:54:49 +05:30
Aditya Patwardhan
45bb06d212 feat(esp-tls): Added build test for the custom stack registration 2026-02-04 13:53:29 +05:30
Aditya Patwardhan
f96119db75 feat(esp-tls): Added support to register custom tls stack
* Removed the esp_tls_wolfssl layer from esp-tls
    * Migrated Error codes
2026-02-04 13:53:25 +05:30
harshal.patil
e9ea55bea2 feat(mbedtls/ecdsa): Introduce PSA ECDSA driver 2026-01-19 09:14:37 +05:30
Ashish Sharma
cca2a54624 feat: migrates esp-tls to PSA APIs 2025-12-30 09:31:49 +05:30
C.S.M
f405e51784 ci(esp32s31): Add ci build test for esp32s31 2025-12-11 15:17:15 +08:00
Ashish Sharma
9fe50060e6 feat(mbedtls): update to version 3.6.5 2025-11-11 10:07:05 +08:00
0xFEEDC0DE64
5b56b00ac8 feat(esp_http_server): Allow the https server to request client certs optionally
Closes https://github.com/espressif/esp-idf/pull/17641
2025-10-27 14:19:17 +08:00
Ashish Sharma
62f852a93b feat(esp_tls): supports setting tls version and ciphersuite in server config
Closes https://github.com/espressif/esp-idf/issues/17660
2025-10-03 15:19:41 +08:00
Jared Pon
2b42a6aa2b fix(esp_tls_conn_new_sync): Fix esp_tls_conn_new_sync's doc to reflect its implementation
Closes https://github.com/espressif/esp-idf/pull/17652
Closes https://github.com/espressif/esp-idf/issues/17598
2025-09-30 10:02:20 +08:00
Ashish Sharma
9cb348789c fix(esp_tls): limit ret code from esp_mbedtls_handshake 2025-09-24 09:36:38 +08:00
nilesh.kale
54d97fdac1 fix(esp-tls): removed unncessary log for certificate verification
This commit removed unnecessary and confusing log for
certificate verify if there is another issue during tls connection.
2025-09-17 13:04:16 +08:00
nilesh.kale
421b9abd0d fix(esp-tls): added missing event tracker capture during mbedtls read operation
This commit fixed missing event tracker capture and
added new error code ESP_ERR_MBEDTLS_SSL_READ_FAILED.

Closes https://github.com/espressif/esp-idf/issues/16239
2025-09-17 13:04:16 +08:00
hrushikesh.bhosale
bf7dc18bd6 fix(esp_tls): Fixed build failure for sbv2 ecdsa
Made ESP_TLS_ECDSA_CURVE_SECP384R1 under SOC CAP.
2025-09-09 16:01:04 +05:30