diff options
author | Stefan <79058696+StefanKropp@users.noreply.github.com> | 2021-04-17 13:28:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-17 13:28:54 +0200 |
commit | 3ba38eafa8ff0a53937fafebc0f8754944d57601 (patch) | |
tree | 73daec63c0830b8393e4a906c02b7fbcd4f33cfd /src/omemo | |
parent | c79979401b316e66ae13eba89f3d552fbe95780b (diff) | |
download | profani-tty-3ba38eafa8ff0a53937fafebc0f8754944d57601.tar.gz |
OMEMO - trust mode (#1506)
Add OMEMO trust mode capabilities. * ToFu / first usage * blind trust * manual
Diffstat (limited to 'src/omemo')
-rw-r--r-- | src/omemo/omemo.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 495842bf..8c7a1276 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -542,6 +542,34 @@ omemo_set_device_list(const char* const from, GList* device_list) } } + // OMEMO trustmode ToFu + if (g_strcmp0(prefs_get_string(PREF_OMEMO_TRUST_MODE), "firstusage") == 0) { + log_info("[OMEMO] Checking firstusage state for %s", jid->barejid); + GHashTable* trusted = g_hash_table_lookup(omemo_ctx.identity_key_store.trusted, jid->barejid); + if (trusted) { + if (g_hash_table_size(trusted) > 0) { + log_info("[OMEMO] Found trusted device for %s - skip firstusage", jid->barejid); + return; + } + } else { + if (device_list) { + cons_show("OMEMO: No trusted devices found for %s", jid->barejid); + GList* device_id; + for (device_id = device_list; device_id != NULL; device_id = device_id->next) { + GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid->barejid); + if (known_identities) { + GList* fp = NULL; + for (fp = g_hash_table_get_keys(known_identities); fp != NULL; fp = fp->next) { + if (device_id->data == g_hash_table_lookup(known_identities, fp->data)) { + cons_show("OMEMO: Adding firstusage trust for %s device %d - Fingerprint %s", jid->barejid, device_id->data, omemo_format_fingerprint(fp->data)); + omemo_trust(jid->barejid, omemo_format_fingerprint(fp->data)); + } + } + } + } + } + } + } jid_destroy(jid); } @@ -622,6 +650,14 @@ omemo_start_device_session(const char* const jid, uint32_t device_id, gboolean trusted = is_trusted_identity(&address, (uint8_t*)identity_key_raw, identity_key_len, &omemo_ctx.identity_key_store); + if ((g_strcmp0(prefs_get_string(PREF_OMEMO_TRUST_MODE), "blind") == 0) && !trusted) { + char* fp = _omemo_fingerprint(identity_key, TRUE); + cons_show("Blind trust for %s device %d (%s)", jid, device_id, fp); + omemo_trust(jid, fp); + free(fp); + trusted = TRUE; + } + if (!trusted) { goto out; } |