X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost3410%2F2001_test.go;h=9e1910d7825c091503131a3c4d616202dbfdec5e;hb=3f0105abe94dc598a5aa321abb6437f5b492d675;hp=3d646eadc19d61f1d501f5d5f711b59680d22b7d;hpb=d1cbfa307ebcb72b61f926dfdbc21175a3eec1a8;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost3410/2001_test.go b/src/cypherpunks.ru/gogost/gost3410/2001_test.go index 3d646ea..9e1910d 100644 --- a/src/cypherpunks.ru/gogost/gost3410/2001_test.go +++ b/src/cypherpunks.ru/gogost/gost3410/2001_test.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2018 Sergey Matveev +// Copyright (C) 2015-2019 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -59,10 +59,7 @@ func TestRFCVectors(t *testing.T) { 0x3a, 0xd0, 0x43, 0xfd, 0x39, 0xdc, 0x04, 0x93, } - c, err := NewCurveFromParams(CurveParamsGostR34102001Test) - if err != nil { - t.FailNow() - } + c := CurveIdGostR34102001TestParamSet() prv, err := NewPrivateKey(c, Mode2001, priv) if err != nil { t.FailNow() @@ -92,7 +89,7 @@ func TestRFCVectors(t *testing.T) { } func TestRandom2001(t *testing.T) { - c, _ := NewCurveFromParams(CurveParamsGostR34102001Test) + c := CurveIdGostR34102001TestParamSet() f := func(data [31]byte, digest [32]byte) bool { prv, err := NewPrivateKey( c, @@ -127,7 +124,7 @@ func TestRandom2001(t *testing.T) { } func BenchmarkSign2001(b *testing.B) { - c, _ := NewCurveFromParams(CurveParamsGostR34102001Test) + c := CurveIdGostR34102001TestParamSet() prv, err := GenPrivateKey(c, Mode2001, rand.Reader) if err != nil { b.FailNow() @@ -141,7 +138,7 @@ func BenchmarkSign2001(b *testing.B) { } func BenchmarkVerify2001(b *testing.B) { - c, _ := NewCurveFromParams(CurveParamsGostR34102001Test) + c := CurveIdGostR34102001TestParamSet() prv, err := GenPrivateKey(c, Mode2001, rand.Reader) if err != nil { b.FailNow() @@ -163,8 +160,10 @@ func BenchmarkVerify2001(b *testing.B) { } func TestPrvEqualsTo1(t *testing.T) { - c, _ := NewCurveFromParams(CurveParamsGostR34102001Test) - prv, err := NewPrivateKey(c, Mode2001, []byte{0x01}) + c := CurveIdGostR34102001TestParamSet() + prvRaw := make([]byte, int(Mode2001)) + prvRaw[len(prvRaw)-1] = 1 + prv, err := NewPrivateKey(c, Mode2001, prvRaw) if err != nil { t.FailNow() } @@ -172,7 +171,12 @@ func TestPrvEqualsTo1(t *testing.T) { if err != nil { t.FailNow() } - digest := []byte{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01} + digest := []byte{ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + } sign, err := prv.SignDigest(digest, rand.Reader) if err != nil { t.FailNow()