mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 01:06:21 +00:00
OMEMO - trust mode (#1506)
Add OMEMO trust mode capabilities. * ToFu / first usage * blind trust * manual
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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." },
|
||||
|
||||
@@ -8474,6 +8474,37 @@ cmd_omemo_start(ProfWin* window, const char* const command, gchar** args)
|
||||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user