diff --git a/sm2/sm2_dsa_test.go b/sm2/sm2_dsa_test.go index d57f010..1faa41a 100644 --- a/sm2/sm2_dsa_test.go +++ b/sm2/sm2_dsa_test.go @@ -54,8 +54,8 @@ func TestNewPrivateKey(t *testing.T) { func TestNewPrivateKeyFromInt(t *testing.T) { // test nil _, err := NewPrivateKeyFromInt(nil) - if err == nil || err.Error() != "sm2: invalid private key size" { - t.Errorf("should throw sm2: invalid private key size") + if err == nil || err.Error() != "sm2: private key is nil" { + t.Errorf("should throw sm2: private key is nil") } // test 1 _, err = NewPrivateKeyFromInt(big.NewInt(1)) diff --git a/sm2/sm2_keyexchange_sample_test.go b/sm2/sm2_keyexchange_sample_test.go index a649623..5ccf5f3 100644 --- a/sm2/sm2_keyexchange_sample_test.go +++ b/sm2/sm2_keyexchange_sample_test.go @@ -301,7 +301,10 @@ func calculateSampleZA(pub *ecdsa.PublicKey, a *big.Int, uid []byte) ([]byte, er if uidLen > 0 { 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.Y)) return md.Sum(nil), nil