package rand
import "crypto/internal/rand"
Index ¶
- Variables
- func CustomReader(r io.Reader) io.Reader
- func IsDefaultReader(r io.Reader) bool
- func SetTestingReader(r io.Reader)
Variables ¶
Reader is an io.Reader that calls drbg.Read.
It should be used internally instead of crypto/rand.Reader, because the latter can be set by applications outside of tests. These applications then risk breaking between Go releases, if the way the Reader is used changes.
Functions ¶
func CustomReader ¶
CustomReader returns Reader or, only if the GODEBUG setting "cryptocustomrand=1" is set, the provided io.Reader.
If returning a non-default Reader, it calls randutil.MaybeReadByte on it.
func IsDefaultReader ¶
IsDefaultReader reports whether r is the default crypto/rand.Reader.
If true, the Read method of r can be assumed to call drbg.Read.
func SetTestingReader ¶
SetTestingReader overrides all calls to drbg.Read. The Read method of r must never return an error or return short.
SetTestingReader panics when building against Go Cryptographic Module v1.0.0.
SetTestingReader is pulled by testing/cryptotest.setGlobalRandom via go:linkname.
Source Files ¶
- Version
- v1.26.0-rc.1
- Published
- Dec 15, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 11 seconds ago –
Tools for package owners.