mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 12:46:18 +08:00
sm2: fix test cases
This commit is contained in:
parent
89317b8f0b
commit
6b18205bba
@ -54,8 +54,8 @@ func TestNewPrivateKey(t *testing.T) {
|
|||||||
func TestNewPrivateKeyFromInt(t *testing.T) {
|
func TestNewPrivateKeyFromInt(t *testing.T) {
|
||||||
// test nil
|
// test nil
|
||||||
_, err := NewPrivateKeyFromInt(nil)
|
_, err := NewPrivateKeyFromInt(nil)
|
||||||
if err == nil || err.Error() != "sm2: invalid private key size" {
|
if err == nil || err.Error() != "sm2: private key is nil" {
|
||||||
t.Errorf("should throw sm2: invalid private key size")
|
t.Errorf("should throw sm2: private key is nil")
|
||||||
}
|
}
|
||||||
// test 1
|
// test 1
|
||||||
_, err = NewPrivateKeyFromInt(big.NewInt(1))
|
_, err = NewPrivateKeyFromInt(big.NewInt(1))
|
||||||
|
@ -301,7 +301,10 @@ func calculateSampleZA(pub *ecdsa.PublicKey, a *big.Int, uid []byte) ([]byte, er
|
|||||||
if uidLen > 0 {
|
if uidLen > 0 {
|
||||||
md.Write(uid)
|
md.Write(uid)
|
||||||
}
|
}
|
||||||
writeCurveParams(md, pub.Curve.Params())
|
md.Write(bigIntToBytes(pub.Curve, a))
|
||||||
|
md.Write(bigIntToBytes(pub.Curve, pub.Params().B))
|
||||||
|
md.Write(bigIntToBytes(pub.Curve, pub.Params().Gx))
|
||||||
|
md.Write(bigIntToBytes(pub.Curve, pub.Params().Gy))
|
||||||
md.Write(bigIntToBytes(pub.Curve, pub.X))
|
md.Write(bigIntToBytes(pub.Curve, pub.X))
|
||||||
md.Write(bigIntToBytes(pub.Curve, pub.Y))
|
md.Write(bigIntToBytes(pub.Curve, pub.Y))
|
||||||
return md.Sum(nil), nil
|
return md.Sum(nil), nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user