diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-21 12:10:59 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-21 12:10:59 +0100 |
commit | b212e765ad521f685bb6817e9b65b19a51d9a933 (patch) | |
tree | 9ec1059eadd8e5bf925e32e801ffbddee7f239d0 /src/controller.c | |
parent | b4389fd12e501a30af0f27693a6ab60bb3c8ad3e (diff) | |
download | rspamd-b212e765ad521f685bb6817e9b65b19a51d9a933.tar.gz rspamd-b212e765ad521f685bb6817e9b65b19a51d9a933.zip |
[Feature] Allow catena encrypted passwords in controller
Diffstat (limited to 'src/controller.c')
-rw-r--r-- | src/controller.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/controller.c b/src/controller.c index f3e21730e..542f197c3 100644 --- a/src/controller.c +++ b/src/controller.c @@ -174,8 +174,9 @@ rspamd_is_encrypted_password (const gchar *password, { const gchar *start, *end; gint64 id; - gsize size; + gsize size, i; gboolean ret = FALSE; + const struct rspamd_controller_pbkdf *p; if (password[0] == '$') { /* Parse id */ @@ -192,11 +193,18 @@ rspamd_is_encrypted_password (const gchar *password, gchar *endptr; id = strtoul (start, &endptr, 10); - if ((endptr == NULL || *endptr == *end) && id == RSPAMD_PBKDF_ID_V1) { - ret = TRUE; + if ((endptr == NULL || *endptr == *end)) { + for (i = 0; i < RSPAMD_PBKDF_ID_MAX - 1; i ++) { + p = &pbkdf_list[i]; + + if (p->id == id) { + ret = TRUE; + if (pbkdf != NULL) { + *pbkdf = &pbkdf_list[0]; + } - if (pbkdf != NULL) { - *pbkdf = &pbkdf_list[0]; + break; + } } } } @@ -298,7 +306,8 @@ rspamd_check_encrypted_password (struct rspamd_controller_worker_ctx *ctx, local_key = g_alloca (pbkdf->key_len); rspamd_cryptobox_pbkdf (password->begin, password->len, salt_decoded, salt_len, - local_key, pbkdf->key_len, pbkdf->rounds); + local_key, pbkdf->key_len, pbkdf->complexity, + pbkdf->type); if (!rspamd_constant_memcmp (key_decoded, local_key, pbkdf->key_len)) { msg_info_ctx ("incorrect or absent password has been specified"); |