summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto/blake2b/blake2b.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-07-20 15:22:49 -0700
committerGitHub <noreply@github.com>2017-07-20 15:22:49 -0700
commit58839cefb50e56ae5b157b37e9814ae83ceee70b (patch)
tree5de966481678096fc9567f74f96673b34a65127c /vendor/golang.org/x/crypto/blake2b/blake2b.go
parente2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff)
downloadchat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/golang.org/x/crypto/blake2b/blake2b.go')
-rw-r--r--vendor/golang.org/x/crypto/blake2b/blake2b.go31
1 files changed, 22 insertions, 9 deletions
diff --git a/vendor/golang.org/x/crypto/blake2b/blake2b.go b/vendor/golang.org/x/crypto/blake2b/blake2b.go
index ce6224101..7f0a86e44 100644
--- a/vendor/golang.org/x/crypto/blake2b/blake2b.go
+++ b/vendor/golang.org/x/crypto/blake2b/blake2b.go
@@ -2,9 +2,19 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package blake2b implements the BLAKE2b hash algorithm as
-// defined in RFC 7693.
-package blake2b // import "golang.org/x/crypto/blake2b"
+// Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693
+// and the extendable output function (XOF) BLAKE2Xb.
+//
+// For a detailed specification of BLAKE2b see https://blake2.net/blake2.pdf
+// and for BLAKE2Xb see https://blake2.net/blake2x.pdf
+//
+// If you aren't sure which function you need, use BLAKE2b (Sum512 or New512).
+// If you need a secret-key MAC (message authentication code), use the New512
+// function with a non-nil key.
+//
+// BLAKE2X is a construction to compute hash values larger than 64 bytes. It
+// can produce hash values between 0 and 4 GiB.
+package blake2b
import (
"encoding/binary"
@@ -171,7 +181,13 @@ func (d *digest) Write(p []byte) (n int, err error) {
return
}
-func (d *digest) Sum(b []byte) []byte {
+func (d *digest) Sum(sum []byte) []byte {
+ var hash [Size]byte
+ d.finalize(&hash)
+ return append(sum, hash[:d.size]...)
+}
+
+func (d *digest) finalize(hash *[Size]byte) {
var block [BlockSize]byte
copy(block[:], d.block[:d.offset])
remaining := uint64(BlockSize - d.offset)
@@ -185,10 +201,7 @@ func (d *digest) Sum(b []byte) []byte {
h := d.h
hashBlocks(&h, &c, 0xFFFFFFFFFFFFFFFF, block[:])
- var sum [Size]byte
- for i, v := range h[:(d.size+7)/8] {
- binary.LittleEndian.PutUint64(sum[8*i:], v)
+ for i, v := range h {
+ binary.LittleEndian.PutUint64(hash[8*i:], v)
}
-
- return append(b, sum[:d.size]...)
}