MCPcopy Create free account
hub / github.com/SermoDigital/jose / Verify

Method Verify

crypto/ecdsa.go:56–74  ·  view source on GitHub ↗

Verify implements the Verify method from SigningMethod. For this verify method, key must be an *ecdsa.PublicKey.

(raw []byte, signature Signature, key interface{})

Source from the content-addressed store, hash-verified

54// Verify implements the Verify method from SigningMethod.
55// For this verify method, key must be an *ecdsa.PublicKey.
56func (m *SigningMethodECDSA) Verify(raw []byte, signature Signature, key interface{}) error {
57
58 ecdsaKey, ok := key.(*ecdsa.PublicKey)
59 if !ok {
60 return ErrInvalidKey
61 }
62
63 // Unmarshal asn1 ECPoint
64 var ecpoint ECPoint
65 if _, err := asn1.Unmarshal(signature, &ecpoint); err != nil {
66 return err
67 }
68
69 // Verify the signature
70 if !ecdsa.Verify(ecdsaKey, m.sum(raw), ecpoint.R, ecpoint.S) {
71 return ErrECDSAVerification
72 }
73 return nil
74}
75
76// Sign implements the Sign method from SigningMethod.
77// For this signing method, key must be an *ecdsa.PrivateKey.

Callers

nothing calls this directly

Calls 2

sumMethod · 0.95
VerifyMethod · 0.65

Tested by

no test coverage detected