skein512

package
v1.0.2018 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package skein implements the Skein-512 hash function, MAC, and stream cipher as defined in "The Skein Hash Function Family, v1.3".

Index

Constants

View Source
const BlockSize = 64

BlockSize is the block size of Skein-512 in bytes.

Variables

This section is empty.

Functions

func NewHash

func NewHash(outLen uint64) hash.Hash

NewHash returns hash.Hash calculating checksum of the given length in bytes (for example, to calculate 256-bit hash, outLen must be set to 32).

func NewMAC

func NewMAC(outLen uint64, key []byte) hash.Hash

NewMAC returns hash.Hash calculating Skein Message Authentication Code of the given length in bytes. A MAC is a cryptographic hash that uses a key to authenticate a message. The receiver verifies the hash by recomputing it using the same key.

func NewStream

func NewStream(key []byte, nonce []byte) cipher.Stream

NewStream returns a cipher.Stream for encrypting a message with the given key and nonce. The same key-nonce combination must not be used to encrypt more than one message. There are no limits on the length of key or nonce.

Types

type Args

type Args struct {
	// Key is a secret key for MAC, KDF, or stream cipher
	Key []byte
	// Person is a personalization string
	Person []byte
	// PublicKey is a public key for signature hashing
	PublicKey []byte
	// KeyId is a key identifier for KDF
	KeyId []byte
	// Nonce for stream cipher or randomized hashing
	Nonce []byte
	// NoMsg indicates whether message input is used by the function.
	NoMsg bool
}

Args can be used to configure hash function for different purposes. All fields are optional: if a field is nil, it will not be used.

type Hash

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

Hash represents a state of Skein hash function. It implements hash.Hash interface.

func New

func New(outLen uint64, args *Args) *Hash

New returns a new skein.Hash configured with the given arguments. The final output length of hash function in bytes is outLen (for example, 64 when calculating 512-bit hash). Configuration arguments may be nil.

func (*Hash) BlockSize

func (h *Hash) BlockSize() int

BlockSize returns the hash's underlying block size.

func (*Hash) OutputReader

func (h *Hash) OutputReader() io.Reader

OutputReader returns an io.Reader that can be used to read arbitrary-length output of the hash. Reading from it doesn't change the underlying hash state.

func (*Hash) Reset

func (h *Hash) Reset()

Reset resets hash to its state after initialization. If hash was initialized with arguments, such as key, these arguments are preserved.

func (*Hash) Size

func (h *Hash) Size() int

Size returns the number of bytes Sum will return. If the hash was created with output size greater than the maximum size of int, the result is undefined.

func (*Hash) Sum

func (h *Hash) Sum(p []byte) []byte

Sum appends the current hash to in and returns the resulting slice. It does not change the underlying hash state.

func (*Hash) Write

func (h *Hash) Write(b []byte) (n int, err error)

Write adds more data to the running hash. It never returns an error.

Jump to

Keyboard shortcuts

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