xof

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package xof provides an interface for extendable-output functions

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMismatchLengthWrite returns when hash's write operation writes wrong length of data
	ErrMismatchLengthWrite = errors.New("hash: mismatch requested data and written data lengths")
	// ErrMismatchLengthRead returns when hash's read operation reads wrong length of data
	ErrMismatchLengthRead = errors.New("hash: mismatch requested data and read data lengths")
)

Functions

This section is empty.

Types

type Extendable

type Extendable uint

Extendable defines type for XOF functions

const (
	SHAKE128 Extendable = 1 + iota //nolint:revive //no need doc
	SHAKE256                       //nolint:revive //no need doc
	BLAKE2XB                       //nolint:revive //no need doc
	BLAKE2XS                       //nolint:revive //no need doc
)

func (Extendable) New

func (id Extendable) New() XOF

New returns a new instance for extendable-output function

type XOF

type XOF interface {
	// Write absorbs more data into the XOF's state. It panics if called after Read.
	io.Writer

	// Read reads more output from the XOF. It returns io.EOF if the limit has been reached.
	io.Reader

	// Clone returns a copy of the XOF in its current state.
	Clone() XOF

	// Reset restores the XOF to its initial state and discards all data appended by Write.
	Reset()

	// MustWriteAll writes all inputs into the XOF's state. It panics if called after Read.
	// It return error ErrMismatchLengthWrite if mismatch lengths, io.Writer's errors otherwise
	MustWriteAll(inputs ...[]byte) error

	// MustReadFull reads exactly len(buf) bytes from XOF's state.
	// It returns an error if fewer bytes were read.
	// The error is ErrMismatchLengthRead only if mismatch lengths, io.ReadFull's errors otherwise
	MustReadFull(buff []byte) error

	// String returns string representation of the XOF algorithm.
	String() string
}

XOF defines the interface to hash functions that support arbitrary-length output

Jump to

Keyboard shortcuts

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