X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost3410%2Fvko.go;h=71f61d1adb1e355d312bd181cec9b19723328fd8;hb=5fc90f4d05f0515cc91dd9feceb813e2b753cbb7;hp=1ac5ea3722f108b7b1860bffeccb2f71b9b48b44;hpb=c40d1e5634cf6d540d908a57423f4b504e39f186;p=gogost.git diff --git a/gost3410/vko.go b/gost3410/vko.go index 1ac5ea3..71f61d1 100644 --- a/gost3410/vko.go +++ b/gost3410/vko.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2020 Sergey Matveev +// Copyright (C) 2015-2022 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 }