Repository navigation
Releases
mojo-tls v0.1.1
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_signintls.asym, and the secp384r1 sign and verify paths inRealCrypto(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
DOWNGRDsentinel when an on-path peer strippedsupported_versionsfrom 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.feedkept 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 - 5bytes 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
TlsServerwith no certificate in itsTlsConfigcrashed the event loop on the first ClientHello. It now raises when it is constructed. - Medium The TLS 1.3 client accepted
key_share,supported_versionsandsignature_algorithmsin EncryptedExtensions when it had offered them. An extension not defined for the message isillegal_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_errorbefore 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 staysunsupported_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.sniand 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=Falsestays silent. - The key loader accepts secp384r1. Before, it refused every curve but P-256.
Audit findings checked and left unchanged:
- #6:
Cipher.sealtakes 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_messageby 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 failedP-256 scalar multonce while this release was checked, with code this release did not touch. The gate retries three times. docs/perf.mdis not re-measured. The only hot-path edit is one integer compare per TLS 1.2 record inwrite_recandpoll.- 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
acf3763test(x509): a P-384 private key loads now; the key stage signs it and openssl verifies137f377fix(tls13): lower-case the server_name the engine keepsed7ed32fix(tls12): str_of builds a String from peer bytes without claiming UTF-899c207dfix(tls13): ServerHello extension alerts follow RFC 8446 4.2b4220a6fix(tls13): EncryptedExtensions only carries extensions defined for itf0afc87fix(net): TlsServer refuses an empty certificate list at construction149edd8fix(tls13): refused early data pays at least one byte per record071cdb7fix(tls12): P-384 certificates in RealCrypto (sign, verify, key loader)2907b6ffix(tls12): compact the input buffer when reads end inside a record140aa8dfix(tls12): refuse to wrap the record sequence number0706298fix(tls12): send the DOWNGRD sentinel whenever a TLS 1.3 server answers with 1.2