// Pure Go GOST cryptographic functions library.
package gogost
-const Version = "5.0.2"
+const Version = "5.1.0"
if err != nil {
return nil, err
}
- ukm = ukm.Mul(ukm, prv.C.Co)
- if ukm.Cmp(bigInt1) != 0 {
- keyX, keyY, err = prv.C.Exp(ukm, keyX, keyY)
+ u := big.NewInt(0).Set(ukm).Mul(ukm, prv.C.Co)
+ if u.Cmp(bigInt1) != 0 {
+ keyX, keyY, err = prv.C.Exp(u, keyX, keyY)
if err != nil {
return nil, err
}
import (
"bytes"
"encoding/hex"
+ "math/big"
"testing"
"testing/quick"
)
}
}
+func TestVKOUKMAltering(t *testing.T) {
+ c := CurveIdtc26gost34102012256paramSetA()
+ ukm := big.NewInt(1)
+ prv, err := NewPrivateKey(c, bytes.Repeat([]byte{0x12}, 32))
+ if err != nil {
+ panic(err)
+ }
+ pub, err := prv.PublicKey()
+ if err != nil {
+ panic(err)
+ }
+ _, err = prv.KEK(pub, ukm)
+ if err != nil {
+ panic(err)
+ }
+ if ukm.Cmp(big.NewInt(1)) != 0 {
+ t.FailNow()
+ }
+}
+
func TestRandomVKO2001(t *testing.T) {
c := CurveIdGostR34102001TestParamSet()
f := func(prvRaw1 [32]byte, prvRaw2 [32]byte, ukmRaw [8]byte) bool {
@table @strong
+@anchor{Release 5.1.0}
+@item 5.1.0
+ @code{gost3410/KEK*} functions do not alter @code{ukm} argument.
+ It is safe to reuse now.
+
@anchor{Release 5.0.0}
@item 5.0.0
Backward incompatible remove of excess misleading @code{gost3410.Mode}