drbg

package
v0.2101.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Overview

Package drbg implements the HMAC_DRBG construct as per NIST Special Publication 800-90A Revision 1.

Index

Constants

View Source
const (
	// MaxLength is the maximum length of the input entropy, personalization
	// nonce, and additional input bit strings in bytes.
	//
	// Note: SP 800-90A R1 allows 8 bits more than the value used.
	MaxLength = math.MaxUint32 // 2^35 - 8 bits.

	// ReseedInterval is the maximum number of requests that can be made
	// before a reseed operation is required.
	ReseedInterval = 1 << 48
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Drbg

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

Drbg is a keyed and initialized HMAC_DRBG instance.

Note: This implementation does not support reseeding, and if the internal counter is exceeded, the instance will be rendered unusable. The limit is sufficiently large that it will not be hit under realistic usage.

func New

func New(hash crypto.Hash, entropyInput, nonce, personalizationString []byte) (*Drbg, error)

New creates a new HMAC_DRBG instance with the specified configuration.

func (*Drbg) Read

func (r *Drbg) Read(p []byte) (n int, err error)

Read reads len(p) bytes from HMAC_DRBG. It will always succeed completely (n = len(p)) or not at all. On failures, any partial reads already copied into p will be overwritten by NUL bytes.

Note: 0 length reads are a no-op and do not advance the HMAC_DRBG state.

Jump to

Keyboard shortcuts

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