diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-24 17:59:40 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-24 17:59:40 +0100 |
commit | f1f8be8205f221ea213d4c304ffc7e6bd2c47aa2 (patch) | |
tree | 8d9cf7fad808f0232660eaa8f1a797aaa1937771 /src/libutil/util.c | |
parent | 2845e192b02897996de2c1a0e65e11f7f268072a (diff) | |
download | rspamd-f1f8be8205f221ea213d4c304ffc7e6bd2c47aa2.tar.gz rspamd-f1f8be8205f221ea213d4c304ffc7e6bd2c47aa2.zip |
Move constant_memcmp to libutil code.
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r-- | src/libutil/util.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 506940171..fd66cc321 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -54,6 +54,8 @@ #include <mach/mach_time.h> #endif +#include "blake2.h" + /* Check log messages intensity once per minute */ #define CHECK_TIME 60 /* More than 2 log messages per second */ @@ -61,6 +63,15 @@ /* Default connect timeout for sync sockets */ #define CONNECT_TIMEOUT 3 +const struct rspamd_controller_pbkdf pbkdf_list[] = { + { + .id = RSPAMD_PBKDF_ID_V1, + .rounds = 16000, + .salt_len = 20, + .key_len = BLAKE2B_OUTBYTES / 2 + } +}; + gint rspamd_socket_nonblocking (gint fd) { @@ -1990,6 +2001,30 @@ rspamd_time_jitter (gdouble in, gdouble jitter) return in + jitter * res; } +gboolean +rspamd_constant_memcmp (const guchar *a, const guchar *b, gsize len) +{ + gsize lena, lenb, i; + gint acc = 0; + + if (len == 0) { + lena = strlen (a); + lenb = strlen (b); + + if (lena != lenb) { + return FALSE; + } + + len = lena; + } + + for (i = 0; i < len; i++) { + acc |= a[i] ^ b[i]; + } + + return acc == 0; +} + #if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000000UL struct event_base * event_get_base (struct event *ev) |