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 / om / tls / test / integrity / version.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note om/tls/test/integrity/version.om: the show-version service before and after the self-tests. |
| 3 | note Prints the version line, then "check D" (fips_check 0; 16 = integrity failure), then the line |
| 4 | note again, then "short N" for a 16-byte buffer (0 expected). Exit 0 when fips_check passed, 3 when |
| 5 | note it refused. |
| 6 | text ivchk "check " |
| 7 | text ivsh "short " |
| 8 | text ivnl "\n" |
| 9 | |
| 10 | fn ivnum x ulong to void |
| 11 | d = new uchar 20 0 |
| 12 | n = ulong 0 |
| 13 | v = x |
| 14 | for i ulong 20 |
| 15 | if or eq i 0 ne v 0 |
| 16 | put d sub 19 n uchar add 48 rem v 10 |
| 17 | v = div v 10 |
| 18 | n = add n 1 |
| 19 | end |
| 20 | end |
| 21 | r = write 1 d sub 20 n n |
| 22 | r = write 1 ivnl 0 1 |
| 23 | end |
| 24 | |
| 25 | fn main to int |
| 26 | o = new uchar 256 0 |
| 27 | s = new uchar 16 0 |
| 28 | n = tls_version o |
| 29 | r = write 1 o 0 n |
| 30 | d = fips_check 0 |
| 31 | r = write 1 ivchk 0 len ivchk |
| 32 | ivnum d |
| 33 | n = tls_version o |
| 34 | r = write 1 o 0 n |
| 35 | r = write 1 ivsh 0 len ivsh |
| 36 | ivnum tls_version s |
| 37 | if ne d 0 |
| 38 | ret 3 |
| 39 | end |
| 40 | ret 0 |
| 41 | end |