interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / om / tls / test / fuzz / fz_https.om

95 lines · 2709 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note fz_https.om: fuzz target for an HTTPS response read through seed/net/https.om: http.om's
3note response parser (hrsprd, hbodyall) over the TLS transport (htlsrecv, htlsrecvd), so the TLS
4note record layer and the post-handshake path of om/tls/tls.om (tls_read, tls_rdapp, tls_rdrec,
5note tls_ralert, tls_post: NewSessionTicket, KeyUpdate) see the same bytes as the HTTP parser.
6note The connection starts as already established (fixed application keys, as after tls_connect):
7note the handshake itself is fz_flight's target.
8note Input: M chunks. M bit 0: response to HEAD; bit 1: suite (0 = TLS_CHACHA20_POLY1305_SHA256,
9note 1 = TLS_AES_128_GCM_SHA256). The chunks (common.om fz_feed) are sealed under the server's
10note application key and are all in the socket, its write side shut, before the client reads.
11
12note fz_tset: an established client state t on fd with suite su and fixed keys
13fn fz_tset t edit uchar * fd ulong su ulong to void
14tls_pn t TLFD fd 4
15put t TLPH 1
16put t TLSU uchar su
17put t TLWK 1
18put t TLRK 1
19put t TLCCS 2
20fz_fill t TLSAP 32 65
21fz_fill t TLCAP 32 97
22fz_fill t TLWKEY 32 129
23fz_fill t TLWIV 12 161
24fz_fill t TLRKEY 32 173
25fz_fill t TLRIV 12 205
26end
27
28note fz_mirc: m = the server side of t: it seals with t's read key and traffic secret, writing to fd
29fn fz_mirc m edit uchar * t view uchar * fd ulong to void
30for i ulong 32
31put m add TLWKEY i get t add TLRKEY i
32put m add TLSAP i get t add TLSAP i
33end
34for i ulong 12
35put m add TLWIV i get t add TLRIV i
36end
37put m TLSU get t TLSU
38put m TLWK 1
39tls_pn m TLFD fd 4
40end
41
42note fz_sconn: client cs/io on a socket pair, TLS established, every chunk of x sealed into it and
43note the server's write side shut; 0 ok, negative when the setup failed
44fn fz_sconn cs edit ulong 320 io edit uchar 262144 m edit uchar * x view uchar * to long
45fds = new ulong 2 0
46if ne fz_pair fds 0
47ret -1
48end
49r = hinit cs io int get fds 0 0
50if lt r 0
51ret r
52end
53r = htlsinit cs io FZHOST
54if lt r 0
55ret r
56end
57b = get cs HTB
58su = add 1 and shr ulong get x 0 1 1
59fz_tset part io b TLCSZ get fds 0 su
60fz_mirc m view part io b TLCSZ get fds 1
61s = fz_feed m x 1
62z = shutdown int get fds 1 1
63ret 0
64end
65
66fn fz_srun cs edit ulong 320 io edit uchar 262144 m edit uchar * x view uchar * to long
67aux = new uchar 65536 0
68r = fz_sconn cs io m x
69if lt r 0
70ret r
71end
72put cs HHEADMX 2048
73put cs HHMAX 16
74put cs HBCAP 4096
75put cs HFRMAX 1024
76put cs HISHEAD and ulong get x 0 1
77r = hrsprd cs io
78if le r 0
79ret r
80end
81ret hbodyall cs io part aux 0 65536
82end
83
84fn main to int
85cs = new ulong 320 0
86io = new uchar 262144 0
87m = new uchar TLCSZ 0
88in = new uchar FZCAP 0
89n = fz_read in
90if lt n 1
91ret 0
92end
93r = fz_srun cs io m part in 0 n
94ret 0
95end