1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // This file defines the ShakeHash interface, and provides
8 // functions for creating SHAKE instances, as well as utility
9 // functions for hashing bytes to arbitrary-length output.
15 // ShakeHash defines the interface to hash functions that
16 // support arbitrary-length output.
17 type ShakeHash interface {
18 // Write absorbs more data into the hash's state. It panics if input is
19 // written to it after output has been read from it.
22 // Read reads more output from the hash; reading affects the hash's
23 // state. (ShakeHash.Read is thus very different from Hash.Sum)
24 // It never returns an error.
27 // Clone returns a copy of the ShakeHash in its current state.
30 // Reset resets the ShakeHash to its initial state.
34 func (d *state) Clone() ShakeHash {
38 // NewShake128 creates a new SHAKE128 variable-output-length ShakeHash.
39 // Its generic security strength is 128 bits against all attacks if at
40 // least 32 bytes of its output are used.
41 func NewShake128() ShakeHash { return &state{rate: 168, dsbyte: 0x1f} }
43 // NewShake256 creates a new SHAKE128 variable-output-length ShakeHash.
44 // Its generic security strength is 256 bits against all attacks if
45 // at least 64 bytes of its output are used.
46 func NewShake256() ShakeHash { return &state{rate: 136, dsbyte: 0x1f} }
48 // ShakeSum128 writes an arbitrary-length digest of data into hash.
49 func ShakeSum128(hash, data []byte) {
55 // ShakeSum256 writes an arbitrary-length digest of data into hash.
56 func ShakeSum256(hash, data []byte) {