fastRNG

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 9 Imported by: 51

Documentation

Overview

Package fastRNG is an implementation of the Fortuna construction as specified by Ferguson, Schneier and Kohno in 'Cryptography Engineering: Design Principles and Practical Applications' Link: https://www.schneier.com/academic/paperfiles/fortuna.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fortuna

func Fortuna(src, ext []byte, fortunaHash hash.Hash) cipher.Stream

The Fortuna construction is used to generate randomness

Types

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func (*Stream) Close

func (s *Stream) Close()

Closes the stream returning it to its source generator if there is room in the pool

func (Stream) Read

func (s Stream) Read(b []byte) (int, error)

Read reads up to len(b) bytes from the csprng.Source object. This function returns and error if the stream is locked. Users of stream objects should close them when they are finished using them. We read the AES BlockSize into AES then run it until blockSize*scalingFactor bytes are read. Every time BlockSize*scalingFactor bytes are read this functions blocks until it rereads csprng.Source. Will crash if the stream has been closed.

func (Stream) SetSeed

func (s Stream) SetSeed(seed []byte) error

SetSeed does not do anything. Function exists to comply with the csprng.Source interface.

type StreamGenerator

type StreamGenerator struct {
	// contains filtered or unexported fields
}

func NewStreamGenerator

func NewStreamGenerator(scalingFactor uint, maxWaiting uint,
	rng csprng.SourceConstructor) *StreamGenerator

NewStreamGenerator creates a StreamGenerator object containing streamCount streams. The passed in rngConstructor will be the source of randomness for the streams. maxWaiting allows the creation of a pool for the reuse of streams. To reuse a stream it must be closed, then it will be returned on the next attempted get of a new stream. Set it to zero if reuse isn't wanted

func (*StreamGenerator) GetStream

func (sg *StreamGenerator) GetStream() *Stream

GetStream gets an existing stream or creates a new stream object. It returns a new stream object if none can be retrieved from the pool of waiting streams

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL