GMimeStream *part_stream;
GByteArray *part_content;
gchar *hdrs;
+ /* Blake2b applied to string 'rspamd' */
+ static const guchar hash_key[] = {
+ 0x78,0x6a,0x02,0xf7,0x42,0x01,0x59,0x03,
+ 0xc6,0xc6,0xfd,0x85,0x25,0x52,0xd2,0x72,
+ 0x91,0x2f,0x47,0x40,0xe1,0x58,0x47,0x61,
+ 0x8a,0x86,0xe2,0x17,0xf7,0x1f,0x54,0x19,
+ 0xd2,0x5e,0x10,0x31,0xaf,0xee,0x58,0x53,
+ 0x13,0x89,0x64,0x44,0x93,0x4e,0xb0,0x4b,
+ 0x90,0x3a,0x68,0x5b,0x14,0x48,0xb7,0x55,
+ 0xd5,0x6f,0x70,0x1a,0xfe,0x9b,0xe2,0xce
+ };
task = md->task;
/* 'part' points to the current part node that g_mime_message_foreach_part() is iterating over */
mime_part->mime = part;
mime_part->boundary = g_mime_multipart_get_boundary (GMIME_MULTIPART (part));
+ if (mime_part->boundary) {
+ rspamd_cryptobox_hash (mime_part->digest, mime_part->boundary,
+ strlen (mime_part->boundary), hash_key, sizeof (hash_key));
+ }
+
debug_task ("found part with content-type: %s/%s",
type->type,
type->subtype);
part));
mime_part->mime = part;
+ if (mime_part->content->len > 0) {
+ rspamd_cryptobox_hash (mime_part->digest,
+ mime_part->content->data, mime_part->content->len,
+ hash_key, sizeof (hash_key));
+ }
+
debug_task ("found part with content-type: %s/%s",
type->type,
type->subtype);
gint flag,
guint32 weight,
rspamd_mempool_t *pool,
- const guchar *data,
- gsize datalen)
+ guchar digest[rspamd_cryptobox_HASHBYTES])
{
struct rspamd_fuzzy_cmd *cmd;
struct rspamd_fuzzy_encrypted_cmd *enccmd = NULL;
struct fuzzy_cmd_io *io;
- rspamd_cryptobox_hash_state_t st;
if (rule->peer_key) {
enccmd = rspamd_mempool_alloc0 (pool, sizeof (*enccmd));
}
cmd->shingles_count = 0;
cmd->tag = ottery_rand_uint32 ();
- /* Use blake2b for digest */
- rspamd_cryptobox_hash_init (&st, rule->hash_key->str, rule->hash_key->len);
- rspamd_cryptobox_hash_update (&st, data, datalen);
- rspamd_cryptobox_hash_final (&st, cmd->digest);
+ memcpy (cmd->digest, digest, sizeof (cmd->digest));
io = rspamd_mempool_alloc (pool, sizeof (*io));
io->flags = 0;
fuzzy_module_ctx->min_width) {
io = fuzzy_cmd_from_data_part (rule, c, flag, value,
task->task_pool,
- image->data->data, image->data->len);
+ image->parent->digest);
if (io) {
g_ptr_array_add (res, io);
}
fuzzy_module_ctx->min_bytes) {
io = fuzzy_cmd_from_data_part (rule, c, flag, value,
task->task_pool,
- mime_part->content->data, mime_part->content->len);
+ mime_part->digest);
if (io) {
g_ptr_array_add (res, io);
}