X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost3410%2Fvko.go;h=b3036f577d2c7bd26a03ff38bdaa4442450ca3cb;hb=6d9056bfe4a2d69469a1e70f3bf08f89b377b06e;hp=bb10f9430b98bbf818c24e2bbb912bafb8fffa6e;hpb=c07494bbd559b9d00f391e28cfd070e18afe9900;p=gogost.git diff --git a/gost3410/vko.go b/gost3410/vko.go index bb10f94..b3036f5 100644 --- a/gost3410/vko.go +++ b/gost3410/vko.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2019 Sergey Matveev +// Copyright (C) 2015-2021 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 @@ -24,12 +24,13 @@ func (prv *PrivateKey) KEK(pub *PublicKey, ukm *big.Int) ([]byte, error) { if err != nil { return nil, err } - 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 } } - pk := PublicKey{prv.C, prv.Mode, keyX, keyY} + pk := PublicKey{prv.C, keyX, keyY} return pk.Raw(), nil }