Skip to content

Commit

Permalink
[dev.boringcrypto] crypto/rsa: fix boringFakeRandomBlind to work with…
Browse files Browse the repository at this point in the history
… (*big.Int).ModInverse

http://golang.org/cl/108996 removed the local modInverse and its call in
decrypt in favor of (*big.Int).ModInverse. boringFakeRandomBlind copies
decrypt, so it needs to be updated as well.

Change-Id: I59a6c17c2fb9cc7f38cbb59dd9ed11846737d220
Reviewed-on: https://go-review.googlesource.com/113676
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
FiloSottile committed May 18, 2018
1 parent a3f9ce3 commit 019a994
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/crypto/rsa/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func boringFakeRandomBlind(random io.Reader, priv *PrivateKey) {
boring.UnreachableExceptTests()

// Copied from func decrypt.
ir := new(big.Int)
for {
r, err := rand.Int(random, priv.N)
if err != nil {
Expand All @@ -155,8 +156,8 @@ func boringFakeRandomBlind(random io.Reader, priv *PrivateKey) {
if r.Cmp(bigZero) == 0 {
r = bigOne
}
_, ok := modInverse(r, priv.N)
if ok {
ok := ir.ModInverse(r, priv.N)
if ok != nil {
break
}
}
Expand Down

0 comments on commit 019a994

Please sign in to comment.