blake2s

package
v0.0.0-...-8b7e99e Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package blake2s implements the BLAKE2s hash function. BLAKE2s produces hash values from 8 to 256 bit (1 to 32 byte), and can be configured as a MAC. Furthermore BLAKE2s supports salted/randomized and personalized hashing. BLAKE2s can process messages up to 2^64 bytes, which is enough for almost all practical use cases.

Index

Constants

View Source
const (
	// The BLAKE2s block size in bytes.
	BlockSize = 64
	// The max. size of the BLAKE2s checksum
	Size = 32
)
View Source
const (
	// The block flag for message blocks
	MsgFlag uint32 = 0
	// The block flag for the last block
	FinalFlag uint32 = 0xffffffff
)

Variables

This section is empty.

Functions

func Configure

func Configure(hVal *[8]uint32, hashsize int, conf *Config) error

Configure takes the hash size and the BLAKE2s configuration and computes the 8 32-bit chain values. The conf is optional and can be nil, or must be a valid configuraton struct - otherwise a non-nil error is returned.

func Core

func Core(hVal *[8]uint32, counter *[2]uint32, flag uint32, msg []byte)

func ExtractHash

func ExtractHash(out *[Size]byte, hVal *[8]uint32, ctr *[2]uint32, block *[BlockSize]byte, off int)

ExtractHash takes the 8 32-bit chain values, the 64-bit counter, the 64 byte block and a block-offset and extracts the checksum to out.

func New

func New(hashsize int, conf *Config) (hash.Hash, error)

New returns a hash.Hash computing the BLAKE2s checksum with the given hash size using the (optional) conf for configuration. This function returns a non-nil error if the configuration is invalid.

func Sum

func Sum(msg []byte, hashsize int, conf *Config) ([]byte, error)

Sum returns the BLAKE2s checksum with the given hash size of msg using the (optional) conf for configuration. This function returns a non-nil error if the configuration is invalid.

Types

type Config

type Config struct {
	Key      []byte // The key for MAC (length must between 0 and 32)
	Salt     []byte // The salt (length must between 0 and 8)
	Personal []byte // The personalization for unique hashing (length must between 0 and 16)
}

Config contains the BLAKE2s configuration: - Key for computing MACs - Salt for randomized hashing - Personal for personalized hashing All fields are optional and can be nil.

Jump to

Keyboard shortcuts

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