-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify-sig
executable file
·46 lines (39 loc) · 959 Bytes
/
verify-sig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Verifies signatures of a downloaded file
# Assumes the current directory contains files in the form:
# file, file.asc, file.md5, file.sha1, file.sha512
#
# if file not available, you will have to run:
# echo "##-HASH-##" > file.sha512
if [[ -z "$1" ]]; then
echo "usage $0 <file>"
echo "This script looks in pwd ($(pwd)) for signature files"
echo "md5, sha1, sha512, asc"
exit 0
fi
FILE=$1
function check {
SIG=$1
FILE_SIG="$FILE.$SIG"
echo "Checking $FILE_SIG"
if [[ ! -f "$FILE_SIG" ]]; then
echo "WARNING: There is no signature for $FILE_SIG"
return
fi
cat "$FILE_SIG"
echo ""
PROG="$SIG""sum"
RESULT=$(diff <(echo $(cat $FILE_SIG)"") <($PROG $FILE | awk '{print $1}'))
if [[ "$RESULT" ]]; then
echo "FATAL: $SIG Signature for $FILE does NOT match!"
echo $RESULT
exit 1
else
echo "Looks good"
fi
}
check md5
check sha1
check sha512
echo "Calling gpg --verify ${FILE}.asc"
gpg --verify "${FILE}.asc"