Sign implements the Sign method from SigningMethod. For this signing method, must be an *rsa.PrivateKey structure.
(data []byte, key interface{})
| 51 | // Sign implements the Sign method from SigningMethod. |
| 52 | // For this signing method, must be an *rsa.PrivateKey structure. |
| 53 | func (m *SigningMethodRSA) Sign(data []byte, key interface{}) (Signature, error) { |
| 54 | rsaKey, ok := key.(*rsa.PrivateKey) |
| 55 | if !ok { |
| 56 | return nil, ErrInvalidKey |
| 57 | } |
| 58 | sigBytes, err := rsa.SignPKCS1v15(rand.Reader, rsaKey, m.Hash, m.sum(data)) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | return Signature(sigBytes), nil |
| 63 | } |
| 64 | |
| 65 | func (m *SigningMethodRSA) sum(b []byte) []byte { |
| 66 | h := m.Hash.New() |