Commit aea963ec authored by Vojtech Myslivec's avatar Vojtech Myslivec 🚀

Add file signature wrapper function

parent 95caf7a7
......@@ -313,3 +313,46 @@ do_serial() {
return 2
fi
}
do_sign() {
local file="$1"
local tmp=''
local device_type
cache_init
# use stdin if no file is given – store it to temp file
[ -z "$file" ] && {
tmp=$(cache_mktemp)
debug "Store stdin to '$tmp'"
cat > "$tmp"
file="$tmp"
}
[ -f "$file" -a -r "$file" ] || {
error "'$file' is not a readable file"
return 1
}
device_type=$(get_device_type)
case "$device_type" in
"$TYPE_ATSHA")
debug "Call atsha file-challenge-response with '$file'"
cached_atsha_challenge_response_file "$file"
;;
"$TYPE_OTP")
debug "Call otp sign with '$file'"
cached_otp_sign "$file"
;;
*)
error "Unsupported device_type '$device_type'"
return 2
;;
esac
# remove temp file if it was used
[ -z "$tmp" ] || rm -f "$tmp"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment