blake2b

package
v0.0.0-...-34d48bb Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2016 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	// The BLAKE2b block size in bytes.
	BlockSize = 128
	// The max. size of the BLAKE2b checksum
	Size = 64
)
View Source
const (
	// The block flag for message blocks
	MsgFlag uint64 = 0
	// The block flag for the last block
	FinalFlag uint64 = 0xffffffffffffffff
)

Variables

This section is empty.

Functions

func Configure

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

Configure takes the hash size and the BLAKE2b configuration and computes the 8 64-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]uint64, counter *[2]uint64, flag uint64, msg []byte)

func ExtractHash

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

ExtractHash takes the 8 64-bit chain values, the 128-bit counter, the 128 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 BLAKE2b 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 BLAKE2b 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 64)
	Salt     []byte // The salt (length must between 0 and 16)
	Personal []byte // The personalization for unique hashing (length must between 0 and 16)
}

Config contains the BLAKE2b 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