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
- func Configure(hVal *[8]uint64, hashsize int, conf *Config) error
- func Core(hVal *[8]uint64, counter *[2]uint64, flag uint64, msg []byte)
- func ExtractHash(out *[Size]byte, hVal *[8]uint64, ctr *[2]uint64, block *[BlockSize]byte, ...)
- func New(hashsize int, conf *Config) (hash.Hash, error)
- func Sum(msg []byte, hashsize int, conf *Config) ([]byte, error)
- type Config
Constants ¶
const ( // The BLAKE2b block size in bytes. BlockSize = 128 // The max. size of the BLAKE2b checksum Size = 64 )
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 ¶
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 ExtractHash ¶
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.
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.