Scripts para distintas operaciones usando la llave pública

This commit is contained in:
Sandino Araico Sánchez 2024-04-07 00:06:51 -06:00
commit c22272e0d8
Signed by: KBrown
GPG key ID: 991D5D40CC62244F
6 changed files with 123 additions and 0 deletions

15
scripts/get-cert-key Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
if [[ -z $1 ]] ; then
echo "usage: $0 <file.crt>"
exit 1
fi
FILE=$1
if [[ ! -f $FILE ]] ; then
echo "File $FILE does not exist"
exit 2
fi
openssl x509 -in $FILE -noout -pubkey

23
scripts/get-cert-serial Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
if [[ -z $1 ]] ; then
echo "usage: $0 <file.crt>"
exit 1
fi
FILE=$1
if [[ ! -f $FILE ]] ; then
echo "File $FILE does not exist"
exit 2
fi
openssl x509 -in $FILE -noout -text \
| grep -A1 'Serial Number' \
| tail -1 \
| tr ':' "\n" \
| while read B ; do
#echo $B
printf "\x$B"
done
echo

17
scripts/get_token_co Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
if [[ -z $1 ]] ; then
echo "usage: $0 <token_file>"
exit 1
fi
FILE=$1
if [[ ! -f $FILE ]] ; then
echo "File $FILE does not exist"
exit 2
fi
cut -d '#' -f 1 $FILE \
| base64 -d

19
scripts/get_token_co_hash Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
if [[ -z $1 ]] ; then
echo "usage: $0 <token_file>"
exit 1
fi
FILE=$1
if [[ ! -f $FILE ]] ; then
echo "File $FILE does not exist"
exit 2
fi
cut -d '#' -f 1 $FILE \
| base64 -d \
| sha1sum \
| sed 's/\s.*$//'

17
scripts/get_token_sig Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
if [[ -z $1 ]] ; then
echo "usage: $0 <token_file>"
exit 1
fi
FILE=$1
if [[ ! -f $FILE ]] ; then
echo "File $FILE does not exist"
exit 2
fi
cut -d '#' -f 2 $FILE \
| base64 -d

32
scripts/get_token_sig_hash Executable file
View file

@ -0,0 +1,32 @@
#!/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'