Documentation
¶
Overview ¶
Package random provides a feedable CSPRNG.
CSPRNG used is fortuna: github.com/seehuhn/fortuna By default the CSPRNG is fed by two sources: - OS RNG - Entropy gathered by context switching
Index ¶
- Variables
- func Bytes(n int) ([]byte, error)
- func Number(max uint64) (uint64, error)
- func Read(b []byte) (n int, err error)
- func Start() (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)
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.
func (*Feeder) NeedsEntropy ¶
NeedsEntropy returns whether the feeder is currently gathering entropy.
func (*Feeder) SupplyEntropy ¶
SupplyEntropy supplies entropy to to the Feeder, it will block until the Feeder has read from it.
func (*Feeder) SupplyEntropyAsInt ¶
SupplyEntropyAsInt supplies entropy to to the Feeder, it will block until the Feeder has read from it.
func (*Feeder) SupplyEntropyAsIntIfNeeded ¶
SupplyEntropyAsIntIfNeeded supplies entropy to to the Feeder, but will not block if no entropy is currently needed.
func (*Feeder) SupplyEntropyIfNeeded ¶
SupplyEntropyIfNeeded supplies entropy to to the Feeder, but will not block if no entropy is currently needed.