MCPcopy
hub / github.com/golang-jwt/jwt / Verify

Method Verify

rsa.go:49–66  ·  view source on GitHub ↗

Verify implements token verification for the SigningMethod For this signing method, must be an *rsa.PublicKey structure.

(signingString string, sig []byte, key any)

Source from the content-addressed store, hash-verified

47// Verify implements token verification for the SigningMethod
48// For this signing method, must be an *rsa.PublicKey structure.
49func (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.

Callers

nothing calls this directly

Calls 1

newErrorFunction · 0.85

Tested by

no test coverage detected