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/command | |
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/command')
-rw-r--r-- | src/command/cmd_ac.c | 15 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 5 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 31 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 1 |
4 files changed, 52 insertions, 0 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 26c9d948..a4d70598 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -193,6 +193,7 @@ static Autocomplete otr_sendfile_ac; static Autocomplete omemo_ac; static Autocomplete omemo_log_ac; static Autocomplete omemo_policy_ac; +static Autocomplete omemo_trustmode_ac; #endif static Autocomplete connect_property_ac; static Autocomplete tls_property_ac; @@ -682,6 +683,7 @@ cmd_ac_init(void) autocomplete_add(omemo_ac, "fingerprint"); autocomplete_add(omemo_ac, "clear_device_list"); autocomplete_add(omemo_ac, "policy"); + autocomplete_add(omemo_ac, "trustmode"); autocomplete_add(omemo_ac, "char"); omemo_log_ac = autocomplete_new(); @@ -693,6 +695,12 @@ cmd_ac_init(void) autocomplete_add(omemo_policy_ac, "manual"); autocomplete_add(omemo_policy_ac, "automatic"); autocomplete_add(omemo_policy_ac, "always"); + + // Autocomplete OMEMO trustmode + omemo_trustmode_ac = autocomplete_new(); + autocomplete_add(omemo_trustmode_ac, "manual"); + autocomplete_add(omemo_trustmode_ac, "firstusage"); + autocomplete_add(omemo_trustmode_ac, "blind"); #endif connect_property_ac = autocomplete_new(); @@ -1295,6 +1303,7 @@ cmd_ac_reset(ProfWin* window) autocomplete_reset(omemo_ac); autocomplete_reset(omemo_log_ac); autocomplete_reset(omemo_policy_ac); + autocomplete_reset(omemo_trustmode_ac); #endif autocomplete_reset(connect_property_ac); autocomplete_reset(tls_property_ac); @@ -1453,6 +1462,7 @@ cmd_ac_uninit(void) autocomplete_free(omemo_ac); autocomplete_free(omemo_log_ac); autocomplete_free(omemo_policy_ac); + autocomplete_free(omemo_trustmode_ac); #endif autocomplete_free(connect_property_ac); autocomplete_free(tls_property_ac); @@ -2519,6 +2529,11 @@ _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous) return found; } + found = autocomplete_param_with_ac(input, "/omemo trustmode", omemo_trustmode_ac, TRUE, previous); + if (found) { + return found; + } + jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 239467a1..93e12077 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2292,6 +2292,7 @@ static struct cmd_t command_defs[] = { { "log", cmd_omemo_log }, { "start", cmd_omemo_start }, { "end", cmd_omemo_end }, + { "trustmode", cmd_omemo_trust_mode }, { "trust", cmd_omemo_trust }, { "untrust", cmd_omemo_untrust }, { "fingerprint", cmd_omemo_fingerprint }, @@ -2310,6 +2311,7 @@ static struct cmd_t command_defs[] = { "/omemo end", "/omemo fingerprint [<contact>]", "/omemo char <char>", + "/omemo trustmode manual|firstusage|blind", "/omemo policy manual|automatic|always", "/omemo clear_device_list") CMD_DESC( @@ -2322,6 +2324,9 @@ static struct cmd_t command_defs[] = { { "log redact", "Log OMEMO encrypted messages, but replace the contents with [redacted]. This is the default." }, { "fingerprint [<contact>]", "Show contact fingerprints, or current recipient if omitted." }, { "char <char>", "Set the character to be displayed next to OMEMO encrypted messages." }, + { "trustmode manual", "Set the global OMEMO trust mode to manual, OMEMO keys has to be trusted manually." }, + { "trustmode firstusage", "Set the global OMEMO trust mode to ToFu, first OMEMO keys trusted automatically." }, + { "trustmode blind", "Set the global OMEMO trust mode to blind, ALL OMEMO keys trusted automatically." }, { "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." }, { "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." }, { "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 9d8fec50..351f7b98 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -8475,6 +8475,37 @@ cmd_omemo_start(ProfWin* window, const char* const command, gchar** args) } gboolean +cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar** args) +{ +#ifdef HAVE_OMEMO + + if (!args[1]) { + cons_show("Current trust mode is %s", prefs_get_string(PREF_OMEMO_TRUST_MODE)); + return TRUE; + } + + if (g_strcmp0(args[1], "manual") == 0) { + cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]); + cons_show("You need to trust all OMEMO fingerprints manually"); + } else if (g_strcmp0(args[1], "firstusage") == 0) { + cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]); + cons_show("The first seen OMEMO fingerprints will be trusted automatically - new keys must be trusted manually"); + } else if (g_strcmp0(args[1], "blind") == 0) { + cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]); + cons_show("ALL OMEMO fingerprints will be trusted automatically"); + } else { + cons_bad_cmd_usage(command); + return TRUE; + } + prefs_set_string(PREF_OMEMO_TRUST_MODE, args[1]); + +#else + cons_show("This version of Profanity has not been built with OMEMO support enabled"); +#endif + return TRUE; +} + +gboolean cmd_omemo_char(ProfWin* window, const char* const command, gchar** args) { #ifdef HAVE_OMEMO diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index a2c5f8f3..0785963b 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -222,6 +222,7 @@ gboolean cmd_omemo_end(ProfWin* window, const char* const command, gchar** args) gboolean cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args); gboolean cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args); gboolean cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar** args); gboolean cmd_omemo_policy(ProfWin* window, const char* const command, gchar** args); gboolean cmd_omemo_clear_device_list(ProfWin* window, const char* const command, gchar** args); |