27 lines
621 B
Text
27 lines
621 B
Text
get_stack () {
|
|
if [[ ! -z $1 && $1 == "wc" ]];then
|
|
ls /opt/nodemecu/stack | wc -l
|
|
else
|
|
ls /opt/nodemecu/stack | tail -1
|
|
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"
|
|
}
|