#define DKIM_CANON_DEFAULT DKIM_CANON_SIMPLE
+#define RSPAMD_SHORT_BH_LEN 8
+
/* Params */
enum rspamd_dkim_param_type {
DKIM_PARAM_UNKNOWN = -1,
RSPAMD_ARC_PASS
};
+
struct rspamd_dkim_context_s {
struct rspamd_dkim_common_ctx common;
rspamd_mempool_t *pool;
gchar *domain;
gchar *selector;
gint8 *b;
+ gchar *short_b;
gint8 *bh;
gchar *dns_key;
enum rspamd_arc_seal_cv cv;
GError **err)
{
ctx->b = rspamd_mempool_alloc0 (ctx->pool, len);
+ ctx->short_b = rspamd_mempool_alloc0 (ctx->pool, RSPAMD_SHORT_BH_LEN + 1);
+ rspamd_strlcpy (ctx->short_b, param, MIN (len, RSPAMD_SHORT_BH_LEN + 1));
(void)rspamd_cryptobox_base64_decode (param, len, ctx->b, &ctx->blen);
return TRUE;
res->selector = ctx->selector;
res->domain = ctx->domain;
res->fail_reason = NULL;
- res->short_b = rspamd_encode_base64 (ctx->b, 4, 0, NULL);
+ res->short_b = ctx->short_b;
res->rcode = DKIM_CONTINUE;
- rspamd_mempool_add_destructor (task->task_pool, g_free, (gpointer)res->short_b);
if (!body_start) {
res->rcode = DKIM_ERROR;
res->selector = ctx->selector;
res->domain = ctx->domain;
res->fail_reason = NULL;
- res->short_b = rspamd_encode_base64 (ctx->b, 4, 0, NULL);
- rspamd_mempool_add_destructor (task->task_pool, g_free, (gpointer)res->short_b);
+ res->short_b = ctx->short_b;
return res;
}
* * `domain` - dkim domain
* * `selector` - dkim selector
* * `bhash` - short version of b tag (8 base64 symbols)
+ * * `fail_reason` - reason of failure (if applicable)
* @return {list of maps} dkim check results
*/
LUA_FUNCTION_DEF (task, get_dkim_results);
}
if (res->fail_reason) {
- rspamd_lua_table_set (L, "fail", res->fail_reason);
+ rspamd_lua_table_set (L, "fail_reason", res->fail_reason);
}
lua_rawseti (L, -2, i + 1);