DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
tls.h File Reference

Deterministic TLS engine: mbedTLS over a static memory pool (DETWS_ENABLE_TLS). More...

#include "ServerConfig.h"
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Detailed Description

Deterministic TLS engine: mbedTLS over a static memory pool (DETWS_ENABLE_TLS).

Wraps mbedTLS as a server-side TLS layer that keeps the library's zero-heap guarantee: mbedTLS is pointed at a fixed BSS arena via MBEDTLS_MEMORY_BUFFER_ALLOC_C (no system heap), per-connection ssl_context lives in BSS, the RNG is the ESP32 hardware CSPRNG, and the transport BIO is bridged directly to the existing lwIP tcp_pcb + per-connection rx ring - so there is no socket layer and no extra task. The handshake is pumped from the single handle() loop.

ESP32/Arduino only - mbedTLS is not part of the native build. The header compiles everywhere (the functions are no-op stubs unless DETWS_ENABLE_TLS and ARDUINO are both set) so call sites need no extra guards.

Lifecycle per connection:

det_tls_conn_begin(slot); // at accept on the TLS port
// each EvtType::EVT_DATA, until established:
int h = det_tls_handshake(slot); // 1 done, 0 pending, <0 fatal
// once established, app data:
int n = det_tls_read(slot, buf, sizeof buf); // >0 plaintext, 0 again, <0 closed
det_tls_write(slot, data, len); // encrypts -> tcp_write
det_tls_conn_end(slot); // close_notify + free slot ctx

Definition in file tls.h.