sha3

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: BSD-3-Clause Imports: 9 Imported by: 18,006

Documentation

Overview

Package sha3 implements the SHA-3 hash algorithms and the SHAKE extendable output functions defined in FIPS 202.

Most of this package is a wrapper around the crypto/sha3 package in the standard library. The only exception is the legacy Keccak hash functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New224

func New224() hash.Hash

New224 creates a new SHA3-224 hash. Its generic security strength is 224 bits against preimage attacks, and 112 bits against collision attacks.

It is a wrapper for the sha3.New224 function in the standard library.

func New256

func New256() hash.Hash

New256 creates a new SHA3-256 hash. Its generic security strength is 256 bits against preimage attacks, and 128 bits against collision attacks.

It is a wrapper for the sha3.New256 function in the standard library.

func New384

func New384() hash.Hash

New384 creates a new SHA3-384 hash. Its generic security strength is 384 bits against preimage attacks, and 192 bits against collision attacks.

It is a wrapper for the sha3.New384 function in the standard library.

func New512

func New512() hash.Hash

New512 creates a new SHA3-512 hash. Its generic security strength is 512 bits against preimage attacks, and 256 bits against collision attacks.

It is a wrapper for the sha3.New512 function in the standard library.

func NewLegacyKeccak256

func NewLegacyKeccak256() hash.Hash

NewLegacyKeccak256 creates a new Keccak-256 hash.

Only use this function if you require compatibility with an existing cryptosystem that uses non-standard padding. All other users should use New256 instead.

func NewLegacyKeccak512

func NewLegacyKeccak512() hash.Hash

NewLegacyKeccak512 creates a new Keccak-512 hash.

Only use this function if you require compatibility with an existing cryptosystem that uses non-standard padding. All other users should use New512 instead.

func ShakeSum128

func ShakeSum128(hash, data []byte)

ShakeSum128 writes an arbitrary-length digest of data into hash.

func ShakeSum256

func ShakeSum256(hash, data []byte)

ShakeSum256 writes an arbitrary-length digest of data into hash.

func Sum224

func Sum224(data []byte) [28]byte

Sum224 returns the SHA3-224 digest of the data.

It is a wrapper for the sha3.Sum224 function in the standard library.

func Sum256

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

Sum256 returns the SHA3-256 digest of the data.

It is a wrapper for the sha3.Sum256 function in the standard library.

func Sum384

func Sum384(data []byte) [48]byte

Sum384 returns the SHA3-384 digest of the data.

It is a wrapper for the sha3.Sum384 function in the standard library.

func Sum512

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

Sum512 returns the SHA3-512 digest of the data.

It is a wrapper for the sha3.Sum512 function in the standard library.

Types

type ShakeHash

type ShakeHash interface {
	hash.Hash

	// Read reads more output from the hash; reading affects the hash's
	// state. (ShakeHash.Read is thus very different from Hash.Sum.)
	// It never returns an error, but subsequent calls to Write or Sum
	// will panic.
	io.Reader

	// Clone returns a copy of the ShakeHash in its current state.
	Clone() ShakeHash
}

ShakeHash defines the interface to hash functions that support arbitrary-length output. When used as a plain hash.Hash, it produces minimum-length outputs that provide full-strength generic security.

func NewCShake128

func NewCShake128(N, S []byte) ShakeHash

NewCShake128 creates a new instance of cSHAKE128 variable-output-length ShakeHash, a customizable variant of SHAKE128. N is used to define functions based on cSHAKE, it can be empty when plain cSHAKE is desired. S is a customization byte string used for domain separation - two cSHAKE computations on same input with different S yield unrelated outputs. When N and S are both empty, this is equivalent to NewShake128.

func NewCShake256

func NewCShake256(N, S []byte) ShakeHash

NewCShake256 creates a new instance of cSHAKE256 variable-output-length ShakeHash, a customizable variant of SHAKE256. N is used to define functions based on cSHAKE, it can be empty when plain cSHAKE is desired. S is a customization byte string used for domain separation - two cSHAKE computations on same input with different S yield unrelated outputs. When N and S are both empty, this is equivalent to NewShake256.

func NewShake128

func NewShake128() ShakeHash

NewShake128 creates a new SHAKE128 variable-output-length ShakeHash. Its generic security strength is 128 bits against all attacks if at least 32 bytes of its output are used.

func NewShake256

func NewShake256() ShakeHash

NewShake256 creates a new SHAKE256 variable-output-length ShakeHash. Its generic security strength is 256 bits against all attacks if at least 64 bytes of its output are used.

Jump to

Keyboard shortcuts

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