aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcryptobox/cryptobox.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-23 18:16:49 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-23 18:16:49 +0100
commit1703580be7327e219138b6b25716e6cdf142cca5 (patch)
tree6cf406be02224f22b2545ed709d7393528f934dd /src/libcryptobox/cryptobox.h
parent413d624f765a49d29d8e4ab8607121f2a1e9d049 (diff)
downloadrspamd-1703580be7327e219138b6b25716e6cdf142cca5.tar.gz
rspamd-1703580be7327e219138b6b25716e6cdf142cca5.zip
[Feature] Implement IUF interface for specific fast hashes
Diffstat (limited to 'src/libcryptobox/cryptobox.h')
-rw-r--r--src/libcryptobox/cryptobox.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h
index 016e58fc2..b78830ae1 100644
--- a/src/libcryptobox/cryptobox.h
+++ b/src/libcryptobox/cryptobox.h
@@ -343,9 +343,19 @@ void rspamd_cryptobox_hash (guchar *out,
const guchar *key,
gsize keylen);
+enum rspamd_cryptobox_fast_hash_type {
+ RSPAMD_CRYPTOBOX_XXHASH64 = 0,
+ RSPAMD_CRYPTOBOX_XXHASH32,
+ RSPAMD_CRYPTOBOX_MUMHASH,
+ RSPAMD_CRYPTOBOX_T1HA,
+ RSPAMD_CRYPTOBOX_HASHFAST,
+ RSPAMD_CRYPTOBOX_HASHFAST_INDEPENDENT
+};
+
/* Non crypto hash IUF interface */
typedef struct RSPAMD_ALIGNED(16) rspamd_cryptobox_fast_hash_state_s {
- unsigned char opaque[64 + sizeof (size_t) + sizeof (uint64_t)];
+ RSPAMD_ALIGNED(16) guint64 opaque[11];
+ enum rspamd_cryptobox_fast_hash_type type;
} rspamd_cryptobox_fast_hash_state_t;
/**
@@ -357,6 +367,15 @@ void rspamd_cryptobox_fast_hash_init (rspamd_cryptobox_fast_hash_state_t *st,
guint64 seed);
/**
+ * Init cryptobox hash state using key if needed, `st` must point to the buffer
+ * with at least rspamd_cryptobox_HASHSTATEBYTES bytes length. If keylen == 0, then
+ * non-keyed hash is generated
+ */
+void rspamd_cryptobox_fast_hash_init_specific (rspamd_cryptobox_fast_hash_state_t *st,
+ enum rspamd_cryptobox_fast_hash_type type,
+ guint64 seed);
+
+/**
* Update hash with data portion
*/
void rspamd_cryptobox_fast_hash_update (rspamd_cryptobox_fast_hash_state_t *st,
@@ -373,14 +392,6 @@ guint64 rspamd_cryptobox_fast_hash_final (rspamd_cryptobox_fast_hash_state_t *st
guint64 rspamd_cryptobox_fast_hash (const void *data,
gsize len, guint64 seed);
-enum rspamd_cryptobox_fast_hash_type {
- RSPAMD_CRYPTOBOX_XXHASH64 = 0,
- RSPAMD_CRYPTOBOX_XXHASH32,
- RSPAMD_CRYPTOBOX_MUMHASH,
- RSPAMD_CRYPTOBOX_T1HA,
- RSPAMD_CRYPTOBOX_HASHFAST,
- RSPAMD_CRYPTOBOX_HASHFAST_INDEPENDENT
-};
/**
* Platform independent version
*/