interplane.Get Omega
Read in your language

omtls

omtls: a TLS 1.3 client (RFC 8446) written fresh in seeded Omega, for mailhand. Not audited by a cryptographer. Free (Apache-2.0).

Brought by drakestapleton

branch main Branches Tags History

omtls / src / ct / cmp.om

43 lines · 1424 bytes Raw Blame History
1note omtls shared constant-time helpers (ot_ct_). CT core: sized arrays, unrolled loops, constant indices.
2note ot_ct_lo8 gives the low byte of x as a uchar with no branch: a plain `uchar v` conversion emits a range check
3note (a conditional branch to a trap-5 stub); `and x 255` is exact in f64 and UCVTF/FCVTZU/UQXTN narrow it with no
4note branch and no trap site (checked on the emitted code with objdump, omc f4fa7951).
5fn ot_ct_lo8 x ulong to uchar inline
6ret uchar f64 and x 255
7end
8note Equality of two sized byte arrays: OR of the XORs (0..255), then bit 63 of acc - 1 is 1 exactly when acc is 0.
9fn ot_ct_eq16 a view uchar 16 b view uchar 16 to bool
10acc = ulong 0
11for i ulong 16 unroll
12acc = or acc ulong xor get a i get b i
13end
14ret eq and shr sub acc 1 63 1 1
15end
16fn ot_ct_eq32 a view uchar 32 b view uchar 32 to bool
17acc = ulong 0
18for i ulong 32 unroll
19acc = or acc ulong xor get a i get b i
20end
21ret eq and shr sub acc 1 63 1 1
22end
23fn ot_ct_eq48 a view uchar 48 b view uchar 48 to bool
24acc = ulong 0
25for i ulong 48 unroll
26acc = or acc ulong xor get a i get b i
27end
28ret eq and shr sub acc 1 63 1 1
29end
30fn ot_ct_eq64 a view uchar 64 b view uchar 64 to bool
31acc = ulong 0
32for i ulong 64 unroll
33acc = or acc ulong xor get a i get b i
34end
35ret eq and shr sub acc 1 63 1 1
36end
37fn ot_ct_zero32 a view uchar 32 to bool
38acc = ulong 0
39for i ulong 32 unroll
40acc = or acc ulong get a i
41end
42ret eq and shr sub acc 1 63 1 1
43end