X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost3410%2Fpublic.go;h=3bef45f70ef798287edf4b23654e09d2103a730b;hb=f17daeb600c11ad0f3b1e80ac800da82d4a926ca;hp=e2e3814e381e9dd8db2caf0408a67bd79fb65d86;hpb=7ed4c1e0857134c14ef5c03dee48c1cc7a555e98;p=gogost.git diff --git a/gost3410/public.go b/gost3410/public.go index e2e3814..3bef45f 100644 --- a/gost3410/public.go +++ b/gost3410/public.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2020 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 @@ -16,6 +16,7 @@ package gost3410 import ( + "crypto" "fmt" "math/big" ) @@ -107,3 +108,11 @@ func (pub *PublicKey) VerifyDigest(digest, signature []byte) (bool, error) { lm.Mod(lm, pub.C.Q) return lm.Cmp(r) == 0, nil } + +func (our *PublicKey) Equal(theirKey crypto.PublicKey) bool { + their, ok := theirKey.(*PublicKey) + if !ok { + return false + } + return our.X.Cmp(their.X) == 0 && our.Y.Cmp(their.Y) == 0 && our.C.Equal(their.C) +}