]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost3410/2012_test.go
Make private key length validation working
[gogost.git] / src / cypherpunks.ru / gogost / gost3410 / 2012_test.go
index 2e828473bd003cb056ade61510990ac9bc2be805..1814691ae210b09e33ef77f10dcb0fb1f0b4a3bc 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2016 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
@@ -175,12 +175,12 @@ func TestGCL3Vectors(t *testing.T) {
 }
 
 func TestRandom2012(t *testing.T) {
-       c, _ := NewCurveFromParams(CurveParamsGostR34102012TC26ParamSetA)
-       f := func(data [31]byte, digest [64]byte) bool {
+       c := CurveIdtc26gost341012512paramSetA()
+       f := func(prvRaw [64 - 1]byte, digest [64]byte) bool {
                prv, err := NewPrivateKey(
                        c,
                        Mode2012,
-                       append([]byte{0xde}, data[:]...),
+                       append([]byte{0xde}, prvRaw[:]...),
                )
                if err != nil {
                        return false
@@ -210,7 +210,7 @@ func TestRandom2012(t *testing.T) {
 }
 
 func BenchmarkSign2012(b *testing.B) {
-       c, _ := NewCurveFromParams(CurveParamsGostR34102012TC26ParamSetA)
+       c := CurveIdtc26gost341012512paramSetA()
        prv, err := GenPrivateKey(c, Mode2012, rand.Reader)
        if err != nil {
                b.FailNow()
@@ -224,7 +224,7 @@ func BenchmarkSign2012(b *testing.B) {
 }
 
 func BenchmarkVerify2012(b *testing.B) {
-       c, _ := NewCurveFromParams(CurveParamsGostR34102012TC26ParamSetA)
+       c := CurveIdtc26gost341012512paramSetA()
        prv, err := GenPrivateKey(c, Mode2012, rand.Reader)
        if err != nil {
                b.FailNow()