aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/siphash.h6
-rw-r--r--lib/siphash.c8
2 files changed, 11 insertions, 3 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..5290649c71d3 100644
--- a/lib/siphash.c
+++ b/lib/siphash.c
@@ -403,8 +403,8 @@ EXPORT_SYMBOL(hsiphash_4u32);
u32 v2 = 0x6c796765U; \
u32 v3 = 0x74656462U; \
u32 b = ((u32)(len)) << 24; \
- v3 ^= key->key[1]; \
- v2 ^= key->key[0]; \
+ v3 ^= key->key[3]; \
+ v2 ^= key->key[2]; \
v1 ^= key->key[1]; \
v0 ^= key->key[0];
@@ -413,6 +413,10 @@ EXPORT_SYMBOL(hsiphash_4u32);
HSIPROUND; \
v0 ^= b; \
v2 ^= 0xff; \
+ v3 ^= key->key[3]; \
+ v2 ^= key->key[2]; \
+ v1 ^= key->key[1]; \
+ v0 ^= key->key[0]; \
HSIPROUND; \
HSIPROUND; \
HSIPROUND; \