drbg

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

drbg implemented deterministic random bit generator as defined in TTAK.KO-12.0331, TTAK.KO-12.0332, TTAK.KO-12.0189/R1, NIST SP 800-90A.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DRBG

type DRBG interface {
	io.Reader
	io.Closer

	Generate(dst []byte, additionalInput []byte) (n int, err error)

	Reseed(additionalInput []byte) error
	ReseedWithEntropy(additionalInput, entropyInput []byte) error
}

func NewCTRDRBG

func NewCTRDRBG(
	newCipher func(key []byte) (cipher.Block, error),
	keySize int,
	options ...Option,
) (DRBG, error)

NewCTRDRBG Deterministic Random Bit Generator based on Block Cipher

default entropy: if requireDerivationFunction is true, NewEntropy(rand.Reader, strengthBits), otherwise NewEntropy(rand.Reader, blocksize + keysize) If strengthBits is unset or smaller than keySize, strengthBits is set to keySize.

TTAK.KO-12.0189/R1

func NewHMACDRGB

func NewHMACDRGB(
	h func() hash.Hash,
	options ...Option,
) (drbg DRBG, err error)

New Deterministic Random Bit Generator based on HMAC

default entropy: if requireDerivationFunction is true, NewEntropy(rand.Reader, strengthBits, strengthBits*2), otherwise NewEntropy(rand.Reader, blocksize + keysize, blocksize + keysize) If strengthBits is unset or smaller than keySize, strengthBits is set to keySize.

TTAK.KO-12.0332

func NewHashDRGB

func NewHashDRGB(
	h hash.Hash,
	options ...Option,
) (drbg DRBG, err error)

New Deterministic Random Bit Generator based on Hash Function

default entropy: if requireDerivationFunction is true, NewEntropy(rand.Reader, strengthBits, strengthBits*2), otherwise NewEntropy(rand.Reader, blocksize + keysize, blocksize + keysize) If strengthBits is unset or smaller than keySize, strengthBits is set to keySize.

TTAK.KO-12.0331

type Entropy

type Entropy interface {
	Get() ([]byte, error)
}

func NewEntropy

func NewEntropy(rand io.Reader, length int) Entropy

type Option

type Option func(args *args)

func WithCTRLength

func WithCTRLength(ctrLen int) Option

func WithCustomEntropy

func WithCustomEntropy(entropy Entropy) Option

func WithDerivationFunction

func WithDerivationFunction(require bool) Option

func WithInstantiateEntropy

func WithInstantiateEntropy(entropyInput []byte) Option

func WithNonce

func WithNonce(nonce []byte) Option

func WithPersonalizationString

func WithPersonalizationString(personalizationString []byte) Option

func WithPredictionResistance

func WithPredictionResistance(require bool) Option

func WithReseedInterval

func WithReseedInterval(reseedInterval uint64) Option

func WithStrengthBits

func WithStrengthBits(value int) Option

Jump to

Keyboard shortcuts

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