Codebase list golang-github-tjfoc-gmsm / 9ce3d73
Merge pull request #35 from boling-wang/master accept nil uid when calling sm2 sign/verify chenxu authored 4 years ago GitHub committed 4 years ago
2 changed file(s) with 4 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
140140 // fmt.Printf("--> Content Type: %s", info.ContentType)
141141 switch {
142142 case info.ContentType.Equal(oidSignedData):
143 return parseSignedData(info.Content.Bytes)
143144 case info.ContentType.Equal(oidSMSignedData):
144145 return parseSignedData(info.Content.Bytes)
145146 case info.ContentType.Equal(oidEnvelopedData):
351351
352352 // ZA = H256(ENTLA || IDA || a || b || xG || yG || xA || yA)
353353 func ZA(pub *PublicKey, uid []byte) ([]byte, error) {
354 if len(uid) <= 0 {
355 uid = default_uid
356 }
357354 za := sm3.New()
358355 uidLen := len(uid)
359356 if uidLen >= 8192 {
362359 Entla := uint16(8 * uidLen)
363360 za.Write([]byte{byte((Entla >> 8) & 0xFF)})
364361 za.Write([]byte{byte(Entla & 0xFF)})
365 za.Write(uid)
362 if uidLen > 0 {
363 za.Write(uid)
364 }
366365 za.Write(sm2P256ToBig(&sm2P256.a).Bytes())
367366 za.Write(sm2P256.B.Bytes())
368367 za.Write(sm2P256.Gx.Bytes())