diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-25 23:15:16 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-25 23:15:16 +0000 |
commit | 6ca35268fea102054277895f45425bc8a64992b8 (patch) | |
tree | f3332224e21f7c039053ac7ad96a391672779f99 /src/libutil/shingles.c | |
parent | 13d1587064ee25b8dab3e5d37db383a1d48bcc8d (diff) | |
download | rspamd-6ca35268fea102054277895f45425bc8a64992b8.tar.gz rspamd-6ca35268fea102054277895f45425bc8a64992b8.zip |
Start migrating to the new hash API.
Diffstat (limited to 'src/libutil/shingles.c')
-rw-r--r-- | src/libutil/shingles.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c index e3bcc0f10..bc255ec65 100644 --- a/src/libutil/shingles.c +++ b/src/libutil/shingles.c @@ -24,7 +24,6 @@ #include "shingles.h" #include "fstring.h" #include "cryptobox.h" -#include "blake2.h" #define SHINGLES_WINDOW 3 @@ -38,14 +37,13 @@ rspamd_shingles_generate (GArray *input, struct rspamd_shingle *res; GArray *hashes[RSPAMD_SHINGLE_SIZE]; rspamd_sipkey_t keys[RSPAMD_SHINGLE_SIZE]; - guchar shabuf[BLAKE2B_OUTBYTES], *out_key; + guchar shabuf[rspamd_cryptobox_HASHBYTES], *out_key; const guchar *cur_key; GString *row; rspamd_ftok_t *word; - blake2b_state bs; + rspamd_cryptobox_hash_state_t bs; guint64 val; gint i, j, beg = 0; - guint8 shalen; if (pool != NULL) { res = rspamd_mempool_alloc (pool, sizeof (*res)); @@ -54,7 +52,7 @@ rspamd_shingles_generate (GArray *input, res = g_malloc (sizeof (*res)); } - blake2b_init (&bs, BLAKE2B_OUTBYTES); + rspamd_cryptobox_hash_init (&bs, NULL, 0); row = g_string_sized_new (256); cur_key = key; out_key = (guchar *)&keys[0]; @@ -68,14 +66,14 @@ rspamd_shingles_generate (GArray *input, * 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. */ - shalen = sizeof (shabuf); - blake2b_update (&bs, cur_key, 16); - blake2b_final (&bs, shabuf, shalen); + 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]; } - blake2b_init (&bs, BLAKE2B_OUTBYTES); + + rspamd_cryptobox_hash_init (&bs, NULL, 0); cur_key = out_key; out_key += 16; } |