Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CipherWrapper ¶
type CipherWrapper struct {
// contains filtered or unexported fields
}
CipherWrapper holds the state for a single ChaCha20 stream.
type SecureRNG ¶
type SecureRNG struct {
Pool sync.Pool
// ReseedInterval forces a re-key after a set duration.
ReseedInterval time.Duration
// ReseedVolume forces a re-key after generating a set volume of data.
ReseedVolume uint64
}
SecureRNG is a high-throughput, concurrency-safe random number generator backed by the ChaCha20 stream cipher.
SECURITY GUARANTEES:
- Thread Safety: Safe for concurrent use by multiple goroutines.
- Forward Secrecy: Periodic reseeding ensures future key compromises do not reveal past outputs.
- Backward Secrecy: NOT guaranteed (compromise reveals output since last reseed).
WARNING: VM SNAPSHOTS & FORKS This RNG lives in userspace. If the process is forked or the VM snapshotted, the state will be duplicated, leading to identical random streams.
func NewSecureRNG ¶
func NewSecureRNG() *SecureRNG
NewSecureRNG initializes a new RNG with safe defaults (1 Minute / 32GB).
func NewSecureRNGWith ¶
NewSecureRNGWith allows custom reseed parameters.
Click to show internal directories.
Click to hide internal directories.