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/omega-mv/blob/main/aienux/allen/tests/tls-session-records.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / allen / tests / tls-session-records.om` 256 lines ยท 4511 bytes Raw Blame History 1 note Independent protocol construction per RFC8446 sections5,6; real AEAD, no substituted APIs. 2 note These isolate record/lifecycle logic with provisioned epoch keys, not certificate authentication. 3 global Vrec uchar 1024 4 global Vhold uchar 256 5 global Vn ulong 1 6 fn vreset to void 7 tsclear 8 put Tlsstate 0 2 9 put Tsctl 6 5 10 for i ulong 32 11 put Tskey add i 96 uchar i 12 put Tskey add i 64 uchar add i 64 13 end 14 for i ulong 12 15 put Tsiv add i 36 uchar add i 32 16 put Tsiv add i 24 uchar add i 48 17 end 18 end 19 note Encode server wire independently of tsseal/tsnonce; Tcbuf content supplied by fixture. 20 fn vrecord off ulong n ulong typ uchar seq ulong to bool 21 for i ulong 32 22 put Tckey i uchar i 23 end 24 for i ulong 12 25 put Tciv i uchar add i 32 26 end 27 for i ulong 8 28 p = sub ulong 11 i 29 b = uchar and shr seq mul i 8 255 30 put Tciv p xor get Tciv p b 31 end 32 put Tcbuf n typ 33 put Tcaad 0 23 34 put Tcaad 1 3 35 put Tcaad 2 3 36 put Tcaad 3 uchar shr add n 17 8 37 put Tcaad 4 uchar and add n 17 255 38 if not tcseal add n 1 5 39 ret false 40 end 41 for i ulong 5 42 put Vrec add off i get Tcaad i 43 end 44 for i ulong add n 1 45 put Vrec add add off 5 i get Tcbuf i 46 end 47 for i ulong 16 48 p = add add off n 6 49 put Vrec add p i get Tctag i 50 end 51 put Vn 0 add add off n 22 52 ret true 53 end 54 fn vfeed off ulong n ulong to void 55 for i ulong n 56 put Tlsin i get Vrec add off i 57 end 58 tlsinput n 59 end 60 fn vabc to void 61 put Tcbuf 0 97 62 put Tcbuf 1 98 63 put Tcbuf 2 99 64 end 65 fn main to int 66 vreset 67 vabc 68 if not vrecord 0 3 23 0 69 ret 1 70 end 71 for cut ulong 26 72 vreset 73 vfeed 0 cut 74 if lt cut 25 75 if ne get Tlsappn 0 0 76 ret 2 77 end 78 end 79 vfeed cut sub ulong 25 cut 80 if or ne get Tlsstate 0 2 ne get Tlsappn 0 3 81 ret 3 82 end 83 if or ne get Tlsapp 0 97 ne get Tlsapp 2 99 84 ret 4 85 end 86 tlsconsume 2 87 if or ne get Tlsappn 0 1 ne get Tlsapp 0 99 88 ret 5 89 end 90 if ne get Tlsapp 2 0 91 ret 6 92 end 93 end 94 note Coalesced records have independent sequence nonces and accumulate application data. 95 vreset 96 vabc 97 if not vrecord 0 3 23 0 98 ret 7 99 end 100 put Tcbuf 0 100 101 put Tcbuf 1 101 102 if not vrecord 25 2 23 1 103 ret 8 104 end 105 vfeed 0 get Vn 0 106 if or ne get Tlsappn 0 5 ne get Tlsapp 4 101 107 ret 9 108 end 109 note Tampered tag exposes no plaintext and wipes previously queued authenticated bytes too. 110 vreset 111 put Vrec 24 xor get Vrec 24 1 112 vfeed 0 25 113 if or ne get Tlsstate 0 4 ne get Tlsstate 1 6 114 ret 10 115 end 116 if ne get Tlsappn 0 0 117 ret 11 118 end 119 for i ulong 128 120 if ne get Tskey i 0 121 ret 12 122 end 123 end 124 note A fragmented handshake cannot be interleaved with application data. 125 vreset 126 put Tcbuf 0 4 127 put Tcbuf 1 0 128 if not vrecord 0 2 22 0 129 ret 13 130 end 131 vabc 132 if not vrecord 24 3 23 1 133 ret 14 134 end 135 vfeed 0 get Vn 0 136 if or ne get Tlsstate 0 4 ne get Tlsstate 1 5 137 ret 15 138 end 139 note Valid NewSessionTicket split across two records is discarded without resumption. 140 vreset 141 for i ulong 8 142 put Tcbuf i 0 143 end 144 put Tcbuf 0 4 145 put Tcbuf 3 14 146 put Tcbuf 7 1 147 if not vrecord 0 8 22 0 148 ret 16 149 end 150 for i ulong 10 151 put Tcbuf i 0 152 end 153 put Tcbuf 6 1 154 put Tcbuf 7 99 155 if not vrecord 30 10 22 1 156 ret 17 157 end 158 vabc 159 if not vrecord 62 3 23 2 160 ret 18 161 end 162 vfeed 0 get Vn 0 163 if or ne get Tlsstate 0 2 ne get Tlsappn 0 3 164 ret 19 165 end 166 if ne get Tsctl 1 0 167 ret 20 168 end 169 note KeyUpdate is explicitly refused, never interpreted under stale keys. 170 vreset 171 put Tcbuf 0 24 172 put Tcbuf 1 0 173 put Tcbuf 2 0 174 put Tcbuf 3 1 175 put Tcbuf 4 0 176 if not vrecord 0 5 22 0 177 ret 21 178 end 179 vfeed 0 get Vn 0 180 if or ne get Tlsstate 0 4 ne get Tlsstate 1 17 181 ret 22 182 end 183 note Inner zero padding is removed; an all-zero inner plaintext has no type and is refused. 184 vreset 185 vabc 186 put Tcbuf 3 23 187 put Tcbuf 4 0 188 if not vrecord 0 5 0 0 189 ret 33 190 end 191 vfeed 0 get Vn 0 192 if or ne get Tlsstate 0 2 ne get Tlsappn 0 3 193 ret 34 194 end 195 vreset 196 for i ulong 3 197 put Tcbuf i 0 198 end 199 if not vrecord 0 3 0 0 200 ret 35 201 end 202 vfeed 0 get Vn 0 203 if or ne get Tlsstate 0 4 ne get Tlsstate 1 5 204 ret 36 205 end 206 note Authenticated close_notify, unlike transport EOF, sets cleanClose and queues response. 207 vreset 208 put Tcbuf 0 1 209 put Tcbuf 1 0 210 if not vrecord 0 2 21 0 211 ret 23 212 end 213 vfeed 0 get Vn 0 214 if or ne get Tlsstate 0 3 ne get Tlsstate 2 1 215 ret 24 216 end 217 if ne get Tlsoutn 0 24 218 ret 25 219 end 220 note New writes and close requests do not overwrite an undelivered record. 221 vreset 222 put Tlsplain 0 65 223 if not tlswrite 1 224 ret 26 225 end 226 for i ulong get Tlsoutn 0 227 put Vhold i get Tlsout i 228 end 229 put Tlsplain 0 66 230 if tlswrite 1 231 ret 27 232 end 233 tlsclose 234 if ne get Tlsoutn 0 23 235 ret 28 236 end 237 for i ulong 23 238 if ne get Tlsout i get Vhold i 239 ret 29 240 end 241 end 242 tlssent 243 if or ne get Tlsoutn 0 24 ne get Tlsstate 2 0 244 ret 30 245 end 246 note Sequence use is refused before overflow; no nonce wraps. 247 vreset 248 put Tsseq 0 `4294967295` 249 if tlswrite 0 250 ret 31 251 end 252 if or ne get Tlsstate 0 4 ne get Tlsstate 1 13 253 ret 32 254 end 255 ret 0 256 end