upleb.uk

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

summaryrefslogtreecommitdiff
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
parent44fbf6895bd3acd11f552514e746a2e3876cad2d (diff)
release: verify bundled Tor signatures
-rw-r--r--README.md6
-rw-r--r--docs/release-verification.md8
-rw-r--r--docs/tor.md9
-rwxr-xr-xscripts/package-windows-tor.sh71
4 files changed, 78 insertions, 16 deletions
diff --git a/README.md b/README.md
index c30f171..bb6a4d4 100644
--- a/README.md
+++ b/README.md
@@ -462,8 +462,10 @@ make windows-tor
462 462
463That produces `Bitflash-*-windows-with-tor.zip`. The release script downloads 463That produces `Bitflash-*-windows-with-tor.zip`. The release script downloads
464the Tor Expert Bundle from the official Tor archive, verifies its pinned SHA256, 464the Tor Expert Bundle from the official Tor archive, verifies its pinned SHA256,
465and places `tor/tor.exe` beside `Bitflash.exe` so `-managedtor` works without a 465optionally verifies the Tor Project GPG signature when `gpg` is available, and
466separate Tor install. 466places `tor/tor.exe` beside `Bitflash.exe` so `-managedtor` works without a
467separate Tor install. For release builds, use `TOR_VERIFY_GPG=required make
468windows-tor` to require the extra signature check.
467 469
468--- 470---
469 471
diff --git a/docs/release-verification.md b/docs/release-verification.md
index 04d18a3..b8eaf5e 100644
--- a/docs/release-verification.md
+++ b/docs/release-verification.md
@@ -83,9 +83,11 @@ key in `verify-release.sh`.
83 83
84For Windows releases with managed Tor built in, run `make windows-tor`. It 84For Windows releases with managed Tor built in, run `make windows-tor`. It
85creates `Bitflash-*-windows-with-tor.zip` by downloading the Tor Expert Bundle, 85creates `Bitflash-*-windows-with-tor.zip` by downloading the Tor Expert Bundle,
86checking the pinned SHA256 in `scripts/package-windows-tor.sh`, and placing 86checking the pinned SHA256 in `scripts/package-windows-tor.sh`, optionally
87`tor/tor.exe` next to `Bitflash.exe`. Include that zip in `SHA256SUMS` like any 87verifying the Tor Project `.asc` signature, and placing `tor/tor.exe` next to
88other release asset. 88`Bitflash.exe`. For release builds, run `TOR_VERIFY_GPG=required make
89windows-tor` so the signature check is mandatory. Include that zip in
90`SHA256SUMS` like any other release asset.
89 91
90## Why this matters 92## Why this matters
91 93
diff --git a/docs/tor.md b/docs/tor.md
index be6a145..a408704 100644
--- a/docs/tor.md
+++ b/docs/tor.md
@@ -65,9 +65,12 @@ make windows-tor
65``` 65```
66 66
67The packaging script verifies a pinned SHA256 for the downloaded Tor Expert 67The packaging script verifies a pinned SHA256 for the downloaded Tor Expert
68Bundle before copying it into the release directory. The Tor binary is bundled; 68Bundle before copying it into the release directory. When `gpg` is available it
69the runtime data directory, hidden-service key, and control cookie are still 69also verifies the matching `.asc` signature against the pinned Tor Browser
70created under the user's Bitflash data directory. 70Developers signing-key fingerprint. Release builds should use
71`TOR_VERIFY_GPG=required make windows-tor` to make that second check mandatory.
72The Tor binary is bundled; the runtime data directory, hidden-service key, and
73control cookie are still created under the user's Bitflash data directory.
71 74
72To point at a specific Tor executable: 75To point at a specific Tor executable:
73 76
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