interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / trace / sha256-test.om

75 lines · 1788 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Standard SHA-256 vectors: empty, abc, one-block boundary, two blocks and 1000 bytes.
3global fails ulong 1
4global checks ulong 1
5text digs "0123456789abcdef"
6text v0 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
7text e1 "abc"
8text v1 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
9text e2 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
10text v2 "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
11text e3 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
12text v3 "cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1"
13text v4 "41edece42d63e8d9bf515a9ba6932e1c20cbc9f5a5d134645adb5db1b9737ea3"
14text passm "sha256 vectors=5 fails=0\n"
15
16fn hi b uchar to uchar
17ret get digs shr b 4
18end
19fn lo b uchar to uchar
20ret get digs and b 15
21end
22fn hexout d view uchar 32 o edit uchar 64 to void
23for i ulong 32
24put o mul i 2 hi get d i
25put o add mul i 2 1 lo get d i
26end
27end
28fn cmp a view uchar 64 b view uchar 64 to void
29for i ulong 64
30if ne get a i get b i
31put fails 0 add get fails 0 1
32end
33end
34put checks 0 add get checks 0 1
35end
36fn main to int
37buf = new uchar 4096 0
38out = new uchar 32 0
39hxb = new uchar 64 0
40sha256 buf 0 out
41hexout out hxb
42cmp hxb v0
43for i ulong len e1
44put buf i get e1 i
45end
46sha256 buf len e1 out
47hexout out hxb
48cmp hxb v1
49for i ulong len e2
50put buf i get e2 i
51end
52sha256 buf len e2 out
53hexout out hxb
54cmp hxb v2
55for i ulong len e3
56put buf i get e3 i
57end
58sha256 buf len e3 out
59hexout out hxb
60cmp hxb v3
61for i ulong 1000
62put buf i 97
63end
64sha256 buf 1000 out
65hexout out hxb
66cmp hxb v4
67if ne get fails 0 0
68ret 1
69end
70nw = write 1 passm 0 len passm
71if ne nw long len passm
72ret 2
73end
74ret 0
75end