]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/rsa: drop uneeded parameter in modInverse
authorBrian Kessler <brian.m.kessler@gmail.com>
Fri, 21 Jul 2017 08:19:42 +0000 (01:19 -0700)
committerAdam Langley <agl@golang.org>
Wed, 9 Aug 2017 19:28:40 +0000 (19:28 +0000)
The current modInverse implementation allocates a big.Int
for the second parameter of GCD, while only the first is needed.
This is unnecessary and can lead to a speed up for optimizations
of GCD where the second parameter is not calculated at all.

Change-Id: I3f042e140ff643311bc3d0b8d192992d4d2c4c70
Reviewed-on: https://go-review.googlesource.com/50531
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filosottile.wiki@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
src/crypto/rsa/rsa.go

index 1de4fcb473eab9dda4bc88b0c2fe0a13dcb27662..69a2b58a5a6980d6f0385625b842f87852edf179 100644 (file)
@@ -424,8 +424,7 @@ var ErrVerification = errors.New("crypto/rsa: verification error")
 func modInverse(a, n *big.Int) (ia *big.Int, ok bool) {
        g := new(big.Int)
        x := new(big.Int)
-       y := new(big.Int)
-       g.GCD(x, y, a, n)
+       g.GCD(x, nil, a, n)
        if g.Cmp(bigOne) != 0 {
                // In this case, a and n aren't coprime and we cannot calculate
                // the inverse. This happens because the values of n are nearly