aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-22 09:45:14 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-22 09:45:14 +0100
commit39330e41853cf3cf63be1c8dbb8d32ed6dd36328 (patch)
tree6d4c3df980e1b416d99833e10c0383858cbc080b /src
parentccf4b2e63763eeeb64f62cbb3a744bcae285ecea (diff)
downloadrspamd-39330e41853cf3cf63be1c8dbb8d32ed6dd36328.tar.gz
rspamd-39330e41853cf3cf63be1c8dbb8d32ed6dd36328.zip
Fix parsing of openssl keys by semicolon splitting
Diffstat (limited to 'src')
-rw-r--r--src/libutil/http.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c
index 1afa9ac18..beb27cf9b 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -2259,11 +2259,24 @@ gpointer
rspamd_http_connection_make_key (gchar *key, gsize keylen)
{
guchar *decoded_sk, *decoded_pk;
+ gchar *semicolon;
gsize decoded_len;
struct rspamd_http_keypair *kp;
- decoded_sk = rspamd_decode_base32 (key, keylen / 2, &decoded_len);
- decoded_pk = rspamd_decode_base32 (key + keylen / 2, keylen / 2, &decoded_len);
+ semicolon = memchr (key, ':', keylen);
+
+ if (semicolon) {
+ decoded_sk = rspamd_decode_base32 (key, semicolon - key, &decoded_len);
+ decoded_pk = rspamd_decode_base32 (semicolon + 1,
+ keylen - (semicolon - key + 1),
+ &decoded_len);
+ }
+ else {
+ decoded_sk = rspamd_decode_base32 (key, keylen / 2, &decoded_len);
+ decoded_pk = rspamd_decode_base32 (key + keylen / 2,
+ keylen / 2,
+ &decoded_len);
+ }
if (decoded_pk != NULL && decoded_sk != NULL) {
if (decoded_len == rspamd_cryptobox_pk_bytes ()) {
@@ -2274,7 +2287,7 @@ rspamd_http_connection_make_key (gchar *key, gsize keylen)
blake2b (kp->id, kp->pk, NULL, sizeof (kp->id),
rspamd_cryptobox_pk_bytes (), 0);
- return (gpointer)kp;
+ return (gpointer) kp;
}
g_free (decoded_pk);
g_free (decoded_sk);