Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omtls/blob/main/README.md # omtls omtls: a TLS 1.3 client (RFC 8446) written fresh in seeded Omega, for mailhand. Not audited by a cryptographer. Free (Apache-2.0). Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omtls / README.md` 132 lines ยท 9403 bytes Raw Blame History Source # omtls omtls is a TLS 1.3 client written in seeded Omega, the language of omega-mv . It exists so that mailhand can read and send mail on a real mail account (IMAP on port 993, SMTP submission on 465 or 587) without a host TLS library. It was written fresh from the public standards (RFC 8446 and the RFCs and FIPS documents named below), in Omega only: no C, Rust, Python or shell logic, no OpenSSL or other TLS library in the product. It has not been audited by a cryptographer. Read the section "What it is not" before you rely on it. ## What it does - TLS 1.3 (RFC 8446), client side only. It refuses TLS 1.2 and older with a clear error; it never downgrades. - Cipher suites TLS_CHACHA20_POLY1305_SHA256 and TLS_AES_128_GCM_SHA256; key exchange X25519. - Server authentication: the certificate chain is built and checked against a trust store you give it as a PEM file (for example `/etc/ssl/certs/ca-certificates.crt`): validity dates, host name (subjectAltName only), basicConstraints and path length, keyUsage, extKeyUsage, unknown critical extensions, and the signatures (RSA PKCS#1 v1.5 and RSA-PSS for certificates, RSA-PSS and ECDSA P-256/P-384 for the server's CertificateVerify). - SNI, optional ALPN, Finished verification, alerts, KeyUpdate in both directions, close_notify. A stream that ends without close_notify is reported as truncated, never as the end of the data. - An empty client Certificate when the server asks for one (no client certificates). ## How to build and check it You need only this repository and the compiler named in `PIN`, the one place the pin is written: the omega-mv commit on its first line and the sha256 of that commit's `seed/out/omc` on its second. Copy that `seed/out/omc` to `./omc` (for example `git --git-dir OMEGA-MV.git cat-file blob COMMIT:seed/out/omc > omc`). The gate refuses any other compiler. The host is Linux on AArch64. ``` mkdir -p build && ./omc < tools/boot.om > build/boot && chmod 755 build/boot build/boot gate && build/gate # checks the compiler pin, builds everything, runs every test build/boot omtls # the command: build/omtls HOST PORT [ROOTS [ALPN [CONNECT-ADDRESS]]] ``` `build/boot UNIT` joins the files listed in `units/UNIT.list` into one unit and compiles it. The library for other programs is `units/lib.list`. ## What it has been checked against The gate (`tests/GATE`, run by `build/gate`) runs all of these. Where every vector file came from and its sha256 is in `tests/vectors/PROVENANCE.md`. - Known-answer tests for every primitive: SHA-256/384/512 (NIST CAVP), HMAC (RFC 4231), HKDF (RFC 5869 and Wycheproof), ChaCha20, Poly1305 and ChaCha20-Poly1305 (RFC 8439 and Wycheproof), AES-128/256 and GCM (FIPS 197, NIST GCM vectors and Wycheproof), X25519 (RFC 7748 including the 1000-iteration vector, and Wycheproof, including the low-order points), RSA PKCS#1 v1.5 and RSA-PSS verification and ECDSA P-256 and P-384 verification (Wycheproof and NIST CAVP), plus hand-written edge cases. - RFC 8448 section 3 ("Simple 1-RTT Handshake") replayed byte for byte: given the trace's ClientHello and key, the client produces the trace's records exactly and derives the trace's traffic secrets. - A hostile test server (written in Omega, `tests/srv/tlssrv.om`) on a private port, 27 cases: bad Finished, bad CertificateVerify, wrong certificate name, expired certificate, untrusted root, truncated and oversized records during and after the handshake, a TLS 1.2 ServerHello with the downgrade sentinel, a TLS 1.3 ServerHello carrying the sentinel, a HelloRetryRequest, a low-order key share, an unsolicited extension, plaintext after the keys changed, an alert flood, a renegotiation attempt, a bad record MAC, a wrong session id echo, a PKCS#1 CertificateVerify, a certificate entry of 1,000,001 bytes, a stream that ends without close_notify, and the good paths (both suites, ALPN, KeyUpdate both ways, a flight split into 7-byte records). Each gives its defined error, no crash, and the client sends no application data after a refusal. - Mutants: each check that matters has a deliberately broken copy (skip Finished verification, skip name matching, accept expired certificates, a branching compare in the constant-time code, and more); the gate requires every one of them to fail its test. - OpenSSL `s_server` as a verification oracle only (never linked): both suites, an RSA and an ECDSA certificate chain, and the refusals of a TLS 1.2-only and a P-256-only server. - Real servers: handshakes to interplane.io (HTTPS) and to mail providers' IMAP ports (handshake and greeting only, no login). ## Constant time The code that touches secrets is split into a core (`src/ct/`) and the code around it. The core takes only fixed-size arrays, every loop in it is unrolled by the compiler and every array index is a constant. The gate compiles the core and reads the machine code the compiler wrote (`ctscan` in `tools/gate.om`): it refuses any conditional branch, any division instruction, any load or store whose address comes from a register offset (an index that could depend on a secret) and any indirect branch (the trap path). So the claim "no secret-dependent branch or memory address in the primitives" is checked on the compiler's output, not only on the source. Tag and Finished comparisons are fixed-length and go through that core. The code around the core (loops over message lengths, record handling) branches only on public values: lengths, counters and protocol fields. That part is checked by reading, not by the scan. One known exception: removing the zero padding of a received record (`ot_tl_dec`) scans back to the last non-zero byte, so its time depends on the padding length the server chose (RFC 8446 5.4 accepts this; omtls never pads). On AArch64 the program also sets the DIT bit (data-independent timing) before the handshake. ## Limits What Limit Why Record 2^14 plaintext, 2^14 + 256 protected RFC 8446 wire limits Handshake message 2^24 - 1 bytes the 24-bit length field One certificate entry 1 MiB (refused above: error 24) handed to the X.509 code as a local array: the compiler gives no run-time allocation and globals cannot be passed RSA modulus 16384 bits bignum limbs are stack arrays, same reason Trust store plus presented chain 16 MiB less 64 KiB the X.509 store; a larger store is refused, never truncated Certificate path search 1,000,000 candidate examinations stops a hostile server's cross-certificate maze (containment of untrusted input) Every network operation 30 s, one deadline per handshake / read / write liveness against a stuck peer; settable with `ot_tl_deadline` ## Keys and secrets - Randomness comes from Linux getrandom (the `random` word). If the system gives none, the handshake stops with error 19; nothing falls back to a weaker source. - The handshake secrets live in one local array and are overwritten before the handshake returns; the traffic keys are overwritten when the connection closes or fails; after the handshake and after every record operation the dead stack below the caller is zeroed with the Omega `scrub` word. - Where the language does not let us: Omega has no way to pin memory or keep it out of a core dump or swap, and copies the compiler makes in registers are only cleared by `scrub` as far as it reaches. ## What it is not - Not audited. No cryptographer has reviewed it. An audit should look first at: the constant-time claim for the code around the core (`src/aead.om`, `src/gcm.om`, `src/x25519.om` drivers and `src/tls.om`), the AES S-box and GHASH implementations (`src/ct/aes.om`), the X25519 field arithmetic bounds (`src/ct/x25.om`), the RSA and ECDSA verification code (`src/rsa.om`, `src/ec.om`, `src/bn.om`), the certificate path builder and name matching (`src/x509.om`), and the handshake state machine (`src/tls.om`): which message may follow which, and every length check. - Not a server; no session resumption, no 0-RTT, no PSK, no client certificates, no HelloRetryRequest. - Only the two suites and X25519 above. TLS_AES_256_GCM_SHA384 and the P-256/P-384 key shares are not offered. Of the providers checked on 2026-11-11 only Microsoft's (outlook.office365.com) needs them: it does not offer X25519 at all; and Microsoft mail also needs OAuth2, which is not in this slice. - No OAuth2 (XOAUTH2): Microsoft (Outlook.com, Hotmail, Microsoft 365) cannot be used; Gmail, Yahoo and iCloud work only with an app password, which those providers allow only with two-step verification on the account. - No OCSP, CRLs or certificate transparency checks; name constraints only for DNS names. - IPv4 only; the DNS lookup is a plain UDP query to the system's resolver (TLS checks the name, DNS does not). - AES-GCM is slow (about 7 MB/s, a bitsliced constant-time AES); servers that prefer ChaCha20-Poly1305 run at about 170 MB/s. - Not tested on any CPU but the Spark's GB10 (AArch64). - `tests/fixtures/` holds private keys made for the tests; they protect nothing. ## Licence Apache-2.0, see LICENSE. `vendor/omega-mcp/sha256-om2.om` is the SHA-256 unit from omega-mv, copied unchanged from omega-mcp (see NOTICE).