drbg

package
v0.0.0-...-b59c172 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: BSD-2-Clause, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package drbg implements a minimalistic DRBG based off SipHash-2-4 in OFB mode.

Index

Constants

View Source
const SeedLength = 16 + Size

SeedLength is the length of the HashDrbg seed.

View Source
const Size = siphash.Size

Size is the length of the HashDrbg output.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashDrbg

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

HashDrbg is a CSDRBG based off of SipHash-2-4 in OFB mode.

func NewHashDrbg

func NewHashDrbg(seed *Seed) (*HashDrbg, error)

NewHashDrbg makes a HashDrbg instance based off an optional seed. The seed is truncated to SeedLength.

func (*HashDrbg) Int63

func (drbg *HashDrbg) Int63() int64

Int63 returns a uniformly distributed random integer [0, 1 << 63).

func (*HashDrbg) NextBlock

func (drbg *HashDrbg) NextBlock() []byte

NextBlock returns the next 8 byte DRBG block.

func (*HashDrbg) Seed

func (drbg *HashDrbg) Seed(seed int64)

Seed does nothing, call NewHashDrbg if you want to reseed.

type InvalidSeedLengthError

type InvalidSeedLengthError int

InvalidSeedLengthError is the error returned when the seed provided to the DRBG is an invalid length.

func (InvalidSeedLengthError) Error

func (e InvalidSeedLengthError) Error() string

type Seed

type Seed [SeedLength]byte

Seed is the initial state for a HashDrbg. It consists of a SipHash-2-4 key, and 8 bytes of initial data.

func NewSeed

func NewSeed() (seed *Seed, err error)

NewSeed returns a Seed initialized with the runtime CSPRNG.

func SeedFromBytes

func SeedFromBytes(src []byte) (seed *Seed, err error)

SeedFromBytes creates a Seed from the raw bytes, truncating to SeedLength as appropriate.

func SeedFromHex

func SeedFromHex(encoded string) (seed *Seed, err error)

SeedFromHex creates a Seed from the hexdecimal representation, truncating to SeedLength as appropriate.

func (*Seed) Bytes

func (seed *Seed) Bytes() *[SeedLength]byte

Bytes returns a pointer to the raw HashDrbg seed.

func (*Seed) Hex

func (seed *Seed) Hex() string

Hex returns the hexdecimal representation of the seed.

Jump to

Keyboard shortcuts

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