Skip to content

Commit 9d04122

Browse files
FiloSottilegopherbot
authored andcommitted
crypto/rsa: drop contradictory promise to keep PublicKey modulus secret
We claim to treat N as secret (and indeed bigmod is constant time in relation to the modulus) but at the same time we warn that all inputs to VerifyPKCS1v15 and Verify are public: > The inputs are not considered confidential, and may leak through > timing side channels, or if an attacker has control of part of the > inputs. See #67043 (which focuses on the inverse, recovering signatures by controlling the public key input to Verify), and in particular #67043 (comment). Stopping the Verify adaptive attack would require significantly more complexity, the kind that has caused vulnerabilities in the past (e.g. CVE-2016-2107). On the other hand, assuming that a public key is confidential is unlikely to work in practice, since it can be recovered from just two valid (message, signature) pairs. See for example https://keymaterial.net/2024/06/15/reconstructing-public-keys-from-signatures/. This comment was introduced in CL 552935, not really due to a need to specify that N was secret, but rather to clarify that E is not (so it could be used in variable-time exponentiation). Change-Id: I6a6a6964f3f8d2dc2fcc13ce938b271c9de9666b Reviewed-on: https://go-review.googlesource.com/c/go/+/687616 Reviewed-by: Roland Shoemaker <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 1ca2368 commit 9d04122

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/crypto/rsa/rsa.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ var bigOne = big.NewInt(1)
6363

6464
// A PublicKey represents the public part of an RSA key.
6565
//
66-
// The value of the modulus N is considered secret by this library and protected
67-
// from leaking through timing side-channels. However, neither the value of the
68-
// exponent E nor the precise bit size of N are similarly protected.
66+
// The values of N and E are not considered confidential, and may leak through
67+
// side channels, or could be mathematically derived from other public values.
6968
type PublicKey struct {
7069
N *big.Int // modulus
7170
E int // public exponent

0 commit comments

Comments
 (0)