diff options
author | Russ Cox <rsc@golang.org> | 2022-04-27 09:02:53 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2022-04-29 14:23:27 +0000 |
commit | 0ec08283c8e3a673d9916c186f8d2f5428846862 (patch) | |
tree | 8763286823f38bed61ef2f1346d64482652b6d84 /src/crypto/sha512/sha512.go | |
parent | 3cb10d14b7671ceee374d90ae0d4c3d024838f8a (diff) | |
download | go-0ec08283c8e3a673d9916c186f8d2f5428846862.tar.gz go-0ec08283c8e3a673d9916c186f8d2f5428846862.zip |
[dev.boringcrypto] crypto/internal/boring: make SHA calls allocation-free
The standard Go implementations are allocation-free.
Making the BoringCrypto ones the same helps avoid
surprises, including in some of our own tests.
For #51940.
Change-Id: Ic9c5dc46f5e29ca85f571244be2b380ec2cf89c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/395876
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/crypto/sha512/sha512.go')
-rw-r--r-- | src/crypto/sha512/sha512.go | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/crypto/sha512/sha512.go b/src/crypto/sha512/sha512.go index 1285cca7ee6..c800a294a27 100644 --- a/src/crypto/sha512/sha512.go +++ b/src/crypto/sha512/sha512.go @@ -12,13 +12,12 @@ package sha512 import ( "crypto" + "crypto/internal/boring" "encoding/binary" "errors" "hash" ) -import "crypto/internal/boring" - func init() { crypto.RegisterHash(crypto.SHA384, New384) crypto.RegisterHash(crypto.SHA512, New) @@ -345,11 +344,7 @@ func (d *digest) checkSum() [Size]byte { // Sum512 returns the SHA512 checksum of the data. func Sum512(data []byte) [Size]byte { if boring.Enabled { - h := New() - h.Write(data) - var ret [Size]byte - h.Sum(ret[:0]) - return ret + return boring.SHA512(data) } d := digest{function: crypto.SHA512} d.Reset() @@ -360,11 +355,7 @@ func Sum512(data []byte) [Size]byte { // Sum384 returns the SHA384 checksum of the data. func Sum384(data []byte) [Size384]byte { if boring.Enabled { - h := New384() - h.Write(data) - var ret [Size384]byte - h.Sum(ret[:0]) - return ret + return boring.SHA384(data) } d := digest{function: crypto.SHA384} d.Reset() |