blake2b

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: BSD-3-Clause Imports: 1 Imported by: 2

Documentation

Overview

Package blake2b implements the BLAKE2b secure hashing algorithm with support for salting and personalization. BLAKE2b is optimized for 64-bit platforms and produces digests of any size between 1 and 64 bytes

Index

Constants

View Source
const (
	// The length of the key field.
	KeyLength = 64
	// The maximum number of bytes to produce.
	MaxOutput = 64
	// Max size of the salt, in bytes
	SaltLength = 16
	// Max size of the personalization string, in bytes
	SeparatorLength = 16
	// Number of G function rounds for BLAKE2b.
	RoundCount = 12
	// Size of a block buffer in bytes
	BlockSize = 128

	// Initialization vector for BLAKE2b
	IV0 uint64 = 0x6a09e667f3bcc908
	IV1 uint64 = 0xbb67ae8584caa73b
	IV2 uint64 = 0x3c6ef372fe94f82b
	IV3 uint64 = 0xa54ff53a5f1d36f1
	IV4 uint64 = 0x510e527fade682d1
	IV5 uint64 = 0x9b05688c2b3e6c1f
	IV6 uint64 = 0x1f83d9abfb41bd6b
	IV7 uint64 = 0x5be0cd19137e2179
)

The constant values will be different for other BLAKE2 variants. These are appropriate for BLAKE2b.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digest

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

Digest represents the internal state of the BLAKE2b algorithm.

func NewDigest

func NewDigest(key, salt, personalization []byte, outputBytes int) (*Digest, error)

NewDigest constructs a new instance of a BLAKE2b hash with the provided configuration.

func (*Digest) BlockSize

func (d *Digest) BlockSize() int

BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.

func (*Digest) Reset

func (d *Digest) Reset()

Reset resets the Hash to its initial state.

func (*Digest) Size

func (d *Digest) Size() int

Size returns the digest output size in bytes.

func (*Digest) Sum

func (d *Digest) Sum(b []byte) (out []byte)

Sum appends the current hash to b and returns the resulting slice. It does not change the underlying hash state.

func (*Digest) Write

func (d *Digest) Write(input []byte) (n int, err error)

Write adds more data to the running hash.

Jump to

Keyboard shortcuts

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