]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost3410/curve.go
Raise copyright years
[gogost.git] / src / cypherpunks.ru / gogost / gost3410 / curve.go
index 70f5a66c3596f11b89df39fea74ee1a0a4119da1..d253d8eea61adea237e7f7dfb63ad249cdd80c4b 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2016 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2017 Sergey Matveev <stargrave@stargrave.org>
 //
 // 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
@@ -116,14 +116,14 @@ func (c *Curve) add(p1x, p1y, p2x, p2y *big.Int) {
 }
 
 func (c *Curve) Exp(degree, xS, yS *big.Int) (*big.Int, *big.Int, error) {
+       if degree.Cmp(zero) == 0 {
+               return nil, nil, errors.New("Bad degree value")
+       }
        dg := big.NewInt(0).Sub(degree, bigInt1)
        tx := big.NewInt(0).Set(xS)
        ty := big.NewInt(0).Set(yS)
        cx := big.NewInt(0).Set(xS)
        cy := big.NewInt(0).Set(yS)
-       if dg.Cmp(zero) == 0 {
-               return nil, nil, errors.New("Bad degree value")
-       }
        for dg.Cmp(zero) != 0 {
                if dg.Bit(0) == 1 {
                        c.add(tx, ty, cx, cy)