aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-03-06 14:39:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-03-06 14:39:34 +0000
commit19442df4068b480b5d0bcc9c18b042658bb47fac (patch)
tree6e4e92e36ea6e32901ff57bbf84debe58321ba31 /contrib
parent7f19585b8e73e31d808ce719b904392a93f63621 (diff)
downloadrspamd-19442df4068b480b5d0bcc9c18b042658bb47fac.tar.gz
rspamd-19442df4068b480b5d0bcc9c18b042658bb47fac.zip
[Minor] Use IUF interface for hashing
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libucl/ucl_hash.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/contrib/libucl/ucl_hash.c b/contrib/libucl/ucl_hash.c
index 9019cbeee..628980d28 100644
--- a/contrib/libucl/ucl_hash.c
+++ b/contrib/libucl/ucl_hash.c
@@ -65,7 +65,7 @@ extern const guchar lc_map[256];
static inline uint32_t
ucl_hash_func (const ucl_object_t *o)
{
- return rspamd_cryptobox_fast_hash (o->key, o->keylen, 0xdeadbabe);
+ return rspamd_cryptobox_fast_hash (o->key, o->keylen, 0xb9a1ef83c4561c95ULL);
}
static inline int
@@ -94,9 +94,11 @@ ucl_hash_caseless_func (const ucl_object_t *o)
} c;
uint32_t pp;
} u;
- uint64_t h = 0xdeadbabe;
+ uint64_t h = 0xe5ae6ab1ef9f3b54ULL;
+ rspamd_cryptobox_fast_hash_state_t hst;
fp = len - leftover;
+ rspamd_cryptobox_fast_hash_init (&hst, h);
for (i = 0; i != fp; i += 4) {
u.c.c1 = s[i], u.c.c2 = s[i + 1], u.c.c3 = s[i + 2], u.c.c4 = s[i + 3];
@@ -104,7 +106,7 @@ ucl_hash_caseless_func (const ucl_object_t *o)
u.c.c2 = lc_map[u.c.c2];
u.c.c3 = lc_map[u.c.c3];
u.c.c4 = lc_map[u.c.c4];
- h = rspamd_cryptobox_fast_hash (&u.pp, sizeof (u), h);
+ rspamd_cryptobox_fast_hash_update (&hst, &u, sizeof (u));
}
u.pp = 0;
@@ -112,25 +114,27 @@ ucl_hash_caseless_func (const ucl_object_t *o)
case 3:
u.c.c3 = lc_map[(unsigned char)s[i++]];
case 2:
+ /* fallthrough */
u.c.c2 = lc_map[(unsigned char)s[i++]];
case 1:
+ /* fallthrough */
u.c.c1 = lc_map[(unsigned char)s[i]];
- rspamd_cryptobox_fast_hash (&u.pp, leftover, h);
+ rspamd_cryptobox_fast_hash_update (&hst, &u, sizeof (u));
break;
}
- return h;
+ return rspamd_cryptobox_fast_hash_final (&hst);
}
-static inline int
+static inline bool
ucl_hash_caseless_equal (const ucl_object_t *k1, const ucl_object_t *k2)
{
if (k1->keylen == k2->keylen) {
return rspamd_lc_cmp (k1->key, k2->key, k1->keylen) == 0;
}
- return 0;
+ return false;
}
KHASH_INIT (ucl_hash_caseless_node, const ucl_object_t *, struct ucl_hash_elt, 1,