Skip to content

Commit 7aa10a3

Browse files
committed
hmac: get rid of reflection in hmac calculation as well
1 parent e8810ff commit 7aa10a3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

hmac/hmac.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ func VerifyHMACLoginAndPassword(mac hash.Hash, login, password []byte) bool {
4343
}
4444

4545
func CalculateHMACSignature(mac hash.Hash, username []byte, expire int64) []byte {
46+
var buf [unsafe.Sizeof(expire)]byte
47+
binary.BigEndian.PutUint64(buf[:], uint64(expire))
48+
4649
mac.Reset()
4750
mac.Write(hmacSignaturePrefix)
4851
mac.Write(username)
49-
binary.Write(mac, binary.BigEndian, expire)
52+
mac.Write(buf[:])
53+
5054
return mac.Sum(nil)
5155
}

0 commit comments

Comments
 (0)