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
omega-mv / seed / qualification / om2 / fixtures / oracle / fipschk.py
| 1 | # Compare bc-derived K/H (kiv.out) with the hex tables extracted by pdftotext from NIST.FIPS.180-4.pdf. |
| 2 | import re, sys |
| 3 | t = open(sys.argv[1]).read().split("\n") |
| 4 | k = " ".join(t[585:593]).split() # lines 586-593: section 4.2.2 SHA-256 K |
| 5 | h = [re.search(r"= ([0-9a-f]{8})\b", t[i].strip()).group(1) for i in range(729, 737)] # 5.3.3 |
| 6 | assert len(k) == 64 and all(re.fullmatch(r"[0-9a-f]{8}", x) for x in k) |
| 7 | got = [l.split() for l in open(sys.argv[2])] |
| 8 | assert [int(x, 16) for x in k] == [int(g[3]) for g in got if g[0] == 'K'] |
| 9 | assert [int(x, 16) for x in h] == [int(g[3]) for g in got if g[0] == 'H'] |
| 10 | print("PASS bc K[0..63] and H(0)[0..7] equal FIPS 180-4 sections 4.2.2 and 5.3.3") |