frigoclavis/scripts/get_token_sig_hash

32 lines
540 B
Bash
Executable file

#!/bin/bash
if [[ -z $1 ]] ; then
echo "usage: $0 <token_file> <key.pub>"
exit 1
fi
if [[ -z $2 ]] ; then
echo "usage: $0 <token_file> <key.pub>"
exit 2
fi
FILE=$1
KEY=$2
if [[ ! -f $FILE ]] ; then
echo "Token file $FILE does not exist"
exit 3
fi
if [[ ! -f $KEY ]] ; then
echo "Key file $KEY does not exist"
exit 4
fi
cut -d '#' -f 2 $FILE \
| base64 -d \
| base64 -d \
| openssl pkeyutl -verifyrecover -pubin -inkey $KEY \
| openssl asn1parse -inform DER \
| grep 'OCTET STRING' \
| cut -d ':' -f 4 \
| tr 'A-Z' 'a-z'