go/doc/next/6-stdlib/99-minor
Filippo Valsorda 2b8dbb35b0 crypto,testing/cryptotest: ignore random io.Reader params, add SetGlobalRandom
First, we centralize all random bytes generation through drbg.Read. The
rest of the FIPS 140-3 module can't use external functions anyway, so
drbg.Read needs to have all the logic.

Then, make sure that the crypto/... tree uses drbg.Read (or the new
crypto/internal/rand.Reader wrapper) instead of crypto/rand, so it is
unaffected by applications setting crypto/rand.Reader.

Next, pass all unspecified random io.Reader parameters through the new
crypto/internal/rand.CustomReader, which just redirects to drbg.Read
unless GODEBUG=cryptocustomrand=1 is set. Move all the calls to
MaybeReadByte there, since it's only needed for these custom Readers.

Finally, add testing/cryptotest.SetGlobalRandom which sets
crypto/rand.Reader to a locked deterministic source and overrides
drbg.Read. This way SetGlobalRandom should affect all cryptographic
randomness in the standard library.

Fixes #70942

Co-authored-by: qiulaidongfeng <2645477756@qq.com>
Change-Id: I6a6a69641311d9fac318abcc6d79677f0e406100
Reviewed-on: https://go-review.googlesource.com/c/go/+/724480
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-26 16:01:17 -08:00
..
bytes bytes: add Buffer.Peek 2025-11-03 09:39:00 -08:00
crypto crypto,testing/cryptotest: ignore random io.Reader params, add SetGlobalRandom 2025-11-26 16:01:17 -08:00
database/sql/driver database/sql: allow drivers to override Scan behavior 2025-08-11 14:27:36 -07:00
debug/elf debug/elf: sync new loong64 relocation types up to LoongArch ELF psABI v20250521 2025-11-17 17:00:42 -08:00
errors errors: add AsType 2025-09-30 10:22:08 -07:00
go go/ast: fix BasicLit.End position for raw strings containing \r 2025-11-17 10:52:48 -08:00
image/jpeg doc/next: document new image/jpeg DCT in release notes 2025-09-25 08:49:17 -07:00
log/slog log/slog: add multiple handlers support for logger 2025-09-04 11:07:44 -07:00
net net/http: add Transport.NewClientConn 2025-11-24 17:26:36 -08:00
os os/signal: make NotifyContext cancel the context with a cause 2025-11-20 13:01:32 -08:00
reflect reflect: add iterator equivalents for NumField, NumIn, NumOut and NumMethod 2025-11-25 09:18:42 -08:00
testing crypto,testing/cryptotest: ignore random io.Reader params, add SetGlobalRandom 2025-11-26 16:01:17 -08:00
0-heading.md doc/next: initialize 2025-07-23 11:41:17 -07:00
README doc/next: initialize 2025-07-23 11:41:17 -07:00

API changes and other small changes to the standard library go here.