upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-13 14:35:49 -0300
committerNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-13 14:35:49 -0300
commit03e583395c42124521d09287bef29bf1d1bbe59b (patch)
tree4590b138ec6fb4848004ffa224273b7b6bb45e38 /scripts
parent44fbf6895bd3acd11f552514e746a2e3876cad2d (diff)
release: verify bundled Tor signatures
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/package-windows-tor.sh71
1 files changed, 63 insertions, 8 deletions
diff --git a/scripts/package-windows-tor.sh b/scripts/package-windows-tor.sh
index 084fd1a..c8cca3b 100755
--- a/scripts/package-windows-tor.sh
+++ b/scripts/package-windows-tor.sh
@@ -8,11 +8,15 @@ TOR_VERSION="${TOR_VERSION:-15.0.19}"
8TOR_ARCHIVE_NAME="tor-expert-bundle-windows-x86_64-${TOR_VERSION}.tar.gz" 8TOR_ARCHIVE_NAME="tor-expert-bundle-windows-x86_64-${TOR_VERSION}.tar.gz"
9TOR_URL="${TOR_URL:-https://archive.torproject.org/tor-package-archive/torbrowser/${TOR_VERSION}/${TOR_ARCHIVE_NAME}}" 9TOR_URL="${TOR_URL:-https://archive.torproject.org/tor-package-archive/torbrowser/${TOR_VERSION}/${TOR_ARCHIVE_NAME}}"
10TOR_SHA256="${TOR_SHA256:-6AC067402C7B4A3DC37887ED3754B3914B67FDC220C966190683E9CCF91ABF0F}" 10TOR_SHA256="${TOR_SHA256:-6AC067402C7B4A3DC37887ED3754B3914B67FDC220C966190683E9CCF91ABF0F}"
11TOR_ASC_URL="${TOR_ASC_URL:-${TOR_URL}.asc}"
12TOR_SIGNING_KEY_FINGERPRINT="${TOR_SIGNING_KEY_FINGERPRINT:-EF6E286DDA85EA2A4BA7DE684E2C6E8793298290}"
13TOR_VERIFY_GPG="${TOR_VERIFY_GPG:-auto}"
11 14
12BUNDLE_DIR="${BUNDLE_DIR:-$ROOT/Bitflash-${VERSION}-windows}" 15BUNDLE_DIR="${BUNDLE_DIR:-$ROOT/Bitflash-${VERSION}-windows}"
13OUT_ZIP="${OUT_ZIP:-$ROOT/Bitflash-${VERSION}-windows-with-tor.zip}" 16OUT_ZIP="${OUT_ZIP:-$ROOT/Bitflash-${VERSION}-windows-with-tor.zip}"
14CACHE_DIR="${CACHE_DIR:-$ROOT/.cache}" 17CACHE_DIR="${CACHE_DIR:-$ROOT/.cache}"
15ARCHIVE="${TOR_ARCHIVE:-$CACHE_DIR/$TOR_ARCHIVE_NAME}" 18ARCHIVE="${TOR_ARCHIVE:-$CACHE_DIR/$TOR_ARCHIVE_NAME}"
19ASC_FILE="${TOR_ASC:-$ARCHIVE.asc}"
16 20
17usage() { 21usage() {
18 cat <<EOF 22 cat <<EOF
@@ -25,8 +29,11 @@ Environment overrides:
25 VERSION Bitflash release version, default read from Makefile 29 VERSION Bitflash release version, default read from Makefile
26 TOR_VERSION Tor Expert Bundle version, default ${TOR_VERSION} 30 TOR_VERSION Tor Expert Bundle version, default ${TOR_VERSION}
27 TOR_URL Download URL, default official Tor archive URL 31 TOR_URL Download URL, default official Tor archive URL
32 TOR_ASC_URL Signature URL, default TOR_URL.asc
28 TOR_SHA256 Expected archive SHA256 33 TOR_SHA256 Expected archive SHA256
29 TOR_ARCHIVE Use an existing archive instead of downloading 34 TOR_ARCHIVE Use an existing archive instead of downloading
35 TOR_ASC Use an existing detached signature
36 TOR_VERIFY_GPG auto, required, or off; default auto
30 BUNDLE_DIR Existing unpacked Windows release directory 37 BUNDLE_DIR Existing unpacked Windows release directory
31 OUT_ZIP Output zip path 38 OUT_ZIP Output zip path
32EOF 39EOF
@@ -48,6 +55,19 @@ need sha256sum
48need tar 55need tar
49need zip 56need zip
50 57
58download() {
59 local url="$1"
60 local out="$2"
61 if command -v curl >/dev/null 2>&1; then
62 curl -L --fail --output "$out" "$url"
63 elif command -v wget >/dev/null 2>&1; then
64 wget -O "$out" "$url"
65 else
66 echo "missing required command: curl or wget" >&2
67 exit 1
68 fi
69}
70
51if [ ! -d "$BUNDLE_DIR" ]; then 71if [ ! -d "$BUNDLE_DIR" ]; then
52 echo "missing Windows release directory: $BUNDLE_DIR" >&2 72 echo "missing Windows release directory: $BUNDLE_DIR" >&2
53 echo "run 'make windows' first, or set BUNDLE_DIR" >&2 73 echo "run 'make windows' first, or set BUNDLE_DIR" >&2
@@ -65,14 +85,7 @@ OUT_ZIP_ABS="$OUT_PARENT/$OUT_NAME"
65 85
66mkdir -p "$CACHE_DIR" 86mkdir -p "$CACHE_DIR"
67if [ ! -f "$ARCHIVE" ]; then 87if [ ! -f "$ARCHIVE" ]; then
68 if command -v curl >/dev/null 2>&1; then 88 download "$TOR_URL" "$ARCHIVE"
69 curl -L --fail --output "$ARCHIVE" "$TOR_URL"
70 elif command -v wget >/dev/null 2>&1; then
71 wget -O "$ARCHIVE" "$TOR_URL"
72 else
73 echo "missing required command: curl or wget" >&2
74 exit 1
75 fi
76fi 89fi
77 90
78got="$(sha256sum "$ARCHIVE" | awk '{print tolower($1)}')" 91got="$(sha256sum "$ARCHIVE" | awk '{print tolower($1)}')"
@@ -87,6 +100,48 @@ fi
87tmp="$(mktemp -d "${TMPDIR:-/tmp}/bitflash-tor-package.XXXXXX")" 100tmp="$(mktemp -d "${TMPDIR:-/tmp}/bitflash-tor-package.XXXXXX")"
88trap 'rm -rf "$tmp"' EXIT 101trap 'rm -rf "$tmp"' EXIT
89 102
103case "$TOR_VERIFY_GPG" in
104 auto|required|off) ;;
105 *) echo "TOR_VERIFY_GPG must be auto, required, or off" >&2; exit 2 ;;
106esac
107
108if [ "$TOR_VERIFY_GPG" != "off" ]; then
109 if command -v gpg >/dev/null 2>&1; then
110 if [ ! -f "$ASC_FILE" ]; then
111 download "$TOR_ASC_URL" "$ASC_FILE"
112 fi
113 gnupg_home="$tmp/gnupg"
114 mkdir -p "$gnupg_home"
115 chmod 0700 "$gnupg_home"
116 gpg --homedir "$gnupg_home" --batch --auto-key-locate nodefault,wkd,keyserver \
117 --locate-keys torbrowser@torproject.org >/dev/null 2>&1 || {
118 if [ "$TOR_VERIFY_GPG" = "required" ]; then
119 echo "could not import Tor Browser Developers signing key" >&2
120 exit 1
121 fi
122 echo "WARNING: skipped Tor GPG signature verification; signing key import failed" >&2
123 }
124 if gpg --homedir "$gnupg_home" --batch --with-colons --fingerprint "$TOR_SIGNING_KEY_FINGERPRINT" \
125 2>/dev/null | grep -q "^fpr:::::::::${TOR_SIGNING_KEY_FINGERPRINT}:"; then
126 gpg --homedir "$gnupg_home" --batch --verify "$ASC_FILE" "$ARCHIVE" >/dev/null 2>&1 || {
127 echo "Tor archive GPG signature verification failed" >&2
128 exit 1
129 }
130 echo "Tor archive GPG signature verified against ${TOR_SIGNING_KEY_FINGERPRINT}"
131 elif [ "$TOR_VERIFY_GPG" = "required" ]; then
132 echo "Tor signing key fingerprint mismatch" >&2
133 exit 1
134 else
135 echo "WARNING: skipped Tor GPG signature verification; signing key fingerprint was not available" >&2
136 fi
137 elif [ "$TOR_VERIFY_GPG" = "required" ]; then
138 echo "missing required command for TOR_VERIFY_GPG=required: gpg" >&2
139 exit 1
140 else
141 echo "WARNING: gpg not found; relying on pinned SHA256 only" >&2
142 fi
143fi
144
90mkdir -p "$tmp/extract" 145mkdir -p "$tmp/extract"
91tar -xzf "$ARCHIVE" -C "$tmp/extract" 146tar -xzf "$ARCHIVE" -C "$tmp/extract"
92 147