siphash: use one source of truth for siphash permutations
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 7 May 2022 12:03:46 +0000 (14:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 May 2022 07:29:15 +0000 (09:29 +0200)
commitf4cb809a90df1daeaab4e65ae2064918575b4e6d
tree8132bf989fbc324d0cb7ad63c675e404312f4049
parent82caef84092e5d065932be53d6b341f22f68c649
siphash: use one source of truth for siphash permutations

commit e73aaae2fa9024832e1f42e30c787c7baf61d014 upstream.

The SipHash family of permutations is currently used in three places:

- siphash.c itself, used in the ordinary way it was intended.
- random32.c, in a construction from an anonymous contributor.
- random.c, as part of its fast_mix function.

Each one of these places reinvents the wheel with the same C code, same
rotation constants, and same symmetry-breaking constants.

This commit tidies things up a bit by placing macros for the
permutations and constants into siphash.h, where each of the three .c
users can access them. It also leaves a note dissuading more users of
them from emerging.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c
include/linux/prandom.h
include/linux/siphash.h
lib/siphash.c