'
}
+session_mac(){
+ if which openssl >/dev/null; then
+ openssl dgst -sha1 -hmac "$(server_key)" -binary |slopecode
+ else
+ { cat; server_key; } |sha256sum |cut -d\ -f1
+ fi
+}
+
randomid(){
dd bs=12 count=1 if=/dev/urandom 2>&- \
| slopecode
local file="$1"
{ stat -c %F%i%n%N%s%Y "$file" 2>&-
printf %s "$SESSION_ID"
- server_key
- } | sha256sum | cut -d\ -f1
+ } | session_mac
}
update_session(){
END
serverkey="$(server_key)"
- checksig="$(printf %s "$sid" "$time" "$serverkey" | sha256sum)"
- checksig="${checksig%% *}"
+ checksig="$(printf %s "$sid" "$time" |session_mac)"
if ! [ "$checksig" = "$sig" \
-a "$time" -ge "$_DATE" \
fi
time=$(( $_DATE + $SESSION_TIMEOUT ))
- sig="$(printf %s "$sid" "$time" "$serverkey" |sha256sum)"
- sig="${sig%% *}"
+ sig="$(printf %s "$sid" "$time" |session_mac)"
printf %s\\n "${sid}-${time}-${sig}"
}