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/omnet/blob/main/om/cbor/test/gen/regen.sh # omnet aien-dev/omnet Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omnet / om / cbor / test / gen / regen.sh` 41 lines ยท 2197 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Regenerates the oracle-made vector files of om/cbor into OUTDIR (default: test/vectors). 4 # Usage: sh om/cbor/test/gen/regen.sh GO [OUTDIR] 5 # GO is a Go toolchain >= 1.26.5 (the go directive of tailscale.com v1.102.0). The oracle imports 6 # tailscale.com/tka v1.102.0 and github.com/fxamacker/cbor/v2 v2.9.0 (go.sum pins both); the first 7 # run downloads them through the Go module proxy. Test referee only: nothing here is shipped. 8 set -eu 9 go=${1:?usage: regen.sh GO [OUTDIR]} 10 here=$(cd "$(dirname "$0")" && pwd) 11 out=${2:-$(dirname "$here")/vectors} 12 bin=$(mktemp -d) 13 trap 'rm -rf "$bin"' EXIT 14 (cd "$here/oracle" && "$go" build -o "$bin/oracle" .) 15 gov=$("$go" env GOVERSION) 16 o="$bin/oracle" 17 18 hdr() { # hdr FILE COMMAND DESCRIPTION 19 { 20 echo "# om/cbor vectors: $3" 21 echo "# Generated by \`oracle $2\` (om/cbor/test/gen/oracle, $gov) from tailscale.com v1.102.0" 22 echo "# (tka types and Serialize/Unserialize) and github.com/fxamacker/cbor/v2 v2.9.0." 23 echo "# Regenerate: sh om/cbor/test/gen/regen.sh GO. Same seed, same bytes." 24 } > "$1" 25 } 26 27 hdr "$out/tka-structs.txt" "gen 1 1200" "AUM, NodeKeySignature and State structures." 28 echo "# Line: TYPE HEX HASH K1. HEX = tka Serialize (CTAP2); HASH = AUM.Hash() for aum, BLAKE2s-256(HEX) otherwise; K1 = major:argument at key 1." >> "$out/tka-structs.txt" 29 "$o" gen 1 1200 >> "$out/tka-structs.txt" 30 31 hdr "$out/hostile.txt" "hostile" "hostile corpus, each case judged by tka's own Unserialize." 32 echo "# Line: CLASS TARGET WF ACCEPT RESER HEX DESCRIPTION. WF = Wellformed code (0 = well-formed); ACCEPT = TARGET.Unserialize accepted; RESER = tka Serialize after decoding, or -." >> "$out/hostile.txt" 33 "$o" hostile >> "$out/hostile.txt" 34 35 hdr "$out/fuzz.txt" "fuzz 1 2000" "random mutations (bit flips, byte changes, cuts, inserts, deletes) of generated structures." 36 echo "# Line: WF AUM NKS HEX. AUM/NKS = 1 when tka's AUM/NodeKeySignature Unserialize accepted the bytes." >> "$out/fuzz.txt" 37 "$o" fuzz 1 2000 >> "$out/fuzz.txt" 38 39 hdr "$out/utf8.txt" "utf8 1 2000" "single CBOR text strings; VALID from Go unicode/utf8.Valid." 40 echo "# Line: VALID HEX." >> "$out/utf8.txt" 41 "$o" utf8 1 2000 >> "$out/utf8.txt"