$ show cloudflare/tls-tris
cloudflare/tls-tris is a Go library that extends the standard library's crypto/tls package with experimental TLS 1.3 support, post-quantum key exchange (SIDH, SIKE, and hybrids), delegated credentials, and 0-RTT. It is not a standalone package; it replaces the Go standard library's crypto/tls via a patched GOROOT. The library implements full client and server TLS 1.3 handshakes, record layer processing, session ticketing, and provides APIs consistent with the standard Go tls package (tls.Config, tls.Conn, tls.Dial). The codebase is derived from Go 1.10-era crypto/tls with extensive modifications. It includes integration with Cloudflare's SIDH library for post-quantum cryptography and supports hybrid key exchange combining X25519 with SIDH or SIKE. The repository contains comprehensive test infrastructure including golden test data files, BoringSSL test suite runner (bogo), Docker-based interop testing against other TLS implementations (NSS, picotls, mint), and Caddy integration examples. However, the TLS 1.3 implementation is based on early IETF drafts (draft-18, -21, -22, -28) and is not compliant with the final RFC 8446. The post-quantum algorithms SIDH and SIKE have been broken by the Castryck-Decru attack; this code is cryptographically obsolete. The library requires a custom Go toolchain (patched from Go 1.10) and cannot be vendored or used as a standard Go module, making it incompatible with modern Go development workflows.
The LLM identified 4 files worth highlighting for reuse:
Defines a `kex` interface with methods `generateKeyShare` and `keyAgreementClient`/`keyAgreementServer`, and provides concrete implementations for NIST curves, X25519, SIDHp503, SIKEp503, and hybrid combinations (e.g., X25519+SIDH). Each implementation encapsulates the specific arithmetic and protocol differences, making it easy to add new key exchange algorithms without modifying the handshake logic. This is a clean example of the Strategy pattern applied to cryptographic key agreement and is reusable in any Go TLS implementation that needs to support multiple curves.
Implements the `Conn` struct and `halfConn` for managing TLS record layer encryption state. `halfConn` handles sequence numbers, MAC, cipher operations (encrypt, decrypt), and CBC padding removal in a constant-time manner. The separation of read and write states into two `halfConn` instances within `Conn` provides a clean abstraction for bidirectional encrypted streams. This pattern is reusable in any protocol that requires a stateful encrypted record layer with sequence number replay protection.
Contains all TLS handshake message types (e.g., ClientHelloMsg, ServerHelloMsg, CertificateMsg13) with consistent marshal/unmarshal methods, raw byte caching, and equality checks. The pattern is a type-safe, version-aware serialization layer that can be extended for new handshake messages. The caching of serialized forms avoids redundant encoding in repeated operations. This design is reusable for any binary protocol message definition.
A Python unittest-based test runner that orchestrates Docker containers running various TLS implementations (BoringSSL, NSS, picotls, mint, and the tris-testclient) and performs handshake tests with configurable parameters (cipher suites, 0-RTT, ALPN, post-quantum groups). It provides a reusable framework for testing TLS implementations across different stacks. The runner is well-structured with parameterized test cases and clear failure reporting, and can be adapted to test any TLS library that provides a command-line client/server interface.