From 0d4bf7ef10f5c93f3f0ee828d353bb9da2c27d48 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 5 Dec 2021 18:18:38 +0000 Subject: [PATCH] [Minor] Add xxh3 support to lua_cryptobox --- src/lua/lua_cryptobox.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index 7d1b8e4a9..7c19a7805 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -45,6 +45,7 @@ enum lua_cryptobox_hash_type { LUA_CRYPTOBOX_HASH_HMAC, LUA_CRYPTOBOX_HASH_XXHASH64, LUA_CRYPTOBOX_HASH_XXHASH32, + LUA_CRYPTOBOX_HASH_XXHASH3, LUA_CRYPTOBOX_HASH_MUM, LUA_CRYPTOBOX_HASH_T1HA, }; @@ -977,6 +978,7 @@ rspamd_lua_hash_update (struct rspamd_lua_cryptobox_hash *h, break; case LUA_CRYPTOBOX_HASH_XXHASH64: case LUA_CRYPTOBOX_HASH_XXHASH32: + case LUA_CRYPTOBOX_HASH_XXHASH3: case LUA_CRYPTOBOX_HASH_MUM: case LUA_CRYPTOBOX_HASH_T1HA: rspamd_cryptobox_fast_hash_update (h->content.fh, p, len); @@ -1140,6 +1142,13 @@ rspamd_lua_hash_create (const gchar *type, const gchar *key, gsize keylen) RSPAMD_CRYPTOBOX_XXHASH32, 0); h->out_len = sizeof (guint32); } + else if (g_ascii_strcasecmp (type, "xxh3") == 0) { + h->type = LUA_CRYPTOBOX_HASH_XXHASH3; + h->content.fh = rspamd_cryptobox_fast_hash_new (); + rspamd_cryptobox_fast_hash_init_specific (h->content.fh, + RSPAMD_CRYPTOBOX_XXHASH3, 0); + h->out_len = sizeof (guint64); + } else if (g_ascii_strcasecmp (type, "mum") == 0) { h->type = LUA_CRYPTOBOX_HASH_MUM; h->content.fh = rspamd_cryptobox_fast_hash_new (); @@ -1467,6 +1476,10 @@ lua_cryptobox_hash_reset (lua_State *L) rspamd_cryptobox_fast_hash_init_specific (h->content.fh, RSPAMD_CRYPTOBOX_XXHASH32, 0); break; + case LUA_CRYPTOBOX_HASH_XXHASH3: + rspamd_cryptobox_fast_hash_init_specific (h->content.fh, + RSPAMD_CRYPTOBOX_XXHASH3, 0); + break; case LUA_CRYPTOBOX_HASH_MUM: rspamd_cryptobox_fast_hash_init_specific (h->content.fh, RSPAMD_CRYPTOBOX_MUMHASH, 0); @@ -1518,6 +1531,7 @@ lua_cryptobox_hash_finish (struct rspamd_lua_cryptobox_hash *h) break; case LUA_CRYPTOBOX_HASH_XXHASH64: case LUA_CRYPTOBOX_HASH_XXHASH32: + case LUA_CRYPTOBOX_HASH_XXHASH3: case LUA_CRYPTOBOX_HASH_MUM: case LUA_CRYPTOBOX_HASH_T1HA: ll = rspamd_cryptobox_fast_hash_final (h->content.fh); -- 2.39.5