Verify implements token verification for the SigningMethod For this signing method, must be an *rsa.PublicKey structure.
(signingString string, sig []byte, key any)
| 47 | // Verify implements token verification for the SigningMethod |
| 48 | // For this signing method, must be an *rsa.PublicKey structure. |
| 49 | func (m *SigningMethodRSA) Verify(signingString string, sig []byte, key any) error { |
| 50 | var rsaKey *rsa.PublicKey |
| 51 | var ok bool |
| 52 | |
| 53 | if rsaKey, ok = key.(*rsa.PublicKey); !ok { |
| 54 | return newError("RSA verify expects *rsa.PublicKey", ErrInvalidKeyType) |
| 55 | } |
| 56 | |
| 57 | // Create hasher |
| 58 | if !m.Hash.Available() { |
| 59 | return ErrHashUnavailable |
| 60 | } |
| 61 | hasher := m.Hash.New() |
| 62 | hasher.Write([]byte(signingString)) |
| 63 | |
| 64 | // Verify the signature |
| 65 | return rsa.VerifyPKCS1v15(rsaKey, m.Hash, hasher.Sum(nil), sig) |
| 66 | } |
| 67 | |
| 68 | // Sign implements token signing for the SigningMethod |
| 69 | // For this signing method, must be an *rsa.PrivateKey structure. |
nothing calls this directly
no test coverage detected