wolfNanoTLS

wolfNanoTLS is a TLS 1.3-only embedded library on wolfCrypt that I built to come in well under mbedTLS. It does: an 18.2 KB TLS 1.3 client on Cortex-M33, 49% smaller than a hard-minimized mbedTLS 4.1, with post-quantum key exchange and signatures that mbedTLS does not have.

Role: creator C, TLS 1.3, wolfCrypt, Cortex-M33 aidangarske/wolfNanoTLS footprint wiki
01 / Problem and boundary

Get TLS 1.3 well under mbedTLS

For a small Cortex-M device, mbedTLS is the library to beat on size. Full wolfSSL with X.509 is about 150 KB, which is too much for many of those parts. I started wolfNanoTLS as my own project with one measurable goal: a TLS 1.3 stack on wolfCrypt that comes in well under mbedTLS for the same job, without giving up certificate validation or post-quantum options. The crypto is wolfCrypt. The TLS layer, the X.509 parser, the build profiles and the measurement harness are mine.

02 / Result

The goal was met

Every library is built from source for Cortex-M33 with the same flags (-Os -flto -ffunction-sections -fdata-sections -Wl,--gc-sections, ArmGNU 14.2), and every one is hard-minimized to the same scope. mbedTLS gets its smallest settings too, so the comparison does not favor wolfNanoTLS. Percentages are how much smaller wolfNanoTLS is.

Cortex-M33 .text, byteswolfNanoTLSmbedTLS 4.1.0mbedTLS 3.6.0wolfSSL
PSK + ECDHE, X2551918,68036,512 (49%)42,100 (56%)48,495 (61%)
PSK + ECDHE, P-25626,60442,284 (37%)50,848 (48%)62,182 (57%)
Certificates, P-25654,28070,832 (23%)101,232 (46%)151,829 (64%)
Server, certificates, P-25646,76872,645 (36%)96,822 (52%)152,725 (69%)
Client, ML-DSA-44 certificates69,071not supportednot supportednot measured

The smallest client, PSK with X25519, is 18.2 KB, about half of a hard-minimized mbedTLS 4.1. That fits on Cortex-M0+ and M4 parts with 32 KB of flash, where mbedTLS does not. Full numbers and the configs to reproduce them are on the Footprint and Comparison wiki pages.

03 / Architecture and tradeoffs

Where the bytes went

The raw crypto primitives are close to parity with mbedTLS, whose compact bignum and ECP code is its strength. The gap is in the layers above. mbedTLS routes X25519 through its general elliptic-curve and bignum code and the mandatory PSA dispatch layer, and it links full AES tables. wolfNanoTLS calls wolfCrypt directly and uses specialized X25519 field arithmetic.

The cert path had the biggest single cut. wolfSSL's asn.c decodes far more than a TLS client needs, and its size options trimmed only about 3.4% here because --gc-sections already drops most of what they remove. Replacing it with a hand-written DER walker saved 15%. The tradeoff is scope: wn_x509 parses the RFC 5280 subset the handshake enforces, so asn.c stays the default for anyone who needs full DN, policies, name constraints or CRL and OCSP fields.

04 / What I built

The changes behind the numbers

05 / Verification

How it was checked

PREvidence
#27The crypto floor runs on an emulated STM32H563 Cortex-M33 in CI through m33mu
#80Live HTTPS against a public site: real RSA-4096 CA chains validated to ISRG Root X1 on every build
#97100% line coverage required for wn_x509.c
#111No-malloc proof: a linker-wrapped probe counts every allocation call across the whole PSK handshake and requires zero
#28 #42Daily Coverity Scan; attacker-controlled loop lengths bounded
#46 #53 #69 #77Rounds of TLS 1.3 hardening against RFC 8446: record sequence numbers, strict ServerHello and encrypted-flight checks, alert nonce reuse
06 / Limits and next steps

Where the lead is smallest

The lead shrinks on the full web-PKI device build. A client-plus-server binary with RSA, ECDSA and Ed25519 certificates is 61,424 bytes against 73,108 for mbedTLS 4.1, only 16% smaller. The ML-DSA-44 row is built without -flto because of a GCC 14.2 LTO bug in wc_mldsa.c, so it slightly overstates its size. A PSA backend for Arm parts is the next step on the roadmap.

All my merged pull requests 39 in aidangarske/wolfNanoTLS
  • #112TLS 1.3 server PSK and x509 cert
  • #111Selectable memory model (heap default / SMALL_STACK / NO_MALLOC) + empirical no-alloc proof
  • #108Reuse wolfSSL feature macros for crypto capabilities; retire WOLFNANO_HAVE_* aliases
  • #110Apply the correct README trim (from PR #107) to main
  • #109Trim README to a minimal factual overview
  • #105Trim FIPS crypto backend out of wolfNanoTLS (single src backend)
  • #97[x509] wn_x509.c 100% line-coverage gate
  • #107Trim README to a minimal, no-fluff overview
  • #90[x509] native wn_x509 lightweight X.509 parser as default cert backend
  • #88[rename] revert macro namespace WOLFNANOTLS_ back to WOLFNANO_
  • #89[ci] fix host-asm: build intel bench with aes_x86_64_asm.S
  • #87[test] add wolfSSL-style renewcerts.sh to regenerate test PKI
  • #85[test] Check wn_Hybrid_ServerRespond return in mock server (Coverity CID 647014)
  • #84[x509] Enforce certificate validity period (notBefore/notAfter) via injected clock
  • #83[tls] Offer + verify SHA-384/512 signature schemes (ECDSA P-384, RSA-PSS-384/512)
  • #80Send SNI (#33) + verify real RSA-4096 CA chains + live HTTPS example/CI
  • #79Refresh ML-DSA-44 bench/footprint numbers; split mbedTLS/wolfSSL comparison into its own doc
  • #78Default ML-DSA to level 2 (ML-DSA-44) with opt-in 65/87; [ci] auto-pin commit format
  • #77Round-5 hardening: alert nonce reuse, session-on-failure, RFC strictness (CertVerify schemes, PSK, CCS)
  • #76EncryptedExtensions, fragmentation reassembly, secret-wipe, tests, CI
  • #69[security] TLS protocol strictness (closes #55, #56, #57, #58)
  • #68[security] crypto-seam hardening (closes #59, #60, #61)
  • #67[fix] scan tooling / docs / CI cleanup
  • #54[cleanup] mark record protect/unprotect internal (refs #43)
  • #53[security] 64-bit TLS record sequence numbers (closes #44)
  • #52[cleanup] mark wn_msg reader/writer helpers internal
  • #51[security] cert chain constraint checks: CA flag + keyUsage/serverAuth EKU
  • #50[security] ServerHello + encrypted-flight strictness
  • #49[security] free-safety on early handshake failure
  • #48[x509] server identity validation: hostname (SAN/CN) + SPKI pin (#35)
  • #47[security] fix wn_Send length overflow + wn_Close NULL-transport
  • #46[security] TLS 1.3 hardening from a full-repo and RFC 8446 review
  • #42[security] bound attacker-controlled loop lengths (Coverity)
  • #31[handshake] detect and reject HelloRetryRequest
  • #30[pqc] ML-DSA-65 CertificateVerify (scheme 0x0905)
  • #29[example] cert + PQC client example programs
  • #28[ci] Coverity Scan on a daily schedule + scan badge
  • #27[ci] Run wolfNano floor on emulated Cortex-M33 (STM32H563) via m33mu
  • #23[pqc] Wire X25519MLKEM768 hybrid key exchange into the handshake

all work view the repository