diff options
Diffstat (limited to 'src/omemo')
-rw-r--r-- | src/omemo/omemo.c | 22 | ||||
-rw-r--r-- | src/omemo/omemo.h | 1 |
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); |