From 63eb2e602070feb5536c08009e494cbab20ad921 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 11 May 2016 14:59:29 +0100 Subject: [Feature] Add and use mumhash for non-crypto hashing --- src/libcryptobox/cryptobox.c | 13 +++++++------ src/libcryptobox/cryptobox.h | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/libcryptobox') diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index 8fb0a7d56..0617f8c21 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -32,6 +32,8 @@ #include "ottery.h" #include "printf.h" #include "xxhash.h" +#define MUM_TARGET_INDEPENDENT_HASH 1 /* For 32/64 bit equal hashes */ +#include "../../contrib/mumhash/mum.h" #ifdef HAVE_CPUID_H #include @@ -1457,11 +1459,8 @@ guint64 rspamd_cryptobox_fast_hash (const void *data, gsize len, guint64 seed) { -#if defined(__LP64__) || defined(_LP64) - return XXH64 (data, len, seed); -#else - return XXH32 (data, len, seed); -#endif + return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_MUMHASH, + data, len, seed); } @@ -1475,7 +1474,9 @@ rspamd_cryptobox_fast_hash_specific ( case RSPAMD_CRYPTOBOX_XXHASH32: return XXH32 (data, len, seed); case RSPAMD_CRYPTOBOX_XXHASH64: - default: return XXH64 (data, len, seed); + case RSPAMD_CRYPTOBOX_MUMHASH: + default: + return mum_hash (data, len, seed); } } diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h index 9bab560ee..18e66df60 100644 --- a/src/libcryptobox/cryptobox.h +++ b/src/libcryptobox/cryptobox.h @@ -356,7 +356,8 @@ guint64 rspamd_cryptobox_fast_hash (const void *data, enum rspamd_cryptobox_fast_hash_type { RSPAMD_CRYPTOBOX_XXHASH64 = 0, - RSPAMD_CRYPTOBOX_XXHASH32 + RSPAMD_CRYPTOBOX_XXHASH32, + RSPAMD_CRYPTOBOX_MUMHASH }; /** * Platform independent version -- cgit v1.2.3