Compare commits

...

4 commits

Author SHA1 Message Date
f b6c02292e2 firmar un archivo y devolver el nombre del archivo firmado 2022-03-03 16:34:47 -03:00
f 9ad90339ba generar una llave privada 2022-03-03 16:34:32 -03:00
f 37f3f1586e variable para la llave privada 2022-03-03 16:33:12 -03:00
f d6d240b6b2 no commitear llaves por error 2022-03-03 16:33:03 -03:00
3 changed files with 24 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
./key
./key.pub

View file

@ -6,5 +6,26 @@ get_stack () {
fi
}
# Generar una llave privada ECDSA si no existe
generate_private_key () {
test -f "$private_key" && return 1
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"
}

View file

@ -14,3 +14,4 @@ stack=$install_dir/stack
historical=$install_dir/historical
log=$install_dir/errors.log
corrupt=$install_dir/corrupt
private_key=$install_dir/key