diff options
Diffstat (limited to 'src/validate.sh')
-rw-r--r-- | src/validate.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/validate.sh b/src/validate.sh new file mode 100644 index 0000000..4f73729 --- /dev/null +++ b/src/validate.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +validate_checksum () { + local file=$1 + local checksum=$2 + [ ! -f $file ] && return 1 + [ "$(md5sum $file | awk '{ print $1; }')" = "$checksum" ] +} + +validate_sig () { + local pkg_file=$1 + local info_file=$2 + local keychain + + local sig_encoded=$(sed -rn "s/^SIGNATURE=(.*)/\1/p" $info_file) + local sig_file="${pkg_file}.sig" + + echo $sig_encoded | tr ' ' '\n' | base64 -d > $sig_file + + for key in ${KEYCHAIN_DIR}/*.pub; do + ${VERBOSE} && printf "${LIGHT_BLACK}Checking verification against $(basename $key) for $(basename $pkg_file)\n${RESET}" + openssl dgst -verify $key -signature $sig_file $pkg_file | grep -q "OK" && return 0 + done + return 1 +} |