Skip to content

Commit

Permalink
Fix error return from HMAC signing method (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
ss49919201 authored Jan 26, 2024
1 parent 3c0777d commit 6bcdd9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (m *SigningMethodHMAC) Verify(signingString string, sig []byte, key interfa
func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte, error) {
if keyBytes, ok := key.([]byte); ok {
if !m.Hash.Available() {
return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType)
return nil, ErrHashUnavailable
}

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

return nil, ErrInvalidKeyType
return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType)
}

0 comments on commit 6bcdd9d

Please sign in to comment.