about summary refs log tree commit diff stats
path: root/src/omemo
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2022-05-31 15:44:44 +0200
committerMichael Vetter <jubalh@iodoru.org>2022-05-31 15:44:44 +0200
commit2e85f18cd61b358c8c654a90ef64cf80af5a33c6 (patch)
tree00a599cf7b6b5d5b159de8ba626c79f2564a0447 /src/omemo
parent754c110a34bf608bee3990e5b626203699b879d2 (diff)
downloadprofani-tty-2e85f18cd61b358c8c654a90ef64cf80af5a33c6.tar.gz
Use our omemo sid/fingerprint in qr code
Current clients sid/fingerprint will be shown in following format:
`xmpp:<user@server>?omemo-sid-<numerical-sid>=<omemo-fingerprint-hex-string>`

Fix https://github.com/profanity-im/profanity/issues/1320
Diffstat (limited to 'src/omemo')
-rw-r--r--src/omemo/omemo.c18
-rw-r--r--src/omemo/omemo.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index e6d9da42..9f67d24c 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -1896,3 +1896,21 @@ out:
     curl_url_cleanup(url);
     return ret;
 }
+
+/* returns a string in the format `xmpp:<user@server>?omemo-sid-<numerical-sid>=<omemo-fingerprint-hex-string>`
+ * used for verification over QR codes
+ */
+char*
+omemo_qrcode_str()
+{
+    char* mybarejid = connection_get_barejid();
+    char* fingerprint = omemo_own_fingerprint(TRUE);
+    uint32_t sid = omemo_device_id();
+
+    char* qrstr = g_strdup_printf("xmpp:%s?omemo-sid-%d=%s", mybarejid, sid, fingerprint);
+
+    free(mybarejid);
+    free(fingerprint);
+
+    return qrstr;
+}
diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h
index 7e7c1f14..624bec51 100644
--- a/src/omemo/omemo.h
+++ b/src/omemo/omemo.h
@@ -105,3 +105,5 @@ char* omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res);
 gcry_error_t omemo_decrypt_file(FILE* in, FILE* out, off_t file_size, const char* fragment);
 void omemo_free(void* a);
 int omemo_parse_aesgcm_url(const char* aesgcm_url, char** https_url, char** fragment);
+
+char* omemo_qrcode_str();