Skip to content

Commit a0819fb

Browse files
Yawninggopherbot
authored andcommitted
sha3: fix cSHAKE initialization for extremely large N and or S
While both impractical and unlikely, the multiplication could overflow on 32-bit architectures. The 64-bit architecture case is unaffected by both the maximum length of Go slices being too small to trigger the overflow (everything except s390), and it being safe to assume no machine has more than 2 EiB of memory. Fixes golang/go#66232 Change-Id: I19c15d42d2d6af35e296697159d43d02f513e614 GitHub-Last-Rev: 503e180 GitHub-Pull-Request: #286 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/570876 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Filippo Valsorda <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 42ee18b commit a0819fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sha3/shake.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ func newCShake(N, S []byte, rate, outputLen int, dsbyte byte) ShakeHash {
8585

8686
// leftEncode returns max 9 bytes
8787
c.initBlock = make([]byte, 0, 9*2+len(N)+len(S))
88-
c.initBlock = append(c.initBlock, leftEncode(uint64(len(N)*8))...)
88+
c.initBlock = append(c.initBlock, leftEncode(uint64(len(N))*8)...)
8989
c.initBlock = append(c.initBlock, N...)
90-
c.initBlock = append(c.initBlock, leftEncode(uint64(len(S)*8))...)
90+
c.initBlock = append(c.initBlock, leftEncode(uint64(len(S))*8)...)
9191
c.initBlock = append(c.initBlock, S...)
9292
c.Write(bytepad(c.initBlock, c.rate))
9393
return &c

0 commit comments

Comments
 (0)