mirror of https://github.com/golang-jwt/jwt.git
Fix error return from HMAC signing method (#371)
This commit is contained in:
parent
3c0777d0c9
commit
6bcdd9d5b6
4
hmac.go
4
hmac.go
|
@ -91,7 +91,7 @@ func (m *SigningMethodHMAC) Verify(signingString string, sig []byte, key interfa
|
||||||
func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte, error) {
|
func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte, error) {
|
||||||
if keyBytes, ok := key.([]byte); ok {
|
if keyBytes, ok := key.([]byte); ok {
|
||||||
if !m.Hash.Available() {
|
if !m.Hash.Available() {
|
||||||
return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType)
|
return nil, ErrHashUnavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
hasher := hmac.New(m.Hash.New, keyBytes)
|
hasher := hmac.New(m.Hash.New, keyBytes)
|
||||||
|
@ -100,5 +100,5 @@ func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte,
|
||||||
return hasher.Sum(nil), nil
|
return hasher.Sum(nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrInvalidKeyType
|
return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue