aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/str_util.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-04-09 17:13:12 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-04-09 17:13:12 +0100
commitc2351037b581724ce6d6cbcf4da5a0115b87c8de (patch)
treed55bd57d8bda456308b21cba7827fb2e2fc272a0 /src/libutil/str_util.h
parentf5c0d7116e373fa48ab465e8d8dcae1ddaf44932 (diff)
downloadrspamd-c2351037b581724ce6d6cbcf4da5a0115b87c8de.tar.gz
rspamd-c2351037b581724ce6d6cbcf4da5a0115b87c8de.zip
[Feature] Support multiple base32 alphabets
Diffstat (limited to 'src/libutil/str_util.h')
-rw-r--r--src/libutil/str_util.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h
index 22643176b..e7e5532c3 100644
--- a/src/libutil/str_util.h
+++ b/src/libutil/str_util.h
@@ -143,36 +143,43 @@ gboolean rspamd_strtoul (const gchar *s, gsize len, gulong *value);
gpointer rspamd_str_pool_copy (gconstpointer data, gpointer ud);
/**
- * Encode string using base32 encoding
+ * Encode string using hex encoding
* @param in input
* @param inlen input length
* @return freshly allocated base32 encoding of a specified string
*/
-gchar *rspamd_encode_base32 (const guchar *in, gsize inlen);
+gchar *rspamd_encode_hex (const guchar *in, gsize inlen);
/**
- * Decode string using base32 encoding
+ * Decode string using hex encoding
* @param in input
* @param inlen input length
* @return freshly allocated base32 decoded value or NULL if input is invalid
*/
-guchar *rspamd_decode_base32 (const gchar *in, gsize inlen, gsize *outlen);
+guchar *rspamd_decode_hex (const gchar *in, gsize inlen);
+
+enum rspamd_base32_type {
+ RSPAMD_BASE32_DEFAULT = 0,
+ RSPAMD_BASE32_ZBASE = 0,
+ RSPAMD_BASE32_BLEACH
+};
/**
- * Encode string using hex encoding
+ * Encode string using base32 encoding
* @param in input
* @param inlen input length
* @return freshly allocated base32 encoding of a specified string
*/
-gchar *rspamd_encode_hex (const guchar *in, gsize inlen);
+gchar *rspamd_encode_base32 (const guchar *in, gsize inlen,
+ enum rspamd_base32_type type);
/**
- * Decode string using hex encoding
+ * Decode string using base32 encoding
* @param in input
* @param inlen input length
* @return freshly allocated base32 decoded value or NULL if input is invalid
*/
-guchar *rspamd_decode_hex (const gchar *in, gsize inlen);
+guchar *rspamd_decode_base32 (const gchar *in, gsize inlen, gsize *outlen);
/**
* Encode string using base32 encoding
@@ -183,7 +190,7 @@ guchar *rspamd_decode_hex (const gchar *in, gsize inlen);
* @return encoded len if `outlen` is enough to encode `inlen`
*/
gint rspamd_encode_base32_buf (const guchar *in, gsize inlen, gchar *out,
- gsize outlen);
+ gsize outlen, enum rspamd_base32_type type);
/**
* Decode string using base32 encoding