-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from herbetom/contrib-sigtest
contrib/check-release.sh: init
- Loading branch information
Showing
4 changed files
with
134 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source "${SCRIPT_DIR}/functions-sign.sh" | ||
|
||
declare -A SIGKEYS | ||
|
||
|
||
SIGKEYS["Tom/herbetom"]="3a00002ecf1392e7ddbb8db395412cdcb5d9cd8e310b486c3ec1fc0bf161195b" | ||
SIGKEYS["Kai/wusel42"]="cd2ed332a77bb71ade862d5b8521c59c7987ef418da6ecc69c19f32aa5ec5e66" | ||
SIGKEYS["Jan/Jevermeister"]="6fbba7d2e081a0a2c3d6832d5440e8786f90acabfe462b602531b4665ce58590" | ||
SIGKEYS["Michel/eriu"]="be5155bac7681fb4631bdab72c47b6e606e3f0ccfe50bb8f6cd6866c1c97c729" | ||
SIGKEYS["github-actions-ci"]="ff49b7abc9d2caab57bc5c88fb8cc3b5c5b0eb5312b7cc326a18cc811305592a" | ||
SIGKEYS["buildserver"]="e191158c837941158d827e5c6df971bfb01161d5d6f86a366d8a7897feedf9da" | ||
|
||
function usage() { | ||
echo "Usage: $0 <release-version> <branch>" | ||
echo "Example: $0 2.0.0 stable" | ||
exit 1 | ||
} | ||
|
||
function cleanup() { | ||
rm -rf "$TEMP_DIR" | ||
} | ||
|
||
RELEASE_VERSION="${1:-}" | ||
BRANCH="${2:-}" | ||
|
||
[ -z "$RELEASE_VERSION" ] && usage | ||
[ -z "$BRANCH" ] && usage | ||
|
||
# Create Temporary working directory | ||
TEMP_DIR="$(mktemp -d)" | ||
|
||
MANIFEST_PATH="${TEMP_DIR}/checking.manifest" | ||
|
||
# Download released manifest archive | ||
MANIFEST_URL="https://fw.ffrn.de/images/${RELEASE_VERSION}/images/sysupgrade/${BRANCH}.manifest" | ||
echo "Download manifest from $MANIFEST_URL" | ||
curl -s -L -o "${MANIFEST_PATH}" "${MANIFEST_URL}" | ||
|
||
for name in "${!SIGKEYS[@]}" | ||
do | ||
valid_ci_signature="$(get_valid_signature "${MANIFEST_PATH}" "${SIGKEYS[$name]}")" | ||
|
||
# Check if manifest is signed with the key under test | ||
if [ -n "$valid_ci_signature" ]; then | ||
echo "Manifest is signed with the \"${name}\" key" | ||
echo "Signature: $valid_ci_signature" | ||
fi | ||
done | ||
|
||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
function split_manifest() { | ||
local manifest upper lower | ||
|
||
manifest="$1" | ||
upper="$2" | ||
lower="$3" | ||
|
||
awk 'BEGIN { | ||
sep = 0 | ||
} | ||
/^---$/ { | ||
sep = 1; | ||
next | ||
} | ||
{ | ||
if(sep == 0) { | ||
print > "'"$upper"'" | ||
} else { | ||
print > "'"$lower"'" | ||
} | ||
}' "$manifest" | ||
} | ||
|
||
function create_signature() { | ||
local secret manifest upper lower | ||
|
||
manifest="$1" | ||
secret="$2" | ||
|
||
upper="$(mktemp)" | ||
lower="$(mktemp)" | ||
|
||
# Split manifest into upper and lower part | ||
split_manifest "$manifest" "$upper" "$lower" | ||
|
||
# Sign upper part of manifest | ||
ecdsasign "$upper" < "$secret" | ||
|
||
# Remove temporary files | ||
rm -f "$upper" "$lower" | ||
} | ||
|
||
function get_valid_signature() { | ||
local public_key manifest upper lower | ||
|
||
manifest="$1" | ||
public_key="$2" | ||
|
||
upper="$(mktemp)" | ||
lower="$(mktemp)" | ||
|
||
# Split manifest into upper and lower part | ||
split_manifest "$manifest" "$upper" "$lower" | ||
|
||
# Validate upper part of manifest | ||
while read -r line | ||
do | ||
if ecdsaverify -s "$line" -p "$public_key" "$upper"; then | ||
echo "$line" | ||
break | ||
fi | ||
done < "$lower" | ||
|
||
# Remove temporary files | ||
rm -f "$upper" "$lower" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters