summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/crypto/sha3/sha3.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-10-09 10:13:09 +0200
committerLibravatar GitHub <noreply@github.com>2023-10-09 10:13:09 +0200
commit5aeceb5ff7a0a42ff7154c05e3b3d249c5039aad (patch)
tree4b13559ead2b7bcb54b6c0829eebe7d9645bd40b /vendor/golang.org/x/crypto/sha3/sha3.go
parent[chore] Convert some settings / admin panel JS to TypeScript (#2247) (diff)
downloadgotosocial-5aeceb5ff7a0a42ff7154c05e3b3d249c5039aad.tar.xz
[chore]: Bump golang.org/x/net from 0.15.0 to 0.16.0 (#2260)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.16.0. - [Commits](https://github.com/golang/net/compare/v0.15.0...v0.16.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/golang.org/x/crypto/sha3/sha3.go')
-rw-r--r--vendor/golang.org/x/crypto/sha3/sha3.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/vendor/golang.org/x/crypto/sha3/sha3.go b/vendor/golang.org/x/crypto/sha3/sha3.go
index fa182beb4..4884d172a 100644
--- a/vendor/golang.org/x/crypto/sha3/sha3.go
+++ b/vendor/golang.org/x/crypto/sha3/sha3.go
@@ -121,11 +121,11 @@ func (d *state) padAndPermute(dsbyte byte) {
copyOut(d, d.buf)
}
-// Write absorbs more data into the hash's state. It produces an error
-// if more data is written to the ShakeHash after writing
+// Write absorbs more data into the hash's state. It panics if any
+// output has already been read.
func (d *state) Write(p []byte) (written int, err error) {
if d.state != spongeAbsorbing {
- panic("sha3: write to sponge after read")
+ panic("sha3: Write after Read")
}
if d.buf == nil {
d.buf = d.storage.asBytes()[:0]
@@ -182,12 +182,16 @@ func (d *state) Read(out []byte) (n int, err error) {
}
// Sum applies padding to the hash state and then squeezes out the desired
-// number of output bytes.
+// number of output bytes. It panics if any output has already been read.
func (d *state) Sum(in []byte) []byte {
+ if d.state != spongeAbsorbing {
+ panic("sha3: Sum after Read")
+ }
+
// Make a copy of the original hash so that caller can keep writing
// and summing.
dup := d.clone()
- hash := make([]byte, dup.outputLen)
+ hash := make([]byte, dup.outputLen, 64) // explicit cap to allow stack allocation
dup.Read(hash)
return append(in, hash...)
}