aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-12 01:51:43 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-12 16:06:55 +0200
commit96b86d9dd9b62814e7e6d6444092eefc0a40f26b (patch)
tree2c649b7423aa779e6f5c1ede2946cdb129267a9d
parentMerge tag 'f2fs-for-4.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs (diff)
downloadlinux-dev-jd/hsiphash128-2.tar.xz
linux-dev-jd/hsiphash128-2.zip
hsiphash: always use 128-bit keysjd/hsiphash128-2
This gives us a larger security margin. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--include/linux/siphash.h6
-rw-r--r--lib/siphash.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/siphash.h b/include/linux/siphash.h
index fa7a6b9cedbf..c5abb71ad844 100644
--- a/include/linux/siphash.h
+++ b/include/linux/siphash.h
@@ -86,7 +86,11 @@ static inline u64 siphash(const void *data, size_t len,
#define HSIPHASH_ALIGNMENT __alignof__(unsigned long)
typedef struct {
- unsigned long key[2];
+#if BITS_PER_LONG == 64
+ u64 key[2];
+#else
+ u32 key[4];
+#endif
} hsiphash_key_t;
u32 __hsiphash_aligned(const void *data, size_t len,
diff --git a/lib/siphash.c b/lib/siphash.c
index 3ae58b4edad6..cca5b9fc2207 100644
--- a/lib/siphash.c
+++ b/lib/siphash.c
@@ -413,9 +413,13 @@ EXPORT_SYMBOL(hsiphash_4u32);
HSIPROUND; \
v0 ^= b; \
v2 ^= 0xff; \
+ v1 ^= key->key[2]; \
+ v3 ^= key->key[3]; \
HSIPROUND; \
HSIPROUND; \
HSIPROUND; \
+ v1 ^= key->key[2]; \
+ v3 ^= key->key[3]; \
return v1 ^ v3;
u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)