2014-12-30 04:52:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-09-30 19:38:40 +00:00
|
|
|
if [ $# -eq 0 ] || [ "-h" = "$1" ] || [ "-help" = "$1" ] || [ "--help" = "$1" ]; then
|
2023-01-03 07:41:01 +00:00
|
|
|
cat <<EOHELP
|
2014-12-30 04:52:23 +00:00
|
|
|
Usage: $0 <public> <signed manifest>
|
|
|
|
|
|
|
|
sigtest.sh checks if a manifest is signed by the public key <public>. There is
|
|
|
|
no output, success or failure is indicated via the return code.
|
|
|
|
|
|
|
|
See also:
|
2019-02-16 13:15:55 +00:00
|
|
|
* ecdsautils in https://github.com/freifunk-gluon/ecdsautils
|
|
|
|
* https://gluon.readthedocs.io/en/latest/features/autoupdater.html
|
2014-12-30 04:52:23 +00:00
|
|
|
|
|
|
|
EOHELP
|
2023-01-03 07:41:01 +00:00
|
|
|
exit 1
|
2014-12-30 04:52:23 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
public="$1"
|
|
|
|
manifest="$2"
|
|
|
|
upper="$(mktemp)"
|
|
|
|
lower="$(mktemp)"
|
|
|
|
ret=1
|
|
|
|
|
2023-01-03 07:41:01 +00:00
|
|
|
awk 'BEGIN {
|
|
|
|
sep = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
/^---$/ {
|
|
|
|
sep = 1;
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
if(sep == 0) {
|
|
|
|
print > "'"$upper"'"
|
|
|
|
} else {
|
|
|
|
print > "'"$lower"'"
|
|
|
|
}
|
|
|
|
}' "$manifest"
|
2014-12-30 04:52:23 +00:00
|
|
|
|
2019-09-30 19:38:40 +00:00
|
|
|
while read -r line
|
2014-12-30 04:52:23 +00:00
|
|
|
do
|
2023-01-03 07:41:01 +00:00
|
|
|
if ecdsaverify -s "$line" -p "$public" "$upper"; then
|
|
|
|
ret=0
|
|
|
|
break
|
|
|
|
fi
|
2014-12-30 04:52:23 +00:00
|
|
|
done < "$lower"
|
|
|
|
|
|
|
|
rm -f "$upper" "$lower"
|
|
|
|
exit $ret
|