// vim:fileencoding=utf-8:foldmethod=marker /** * Implementations of the SipHash-2-4-128, SipHash4-8-128, SipHash-2-4-64 and SipHash4-8-64 * algorithms based on https://github.com/veorq/SipHash/blob/master/siphash.c */ #ifndef SIPHASH_H #define SIPHASH_H #include "hasher.h" #include "../../stream/stream.h" #include "../../../common/aliases/aliases.h" #include "../../../common/platform/platform.h" #ifdef WP_PLATFORM_CPP BEGIN_C_LINKAGE #endif // !WP_PLATFORM_CPP #define WP_SIP_HASHER_MAGIC wpU64Const(0x5750534950485348) typedef struct WpSipHasherKey { u64 lo; u64 hi; } WpSipHasherKey; typedef struct WpSipHasherData { WpSipHasherKey key; u64 magic; u64 compression; u64 finalisation; } WpSipHasherData; #ifdef WP_PLATFORM_CPP #define wpSip24HasherData(KEY) (WpSipHasherData{(KEY), WP_SIP_HASHER_MAGIC, 2, 4}) #define wpSip48HasherData(KEY) (WpSipHasherData{(KEY), WP_SIP_HASHER_MAGIC, 4, 8}) #else #define wpSip24HasherData(KEY) ((WpSipHasherData){ \ .key = (KEY), \ .magic = WP_SIP_HASHER_MAGIC, \ .compression = 2, \ .finalisation = 4, \ }) #define wpSip48HasherData(KEY) ((WpSipHasherData){ \ .key = (KEY), \ .magic = WP_SIP_HASHER_MAGIC, \ .compression = 4, \ .finalisation = 8, \ }) #endif WpHasher wpSipHasher(WpSipHasherData *data); WpU128Hash wpSipHasher128(WpU8Stream *bytes, void *hasher_io); #ifdef WP_PLATFORM_CPP END_C_LINKAGE #endif // !WP_PLATFORM_CPP #endif // !SIPHASH_H