#define COLOR_REJECT "#CB4B4B"
#define COLOR_TOTAL "#9440ED"
-#define RSPAMD_PBKDF_ID_V1 1
-
const struct timeval rrd_update_time = {
.tv_sec = 1,
.tv_usec = 0
gboolean is_spam;
};
-
-const struct rspamd_controller_pbkdf pbkdf_list[] = {
- {
- .id = RSPAMD_PBKDF_ID_V1,
- .rounds = 16000,
- .salt_len = 20,
- .key_len = BLAKE2B_OUTBYTES / 2
- }
-};
-
-static 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;
-}
-
static gboolean
rspamd_is_encrypted_password (const gchar *password,
struct rspamd_controller_pbkdf const **pbkdf)
#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 */
/* 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)
{
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)
*/
gdouble rspamd_time_jitter (gdouble in, gdouble jitter);
+/**
+ * Constant time version of memcmp
+ */
+gboolean rspamd_constant_memcmp (const guchar *a, const guchar *b, gsize len);
+
/* Special case for ancient libevent */
#if !defined(LIBEVENT_VERSION_NUMBER) || LIBEVENT_VERSION_NUMBER < 0x02000000UL
struct event_base * event_get_base (struct event *ev);