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

Method Sign

crypto/rsa.go:53–63  ·  view source on GitHub ↗

Sign implements the Sign method from SigningMethod. For this signing method, must be an *rsa.PrivateKey structure.

(data []byte, key interface{})

Source from the content-addressed store, hash-verified

51// Sign implements the Sign method from SigningMethod.
52// For this signing method, must be an *rsa.PrivateKey structure.
53func (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
65func (m *SigningMethodRSA) sum(b []byte) []byte {
66 h := m.Hash.New()

Callers

nothing calls this directly

Calls 2

sumMethod · 0.95
SignatureTypeAlias · 0.85

Tested by

no test coverage detected