From 4e3670842d3655b94c44642b95796faf016c9dfe Mon Sep 17 00:00:00 2001 From: Niels Werensteijn Date: Tue, 11 Oct 2016 11:15:41 +0200 Subject: [PATCH] fixed bug in shiphash23 --- src/siphash24.c | 13 +++++++------ src/siphash24.h | 14 ++++++++++++-- src/ts3init_cookie.c | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/siphash24.c b/src/siphash24.c index 1a209d9..a299c18 100644 --- a/src/siphash24.c +++ b/src/siphash24.c @@ -101,24 +101,25 @@ void ts3init_siphash_update(struct ts3init_siphash_state* state, const u8 *in, s switch (next_byte) { case 1: - m |= ((u64)(*in++)) << 8; if (in==end) goto __exit_update; + m |= ((u64)(*in++)) << 8; case 2: - m |= ((u64)(*in++)) << 16; if (in==end) goto __exit_update; + m |= ((u64)(*in++)) << 16; case 3: - m |= ((u64)(*in++)) << 24; if (in==end) goto __exit_update; + m |= ((u64)(*in++)) << 24; case 4: - m |= ((u64)(*in++)) << 32; if (in==end) goto __exit_update; + m |= ((u64)(*in++)) << 32; case 5: - m |= ((u64)(*in++)) << 40; if (in==end) goto __exit_update; + m |= ((u64)(*in++)) << 40; case 6: - m |= ((u64)(*in++)) << 48; if (in==end) goto __exit_update; + m |= ((u64)(*in++)) << 48; case 7: + if (in==end) goto __exit_update; m |= ((u64)(*in++)) << 56; v3 ^= m; diff --git a/src/siphash24.h b/src/siphash24.h index 7c424a7..00540e2 100644 --- a/src/siphash24.h +++ b/src/siphash24.h @@ -17,9 +17,19 @@ this software. If not, see . */ - +#ifndef __KERNEL__ +#include +#include +#define u8 uint8_t +#define u32 uint32_t +#define u64 uint64_t +#define printk printf +#define le64_to_cpu(x) x +#define cpu_to_le64(x) x +#define inline static inline +#else #include -#include +#endif struct ts3init_siphash_state { diff --git a/src/ts3init_cookie.c b/src/ts3init_cookie.c index aaeb1c9..81a3589 100644 --- a/src/ts3init_cookie.c +++ b/src/ts3init_cookie.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "siphash24.h" #include "ts3init_cookie.h"