blake2s

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

README

Go implementation of BLAKE2s 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/blake2s


DOCUMENTATION

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


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 blake2s implements BLAKE2s cryptographic hash function.

Index

Constants

View Source
const (
	BlockSize  = 64 // block size of algorithm
	Size       = 32 // maximum digest size
	SaltSize   = 8  // maximum salt size
	PersonSize = 8  // maximum personalization string size
	KeySize    = 32 // 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 32-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 BLAKE2s 32-byte checksum.

func NewMAC

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

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

func Sum256

func Sum256(data []byte) [Size]byte

Sum256 returns a 32-byte BLAKE2s hash of data.

Types

type Config

type Config struct {
	Size   uint8  // digest size (if zero, default size of 32 bytes is used)
	Key    []byte // key for prefix-MAC
	Salt   []byte // salt (if < 8 bytes, padded with zeros)
	Person []byte // personalization (if < 8 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), max 2⁴⁸-1
	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