MCPcopy
hub / github.com/tjfoc/gmsm / Sign

Method Sign

sm2/sm2.go:69–75  ·  view source on GitHub ↗

sign format = 30 + len(z) + 02 + len(r) + r + 02 + len(s) + s, z being what follows its size, ie 02+len(r)+r+02+len(s)+s

(random io.Reader, msg []byte, signer crypto.SignerOpts)

Source from the content-addressed store, hash-verified

67
68// sign format = 30 + len(z) + 02 + len(r) + r + 02 + len(s) + s, z being what follows its size, ie 02+len(r)+r+02+len(s)+s
69func (priv *PrivateKey) Sign(random io.Reader, msg []byte, signer crypto.SignerOpts) ([]byte, error) {
70 r, s, err := Sm2Sign(priv, msg, nil, random)
71 if err != nil {
72 return nil, err
73 }
74 return asn1.Marshal(sm2Signature{r, s})
75}
76
77func (pub *PublicKey) Verify(msg []byte, sign []byte) bool {
78 var sm2Sign sm2Signature

Callers 15

TestSm2Function · 0.80
BenchmarkSM2Function · 0.80
Sm2SignFunction · 0.80
Sm2VerifyFunction · 0.80
VerifyFunction · 0.80
zForAffineFunction · 0.80
sm2P256PointAddFunction · 0.80
sm2P256PointSubFunction · 0.80
sm2GenrateWNafFunction · 0.80
doFullHandshakeMethod · 0.80
doFullHandshakeMethod · 0.80

Calls 1

Sm2SignFunction · 0.85

Tested by 2

TestSm2Function · 0.64
BenchmarkSM2Function · 0.64