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