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

106 lines · 2920 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-or-later
2note RFC7748 sections5.2/6.1 official scalar/u/public/shared vectors.
3note https://www.rfc-editor.org/rfc/rfc7748 ; attribution/license in tls-crypto-fixture.om.
4note Negative/metamorphic cases exercise specified clamping, top-bit masking, noncanonical input,
5note small-order rejection, preserved input buffers, and cleared internal scalar/field scratch.
6text Vs "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac44b66e9d4d1b4673c5ad22691957d6af5c11b6421e0ea01d42ca4169e7918ba0d77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb"
7text Vu "e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4ce5210f12786811d3f4b7959d0538ae2c31dbe7106fc03c3efc4cd549c715a4938520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6ade9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f"
8text Vx "c3da55379de9c6908e94ea4df28d084f32eccf03491c71f754b4075577a2855295cbde9476e8907d7aade45cb4b873f88b595a68799fa152e6f8f7647aac79574a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079"
9
10fn tvxload slot ulong peer ulong to void
11for i ulong 32
12p = add mul slot 64 mul i 2
13put Tcxpriv i tvbyte get Vs p get Vs add p 1
14p = add mul peer 64 mul i 2
15put Tcxpeer i tvbyte get Vu p get Vu add p 1
16end
17end
18
19fn tvxwant slot ulong to void
20for i ulong 32
21p = add mul slot 64 mul i 2
22v = tvbyte get Vx p get Vx add p 1
23tvcheck eq get Tcxshare i v 10
24end
25tvscrub
26end
27
28fn tvxpub slot ulong to void
29for i ulong 32
30p = add mul slot 64 mul i 2
31v = tvbyte get Vu p get Vu add p 1
32tvcheck eq get Tcxpub i v 11
33p = add mul slot 64 mul i 2
34v = tvbyte get Vs p get Vs add p 1
35tvcheck eq get Tcxpriv i v 12
36end
37tvscrub
38end
39
40fn tvxzero to void
41tvcheck not tcx25519 20
42for i ulong 32
43tvcheck eq get Tcxshare i 0 21
44end
45tvscrub
46end
47
48fn main to int
49tcwipe
50tvxload 0 0
51tvcheck tcx25519 1
52tvxwant 0
53put Tcxpeer 31 xor get Tcxpeer 31 128
54tvcheck tcx25519 2
55tvxwant 0
56put Tcxpriv 0 xor get Tcxpriv 0 7
57put Tcxpriv 31 xor get Tcxpriv 31 192
58tvcheck tcx25519 3
59tvxwant 0
60tvxload 1 1
61tvcheck tcx25519 4
62tvxwant 1
63tvxload 2 3
64tvcheck tcxpublic 5
65tvxpub 2
66tvcheck tcx25519 6
67tvxwant 2
68tvxload 3 2
69tvcheck tcxpublic 7
70tvxpub 3
71tvcheck tcx25519 8
72tvxwant 2
73for i ulong 32
74put Tcxpeer i 0
75end
76tvxzero
77put Tcxpeer 0 1
78tvxzero
79note p and p+1 are noncanonical encodings of small-order u=0 and u=1.
80for i ulong 32
81put Tcxpeer i 255
82end
83put Tcxpeer 31 127
84put Tcxpeer 0 237
85tvxzero
86put Tcxpeer 0 238
87tvxzero
88note p+9 is a valid noncanonical encoding of the base point u=9.
89put Tcxpeer 0 246
90tvcheck tcx25519 22
91for i ulong 32
92tvcheck eq get Tcxshare i get Tcxpub i 23
93end
94tcwipe
95put Tcxpriv 0 9
96put Tcxpeer 0 9
97tvcheck tcx25519 24
98tvxwant 3
99tcwipe
100tvscrub
101for i ulong 32
102tvcheck eq get Tcxshare i 0 25
103tvcheck eq get Tcxpriv i 0 25
104end
105ret 0
106end