hmacdrbg

package
v0.0.0-...-84c4698 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2017 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const MaxBytesPerGenerate = 937 // ~ 7500bits/8

*937 bytes (~7500 bits) as per the spec.

View Source
const MaxEntropyBytes = 125 // = 1000bits

*Entropy for NewHmacDrbg() and Reseed() must never exceed this number of bytes.

View Source
const MaxPersonalizationBytes = 32 // = 256bits

Variables

This section is empty.

Functions

This section is empty.

Types

type HmacDrbg

type HmacDrbg struct {
	/**The effective security level (eg 128 bits) which this generator was instantiated with.*/
	SecurityLevelBits int
	// contains filtered or unexported fields
}

func NewHmacDrbg

func NewHmacDrbg(securityLevelBits int, entropy, personalization []byte) *HmacDrbg

*Create a new DRBG. desiredSecurityLevelBits must be one of 112, 128, 192, 256.

entropy length (in bits) must be at least 1.5 times securityLevelBits. entropy byte length cannot exceed MaxEntropyBytes.

The personalization can be nil. If non-nil, it's byte length cannot exceed MaxPersonalizationBytes.

If any of the parameters are out-of-range this function will panic.

func (*HmacDrbg) Generate

func (self *HmacDrbg) Generate(outputBytes []byte) bool

*Fill the given byte array with random bytes. Returns false if a reseed is necessary first. This function will panic if the array is larger than MaxBytesPerGenerate.

func (*HmacDrbg) Reseed

func (self *HmacDrbg) Reseed(entropy []byte) error

type HmacDrbgReader

type HmacDrbgReader struct {
	Drbg *HmacDrbg
	// contains filtered or unexported fields
}

*Read from an arbitrary number of bytes from HmacDrbg efficiently. Internally it generates blocks of MaxBytesPerGenerate. It then serves these out through the standard `Read` function. Read returns an error if reseed becomes is necessary.

func NewHmacDrbgReader

func NewHmacDrbgReader(drbg *HmacDrbg) *HmacDrbgReader

func (*HmacDrbgReader) Read

func (self *HmacDrbgReader) Read(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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