summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-12-16 19:59:05 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-12-16 19:59:05 +0100
commit1fb7b43eed281a14752c1a225c930cfe2b68dd0c (patch)
tree34d09e4b704f3c45165addde525682baf68ba429 /src
parenta74be0f2e8e92703a927c4c99a697e46049eb739 (diff)
siphash: preserve endian-ness for quick helper
This fixes errors on big endian machines. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/crypto/siphash.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/crypto/siphash.h b/src/crypto/siphash.h
index 90777b8..102bc1d 100644
--- a/src/crypto/siphash.h
+++ b/src/crypto/siphash.h
@@ -27,16 +27,20 @@ u64 siphash_3u64(const u64 a, const u64 b, const u64 c,
u64 siphash_4u64(const u64 a, const u64 b, const u64 c, const u64 d,
const siphash_key_t key);
-static inline u64 ___siphash_aligned(const u64 *data, size_t len, const siphash_key_t key)
+static inline u64 ___siphash_aligned(const __le64 *data, size_t len, const siphash_key_t key)
{
if (__builtin_constant_p(len) && len == 8)
- return siphash_1u64(data[0], key);
+ return siphash_1u64(le64_to_cpu(data[0]), key);
if (__builtin_constant_p(len) && len == 16)
- return siphash_2u64(data[0], data[1], key);
+ return siphash_2u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]),
+ key);
if (__builtin_constant_p(len) && len == 24)
- return siphash_3u64(data[0], data[1], data[2], key);
+ return siphash_3u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]),
+ le64_to_cpu(data[2]), key);
if (__builtin_constant_p(len) && len == 32)
- return siphash_4u64(data[0], data[1], data[2], data[3], key);
+ return siphash_4u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]),
+ le64_to_cpu(data[2]), le64_to_cpu(data[3]),
+ key);
return __siphash_aligned(data, len, key);
}