firmas #7
1 changed files with 17 additions and 0 deletions
17
functions
17
functions
|
@ -12,3 +12,20 @@ generate_private_key () {
|
|||
|
||||
ssh-keygen -t ecdsa -f "$private_key" -N "" -m PEM
|
||||
}
|
||||
|
||||
# Firmar el archivo usando la llave privada.
|
||||
#
|
||||
# Uso: sign_file archivo.json
|
||||
# Devuelve: archivo.json.sign
|
||||
sign_file () {
|
||||
local _file="$1"
|
||||
|
||||
test ! -f "$_file" && return 1
|
||||
|
||||
if ! openssl dgst -sha512 -sign "$private_key" "$_file" | base64 | tr -d "\n" > "$_file.sign" ; then
|
||||
rm -f "$_file.sign"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$_file.sign"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue