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/om/tls/test/bogo/run.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 / om / tls / test / bogo / run.sh` 143 lines ยท 8016 bytes Raw Blame History 1 #!/bin/sh 2 # BoGo (BoringSSL ssl/test/runner) against the seeded Omega TLS 1.3 client shim. 3 # usage: sh om/tls/test/bogo/run.sh OMC BORINGSSL_DIR GO 4 # OMC pinned omc 5 # BORINGSSL_DIR BoringSSL checkout at BORINGSSL_COMMIT (om/tls/test/bogo/PINS) 6 # GO go binary (GO_VERSION in PINS) 7 # env: BOGO_OUT (default build/tls/bogo), BOGO_TEST (runner -test filter, ';'-separated globs), 8 # BOGO_WORKERS (default 1) 9 # outputs in BOGO_OUT: shim, shim-nc (negative control), runner.test, run.log, results.json, 10 # summary.txt, failures.txt, nc-cand.list, nc-real.json, nc.list, nc.log, nc.json 11 # Runner flags: -allow-unimplemented (the shim exits 89 for any flag or mode it does not implement: 12 # server, DTLS, QUIC, TLS < 1.3, resumption, ...; those tests are SKIP, not PASS) and -loose-errors 13 # (the shim cannot print BoringSSL error strings, so a test that is expected to fail passes on ANY 14 # failure; expected-failure PASS counts are therefore weaker than handshake PASS counts). 15 # Negative control: shim-nc echoes with XOR 0xfe instead of 0xff; every success-expecting test in 16 # NC_TESTS that passes with the real shim (re-checked without -loose-errors) must fail with shim-nc. 17 # Fixture patch: runner-critical-san.patch marks the runner's subjectAltName critical when the 18 # certificate subject is empty (RFC 5280 4.2.1.6 MUST). Unpatched, the runner's leaves have an empty 19 # subject and a non-critical SAN, which x509.om refuses (X509_ERR_MALFORMED, a deliberate strictness; 20 # BoringSSL, Go and OpenSSL without -x509_strict accept it). Only the fixture changes; the test logic 21 # does not. BOGO_UNPATCHED=1 skips the patch to record that policy difference. 22 # exit 0 PASS (no FAIL, negative control detected), 1 FAIL, 3 NOT_RUN (pin mismatch, tool missing) 23 set -u 24 omc=$1 bssl=$2 go=$3 25 here=$(cd "$(dirname "$0")" && pwd) 26 root=$(cd "$here/../../../.." && pwd) 27 out=${BOGO_OUT:-build/tls/bogo} 28 mkdir -p "$out" && out=$(cd "$out" && pwd) 29 pin=$(sed -n 's/^BORINGSSL_COMMIT=//p' "$here/PINS") 30 gov=$(sed -n 's/^GO_VERSION=//p' "$here/PINS") 31 have=$(git -C "$bssl" rev-parse HEAD 2>/dev/null) 32 if [ "$have" != "$pin" ]; then 33 echo "BOGO NOT_RUN boringssl at '$have', pinned $pin" 34 exit 3 35 fi 36 case $("$go" version 2>/dev/null) in 37 *" $gov "*) ;; 38 *) echo "BOGO NOT_RUN go is '$("$go" version 2>&1)', pinned $gov"; exit 3 ;; 39 esac 40 if [ -z "${BOGO_UNPATCHED:-}" ]; then 41 if git -C "$bssl" apply --check "$here/runner-critical-san.patch" 2>/dev/null; then 42 git -C "$bssl" apply "$here/runner-critical-san.patch" || { echo "BOGO NOT_RUN fixture patch"; exit 3; } 43 elif ! git -C "$bssl" apply -R --check "$here/runner-critical-san.patch" 2>/dev/null; then 44 echo "BOGO NOT_RUN fixture patch does not apply" 45 exit 3 46 fi 47 elif git -C "$bssl" apply -R --check "$here/runner-critical-san.patch" 2>/dev/null; then 48 git -C "$bssl" apply -R "$here/runner-critical-san.patch" 49 fi 50 cd "$root" || exit 3 51 sh om/tls/build.sh "$omc" om/tls/test/bogo/shim.om "$out/shim" || { echo "BOGO FAIL shim build"; exit 1; } 52 sed 's/^put b i uchar xor get b i 255$/put b i uchar xor get b i 254/' om/tls/test/bogo/shim.om > "$out/shim-nc.om" 53 if cmp -s om/tls/test/bogo/shim.om "$out/shim-nc.om"; then 54 echo "BOGO FAIL negative-control mutation did not apply" 55 exit 1 56 fi 57 sh om/tls/build.sh "$omc" "$out/shim-nc.om" "$out/shim-nc" || { echo "BOGO FAIL shim-nc build"; exit 1; } 58 cd "$bssl/ssl/test/runner" || exit 3 59 "$go" test -c -o "$out/runner.test" . || { echo "BOGO NOT_RUN runner build"; exit 3; } 60 set -- -shim-path "$out/shim" -allow-unimplemented -loose-errors -num-workers "${BOGO_WORKERS:-1}" -json-output "$out/results.json" 61 [ -n "${BOGO_TEST:-}" ] && set -- "$@" -test "$BOGO_TEST" 62 "$out/runner.test" "$@" > "$out/run.log" 2>&1 63 echo "runner exit $?" >> "$out/run.log" 64 [ -s "$out/results.json" ] || { echo "BOGO FAIL no results.json (see $out/run.log)"; exit 1; } 65 # results.json is json.MarshalIndent: a test is ' "NAME": {' then "actual", "error" lines. 66 # A FAIL is counted as na (with its reason, never as a pass) only for two runner-side refusals that 67 # are not defects of a TLS 1.3-only client: 68 # tls12-only runner "client did not offer any supported protocol versions": the test's runner 69 # config has MaxVersion below TLS 1.3, and om/tls offers TLS 1.3 only by design. 70 # record-301 runner "received record with version 303 when expecting version 301": BoringSSL 71 # expects 0x0301 on the initial ClientHello record; RFC 8446 5.1 allows 0x0303 there. 72 # Every other FAIL stays a FAIL (fail-reason lines classify them; "no cipher suite" / "no curve" 73 # mean the runner insisted on a suite or group om/tls does not offer). 74 summ() { 75 awk -v F="$2" ' 76 /^ "[^"]+": \{$/ { if (n != "") emit(); n = $0; sub(/^ "/, "", n); sub(/": \{$/, "", n); a = ""; e = ""; next } 77 /^ "actual": / { a = $0; sub(/.*"actual": "/, "", a); sub(/".*/, "", a); next } 78 /^ "error": / { e = $0; next } 79 function emit( r) { 80 if (a == "FAIL" && index(e, "client did not offer any supported protocol versions")) { a = "NA"; r = "tls12-only" } 81 else if (a == "FAIL" && index(e, "received record with version 303 when expecting version 301")) { a = "NA"; r = "record-301" } 82 c[a]++ 83 if (a == "NA") { nr[r]++; print n "\tNA " r > F } 84 if (a == "FAIL") { 85 r = "other" 86 if (match(e, /TLSERR [A-Z0-9_]+ detail [0-9]+( [A-Z0-9_]+)?/)) r = substr(e, RSTART + 7, RLENGTH - 7) 87 else if (index(e, "timeout")) r = "timeout" 88 else if (index(e, "unexpected success")) r = "unexpected success" 89 if (index(e, "no cipher suite supported by both")) r = r " (runner: no common cipher suite)" 90 if (index(e, "no curve supported by both")) r = r " (runner: no common group)" 91 why[r]++ 92 print n "\t" r > F 93 } 94 n = "" 95 } 96 END { 97 if (n != "") emit() 98 printf "BOGO-RESULTS tests=%d pass=%d fail=%d na=%d skip=%d\n", c["PASS"] + c["FAIL"] + c["NA"] + c["SKIP"], c["PASS"], c["FAIL"], c["NA"], c["SKIP"] 99 for (r in nr) printf "na-reason %d %s\n", nr[r], r 100 for (r in why) printf "fail-reason %d %s\n", why[r], r 101 }' "$1" 102 } 103 : > "$out/failures.txt" 104 summ "$out/results.json" "$out/failures.txt" | sort > "$out/summary.txt" 105 sort -o "$out/failures.txt" "$out/failures.txt" 106 cat "$out/summary.txt" 107 # Negative control over tests that must SUCCEED. Expected-failure tests pass on any error under 108 # -loose-errors, so an echo-corrupting shim would still pass them; they are filtered out by re-running 109 # the passing candidates with the real shim WITHOUT -loose-errors: the shim never prints BoringSSL error 110 # strings, so only tests that expect success still pass there (nc-real.json). Those must all fail 111 # with shim-nc (nc.json). 112 pass_list() { 113 awk '/^ "[^"]+": \{$/ { n = $0; sub(/^ "/, "", n); sub(/": \{$/, "", n) } 114 /^ "actual": "PASS"/ { print n }' "$1" 115 } 116 pass_list "$out/results.json" | grep -E "${NC_TESTS:-^(LargePlaintext-TLS13-Padded-|TLS13-|Basic-Client)}" | head -60 > "$out/nc-cand.list" 117 : > "$out/nc.list" 118 if [ -s "$out/nc-cand.list" ]; then 119 "$out/runner.test" -shim-path "$out/shim" -allow-unimplemented -num-workers 1 \ 120 -json-output "$out/nc-real.json" -test "$(paste -sd';' "$out/nc-cand.list")" > "$out/nc-real.log" 2>&1 121 pass_list "$out/nc-real.json" | head -20 > "$out/nc.list" 122 fi 123 if [ ! -s "$out/nc.list" ]; then 124 echo "BOGO-NC NOT_RUN no passing success test to mutate" 125 nc=notrun 126 else 127 "$out/runner.test" -shim-path "$out/shim-nc" -allow-unimplemented -num-workers 1 \ 128 -json-output "$out/nc.json" -test "$(paste -sd';' "$out/nc.list")" > "$out/nc.log" 2>&1 129 ncp=$(grep -c '^ "actual": "PASS"' "$out/nc.json") 130 echo "BOGO-NC candidates=$(wc -l < "$out/nc-cand.list") tests=$(wc -l < "$out/nc.list") still_pass=$ncp" 131 if [ "$ncp" -eq 0 ]; then nc=ok; else nc=bad; fi 132 fi 133 fail=$(sed -n 's/^BOGO-RESULTS .* fail=\([0-9]*\) .*/\1/p' "$out/summary.txt") 134 if [ "$fail" -ne 0 ] || [ "$nc" = bad ]; then 135 echo "BOGO FAIL (failures in $out/failures.txt)" 136 exit 1 137 fi 138 if [ "$nc" = notrun ]; then 139 echo "BOGO NOT_RUN negative control" 140 exit 3 141 fi 142 echo "BOGO PASS" 143 exit 0