drbg

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBytes = 1 << 27
View Source
const MaxBytesPerGenerate = 1 << 11
View Source
const ReseedCounterIntervalLevelOne uint64 = 1 << 20
View Source
const ReseedCounterIntervalLevelTest uint64 = 8
View Source
const ReseedCounterIntervalLevelTwo uint64 = 1 << 10
View Source
const ReseedTimeIntervalLevelOne = time.Duration(600) * time.Second
View Source
const ReseedTimeIntervalLevelTest = time.Duration(6) * time.Second
View Source
const ReseedTimeIntervalLevelTwo = time.Duration(60) * time.Second

Variables

View Source
var ErrReseedRequired = errors.New("reseed required")

Functions

This section is empty.

Types

type Base

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

func (*Base) NeedReseed

func (base *Base) NeedReseed() bool

type CTR

type CTR struct {
	Base
	// contains filtered or unexported fields
}

func NewCTR

func NewCTR(cipherProvider func(key []byte) (cipher.Block, error), keyLen int, securityLevel SecurityLevel, gm bool, entropy, nonce, personalization []byte) (*CTR, error)

func NewGmCTR

func NewGmCTR(securityLevel SecurityLevel, entropy, nonce, personalization []byte) (*CTR, error)

func NewNistCTR

func NewNistCTR(cipherProvider func(key []byte) (cipher.Block, error), keyLen int, securityLevel SecurityLevel, entropy, nonce, personalization []byte) (*CTR, error)

func (*CTR) Generate

func (hd *CTR) Generate(b, additional []byte) error

func (*CTR) MaxBytesPerRequest

func (hd *CTR) MaxBytesPerRequest() int

func (*CTR) Reseed

func (hd *CTR) Reseed(entropy, additional []byte) error

type DRBG

type DRBG interface {
	NeedReseed() bool
	Reseed(entropy, additional []byte) error
	Generate(b, additional []byte) error
	MaxBytesPerRequest() int
}

type Hash

type Hash struct {
	Base
	// contains filtered or unexported fields
}

func NewGmHash

func NewGmHash(securityLevel SecurityLevel, entropy, nonce, personalization []byte) (*Hash, error)

func NewHash

func NewHash(newHash func() hash.Hash, securityLevel SecurityLevel, gm bool, entropy, nonce, personalization []byte) (*Hash, error)

func NewNistHash

func NewNistHash(newHash func() hash.Hash, securityLevel SecurityLevel, entropy, nonce, personalization []byte) (*Hash, error)

func (*Hash) Generate

func (hd *Hash) Generate(b, additional []byte) error

func (*Hash) MaxBytesPerRequest

func (hd *Hash) MaxBytesPerRequest() int

func (*Hash) Reseed

func (hd *Hash) Reseed(entropy, additional []byte) error

type Prng

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

func NewCtrPrng

func NewCtrPrng(cipherProvider func(key []byte) (cipher.Block, error), keyLen int, entropySource io.Reader, securityStrength int, gm bool, securityLevel SecurityLevel, personalization []byte) (*Prng, error)

func NewGmCtrPrng

func NewGmCtrPrng(entropySource io.Reader, securityStrength int, securityLevel SecurityLevel, personalization []byte) (*Prng, error)

func NewGmHashPrng

func NewGmHashPrng(entropySource io.Reader, securityStrength int, securityLevel SecurityLevel, personalization []byte) (*Prng, error)

func NewHashPrng

func NewHashPrng(newHash func() hash.Hash, entropySource io.Reader, securityStrength int, gm bool, securityLevel SecurityLevel, personalization []byte) (*Prng, error)

func NewNistCtrPrng

func NewNistCtrPrng(cipherProvider func(key []byte) (cipher.Block, error), keyLen int, entropySource io.Reader, securityStrength int, securityLevel SecurityLevel, personalization []byte) (*Prng, error)

func NewNistHashPrng

func NewNistHashPrng(newHash func() hash.Hash, entropySource io.Reader, securityStrength int, securityLevel SecurityLevel, personalization []byte) (*Prng, error)

func (*Prng) Read

func (prng *Prng) Read(data []byte) (int, error)

type SecurityLevel

type SecurityLevel byte
const (
	SecurityLevelOne  SecurityLevel = 0x01
	SecurityLevelTwo  SecurityLevel = 0x02
	SecurityLevelTest SecurityLevel = 0x99
)

Jump to

Keyboard shortcuts

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