#!/bin/bash
# Tested with gpg 1.4.22,23 and 2.1.23, 2.2.27, 2.2.35, 2.2.40 (Deb12), 2.4.5
# gopenpgp does not natively support PGP cleartext signatures (RFC 4880, section 7)?

rm -r CRCHECK.TXT CrCheck.crc CrCheck.txt.asc

echo "++--------------------------------------------------------------------------++"
echo "CR2GPG for CrCheck + gpg (GnuPG) driver MP Edition (c) by ROSE SWE, Ralph Roth"
echo "Multi-Platform - \$Id: cr2gpg.sh,v 1.6 2025/07/06 17:51:22 ralph Exp $"
echo "++--------------------------------------------------------------------------++"

rm -f CrCheck.asc CrCheck.txt CrCheck.txt.asc crcheck.crc
echo "Validating (crc-checking) all the files in the current directory..."

echo "Please verify with GPG/PGP that this file has a valid signature!" > CrCheck.txt
echo "   gpg --verify CrCheck.txt" >> CrCheck.txt
crcheck -create -hash blake3 >>CrCheck.txt

echo "Signing+Validating now with (GNU)-PGP (GPG must be in the PATH=... statement)"
gpg --clear-sign CrCheck.txt

echo "Moving and touching"
mv CrCheck.txt.asc CrCheck.txt
describe CrCheck.txt "Checksum file, run CrCheck and GPG to verify if tampered"
rtouch -eins CrCheck.txt

