Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
b001840d
Commit
b001840d
authored
Nov 08, 2016
by
neilpang
Browse files
minor: add _hmac function
parent
20a6ab3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
acme.sh
View file @
b001840d
...
@@ -436,6 +436,31 @@ _digest() {
...
@@ -436,6 +436,31 @@ _digest() {
}
}
#Usage: hashalg secret [outputhex]
#Output Base64-encoded hmac
_hmac() {
alg="$1"
hmac_sec="$2"
outputhex="$3"
if [ -z "$hmac_sec" ] ; then
_usage "Usage: _hmac hashalg secret [outputhex]"
return 1
fi
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ]; then
if [ "$outputhex" ] ; then
openssl dgst -$alg -hmac "$hmac_sec" | cut -d = -f 2 | tr -d ' '
else
openssl dgst -$alg -hmac "$hmac_sec" -binary | _base64
fi
else
_err "$alg is not supported yet"
return 1
fi
}
#Usage: keyfile hashalg
#Usage: keyfile hashalg
#Output: Base64-encoded signature value
#Output: Base64-encoded signature value
_sign() {
_sign() {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment