interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / tests / tls-crypto-aead.om

179 lines · 3962 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-or-later
2note RFC8439 sections2.3.2/2.8.2 official block and AEAD vectors; negative cases mutate those vectors.
3note https://www.rfc-editor.org/rfc/rfc8439 ; attribution/license in tls-crypto-fixture.om.
4note Additional zero/partial/full/block-boundary/max-buffer roundtrips are property tests, not oracles.
5text Vblock "10f1e7e4d13b5915500fdd1fa32071c4c7d1f4c733c068030422aa9ac3d46c4ed2826446079faa0914c2d705d98b02a2b5129cd1de164eb9cbd083e8a2503c4e"
6text Vplain "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."
7text Vcipher "d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116"
8text Vtag "1ae10b594f09e26a7e902ecbd0600691"
9text Vaad "50515253c0c1c2c3c4c5c6c7"
10
11fn tvblock to void
12tcwipe
13for i ulong 32
14put Tckey i uchar i
15end
16put Tciv 3 9
17put Tciv 7 74
18tccblock 1
19for i ulong 64
20p = mul i 2
21v = tvbyte get Vblock p get Vblock add p 1
22tvcheck eq get Tccblk i v 1
23end
24tccwipe
25tvscrub
26end
27
28fn tvsetup to void
29tcwipe
30for i ulong 32
31put Tckey i uchar add i 128
32end
33put Tciv 0 7
34for i ulong 8
35put Tciv add i 4 uchar add i 64
36end
37for i ulong 12
38p = mul i 2
39put Tcaad i tvbyte get Vaad p get Vaad add p 1
40end
41for i ulong len Vplain
42put Tcbuf i get Vplain i
43end
44put Tcbuf len Vplain 221
45end
46
47fn tvcipher to void
48for i ulong len Vplain
49p = mul i 2
50v = tvbyte get Vcipher p get Vcipher add p 1
51tvcheck eq get Tcbuf i v 2
52end
53tvcheck eq get Tcbuf len Vplain 221 3
54tvscrub
55end
56
57fn tvtag to void
58for i ulong 16
59p = mul i 2
60v = tvbyte get Vtag p get Vtag add p 1
61tvcheck eq get Tctag i v 4
62end
63end
64
65fn tvbad to void
66note Each bit of every tag byte is checked, with ciphertext unchanged after every rejection.
67for i ulong 16
68for j ulong 8
69v = shl uchar 1 j
70put Tctag i xor get Tctag i v
71tvcheck not tcopen len Vplain 12 5
72tvcipher
73put Tctag i xor get Tctag i v
74end
75end
76for i ulong 12
77put Tcaad i xor get Tcaad i 1
78tvcheck not tcopen len Vplain 12 6
79tvcipher
80put Tcaad i xor get Tcaad i 1
81end
82for i ulong 12
83put Tciv i xor get Tciv i 1
84tvcheck not tcopen len Vplain 12 7
85tvcipher
86put Tciv i xor get Tciv i 1
87end
88for i ulong 32
89put Tckey i xor get Tckey i 1
90tvcheck not tcopen len Vplain 12 8
91tvcipher
92put Tckey i xor get Tckey i 1
93end
94for i ulong len Vplain
95put Tcbuf i xor get Tcbuf i 1
96tvcheck not tcopen len Vplain 12 9
97put Tcbuf i xor get Tcbuf i 1
98tvcipher
99end
100tvcheck not tcopen sub len Vplain 1 12 10
101tvcipher
102tvcheck not tcopen len Vplain 11 11
103tvcipher
104tvcheck not tcopen 65537 12 12
105tvcipher
106tvcheck not tcopen len Vplain 33 12
107tvcipher
108tvcheck not tcopen 18446744073709551615 0 12
109tvcipher
110tvcheck not tcseal 65537 12 13
111tvcipher
112tvcheck not tcseal len Vplain 33 13
113tvcipher
114for i ulong 16
115p = mul i 2
116put Tctag i tvbyte get Vtag p get Vtag add p 1
117end
118end
119
120fn tvround n ulong aadlen ulong to void
121tcwipe
122for i ulong 32
123put Tckey i uchar i
124put Tcaad i uchar add i 32
125end
126note Unique deterministic fixture nonce per length/AAD combination; not production randomness.
127put Tciv 0 uchar and n 255
128put Tciv 1 uchar and shr n 8 255
129put Tciv 2 uchar and shr n 16 255
130put Tciv 3 uchar aadlen
131for i ulong n
132put Tcbuf i uchar and i 255
133end
134if lt n 65536
135put Tcbuf n 233
136end
137tvcheck tcseal n aadlen 30
138tvscrub
139tvcheck tcopen n aadlen 31
140tvscrub
141for i ulong n
142tvcheck eq get Tcbuf i uchar and i 255 32
143end
144if lt n 65536
145tvcheck eq get Tcbuf n 233 33
146end
147end
148
149fn main to int
150tvblock
151tvsetup
152tvcheck tcseal len Vplain 12 14
153tvcipher
154tvtag
155tvbad
156tvcheck tcopen len Vplain 12 15
157for i ulong len Vplain
158tvcheck eq get Tcbuf i get Vplain i 16
159end
160tvscrub
161tvround 0 0
162tvround 1 1
163tvround 15 15
164tvround 16 16
165tvround 17 17
166tvround 63 31
167tvround 64 32
168tvround 65 0
169tvround 65536 32
170tcwipe
171tvscrub
172for i ulong 65536
173tvcheck eq get Tcbuf i 0 34
174end
175for i ulong 32
176tvcheck eq get Tckey i 0 35
177end
178ret 0
179end