aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-03 14:21:44 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-03 14:21:44 +0100
commit5852f300295f0637cda9a53c4271f0b65cafe4c3 (patch)
tree85b434971b59555d7bbeb7e181a52b3a64d841db /src/libutil
parentde922dd854760bcd362adbc3a2dd5a7d203ad10f (diff)
downloadrspamd-5852f300295f0637cda9a53c4271f0b65cafe4c3.tar.gz
rspamd-5852f300295f0637cda9a53c4271f0b65cafe4c3.zip
[Minor] Add images shingles keys caching
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/shingles.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c
index ddac12ac4..73fa04ea1 100644
--- a/src/libutil/shingles.c
+++ b/src/libutil/shingles.c
@@ -243,11 +243,8 @@ rspamd_shingles_from_image (guchar *dct,
{
struct rspamd_shingle *shingle;
guint64 **hashes;
- rspamd_sipkey_t keys[RSPAMD_SHINGLE_SIZE];
- guchar shabuf[rspamd_cryptobox_HASHBYTES], *out_key;
- const guchar *cur_key;
+ guchar **keys;
guint64 d;
- rspamd_cryptobox_hash_state_t bs;
guint64 val;
gint i, j;
gsize hlen, beg = 0;
@@ -261,31 +258,13 @@ rspamd_shingles_from_image (guchar *dct,
shingle = g_malloc (sizeof (*shingle));
}
- rspamd_cryptobox_hash_init (&bs, NULL, 0);
- cur_key = key;
- out_key = (guchar *)&keys[0];
-
/* Init hashes pipes and keys */
hashes = g_slice_alloc (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE);
hlen = RSPAMD_DCT_LEN / NBBY + 1;
+ keys = rspamd_shingles_get_keys_cached (key);
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
hashes[i] = g_slice_alloc (hlen * sizeof (guint64));
- /*
- * To generate a set of hashes we just apply sha256 to the
- * initial key as many times as many hashes are required and
- * xor left and right parts of sha256 to get a single 16 bytes SIP key.
- */
- rspamd_cryptobox_hash_update (&bs, cur_key, 16);
- rspamd_cryptobox_hash_final (&bs, shabuf);
-
- for (j = 0; j < 16; j ++) {
- out_key[j] = shabuf[j];
- }
-
- rspamd_cryptobox_hash_init (&bs, NULL, 0);
- cur_key = out_key;
- out_key += 16;
}
switch (alg) {