From 35dcb815e217c1135012ba81616496c3ad10b3f5 Mon Sep 17 00:00:00 2001 From: davidovski Date: Thu, 17 Feb 2022 02:15:19 +0000 Subject: added file installing --- src/validate.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/validate.sh (limited to 'src/validate.sh') 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 +} -- cgit v1.2.1