interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omtls / src / tlsprod.om

36 lines · 1111 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note tlsprod.om: the product's side of the TLS layer's hooks. Tests link tests/tlshook.om instead, which can fix the
3note ClientHello, the private key, the clock and a pinned leaf for the RFC 8448 replay and can log secrets. None of that
4note exists in a product build: these functions are the only definitions of the hook names there.
5note randomness from Linux getrandom (the `random` host word, blocking until the pool is ready); false when the system
6note gives none, and the handshake then stops with error 19
7fn ot_tl_hk_random b edit uchar * to bool
8n = len b
9p = ulong 0
10while lt p n bound 1000000
11k = random b p sub n p 0
12if eq k -4
13continue
14end
15if le k 0
16ret false
17end
18p = add p ulong k
19end
20ret eq p n
21end
22note no fixed ClientHello: 0 means "build it"
23fn ot_tl_hk_ch ch edit uchar 2048 priv edit uchar 32 to ulong
24ret 0
25end
26fn ot_tl_hk_leaf d view uchar * to void
27end
28note 255 means "validate with the X.509 code"
29fn ot_tl_hk_cert to ulong
30ret 255
31end
32fn ot_tl_hk_now to long
33ret div realns 1000000000
34end
35fn ot_tl_klog which ulong s view uchar 64 to void
36end