crypto/internal/fips140/rsa: do trial divisions in key generation
This is optimized to be cheap in terms of extra code and complexity,
rather than performance, so we reuse the GCD we have for inverting d.
Recovers most of the performance loss since CL 630516, although
benchmarking key generation is by nature extremely noisy.
goos: darwin
goarch: arm64
pkg: crypto/rsa
cpu: Apple M2
│
3b42687c56 │
b3d018a1e8-dirty │
│ sec/op │ sec/op vs base │
GenerateKey/2048-8 104.1m ± 7% 139.7m ± 20% +34.10% (p=0.000 n=20)
Updates #69799
For #69536
Change-Id: I00347610935db8feb0597529a301ad7ace5b2f22
Reviewed-on: https://go-review.googlesource.com/c/go/+/632479
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>