]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost3410/2001_test.go
Forbid any later GNU GPL versions autousage
[gogost.git] / src / cypherpunks.ru / gogost / gost3410 / 2001_test.go
index 953b63215abde1f5989a9383373b6e09492443f6..90da48c62f0cdb3482cadb57ead25dbbf7e5a03e 100644 (file)
@@ -1,10 +1,9 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2017 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2019 Sergey Matveev <stargrave@stargrave.org>
 //
 // 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
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// the Free Software Foundation, version 3 of the License.
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,10 +58,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 +88,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 +123,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 +137,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 +159,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 +170,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()