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

133 lines · 2419 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-or-later
2note RFC8439 section2.5.2 and Appendix A.3 vectors1,5,6,7,8,9,10,11.
3note https://www.rfc-editor.org/rfc/rfc8439 ; attribution/license in tls-crypto-fixture.om.
4note Internal primitive entry points are used to isolate reduction and final-pad carry bugs.
5text Vpk "85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b"
6text Vpm "Cryptographic Forum Research Group"
7text Vpt "a8061dc1305136c6c22b8baf0c0127a9"
8text Vred "e33594d7505e43b900000000000000003394d7505e4379cd0100000000000000"
9
10fn tvpoly n ulong to void
11tcminit
12p = ulong 0
13while lt p n bound 4
14m = sub n p
15if gt m 16
16m = 16
17end
18for i ulong m
19put Tcmblk i get Tcbuf add p i
20end
21tcmblock m
22p = add p m
23end
24tcmfinish
25end
26
27fn tvsmall first uchar to void
28tvcheck eq get Tcmtag 0 first 40
29for i ulong 15
30tvcheck eq get Tcmtag add i 1 0 41
31end
32tccwipe
33tvscrub
34end
35
36fn tvreduce last bool to void
37tcwipe
38put Tcmkey 0 1
39put Tcmkey 8 4
40for i ulong 32
41p = mul i 2
42put Tcbuf i tvbyte get Vred p get Vred add p 1
43end
44if last
45put Tcbuf 48 1
46tvpoly 64
47tvcheck eq get Tcmtag 0 20 50
48tvcheck eq get Tcmtag 8 85 51
49for i ulong 16
50if and ne i 0 ne i 8
51tvcheck eq get Tcmtag i 0 52
52end
53end
54else
55tvpoly 48
56tvsmall 19
57end
58end
59
60fn main to int
61tcwipe
62for i ulong 32
63p = mul i 2
64put Tcmkey i tvbyte get Vpk p get Vpk add p 1
65end
66for i ulong len Vpm
67put Tcbuf i get Vpm i
68end
69tvpoly len Vpm
70for i ulong 16
71p = mul i 2
72v = tvbyte get Vpt p get Vpt add p 1
73tvcheck eq get Tcmtag i v 1
74end
75tcwipe
76tvpoly 64
77tvsmall 0
78note Appendix A.3 vector5: final 130-bit partial reduction.
79tcwipe
80put Tcmkey 0 2
81for i ulong 16
82put Tcbuf i 255
83end
84tvpoly 16
85tvsmall 3
86note Vector6: addition of pad overflows modulo2^128.
87tcwipe
88put Tcmkey 0 2
89for i ulong 16
90put Tcmkey add i 16 255
91end
92put Tcbuf 0 2
93tvpoly 16
94tvsmall 3
95note Vector7: all-ones limbs with a carry.
96tcwipe
97put Tcmkey 0 1
98for i ulong 32
99put Tcbuf i 255
100end
101put Tcbuf 16 240
102put Tcbuf 32 17
103tvpoly 48
104tvsmall 5
105note Vector8: accumulator exactly p must encode0.
106tcwipe
107put Tcmkey 0 1
108for i ulong 16
109put Tcbuf i 255
110put Tcbuf add i 16 254
111put Tcbuf add i 32 1
112end
113put Tcbuf 16 251
114tvpoly 48
115tvsmall 0
116note Vector9: accumulator exactly p-1 must not reduce to0.
117tcwipe
118put Tcmkey 0 2
119for i ulong 16
120put Tcbuf i 255
121end
122put Tcbuf 0 253
123tvpoly 16
124tvcheck eq get Tcmtag 0 250 60
125for i ulong 15
126tvcheck eq get Tcmtag add i 1 255 61
127end
128tvreduce true
129tvreduce false
130tcwipe
131tvscrub
132ret 0
133end