Verify implements the Verify method from SigningMethod. For this verify method, key must be an *ecdsa.PublicKey.
(raw []byte, signature Signature, key interface{})
| 54 | // Verify implements the Verify method from SigningMethod. |
| 55 | // For this verify method, key must be an *ecdsa.PublicKey. |
| 56 | func (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. |