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
- func Configure(hVal *[8]uint32, hashsize int, conf *Config) error
- func Core(hVal *[8]uint32, counter *[2]uint32, flag uint32, msg []byte)
- func ExtractHash(out *[Size]byte, hVal *[8]uint32, ctr *[2]uint32, 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 BLAKE2s block size in bytes. BlockSize = 64 // The max. size of the BLAKE2s checksum Size = 32 )
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 ¶
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 ExtractHash ¶
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.
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.