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 Rendered 1 # omtls 2 3 omtls is a TLS 1.3 client written in seeded Omega, the language of 4 [omega-mv](https://interplane.io/drakestapleton/omega-mv). It exists so that 5 [mailhand](https://interplane.io/drakestapleton/mailhand) can read and send mail on a real mail account 6 (IMAP on port 993, SMTP submission on 465 or 587) without a host TLS library. It was written fresh from the 7 public standards (RFC 8446 and the RFCs and FIPS documents named below), in Omega only: no C, Rust, Python 8 or shell logic, no OpenSSL or other TLS library in the product. 9 10 **It has not been audited by a cryptographer.** Read the section "What it is not" before you rely on it. 11 12 ## What it does 13 14 - TLS 1.3 (RFC 8446), client side only. It refuses TLS 1.2 and older with a clear error; it never 15 downgrades. 16 - Cipher suites TLS_CHACHA20_POLY1305_SHA256 and TLS_AES_128_GCM_SHA256; key exchange X25519. 17 - Server authentication: the certificate chain is built and checked against a trust store you give it as 18 a PEM file (for example `/etc/ssl/certs/ca-certificates.crt`): validity dates, host name (subjectAltName 19 only), basicConstraints and path length, keyUsage, extKeyUsage, unknown critical extensions, and the 20 signatures (RSA PKCS#1 v1.5 and RSA-PSS for certificates, RSA-PSS and ECDSA P-256/P-384 for the 21 server's CertificateVerify). 22 - SNI, optional ALPN, Finished verification, alerts, KeyUpdate in both directions, close_notify. A stream 23 that ends without close_notify is reported as truncated, never as the end of the data. 24 - An empty client Certificate when the server asks for one (no client certificates). 25 26 ## How to build and check it 27 28 You need only this repository and the compiler named in `PIN`, the one place the pin is written: the omega-mv 29 commit on its first line and the sha256 of that commit's `seed/out/omc` on its second. Copy that `seed/out/omc` 30 to `./omc` (for example `git --git-dir OMEGA-MV.git cat-file blob COMMIT:seed/out/omc > omc`). The gate refuses any 31 other compiler. The host is Linux on AArch64. 32 33 ``` 34 mkdir -p build && ./omc < tools/boot.om > build/boot && chmod 755 build/boot 35 build/boot gate && build/gate # checks the compiler pin, builds everything, runs every test 36 build/boot omtls # the command: build/omtls HOST PORT [ROOTS [ALPN [CONNECT-ADDRESS]]] 37 ``` 38 39 `build/boot UNIT` joins the files listed in `units/UNIT.list` into one unit and compiles it. The library for 40 other programs is `units/lib.list`. 41 42 ## What it has been checked against 43 44 The gate (`tests/GATE`, run by `build/gate`) runs all of these. Where every vector file came from and its 45 sha256 is in `tests/vectors/PROVENANCE.md`. 46 47 - Known-answer tests for every primitive: SHA-256/384/512 (NIST CAVP), HMAC (RFC 4231), HKDF (RFC 5869 and 48 Wycheproof), ChaCha20, Poly1305 and ChaCha20-Poly1305 (RFC 8439 and Wycheproof), AES-128/256 and GCM 49 (FIPS 197, NIST GCM vectors and Wycheproof), X25519 (RFC 7748 including the 1000-iteration vector, and 50 Wycheproof, including the low-order points), RSA PKCS#1 v1.5 and RSA-PSS verification and ECDSA P-256 and 51 P-384 verification (Wycheproof and NIST CAVP), plus hand-written edge cases. 52 - RFC 8448 section 3 ("Simple 1-RTT Handshake") replayed byte for byte: given the trace's ClientHello and key, 53 the client produces the trace's records exactly and derives the trace's traffic secrets. 54 - A hostile test server (written in Omega, `tests/srv/tlssrv.om`) on a private port, 27 cases: bad Finished, 55 bad CertificateVerify, wrong certificate name, expired certificate, untrusted root, truncated and oversized 56 records during and after the handshake, a TLS 1.2 ServerHello with the downgrade sentinel, a TLS 1.3 57 ServerHello carrying the sentinel, a HelloRetryRequest, a low-order key share, an unsolicited extension, 58 plaintext after the keys changed, an alert flood, a renegotiation attempt, a bad record MAC, a wrong 59 session id echo, a PKCS#1 CertificateVerify, a certificate entry of 1,000,001 bytes, a stream that ends 60 without close_notify, and the good paths (both suites, ALPN, KeyUpdate both ways, a flight split into 61 7-byte records). Each gives its defined error, no crash, and the client sends no application data after a 62 refusal. 63 - Mutants: each check that matters has a deliberately broken copy (skip Finished verification, skip name 64 matching, accept expired certificates, a branching compare in the constant-time code, and more); the 65 gate requires every one of them to fail its test. 66 - OpenSSL `s_server` as a verification oracle only (never linked): both suites, an RSA and an ECDSA 67 certificate chain, and the refusals of a TLS 1.2-only and a P-256-only server. 68 - Real servers: handshakes to interplane.io (HTTPS) and to mail providers' IMAP ports (handshake and 69 greeting only, no login). 70 71 ## Constant time 72 73 The code that touches secrets is split into a core (`src/ct/`) and the code around it. The core takes only 74 fixed-size arrays, every loop in it is unrolled by the compiler and every array index is a constant. The 75 gate compiles the core and reads the machine code the compiler wrote (`ctscan` in `tools/gate.om`): it 76 refuses any conditional branch, any division instruction, any load or store whose address comes from a 77 register offset (an index that could depend on a secret) and any indirect branch (the trap path). So the 78 claim "no secret-dependent branch or memory address in the primitives" is checked on the compiler's output, 79 not only on the source. Tag and Finished comparisons are fixed-length and go through that core. 80 The code around the core (loops over message lengths, record handling) branches only on public values: 81 lengths, counters and protocol fields. That part is checked by reading, not by the scan. One known 82 exception: removing the zero padding of a received record (`ot_tl_dec`) scans back to the last non-zero byte, 83 so its time depends on the padding length the server chose (RFC 8446 5.4 accepts this; omtls never pads). 84 On AArch64 the program also sets the DIT bit (data-independent timing) before the handshake. 85 86 ## Limits 87 88 | What | Limit | Why | 89 |---|---|---| 90 | Record | 2^14 plaintext, 2^14 + 256 protected | RFC 8446 wire limits | 91 | Handshake message | 2^24 - 1 bytes | the 24-bit length field | 92 | 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 | 93 | RSA modulus | 16384 bits | bignum limbs are stack arrays, same reason | 94 | Trust store plus presented chain | 16 MiB less 64 KiB | the X.509 store; a larger store is refused, never truncated | 95 | Certificate path search | 1,000,000 candidate examinations | stops a hostile server's cross-certificate maze (containment of untrusted input) | 96 | Every network operation | 30 s, one deadline per handshake / read / write | liveness against a stuck peer; settable with `ot_tl_deadline` | 97 98 ## Keys and secrets 99 100 - Randomness comes from Linux getrandom (the `random` word). If the system gives none, the handshake stops 101 with error 19; nothing falls back to a weaker source. 102 - The handshake secrets live in one local array and are overwritten before the handshake returns; the 103 traffic keys are overwritten when the connection closes or fails; after the handshake and after every 104 record operation the dead stack below the caller is zeroed with the Omega `scrub` word. 105 - Where the language does not let us: Omega has no way to pin memory or keep it out of a core dump or swap, 106 and copies the compiler makes in registers are only cleared by `scrub` as far as it reaches. 107 108 ## What it is not 109 110 - **Not audited.** No cryptographer has reviewed it. An audit should look first at: the constant-time 111 claim for the code around the core (`src/aead.om`, `src/gcm.om`, `src/x25519.om` drivers and `src/tls.om`), 112 the AES S-box and GHASH implementations (`src/ct/aes.om`), the X25519 field arithmetic bounds 113 (`src/ct/x25.om`), the RSA and ECDSA verification code (`src/rsa.om`, `src/ec.om`, `src/bn.om`), the 114 certificate path builder and name matching (`src/x509.om`), and the handshake state machine 115 (`src/tls.om`): which message may follow which, and every length check. 116 - Not a server; no session resumption, no 0-RTT, no PSK, no client certificates, no HelloRetryRequest. 117 - Only the two suites and X25519 above. TLS_AES_256_GCM_SHA384 and the P-256/P-384 key shares are not 118 offered. Of the providers checked on 2026-11-11 only Microsoft's (outlook.office365.com) needs them: it does not 119 offer X25519 at all; and Microsoft mail also needs OAuth2, which is not in this slice. 120 - No OAuth2 (XOAUTH2): Microsoft (Outlook.com, Hotmail, Microsoft 365) cannot be used; Gmail, Yahoo and iCloud 121 work only with an app password, which those providers allow only with two-step verification on the account. 122 - No OCSP, CRLs or certificate transparency checks; name constraints only for DNS names. 123 - IPv4 only; the DNS lookup is a plain UDP query to the system's resolver (TLS checks the name, DNS does not). 124 - AES-GCM is slow (about 7 MB/s, a bitsliced constant-time AES); servers that prefer ChaCha20-Poly1305 run at 125 about 170 MB/s. 126 - Not tested on any CPU but the Spark's GB10 (AArch64). 127 - `tests/fixtures/` holds private keys made for the tests; they protect nothing. 128 129 ## Licence 130 131 Apache-2.0, see LICENSE. `vendor/omega-mcp/sha256-om2.om` is the SHA-256 unit from omega-mv, copied 132 unchanged from omega-mcp (see NOTICE).