about summary refs log tree commit diff stats
path: root/src/xmpp/connection.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-10-17 09:23:11 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-10-17 09:23:11 +0200
commit8f5d1751b26646c896e58aeb3b8861bc03d65765 (patch)
tree4a75360c1b13c92ffa4b92f811d487077352a9d3 /src/xmpp/connection.c
parent708bc83870b8c82afea20755ca43efee4ca99338 (diff)
downloadprofani-tty-8f5d1751b26646c896e58aeb3b8861bc03d65765.tar.gz
Change connection_create_stanza_id()
To return identifier and uuid together.
We can remove the prefix later on.
Diffstat (limited to 'src/xmpp/connection.c')
-rw-r--r--src/xmpp/connection.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 32e378e2..99343585 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -458,22 +458,22 @@ connection_free_uuid(char *uuid)
 char*
 connection_create_stanza_id(char *prefix)
 {
-    char *result = NULL;
-    GString *result_str = g_string_new("");
+    unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
     char *uuid = connection_create_uuid();
 
-    if (prefix) {
-        g_string_printf(result_str, "prof_%s_%s", prefix, uuid);
-    } else {
-        g_string_printf(result_str, "prof_%s", uuid);
-    }
+    assert(digest != NULL);
+    assert(uuid != NULL);
 
-    connection_free_uuid(uuid);
+    GString *tmp = g_string_new("");
+    g_string_printf(tmp, "%s%s", prof_identifier, uuid);
+    xmpp_sha1_digest((unsigned char*)tmp->str, strlen(tmp->str), digest);
+    g_string_free(tmp, TRUE);
 
-    result = result_str->str;
-    g_string_free(result_str, FALSE);
+    char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
+    assert(b64 != NULL);
+    free(digest);
 
-    return result;
+    return b64;
 }
 
 char*