Documentation ¶
Overview ¶
Package rng provides a feedable CSPRNG.
CSPRNG used is fortuna: github.com/seehuhn/fortuna By default the CSPRNG is fed by two sources: - It starts with a seed from `crypto/rand` and periodically reseeds from there - A really simple tickfeeder which extracts entropy from the internal go scheduler using goroutines and is meant to be used under load.
The RNG can also be easily fed with additional sources.
Index ¶
- Variables
- func Bytes(n int) ([]byte, error)
- func Number(max uint64) (uint64, error)
- func Read(b []byte) (n int, err error)
- type Feeder
- func (f *Feeder) CloseFeeder()
- func (f *Feeder) NeedsEntropy() bool
- func (f *Feeder) SupplyEntropy(data []byte, entropy int)
- func (f *Feeder) SupplyEntropyAsInt(n int64, entropy int)
- func (f *Feeder) SupplyEntropyAsIntIfNeeded(n int64, entropy int)
- func (f *Feeder) SupplyEntropyIfNeeded(data []byte, entropy int)
- type Rng
Constants ¶
This section is empty.
Variables ¶
var ( // Reader provides a global instance to read from the RNG. Reader io.Reader )
Functions ¶
Types ¶
type Feeder ¶
type Feeder struct {
// contains filtered or unexported fields
}
The Feeder is used to feed entropy to the RNG.
func (*Feeder) CloseFeeder ¶
func (f *Feeder) CloseFeeder()
CloseFeeder stops the feed processing - the responsible goroutine exits. The input channel is closed and the feeder may not be used anymore in any way.
func (*Feeder) NeedsEntropy ¶
NeedsEntropy returns whether the feeder is currently gathering entropy.
func (*Feeder) SupplyEntropy ¶
SupplyEntropy supplies entropy to the Feeder, it will block until the Feeder has read from it.
func (*Feeder) SupplyEntropyAsInt ¶
SupplyEntropyAsInt supplies entropy to the Feeder, it will block until the Feeder has read from it.
func (*Feeder) SupplyEntropyAsIntIfNeeded ¶
SupplyEntropyAsIntIfNeeded supplies entropy to the Feeder, but will not block if no entropy is currently needed.
func (*Feeder) SupplyEntropyIfNeeded ¶
SupplyEntropyIfNeeded supplies entropy to the Feeder, but will not block if no entropy is currently needed.