Repository navigation
Commit 03775d2
zephyr-cp: make TLS 1.2 ECDHE and PEM certificates work on the Pico W boards
Two Kconfig gaps kept an HTTPS server (or client) from ever completing a
handshake on these boards:
- Zephyr's mbedTLS 4 default serves secp256r1 through the p256-m PSA driver
and leaves the builtin ECP module out. mbedTLS then defines the dummy
MBEDTLS_ECP_MAX_BITS 1, and ssl.h sizes the TLS 1.2 premaster buffer
(union mbedtls_ssl_premaster_secret._pms_ecdh[MBEDTLS_ECP_MAX_BYTES]) from
it: sizeof(handshake->premaster) was 1 in the firmware (DWARF). Every ECDHE
key agreement then failed -- "psa_raw_key_agreement() returned -138
(-0x008a)", PSA_ERROR_BUFFER_TOO_SMALL for a 32-byte shared secret -- and
the raw PSA status leaked through mbedtls_ssl_read() as OSError 138 on the
first read of any TLS connection. Disabling the p256-m driver brings the
builtin ECP module back and the buffer is 32 bytes again. This is an
upstream sizing bug (ssl.h should size that buffer from PSA when the ECP
module is absent); the Kconfig is the workaround until it is fixed.
- PEM parsing was not compiled in, so load_cert_chain() with the usual
fullchain.pem / key.pem could only fail; the collector's certstore is PEM.
Verified on a Pico 2 W: an RSA-2048 PEM certificate served from CIRCUITPY
over the softAP; an ESP32-C6 client completed the handshake and received
"HTTP/1.0 200 OK" in 2.0 s. Flash +1,868 B (PEM) and +4,716 B (builtin ECP
instead of p256-m) on the Pico 2 W; no static RAM change.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent ba0232c commit 03775d2
2 files changed
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
28 | 43 | | |
29 | 44 | | |
30 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
28 | 43 | | |
29 | 44 | | |
30 | 45 | | |
| |||
0 commit comments