]> Cypherpunks repositories - gostls13.git/commit
crypto/rsa: check PrivateKey.D for consistency with Dp and Dq
authorFilippo Valsorda <filippo@golang.org>
Fri, 11 Jul 2025 12:28:30 +0000 (14:28 +0200)
committerGopher Robot <gobot@golang.org>
Tue, 9 Sep 2025 19:32:59 +0000 (12:32 -0700)
commitce391744828cb1e0dbd44ffb2622521a15db5b5d
tree2ff2780b114f0625cd4c5da11625bb4d4ca4c08a
parent5d9d0513dcb96409a2625c51431c584c0a12f212
crypto/rsa: check PrivateKey.D for consistency with Dp and Dq

This unfortunately nearly doubles the runtime of
NewPrivateKeyWithPrecomputation. It would be nice to find an alternative
way to check it.

fips140: off
goos: darwin
goarch: arm64
pkg: crypto/rsa
cpu: Apple M2
                            │ 6aeb841faf  │             62ec3e34f3              │
                            │   sec/op    │    sec/op     vs base               │
ParsePKCS8PrivateKey/2048-8   70.28µ ± 0%   116.16µ ± 0%  +65.28% (p=0.002 n=6)

Fixes #74115

Change-Id: I6a6a6964091817d9aee359cc48932167e55184b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/687836
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
doc/next/6-stdlib/99-minor/crypto/rsa/74115.md
src/crypto/internal/fips140/rsa/rsa.go
src/crypto/rsa/rsa_test.go