Skip to content

Commit 6bcdd9d

Browse files
authored
Fix error return from HMAC signing method (#371)
1 parent 3c0777d commit 6bcdd9d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hmac.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (m *SigningMethodHMAC) Verify(signingString string, sig []byte, key interfa
9191
func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte, error) {
9292
if keyBytes, ok := key.([]byte); ok {
9393
if !m.Hash.Available() {
94-
return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType)
94+
return nil, ErrHashUnavailable
9595
}
9696

9797
hasher := hmac.New(m.Hash.New, keyBytes)
@@ -100,5 +100,5 @@ func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte,
100100
return hasher.Sum(nil), nil
101101
}
102102

103-
return nil, ErrInvalidKeyType
103+
return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType)
104104
}

0 commit comments

Comments
 (0)