diff options
| author | 2016-12-16 19:59:05 +0100 | |
|---|---|---|
| committer | 2016-12-16 19:59:05 +0100 | |
| commit | 094e95e736723075d586d7a006c5525f2e3a74d4 (patch) | |
| tree | 17fa1c58ed8bbbbf578af112eb548405481cdaca | |
| parent | ratelimiter: remember newline in error (diff) | |
| download | WireGuard-094e95e736723075d586d7a006c5525f2e3a74d4.tar.xz WireGuard-094e95e736723075d586d7a006c5525f2e3a74d4.zip | |
siphash: preserve endian-ness for quick helper
This fixes errors on big endian machines.
| -rw-r--r-- | src/crypto/siphash.h | 14 |
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); } |
