diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-23 16:08:07 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-23 16:33:06 +0100 |
commit | 5fd920c6deed2953a49ceca2ba6fe6be1ce50181 (patch) | |
tree | e2d8014f45147871c0629eade30855e8a7fe5725 /src/lua/lua_rsa.c | |
parent | 6f84b92277c754dabd00a14deb785d11cbeb5e1c (diff) | |
download | rspamd-5fd920c6deed2953a49ceca2ba6fe6be1ce50181.tar.gz rspamd-5fd920c6deed2953a49ceca2ba6fe6be1ce50181.zip |
[Minor] Allow to fold base64 encoding of signatures
Diffstat (limited to 'src/lua/lua_rsa.c')
-rw-r--r-- | src/lua/lua_rsa.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c index 17675e548..39433a167 100644 --- a/src/lua/lua_rsa.c +++ b/src/lua/lua_rsa.c @@ -557,10 +557,30 @@ static gint lua_rsa_signature_base64 (lua_State *L) { rspamd_fstring_t *sig = lua_check_rsa_sign (L, 1); + guint boundary = 0; gchar *b64; gsize outlen; + enum rspamd_newlines_type how = RSPAMD_TASK_NEWLINES_CRLF; - b64 = rspamd_encode_base64 (sig->str, sig->len, 0, &outlen); + if (lua_isnumber (L, 2)) { + boundary = lua_tonumber (L, 2); + } + + if (lua_isstring (L, 3)) { + const gchar *how_str = lua_tostring (L, 3); + + if (strcmp (how_str, "cr") == 0) { + how = RSPAMD_TASK_NEWLINES_CR; + } + else if (strcmp (how_str, "lf") == 0) { + how = RSPAMD_TASK_NEWLINES_LF; + } + else { + how = RSPAMD_TASK_NEWLINES_CRLF; + } + } + + b64 = rspamd_encode_base64_fold (sig->str, sig->len, boundary, &outlen, how); if (b64) { lua_pushlstring (L, b64, outlen); |