about summary refs log tree commit diff stats
path: root/src/omemo
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-03-13 19:43:07 +0140
committerPaul Fariello <paul@fariello.eu>2019-04-10 17:12:31 +0200
commit2622c2d21a1f120cb39800b8c96b6e5ce916589b (patch)
treee2befec30997a130f8cc354fb813c0aecaca3ebc /src/omemo
parent36ce21fc6d8104ef2145afbe3056747e49032ca4 (diff)
downloadprofani-tty-2622c2d21a1f120cb39800b8c96b6e5ce916589b.tar.gz
Add OMEMO untrust command
Diffstat (limited to 'src/omemo')
-rw-r--r--src/omemo/omemo.c22
-rw-r--r--src/omemo/omemo.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index b45e1834..fceb0363 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -857,6 +857,28 @@ omemo_trust(const char *const jid, const char *const fingerprint_formatted)
     omemo_bundle_request(jid, device_id, omemo_start_device_session_handle_bundle, free, strdup(jid));
 }
 
+void
+omemo_untrust(const char *const jid, const char *const fingerprint_formatted)
+{
+    size_t len;
+    unsigned char *fingerprint = omemo_fingerprint_decode(fingerprint_formatted, &len);
+
+    GHashTableIter iter;
+    gpointer key, value;
+
+    g_hash_table_iter_init(&iter, omemo_ctx.identity_key_store.trusted);
+    while (g_hash_table_iter_next(&iter, &key, &value)) {
+        signal_buffer *buffer = value;
+        unsigned char *original = signal_buffer_data(buffer);
+        /* Skip DJB_TYPE byte */
+        original++;
+        if ((signal_buffer_len(buffer) - 1) == len && memcmp(original, fingerprint, len) == 0) {
+            g_hash_table_remove(omemo_ctx.identity_key_store.trusted, key);
+        }
+    }
+    free(fingerprint);
+}
+
 static void
 lock(void *user_data)
 {
diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h
index 5be0e0cd..7f9b7992 100644
--- a/src/omemo/omemo.h
+++ b/src/omemo/omemo.h
@@ -33,6 +33,7 @@ void omemo_sessions_keyfile_save(void);
 char *omemo_format_fingerprint(const char *const fingerprint);
 char *omemo_own_fingerprint(gboolean formatted);
 void omemo_trust(const char *const jid, const char *const fingerprint);
+void omemo_untrust(const char *const jid, const char *const fingerprint);
 
 void omemo_start_session(const char *const barejid);
 void omemo_start_device_session(const char *const jid, uint32_t device_id, GList *prekeys, uint32_t signed_prekey_id, const unsigned char *const signed_prekey, size_t signed_prekey_len, const unsigned char *const signature, size_t signature_len, const unsigned char *const identity_key, size_t identity_key_len);