commit c22272e0d80da5fe60c417ffbb8d8d5c894fcc94 Author: Sandino Araico Sánchez Date: Sun Apr 7 00:06:51 2024 -0600 Scripts para distintas operaciones usando la llave pública diff --git a/scripts/get-cert-key b/scripts/get-cert-key new file mode 100755 index 0000000..7f8901b --- /dev/null +++ b/scripts/get-cert-key @@ -0,0 +1,15 @@ +#!/bin/bash + +if [[ -z $1 ]] ; then + echo "usage: $0 " + exit 1 +fi + +FILE=$1 + +if [[ ! -f $FILE ]] ; then + echo "File $FILE does not exist" + exit 2 +fi + +openssl x509 -in $FILE -noout -pubkey diff --git a/scripts/get-cert-serial b/scripts/get-cert-serial new file mode 100755 index 0000000..bfaac89 --- /dev/null +++ b/scripts/get-cert-serial @@ -0,0 +1,23 @@ +#!/bin/bash + +if [[ -z $1 ]] ; then + echo "usage: $0 " + 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 diff --git a/scripts/get_token_co b/scripts/get_token_co new file mode 100755 index 0000000..4af044f --- /dev/null +++ b/scripts/get_token_co @@ -0,0 +1,17 @@ +#!/bin/bash + +if [[ -z $1 ]] ; then + echo "usage: $0 " + 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 + diff --git a/scripts/get_token_co_hash b/scripts/get_token_co_hash new file mode 100755 index 0000000..57eb4e7 --- /dev/null +++ b/scripts/get_token_co_hash @@ -0,0 +1,19 @@ +#!/bin/bash + +if [[ -z $1 ]] ; then + echo "usage: $0 " + 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.*$//' + diff --git a/scripts/get_token_sig b/scripts/get_token_sig new file mode 100755 index 0000000..3073d36 --- /dev/null +++ b/scripts/get_token_sig @@ -0,0 +1,17 @@ +#!/bin/bash + +if [[ -z $1 ]] ; then + echo "usage: $0 " + 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 + diff --git a/scripts/get_token_sig_hash b/scripts/get_token_sig_hash new file mode 100755 index 0000000..6a09fa7 --- /dev/null +++ b/scripts/get_token_sig_hash @@ -0,0 +1,32 @@ +#!/bin/bash + +if [[ -z $1 ]] ; then + echo "usage: $0 " + exit 1 +fi +if [[ -z $2 ]] ; then + echo "usage: $0 " + 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' +