drbg

package
v0.0.0-...-57ac6aa Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const SeedLength = 16 + siphash.Size

SeedLength is the number of bytes a drbg seed takes in memory.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b *Seed) bool

Equal is used to test equality of two drbg seeds.

func Overlay

func Overlay(seed, data []byte) error

Overlay is a static method for xoring a byte array with the deterministic random sequence generated from a provided seed.

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 creates a deterministic random number generator from a provided Seed.

func (*HashDrbg) FillBytes

func (d *HashDrbg) FillBytes(b []byte)

FillBytes fills a byte slice from the random number sequence.

func (*HashDrbg) Next

func (d *HashDrbg) Next() []byte

Next returns the next 8 byte DRBG block.

func (*HashDrbg) RandomUint32

func (d *HashDrbg) RandomUint32() uint32

RandomUint32 provides the next block of the random number generator as an integer.

func (*HashDrbg) RandomUint64

func (d *HashDrbg) RandomUint64() uint64

RandomUint64 provides the next block of the random number generator as a long integer.

type Seed

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

Seed holds the state of a deterministic HashDrbg. - SipHash-2-4 keys: key0 and key1 - 8 byte nonce (initialization vector)

func NewSeed

func NewSeed() (*Seed, error)

NewSeed creates a new Seed

func (*Seed) InitVec

func (s *Seed) InitVec() []byte

InitVec provides the initialization vector of the seed.

func (*Seed) Key

func (s *Seed) Key() []byte

Key provides the byte representation of the underlying key for the Seed

func (*Seed) KeyUint128

func (s *Seed) KeyUint128() (uint64, uint64)

KeyUint128 provides a representation of the underlying key as two 64bit ints.

func (*Seed) MarshalBinary

func (s *Seed) MarshalBinary() ([]byte, error)

MarshalBinary creates a byte array representation of a Seed.

func (*Seed) MarshalText

func (s *Seed) MarshalText() ([]byte, error)

MarshalText serializes the seed to textual representation

func (*Seed) UnmarshalBinary

func (s *Seed) UnmarshalBinary(data []byte) error

UnmarshalBinary reconstructs a Seed from a binary implementation, implementing the interface.

func (*Seed) UnmarshalText

func (s *Seed) UnmarshalText(data []byte) error

UnmarshalText restores the seed from a Text representation.

Jump to

Keyboard shortcuts

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