Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/qualification/om2/candidates/sha/run-qual.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / qualification / om2 / candidates / sha / run-qual.sh` 123 lines ยท 8564 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # OM-2 qualification L836 (#748), phaseB/sha-`f5d14cb2`: independent qualification of the OM-2 SHA unit 4 # (aien-dev/om2/sha-compact @ `f5d14cb2`, om/sha256/sha256-om2.om) compiled by the S4 omc and bound by 5 # omega-bridge feat/slice-abi @ `3bb8b8a9`. Tasks 1, 2, 4, 5 of candidates/sha/RESULTS.txt; task 3 is 6 # candidates/sha/mutants/run-mutants.sh. Writes one log per item into EVID; scratch in S. EVID defaults to 7 # build/om2-qual/sha/evidence: a rerun never writes over the recorded receipt evidence/phaseB/sha-`f5d14cb2`. 8 # Usage (repository root): sh seed/qualification/om2/candidates/sha/run-qual.sh [EVID [S]] 9 set -u 10 ROOT=$(pwd) 11 Q=$ROOT/seed/qualification/om2 12 OR=$Q/oracle/sha 13 EVID=${1:-$ROOT/build/om2-qual/sha/evidence} 14 S=${2:-$ROOT/build/om2-qual/sha/run} 15 UNIT=/tmp/zl/qsha/om/sha256/sha256-om2.om 16 OMC2=/tmp/zl/omc-`f6a6492f` 17 PIN2=`499236398aabc652e2dae27fe4bdc4c5db3d3726314356e0dbef23e3345803ec` 18 OMC1=$ROOT/seed/out/omc 19 PIN1=`734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61` 20 BRIDGE=/tmp/zl/qbridge 21 SUM=/usr/bin/sha256sum 22 mkdir -p "$EVID"; rm -rf "$S"; mkdir -p "$S" 23 h() { $SUM < "$1" | cut -d' ' -f1; } 24 run() { # NAME CMD...: log stdout+stderr and the exit status 25 n=$1; shift 26 { echo "\$ $*"; "$@"; echo "EXIT $?"; } > "$EVID/$n.txt" 2>&1 27 tail -n 3 "$EVID/$n.txt" | sed "s/^/[$n] /" 28 } 29 30 # ---- identities ----------------------------------------------------------------------------------- 31 { 32 echo "date $(date -u +%FT%TZ) host $(uname -srm)" 33 echo "unit $UNIT sha256 $(h "$UNIT") bytes $(wc -c < "$UNIT") lines $(wc -l < "$UNIT")" 34 echo "unit repo HEAD $(git -C /tmp/zl/qsha rev-parse HEAD) status-clean=$([ -z "$(git -C /tmp/zl/qsha status --porcelain)" ] && echo yes || echo no)" 35 echo "unit blob at HEAD sha256 $(git -C /tmp/zl/qsha show HEAD:om/sha256/sha256-om2.om | $SUM | cut -d' ' -f1)" 36 echo "omc S4 $OMC2 sha256 $(h "$OMC2") (expected $PIN2)" 37 echo "omc OM-1 pinned $OMC1 sha256 $(h "$OMC1") (expected $PIN1)" 38 echo "bridge HEAD $(git -C $BRIDGE rev-parse HEAD) status-clean=$([ -z "$(git -C $BRIDGE status --porcelain)" ] && echo yes || echo no)" 39 echo "bridge src/native.om sha256 $(h $BRIDGE/src/native.om); tools/native sha256 $(h $BRIDGE/tools/native)" 40 $SUM --version | head -1; /usr/bin/python3 --version; gcc --version | head -1; objdump --version | head -1 41 } > "$EVID/identity.txt" 2>&1 42 [ "$(h "$OMC2")" = $PIN2 ] && [ "$(h "$OMC1")" = $PIN1 ] || { echo "compiler identity mismatch"; exit 3; } 43 44 # ---- task 1: compile ------------------------------------------------------------------------------ 45 "$OMC2" < "$UNIT" > "$S/sha.bin"; e1=$? 46 "$OMC2" < "$UNIT" > "$S/sha2.bin"; e2=$? 47 { 48 echo "\$ $OMC2 < $UNIT > sha.bin (twice)" 49 echo "exit $e1 $e2; deterministic=$(cmp -s "$S/sha.bin" "$S/sha2.bin" && echo yes || echo no)" 50 echo "artifact sha256 $(h "$S/sha.bin") bytes $(wc -c < "$S/sha.bin") words $(( $(wc -c < "$S/sha.bin") / 4 ))" 51 objdump -D -b binary -m aarch64 "$S/sha.bin" | sed -n '8,11p' 52 } > "$EVID/build.txt" 53 cp "$S/sha.bin" "$EVID/sha256-om2.S4.bin" 54 55 # ---- task 2: binding ------------------------------------------------------------------------------ 56 B=$S/bind 57 OMEGA_NATIVE_OMC=$OMC1 OMEGA_NATIVE_OMC2=$OMC2 sh $BRIDGE/tools/native "$B" "$UNIT" > "$S/native.log" 2>&1; eb=$? 58 { 59 echo "\$ OMEGA_NATIVE_OMC=$OMC1 OMEGA_NATIVE_OMC2=$OMC2 sh $BRIDGE/tools/native bind $UNIT" 60 cat "$S/native.log"; echo "exit $eb" 61 echo "generator native-gen (src/native.om compiled by the pinned OM-1 omc) sha256 $(h "$B/work/native-gen")" 62 for f in omega_native.c omega_native.h omega_api.h omega_native.py omega_native.rs omega_native.zig omega_native.go libomega_native.so work/ident.txt work/sha256-om2.bin; do 63 echo "sha256 $(h "$B/$f") $f" 64 done 65 echo "work/sha256-om2.bin == S4 artifact: $(cmp -s "$B/work/sha256-om2.bin" "$S/sha.bin" && echo yes || echo no)" 66 s=$(objdump -t "$B/libomega_native.so" | awk '$NF=="ombr2_code_sha256_om2"{print $1}') 67 off=$(objdump -h "$B/libomega_native.so" | awk '$2 ~ /^\./ {print $3, $4, $6}' | while read -r sz vma fo; do 68 if [ $((0x$vma)) -le $((0x$s)) ] && [ $((0x$s)) -lt $((0x$vma + 0x$sz)) ]; then echo $((0x$s - 0x$vma + 0x$fo)); break; fi; done) 69 echo "embedded code (ombr2_code_sha256_om2, file offset $off) == compiler bytes: $(dd if="$B/libomega_native.so" bs=1 skip="$off" count="$(wc -c < "$S/sha.bin")" 2> /dev/null | cmp -s - "$S/sha.bin" && echo yes || echo no)" 70 echo "--- defined dynamic symbols" 71 nm -D --defined-only "$B/libomega_native.so" | awk '{print $3}' 72 echo "--- v1 symbols (omega_*): $(nm -D "$B/libomega_native.so" | awk '{print $NF}' | grep -c '^omega_')" 73 printf '#include \nuint32_t omega_sha256_init(uint64_t *r, uint8_t *c);\nint main(void){ uint64_t r; uint8_t c[104]; return (int)omega_sha256_init(&r, c); }\n' > "$S/v1use.c" 74 echo "--- v1 caller link (must fail):" 75 gcc "$S/v1use.c" -L"$B" -lomega_native -o "$S/v1use" 2>&1; echo "link exit $?" 76 echo "--- omega_api.h"; cat "$B/omega_api.h" 77 echo "--- omega_native.h"; cat "$B/omega_native.h" 78 } > "$EVID/binding.txt" 2>&1 79 CF="-std=gnu11 -O2 -Wall -Wextra -Werror" 80 gcc $CF -I"$B" "$OR/sha_qual.c" -L"$B" -lomega_native -Wl,-rpath,"$B" -o "$S/sha_qual" || exit 3 81 gcc $CF -DGENHDR='"omega_api.h"' -I"$B" -I"$Q/oracle/s5s7/sha" "$Q/oracle/s5s7/sha/sha_driver.c" -L"$B" -lomega_native -Wl,-rpath,"$B" -o "$S/sha_driver" || exit 3 82 gcc $CF -I"$B" "$OR/trace_child.c" -L"$B" -lomega_native -Wl,-rpath,"$B" -o "$S/trace_child" || exit 3 83 for c in 1 2; do gcc $CF -DCONTROL=$c -I"$B" "$OR/trace_child.c" -L"$B" -lomega_native -Wl,-rpath,"$B" -o "$S/trace_ctl$c" || exit 3; done 84 85 IDENT="omega-ident 1 unit=sha256_om2 abi=2 profile=OM-2 src=$(h "$UNIT") omc=$(h "$OMC2")" 86 run t1-vecoracle /usr/bin/python3 "$OR/vecoracle.py" "$Q/fixtures/sha256-vectors.txt" 87 run t1-vec "$S/sha_qual" vec "$Q/fixtures/sha256-vectors.txt" "$ROOT" 88 run t1-s5s7-sha "$S/sha_driver" 89 run t1-s5s7-sha-big nice -n 19 "$S/sha_driver" big 90 run t2-ident "$S/sha_qual" ident "$IDENT" 91 run t2-rcpt "$S/sha_qual" rcpt 92 run t2-rand748 nice -n 19 "$S/sha_qual" rand 748 1200 93 run t2-rand748-hashlib sh -c "/usr/bin/python3 '$OR/randcheck.py' < '$EVID/t2-rand748.txt'" 94 run t2-rand749 nice -n 19 "$S/sha_qual" rand 749 2000 95 run t2-rand749-hashlib sh -c "/usr/bin/python3 '$OR/randcheck.py' < '$EVID/t2-rand749.txt'" 96 run t2-part nice -n 19 "$S/sha_qual" part 97 run t2-bigzero nice -n 19 "$S/sha_qual" bigzero 98 run t2-big sh -c "free -g; nice -n 19 '$S/sha_qual' big" 99 run t2-bigzero-oracle sh -c "head -c `4294967299` /dev/zero | $SUM; grep EXP_BIG_ZERO '$Q/oracle/s5s7/sha/expected.h'" 100 101 # ---- task 4: leakage ------------------------------------------------------------------------------ 102 "$OMC1" < "$Q/leak/leakscan.om" > "$S/leakscan"; chmod +x "$S/leakscan" 103 { 104 echo "\$ $OMC1 < seed/qualification/om2/leak/leakscan.om > leakscan" 105 echo "leakscan.om sha256 $(h "$Q/leak/leakscan.om"); leakscan binary sha256 $(h "$S/leakscan")" 106 echo "build/om2-qual/leakscan-e13 sha256 $(h "$ROOT/build/om2-qual/leakscan-e13" 2> /dev/null)" 107 for k in 0 1 2 3; do /usr/bin/python3 "$OR/entry.py" "$S/sha.bin" $k "$S/entry$k.bin"; echo "entry$k.bin sha256 $(h "$S/entry$k.bin")"; done 108 } > "$EVID/t4-leak-setup.txt" 2>&1 109 for c in "init entry0" "init-pub entry0 pub:0:32:8" "update entry1" "update-pub entry1 pub:0:32:8" \ 110 "final entry2" "final-pub entry2 pub:0:32:8" "hash entry3"; do 111 set -- $c; n=$1; e=$2; shift 2 112 { echo "\$ leakscan $* < $e.bin"; "$S/leakscan" "$@" < "$S/$e.bin"; echo "EXIT $?"; } > "$EVID/t4-leak-$n.txt" 2>&1 113 { echo "\$ xcheck.py $e.bin t4-leak-$n.txt"; /usr/bin/python3 "$Q/oracle/leak/xcheck.py" "$S/$e.bin" "$EVID/t4-leak-$n.txt"; echo "EXIT $?"; } > "$EVID/t4-xcheck-$n.txt" 2>&1 114 echo "[t4-leak-$n] $(grep -E '^(SUMMARY|VERDICT)' "$EVID/t4-leak-$n.txt" | tr '\n' ' ') revoked=$(grep -c PUBLIC-MEM-REVOKED "$EVID/t4-leak-$n.txt") xcheck=$(tail -n 2 "$EVID/t4-xcheck-$n.txt" | head -n 1)" 115 done 116 rm -rf "$S/leakgate" 117 run t4-leak-gate-pinned nice -n 19 "$ROOT/build/om2-qual/gate-p" "$OMC1" $PIN1 "$Q/leak/leak.cases" "$S/leakgate" 118 run t4-trace nice -n 19 /usr/bin/python3 "$OR/trace.py" "$S/trace_child" "$B/libomega_native.so" "$S/sha.bin" 119 run t4-trace-control1 nice -n 19 /usr/bin/python3 "$OR/trace.py" "$S/trace_ctl1" "$B/libomega_native.so" "$S/sha.bin" 120 run t4-trace-control2 nice -n 19 /usr/bin/python3 "$OR/trace.py" "$S/trace_ctl2" "$B/libomega_native.so" "$S/sha.bin" 121 122 # ---- task 5: size, rotates, stack ----------------------------------------------------------------- 123 run t5-size-stack /usr/bin/python3 "$OR/stack.py" "$S/sha.bin"