Skip to content
This repository was archived by the owner on Nov 22, 2026. It is now read-only.

Releases

mojo-tls v0.1.1

Choose a tag to compare

@amarbarosys amarbarosys released this 13 Nov 00:50

mojo-tls v0.1.1

Released: 2026-11-13 · Commit: tag v0.1.1 · Previous: v0.1.0

What it does

TLS 1.3 and TLS 1.2, client and server, with X.509 certificate validation, in pure Mojo: no OpenSSL, no C library, no foreign calls beyond a few libc
functions. 16.7k lines under src/tls/. It is for Mojo programs that serve HTTPS or connect to TLS servers. Install with pixi add mojo-tls (channels in the README);
examples/server.mojo and examples/client.mojo are the quickstart.

Highlights

  • Security release after an internal audit: 10 of its 14 findings are fixed, and 4 were checked against the RFCs and the tests and need no change.
  • P-384 certificates now work end to end. A TLS 1.2 server can load and use a P-384 key, and a client accepts a P-384 server certificate. Both failed in v0.1.0.
  • A TLS 1.3 server that answers a TLS 1.2 client now always sets the downgrade sentinel (RFC 8446 4.1.3). In v0.1.0 that code could never run.
  • Three denial-of-service paths are closed: an input buffer that grew without bound on TLS 1.2, an early-data budget that empty records never spent, and a server that crashed when its config held no certificate.

Changes

Added

  • P-384 private keys (PKCS#8, SEC1) in the key loader, p384_sign in tls.asym, and the secp384r1 sign and verify paths in RealCrypto (TLS 1.2 key exchange signatures and TLS 1.3 CertificateVerify).

Fixed

Security fixes by severity. The internal audit found them; the downgrade sentinel is graded high and the sequence wrap low.

  • High The TLS 1.2 server did not set the DOWNGRD sentinel when an on-path peer stripped supported_versions from a TLS 1.3 client's hello. The check required the hello to offer 1.3, and such hellos never reach the 1.2 engine.
  • High TLS 1.2 Conn.feed kept every consumed byte when reads ended inside a record, so memory grew with the bytes sent on the connection. The consumed prefix is now dropped past 64 KiB.
  • High TLS 1.3 refused early data charged len - 5 bytes per record to the 64 KiB skip budget. Five-byte records charged 0 and never ran it out. Each record now costs at least one byte.
  • High P-384 certificates failed in RealCrypto (scheme 0x0503, the key loader, verify). A client also rejected a P-384 certificate that the server signed with 0x0403, which TLS 1.2 allows.
  • High TlsServer with no certificate in its TlsConfig crashed the event loop on the first ClientHello. It now raises when it is constructed.
  • Medium The TLS 1.3 client accepted key_share, supported_versions and signature_algorithms in EncryptedExtensions when it had offered them. An extension not defined for the message is illegal_parameter (RFC 8446 4.2).
  • Low TLS 1.2 record sequence numbers wrapped to 0 after 2^64 records, which would repeat the AEAD nonce. Both directions now fail with internal_error before the number wraps.
  • Low A ServerHello extension that the client offered but that is not defined for ServerHello is illegal_parameter. An extension never offered stays unsupported_extension.
  • Low A TLS 1.2 ClientHello with non-UTF-8 ALPN bytes built an invalid String. The bytes now map one code point each, as on the TLS 1.3 path.
  • Low TLS 1.3 kept the SNI as sent (Host.Example.Com). ConnInfo.sni and the ticket binding now use the lower-cased name, as TLS 1.2 does.

Changed

  • A server with a TLS 1.3 engine now sends the downgrade sentinel to every client it answers with TLS 1.2. A client that does not support 1.3 ignores it (RFC 8446 4.1.3), and a server built with tls13=False stays silent.
  • The key loader accepts secp384r1. Before, it refused every curve but P-256.

Audit findings checked and left unchanged:

  • #6: Cipher.seal takes its list borrowed, so the caller keeps it alive. There is no use-after-free.
  • #8: a leading-dot DNS constraint never reaches the matcher, because the parser refuses it.
  • #10: an all-zero inner plaintext is unexpected_message by RFC 8446 5.4.
  • #11: RFC 5280 4.2.1.10 allows a leading period only in URI constraints, and x509-limbo pins the refusal.

Verified

The gates ran on the tree of 137f377, the last commit that changes src/. Later commits change tests and docs.

Check Result
scripts/ci.sh (sym vectors, asym with timing check, x509 with limbo, tls13 gate with interop, check.sh, example.sh) PASS 6/6 gates
tests/check.sh mutants (TLS 1.2 and net mutants, five of them new) PASS gate, all mutants killed; interop 49 PASS, 0 FAIL with P-256, P-384 and RSA keys
tests/gate_tls13.sh --mutants PASS lane 4 gate; rr_grow PASS natively and under heaptide
tests/mutants_x509.sh 59 of 59 mutants killed
tests/oracle.sh signatures from p384_sign verify in openssl, 8 of 8
x509-limbo 9748 cases, 9730 agree, the same 18 pinned as in v0.1.0
tests/matrix.sh (full run by the owner: openssl 3.6.5, Firefox 159.0.1, Vivaldi 8.3.4191.30, Chromium 158, tlsfuzzer 5eebc44, testssl 3c26038) RESULT pass=176 skip=11 fail=0, PASS matrix

Known limits

  • No independent security audit. The timing test (tests/ct.mojo) is a statistical dudect check. On a busy machine it fails sometimes: the unmodified v0.1.0 binary failed P-256 scalar mult once while this release was checked, with code this release did not touch. The gate retries three times.
  • docs/perf.md is not re-measured. The only hot-path edit is one integer compare per TLS 1.2 record in write_rec and poll.
  • ECDSA P-384 signing derives its nonce as RFC 6979 prescribes (HMAC-SHA-384). Its only oracle is openssl verification, because Wycheproof has no signing vectors for it.

Upgrade / run

pixi add mojo-tls@0.1.1

No API changes. TlsServer now raises when TlsConfig.certs is empty.

Commits

  • acf3763 test(x509): a P-384 private key loads now; the key stage signs it and openssl verifies
  • 137f377 fix(tls13): lower-case the server_name the engine keeps
  • ed7ed32 fix(tls12): str_of builds a String from peer bytes without claiming UTF-8
  • 99c207d fix(tls13): ServerHello extension alerts follow RFC 8446 4.2
  • b4220a6 fix(tls13): EncryptedExtensions only carries extensions defined for it
  • f0afc87 fix(net): TlsServer refuses an empty certificate list at construction
  • 149edd8 fix(tls13): refused early data pays at least one byte per record
  • 071cdb7 fix(tls12): P-384 certificates in RealCrypto (sign, verify, key loader)
  • 2907b6f fix(tls12): compact the input buffer when reads end inside a record
  • 140aa8d fix(tls12): refuse to wrap the record sequence number
  • 0706298 fix(tls12): send the DOWNGRD sentinel whenever a TLS 1.3 server answers with 1.2