summaryrefslogtreecommitdiff
path: root/src/validate.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-02-17 02:15:19 +0000
committerdavidovski <david@davidovski.xyz>2022-02-17 02:15:19 +0000
commit35dcb815e217c1135012ba81616496c3ad10b3f5 (patch)
treec1190a25e1cc2ad74674a06f1faac8a0b9db871e /src/validate.sh
parent1117f2bef50ec65aa6bfe55e8e22beb5be092275 (diff)
added file installing
Diffstat (limited to 'src/validate.sh')
-rw-r--r--src/validate.sh25
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
+}