Filippo Valsorda 10fb001c75 crypto/rsa: refuse to generate and/or use keys smaller than 1024 bits
Fixes #68762

Change-Id: Id89c770571d7cc27c6cf7932139ec3424383a7ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/629938
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-22 01:50:32 +00:00

487 B

[GenerateKey] now returns an error if a key of less than 1024 bits is requested. All Sign, Verify, Encrypt, and Decrypt methods now return an error if used with a key smaller than 1024 bits. Such keys are insecure and should not be used. Setting GODEBUG=rsa1024min=0 or including //go:debug rsa1024min=0 in a source file restores the old behavior, but we recommend doing so only in tests, if necessary. A new [GenerateKey] example provides an easy-to-use standard 2048-bit test key.