blake2b

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0, ISC Imports: 3 Imported by: 0

README

Go implementation of BLAKE2b collision-resistant cryptographic hash function
created by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn, and
Christian Winnerlein (https://blake2.net).

INSTALLATION

    $ go get github.com/dchest/blake2b


DOCUMENTATION

    See http://godoc.org/github.com/dchest/blake2b


PUBLIC DOMAIN DEDICATION

Written in 2012 by Dmitry Chestnykh.

To the extent possible under law, the author have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
http://creativecommons.org/publicdomain/zero/1.0/

Documentation

Overview

Package blake2b implements BLAKE2b cryptographic hash function.

Index

Constants

View Source
const (
	BlockSize  = 128 // block size of algorithm
	Size       = 64  // maximum digest size
	SaltSize   = 16  // maximum salt size
	PersonSize = 16  // maximum personalization string size
	KeySize    = 64  // maximum size of key
)

Variables

This section is empty.

Functions

func New

func New(c *Config) (hash.Hash, error)

New returns a new hash.Hash configured with the given Config. Config can be nil, in which case the default one is used, calculating 64-byte digest. Returns non-nil error if Config contains invalid parameters.

func New256

func New256() hash.Hash

New256 returns a new hash.Hash computing the BLAKE2b 32-byte checksum.

func New512

func New512() hash.Hash

New512 returns a new hash.Hash computing the BLAKE2b 64-byte checksum.

func NewMAC

func NewMAC(outBytes uint8, key []byte) hash.Hash

NewMAC returns a new hash.Hash computing BLAKE2b prefix- Message Authentication Code of the given size in bytes (up to 64) with the given key (up to 64 bytes in length).

func Sum256

func Sum256(data []byte) (out [32]byte)

Sum256 returns a 32-byte BLAKE2b hash of data.

func Sum512

func Sum512(data []byte) [64]byte

Sum512 returns a 64-byte BLAKE2b hash of data.

Types

type Config

type Config struct {
	Size   uint8  // digest size (if zero, default size of 64 bytes is used)
	Key    []byte // key for prefix-MAC
	Salt   []byte // salt (if < 16 bytes, padded with zeros)
	Person []byte // personalization (if < 16 bytes, padded with zeros)
	Tree   *Tree  // parameters for tree hashing
}

Config is used to configure hash function parameters and keying. All parameters are optional.

type Tree

type Tree struct {
	Fanout        uint8  // fanout
	MaxDepth      uint8  // maximal depth
	LeafSize      uint32 // leaf maximal byte length (0 for unlimited)
	NodeOffset    uint64 // node offset (0 for first, leftmost or leaf)
	NodeDepth     uint8  // node depth (0 for leaves)
	InnerHashSize uint8  // inner hash byte length
	IsLastNode    bool   // indicates processing of the last node of layer
}

Tree represents parameters for tree hashing.

Jump to

Keyboard shortcuts

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