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 / om / tls / test / x509 / limbo.sh

41 lines · 2247 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# C2SP x509-limbo against om/tls/x509.om. Usage: sh om/tls/test/x509/limbo.sh OMC [LIMBO_DIR]
4# LIMBO_DIR is a clone of https://github.com/C2SP/x509-limbo (cloned into build/ when absent) and is
5# checked against the pinned commit below. gen_limbo.py turns limbo.json into driver R records,
6# driver.om runs them, limbo.py compares with the expected results; every disagreement must be
7# listed in limbo_allow.txt with its reason. Final line "LIMBO PASS|FAIL cases=.. agree=.. ...".
8set -eu
9omc=${1:?usage: limbo.sh OMC [LIMBO_DIR]}
10here=$(cd "$(dirname "$0")" && pwd)
11tls=$(cd "$here/../.." && pwd)
12root=$(cd "$tls/../.." && pwd)
13pin=$(sed -n 's/^OMC_PIN=//p' "$root/om/units.sh")
14limbo_pin=1080e565f26e544bbe9cf99953be8a57c08e7e20
15out="$root/build/tls/x509/limbo"
16src=${2:-$root/build/tls/x509/limbo-src}
17run() { nice -n 19 ionice -c3 "$@"; }
18
19[ "$(sha256sum < "$omc" | cut -c1-64)" = "$pin" ] || { echo "LIMBO FAIL omc is not the pinned compiler"; exit 1; }
20[ -d "$src/.git" ] || git clone -q https://github.com/C2SP/x509-limbo "$src"
21head=$(git -C "$src" rev-parse HEAD)
22case $limbo_pin in "$head"*) ;; *)
23 git -C "$src" fetch -q origin "$limbo_pin" 2>/dev/null || true
24 git -C "$src" -c advice.detachedHead=false checkout -q "$limbo_pin" || { echo "LIMBO FAIL limbo not at $limbo_pin"; exit 1; }
25 head=$(git -C "$src" rev-parse HEAD) ;;
26esac
27rm -rf "$out"
28mkdir -p "$out"
29python3 "$here/gen_limbo.py" "$src/limbo.json" "$out" > /dev/null
30{ echo om2; cat "$tls/sha2.om" "$tls/hkdf.om" "$tls/ec.om" "$tls/rsa.om" "$tls/x509.om" "$here/driver.om"; } > "$out/driver.om"
31if ! run "$omc" < "$out/driver.om" > "$out/driver" 2> "$out/driver.err" || [ -s "$out/driver.err" ]; then
32 echo "LIMBO FAIL omc refused driver.om: $(cat "$out/driver.err")"
33 exit 1
34fi
35chmod +x "$out/driver"
36rc=0
37(cd "$out" && run ./driver < cases.txt > results.txt) || rc=$?
38echo "limbo $head driver $(sha256sum < "$out/driver" | cut -c1-64) exit $rc"
39[ "$rc" -eq 0 ] || { echo "LIMBO FAIL driver exit $rc (a trap is a failure)"; exit 1; }
40python3 "$here/limbo.py" "$out/meta.tsv" "$out/results.txt" "$here/limbo_allow.txt" | tee "$out/judge.txt" | grep -v '^ *[0-9]* explained'
41tail -1 "$out/judge.txt" | grep -q '^LIMBO PASS'