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-sha.om

158 lines · 3566 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-or-later
2note SHA256 empty/abc/56-byte standard FIPS180-4 examples; RFC4231 sections4.2..4.5 HMAC.
3note HKDF RFC5869 Appendix A.1/A.3 extract and both expand blocks via public HMAC API.
4note https://www.rfc-editor.org/rfc/rfc4231 https://www.rfc-editor.org/rfc/rfc5869
5note Attribution/license in required tls-crypto-fixture.om. Return0 means every assertion matched.
6text Vhash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff75bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e519ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04"
7text Vokm "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b8871858658da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8"
8text Vabc "abc"
9text Vlong "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
10text Vhi "Hi There"
11text Vjefe "Jefe"
12text Vwhat "what do ya want for nothing?"
13
14fn tvhash slot ulong to void
15for i ulong 32
16p = add mul slot 64 mul i 2
17v = tvbyte get Vhash p get Vhash add p 1
18tvcheck eq get Tcdigest i v 20
19end
20tvscrub
21end
22
23fn tvwipe to void
24tcwipe
25tvscrub
26end
27
28fn tvsha to void
29tvwipe
30tvcheck tcsha 0 1
31tvhash 0
32for i ulong 3
33put Tcbuf i get Vabc i
34end
35put Tcbuf 3 201
36tvcheck tcsha 3 2
37tvhash 1
38for i ulong 3
39tvcheck eq get Tcbuf i get Vabc i 3
40end
41tvcheck eq get Tcbuf 3 201 3
42for i ulong len Vlong
43put Tcbuf i get Vlong i
44end
45tvcheck tcsha len Vlong 4
46tvhash 2
47tvcheck not tcsha 65537 5
48for i ulong 32
49tvcheck eq get Tcdigest i 0 5
50end
51tvcheck not tcsha 18446744073709551615 5
52tvscrub
53end
54
55fn tvhmac to void
56tvwipe
57for i ulong 20
58put Tckey i 11
59end
60for i ulong len Vhi
61put Tcbuf i get Vhi i
62end
63tvcheck tchmac 20 len Vhi 6
64tvhash 3
65for i ulong len Vhi
66tvcheck eq get Tcbuf i get Vhi i 7
67end
68for i ulong 4
69put Tckey i get Vjefe i
70end
71tvcheck tchmac 4 0 8
72for i ulong len Vwhat
73put Tcbuf i get Vwhat i
74end
75tvcheck tchmac 4 len Vwhat 9
76tvhash 4
77for i ulong 20
78put Tckey i 170
79end
80for i ulong 50
81put Tcbuf i 221
82end
83tvcheck tchmac 20 50 10
84tvhash 5
85for i ulong 25
86put Tckey i uchar add i 1
87end
88for i ulong 50
89put Tcbuf i 205
90end
91tvcheck tchmac 25 50 11
92tvhash 6
93tvcheck not tchmac 33 50 12
94tvcheck not tchmac 32 65537 12
95tvcheck not tchmac 18446744073709551615 0 12
96for i ulong 32
97tvcheck eq get Tcdigest i 0 13
98end
99tvcheck eq get Tcbuf 0 205 13
100tvscrub
101end
102
103fn tvhkdf empty bool to void
104tvwipe
105for i ulong 22
106put Tcbuf i 11
107end
108n = ulong 13
109z = ulong 10
110slot = ulong 7
111base = ulong 0
112if empty
113n = 0
114z = 0
115slot = 8
116base = 84
117else
118for i ulong 13
119put Tckey i uchar i
120end
121end
122tvcheck tchmac n 22 14
123tvhash slot
124for i ulong 32
125put Tckey i get Tcdigest i
126end
127for i ulong z
128put Tcbuf i uchar add i 240
129end
130put Tcbuf z 1
131tvcheck tchmac 32 add z 1 15
132for i ulong 32
133p = add base mul i 2
134v = tvbyte get Vokm p get Vokm add p 1
135tvcheck eq get Tcdigest i v 16
136put Tcbuf i get Tcdigest i
137end
138for i ulong z
139put Tcbuf add i 32 uchar add i 240
140end
141put Tcbuf add z 32 2
142tvcheck tchmac 32 add z 33 17
143for i ulong 10
144p = add add base 64 mul i 2
145v = tvbyte get Vokm p get Vokm add p 1
146tvcheck eq get Tcdigest i v 18
147end
148tvscrub
149end
150
151fn main to int
152tvsha
153tvhmac
154tvhkdf false
155tvhkdf true
156tvwipe
157ret 0
158end