summaryrefslogtreecommitdiffstats
path: root/src/libcryptobox
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-11 16:28:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-11 16:28:07 +0100
commit8105992157606e77f0e88968a40aaf8e528c70d8 (patch)
tree518cf0c901820e4349c2a4cf6b3c968a241a71c2 /src/libcryptobox
parent8cc53b5035580ec35a627aff762200f0f3788ba2 (diff)
downloadrspamd-8105992157606e77f0e88968a40aaf8e528c70d8.tar.gz
rspamd-8105992157606e77f0e88968a40aaf8e528c70d8.zip
[Feature] Try to select the optimal possible function for input
Diffstat (limited to 'src/libcryptobox')
-rw-r--r--src/libcryptobox/cryptobox.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c
index 0617f8c21..d8fc737d7 100644
--- a/src/libcryptobox/cryptobox.c
+++ b/src/libcryptobox/cryptobox.c
@@ -1459,7 +1459,21 @@ guint64
rspamd_cryptobox_fast_hash (const void *data,
gsize len, guint64 seed)
{
- return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_MUMHASH,
+ if (len % 2 == 0) {
+ return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_MUMHASH,
+ data, len, seed);
+ }
+ else {
+#if defined(__LP64__) || defined(_LP64)
+ if (len > 8) {
+ return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64,
+ data, len, seed);
+ }
+#endif
+ }
+
+
+ return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH32,
data, len, seed);
}