]> Cypherpunks.ru repositories - gogost.git/commitdiff
gost3410.PublicKey.Equal method, necessary for Go 1.17 v5.7.0
authorSergey Matveev <stargrave@stargrave.org>
Tue, 17 Aug 2021 13:23:40 +0000 (16:23 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 17 Aug 2021 14:40:18 +0000 (17:40 +0300)
gogost.go
gost3410/curve.go
gost3410/public.go
news.texi

index 068a449ea14bf2a1559ae5e47c36393f850c1fb6..6af0a23e0a054e44d9d1c39e7fbc3eb48516e321 100644 (file)
--- a/gogost.go
+++ b/gogost.go
@@ -1,4 +1,4 @@
 // Pure Go GOST cryptographic functions library.
 package gogost
 
-const Version = "5.6.0"
+const Version = "5.7.0"
index 9ec14ded1de85e6760d63f3f7cfb9f7b965eaeab..1aa783c98e9e452f96e972ecb288aafce07a8f3b 100644 (file)
@@ -159,3 +159,15 @@ func (c *Curve) Exp(degree, xS, yS *big.Int) (*big.Int, *big.Int, error) {
        }
        return tx, ty, nil
 }
+
+func (our *Curve) Equal(their *Curve) bool {
+       return our.P.Cmp(their.P) == 0 &&
+               our.Q.Cmp(their.Q) == 0 &&
+               our.A.Cmp(their.A) == 0 &&
+               our.B.Cmp(their.B) == 0 &&
+               our.X.Cmp(their.X) == 0 &&
+               our.Y.Cmp(their.Y) == 0 &&
+               ((our.E == nil && their.E == nil) || our.E.Cmp(their.E) == 0) &&
+               ((our.D == nil && their.D == nil) || our.D.Cmp(their.D) == 0) &&
+               our.Co.Cmp(their.Co) == 0
+}
index 79f00f441261a14bfcda14cc417531e4e86c0daa..8642a274bbceb0b19046bcdc72c6062339b2ed81 100644 (file)
@@ -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.X.Cmp(their.Y) == 0 && our.C.Equal(their.C)
+}
index a5aabeb421b955756e34264bf111364ce877e0b7..b91a0f19c090062446cef03c0a8ba949385096a6 100644 (file)
--- a/news.texi
+++ b/news.texi
@@ -3,6 +3,10 @@
 
 @table @strong
 
+@anchor{Release 5.7.0}
+@item 5.7.0
+Go 1.17 requires @code{gost3410.PublicKey} to have @code{Equal} method.
+
 @anchor{Release 5.6.0}
 @item 5.6.0
     @itemize