Skip to content

BearSSL - add BEARSSL_SSL_AEAD_ONLY cipher profile - #9355

Open
MrNoname3 wants to merge 1 commit into
esp8266:masterfrom
MrNoname3:bearssl-aead-only
Open

MrNoname3 wants to merge 1 commit into
esp8266:masterfrom
MrNoname3:bearssl-aead-only

Conversation

@MrNoname3

Copy link
Copy Markdown

Adds BEARSSL_SSL_AEAD_ONLY, a build-time cipher profile next to the existing BEARSSL_SSL_BASIC, and a matching third entry in the IDE's SSL Support menu.

Why

setCiphers() and setSSLVersion() restrict what goes on the wire, but br_ssl_client_base_init() / br_ssl_server_base_init() install every algorithm regardless:

  • the ClientHello's signature_algorithms keeps advertising SHA-1 (and SHA-224), because it is built from the installed hashes, and the X.509 validator still accepts SHA-1 signed certificates;
  • the CBC, CCM and 3DES record code, RSA key exchange, the TLS 1.0/1.1 PRF and MD5 stay linked in, even when the application can never negotiate them.

BEARSSL_SSL_BASIC is the only existing knob, and it goes the other way (RSA key exchange + AES-CBC, no elliptic curves).

What the profile does

  • Default suites: ECDHE-ECDSA / ECDHE-RSA with ChaCha20-Poly1305, AES-128-GCM and AES-256-GCM (client), and the matching ECDSA or RSA subset for the server.
  • TLS 1.2 only: the default minimum version becomes BR_TLS12 (BEARSSL_TLS_MIN_DEFAULT), and setSSLVersion() rejects a lower minimum, since the TLS 1.0/1.1 PRF is not installed.
  • Engine and X.509 hashes: SHA-256/384/512 only.
  • Not installed: CBC, CCM, 3DES, RSA key exchange (rsapub), TLS 1.0 PRF, MD5, SHA-1, SHA-224.
  • setCiphersLessSecure() returns false (its RSA/CBC suites are not built).
  • Defining both BEARSSL_SSL_BASIC and BEARSSL_SSL_AEAD_ONLY is an #error.

Without the flag nothing changes.

Effect

On a D1 mini sketch that keeps one TLS 1.2 connection to an ECDSA-certificate server, the image shrinks by about 18 KB (58 BearSSL symbols dropped: the 3DES, CCM, AES-CBC/CTR-CBC, MD5, SHA-224, TLS 1.0 PRF and RSA key-exchange code). IRAM and static DRAM are unchanged. With the hashes not installed, signature_algorithms lists only the SHA-256/384/512 variants.

Testing

  • Built against both this branch and 3.1.2 (the same patch applies to both); BEARSSL_SSL_BASIC alone still builds, and both flags together stop at the #error.
  • The 3.1.2-based build runs on an ESP8266 that connects to an MQTT broker over TLS 1.2 with an ECDSA certificate.
  • With this branch, a capture of the ESP8266's handshake shows a TLS 1.2 record layer, only the suites the application set, and signature_algorithms without any SHA-1 or SHA-224 entry; the connection then carries application data normally.
  • boards.txt regenerated with tools/boards.txt.py --boardsgen.
  • Documentation: a Build-time Cipher Profiles section in doc/esp8266wifi/bearssl-client-secure-class.rst.

A build-time profile next to BEARSSL_SSL_BASIC: TLS 1.2 only, ECDHE key
exchange with ChaCha20-Poly1305 or AES-GCM only. The default client and
server setup no longer installs CBC, CCM, 3DES, RSA key exchange, the
TLS 1.0/1.1 PRF or the MD5, SHA-1 and SHA-224 hashes, so none of them is
offered in the ClientHello or accepted in a signature, and the linker
drops their code. setSSLVersion() refuses a minimum below TLS 1.2 and
setCiphersLessSecure() fails under the profile.

The IDE gets it as a third "SSL Support" menu entry.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant