blake2xb

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2017 License: CC0-1.0 Imports: 5 Imported by: 1

README

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

INSTALLATION

    $ go get github.com/nogoegst/blake2xb


DOCUMENTATION

    See http://godoc.org/github.com/nogoegst/blake2xb


PUBLIC DOMAIN DEDICATION

BLAKE2b implementation written in 2012 by Dmitry Chestnykh.
BLAKE2Xb implementation written in 2017 by Ivan Markin.

To the extent possible under law, the authors 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

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

This section is empty.

Types

type BLAKE2xb

type BLAKE2xb struct {
	// contains filtered or unexported fields
}

func (*BLAKE2xb) BlockSize

func (b *BLAKE2xb) BlockSize() int

BlockSize returns the algorithm block size in bytes.

func (*BLAKE2xb) Read

func (x *BLAKE2xb) Read(out []byte) (n int, err error)

Read reads output of BLAKE2xb XOF. It returns io.EOF if the end of XOF output is reached.

func (*BLAKE2xb) Reset

func (x *BLAKE2xb) Reset()

Reset resets BLAKE2xb to the initial state.

func (*BLAKE2xb) Size

func (b *BLAKE2xb) Size() int

Size returns the digest size in bytes.

func (*BLAKE2xb) Sum

func (b *BLAKE2xb) Sum(in []byte) []byte

Sum returns the calculated checksum.

func (*BLAKE2xb) Write

func (x *BLAKE2xb) Write(p []byte) (written int, err error)

Write absorbs data on input. It panics if input is written after output has been read from the XOF (i.e. Read has been called).

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.

func NewConfig

func NewConfig(l uint32) (c *Config)

NewConfig creates default config c for BLAKE2xb with output length of l. If l is 0, maximum output length is used (2^32-1).

type Tree

type Tree struct {
	Fanout        uint8  // fanout
	MaxDepth      uint8  // maximal depth
	LeafSize      uint32 // leaf maximal byte length (0 for unlimited)
	NodeOffset    uint32 // node offset (0 for first, leftmost or leaf)
	XOFLength     uint32 // XOF digest length
	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.

type XOFHash

type XOFHash interface {
	hash.Hash
	io.Reader
}

func New

func New(l uint32) (XOFHash, error)

func NewMAC

func NewMAC(outBytes uint32, key []byte) XOFHash

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

func NewWithConfig

func NewWithConfig(c *Config) (XOFHash, error)

NewX creates new BLAKE2xb instance using config c.

Jump to

Keyboard shortcuts

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