mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-02 19:04:14 +02:00
cryptutil: use bytes for hmac (#2067)
This commit is contained in:
parent
a935c1ba30
commit
a51c7140ea
12 changed files with 28 additions and 28 deletions
|
@ -20,15 +20,15 @@ var (
|
|||
)
|
||||
|
||||
// GenerateHMAC produces a symmetric signature using a shared secret key.
|
||||
func GenerateHMAC(data []byte, key string) []byte {
|
||||
h := hmac.New(sha512.New512_256, []byte(key))
|
||||
func GenerateHMAC(data, key []byte) []byte {
|
||||
h := hmac.New(sha512.New512_256, key)
|
||||
h.Write(data)
|
||||
return h.Sum(nil)
|
||||
}
|
||||
|
||||
// CheckHMAC securely checks the supplied MAC against a message using the
|
||||
// shared secret key.
|
||||
func CheckHMAC(data, suppliedMAC []byte, key string) bool {
|
||||
func CheckHMAC(data, suppliedMAC, key []byte) bool {
|
||||
expectedMAC := GenerateHMAC(data, key)
|
||||
return hmac.Equal(expectedMAC, suppliedMAC)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue