firmas #7

Open
fauno wants to merge 9 commits from firmas into master
3 changed files with 20 additions and 0 deletions

2
.gitignore vendored Normal file
View file

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

View file

@ -6,5 +6,22 @@ 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 "" -C "$@"
}
# Firmar el archivo usando la llave privada.
#
# Uso: sign_file archivo.json
# Devuelve: La firma
sign_file () {
local _file="$1"
test ! -f "$_file" && return 1
test -f "$_file.sig" || ssh-keygen -Y sign -f "$private_key" -n file "$_file" 2>&1 >/dev/null
cat "${_file}.sig" | grep -v SIGNATURE | tr -d "\n"
}

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