[dev.boringcrypto] crypto/rsa: fix boringFakeRandomBlind to work with (*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>
This commit is contained in:
Filippo Valsorda 2018-05-15 11:24:57 -04:00
parent a3f9ce3313
commit 019a994e32
1 changed files with 3 additions and 2 deletions

View File

@ -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 {
@ -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
}
}