Newer
Older
Import / applications / MakePDF / Crypto / rsa-tests / secure-run.sh
@John John on 29 Dec 2020 572 bytes bulk import from macbookpro checkouts
#!/bin/bash

# Takes a file that was generated by the signer.sh script
# Checks the signature is correct using the public key from mykey.pub
# Then runs the program if the signature is valid


# Split the file back out in to two files, the original and the signature
head -c -256 $1 > $1.tmp
tail -c  256 $1 > tmp-signature.file

cat $1.tmp | openssl sha512 -verify mykey.pub -signature tmp-signature.file | grep "Verified OK" > /dev/null
if [ "$?" == "0" ]
then
    chmod a+x ./$1.tmp
    ./$1.tmp
else
    echo "Verification failed"
fi

rm $1.tmp
rm tmp-signature.file