]> Cypherpunks repositories - gostls13.git/commit
runtime: make it harder to find collisions in the 64-bit fallback hash
authorkhr@golang.org <khr@golang.org>
Tue, 16 Apr 2024 00:52:20 +0000 (17:52 -0700)
committerKeith Randall <khr@golang.org>
Fri, 19 Apr 2024 17:38:07 +0000 (17:38 +0000)
commitef2f3391da20e4aca689033045c0d00fddd0b190
tree5bab32ea9a1f7bca26d60c6d987557a1fdfd9df8
parent2b82a4f488179a62a69dd318ea62f0624641ae63
runtime: make it harder to find collisions in the 64-bit fallback hash

Currently the first argument to mix() can be set by an attacker, as it
is just the input bytes xored by some constants. That lets an attacker
set the value being multipled by to 0. That can lead to lots of
collisions. To fix, xor the first argument with the process-wide seed,
so the magic collision-generating value isn't a constant known to the
attacker.  (Maybe there's a timing attack that could figure out the
process-wide seed, but that's a much harder attack.)

Fixes #66841

Change-Id: I33e073c78355d1cee08660de52074e6ccc38b426
Reviewed-on: https://go-review.googlesource.com/c/go/+/579115
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/hash64.go
src/runtime/hash_test.go