mirror of https://github.com/golang-jwt/jwt.git
split ErrInvalidKey into ErrInvalidType and ErrInvalidKey
This commit is contained in:
parent
2240de772c
commit
f7288992d2
4
ecdsa.go
4
ecdsa.go
|
@ -69,7 +69,7 @@ func (m *SigningMethodECDSA) Verify(signingString, signature string, key interfa
|
||||||
case *ecdsa.PublicKey:
|
case *ecdsa.PublicKey:
|
||||||
ecdsaKey = k
|
ecdsaKey = k
|
||||||
default:
|
default:
|
||||||
return ErrInvalidKey
|
return ErrInvalidType
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(sig) != 2*m.KeySize {
|
if len(sig) != 2*m.KeySize {
|
||||||
|
@ -103,7 +103,7 @@ func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string
|
||||||
case *ecdsa.PrivateKey:
|
case *ecdsa.PrivateKey:
|
||||||
ecdsaKey = k
|
ecdsaKey = k
|
||||||
default:
|
default:
|
||||||
return "", ErrInvalidKey
|
return "", ErrInvalidType
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the hasher
|
// Create the hasher
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
|
|
||||||
// Error constants
|
// Error constants
|
||||||
var (
|
var (
|
||||||
ErrInvalidKey = errors.New("key is invalid or of invalid type")
|
ErrInvalidKey = errors.New("key is invalid")
|
||||||
|
ErrInvalidType = errors.New("key is of invalid type")
|
||||||
ErrHashUnavailable = errors.New("the requested hash function is unavailable")
|
ErrHashUnavailable = errors.New("the requested hash function is unavailable")
|
||||||
ErrNoTokenInRequest = errors.New("no token present in request")
|
ErrNoTokenInRequest = errors.New("no token present in request")
|
||||||
)
|
)
|
||||||
|
|
2
hmac.go
2
hmac.go
|
@ -49,7 +49,7 @@ func (m *SigningMethodHMAC) Verify(signingString, signature string, key interfac
|
||||||
// Verify the key is the right type
|
// Verify the key is the right type
|
||||||
keyBytes, ok := key.([]byte)
|
keyBytes, ok := key.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrInvalidKey
|
return ErrInvalidType
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode signature, for comparison
|
// Decode signature, for comparison
|
||||||
|
|
2
rsa.go
2
rsa.go
|
@ -65,7 +65,7 @@ func (m *SigningMethodRSA) Verify(signingString, signature string, key interface
|
||||||
case *rsa.PublicKey:
|
case *rsa.PublicKey:
|
||||||
rsaKey = k
|
rsaKey = k
|
||||||
default:
|
default:
|
||||||
return ErrInvalidKey
|
return ErrInvalidType
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create hasher
|
// Create hasher
|
||||||
|
|
|
@ -106,7 +106,7 @@ func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (strin
|
||||||
case *rsa.PrivateKey:
|
case *rsa.PrivateKey:
|
||||||
rsaKey = k
|
rsaKey = k
|
||||||
default:
|
default:
|
||||||
return "", ErrInvalidKey
|
return "", ErrInvalidType
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the hasher
|
// Create the hasher
|
||||||
|
|
Loading…
Reference in New Issue