Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(46)

Side by Side Diff: sha3/shake.go

Issue 130950043: code review 130950043: go.crypto/sha3: update to sync with draft FIPS-202
Patch Set: diff -r f3cebac2bd11c2bf03c15bfa4c66688ad02a0a40 https://code.google.com/p/go.crypto Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sha3/sha3f202.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 package sha3
6
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.
10
11 import (
12 "io"
13 )
14
15 // Shake 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.
19 // It never returns an error.
20 io.Writer
21 // Read reads more output from the hash; reading affects the hash's
22 // state. (Shake.Read is thus very different from Hash.Sum)
23 // It never returns an error.
24 io.Reader
25
26 // Barrier overwrites (200 - rate) bytes of the hash's state
27 // with zeros, making it computationally infeasible to recover
28 // previous inputs.
29 Barrier()
30
31 // Reset resets the Hash to its initial state.
32 Reset()
33 }
34
35 // NewShake128 creates a new SHAKE128 variable-output-length Sponge.
36 // Its generic security strength is 128 bits against all attacks if at
37 // least 32 bytes of its output are used.
38 func NewShake128() ShakeHash { return &state{rate: 168, dsbyte: 0x1f} }
39
40 // NewShake256 creates a new SHAKE128 variable-output-length Sponge.
41 // Its generic security strength is 256 bits against all attacks if
42 // at least 64 bytes of its output are used.
43 func NewShake256() ShakeHash { return &state{rate: 136, dsbyte: 0x1f} }
44
45 // ShakeSum128 writes an arbitrary-length digest of data into hash.
46 func ShakeSum128(hash, data []byte) {
47 h := NewShake128()
48 h.Write(data)
49 h.Read(hash)
50 }
51
52 // ShakeSum256 writes an arbitrary-length digest of data into hash.
53 func ShakeSum256(hash, data []byte) {
54 h := NewShake256()
55 h.Write(data)
56 h.Read(hash)
57 }
OLDNEW
« no previous file with comments | « sha3/sha3f202.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b