Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/omemo #1039

Merged
merged 100 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
4a5b672
Link against libsignal-protocol-c
paulfariello Feb 19, 2019
bfbc8ed
Add crypto backend for signal-protocol
paulfariello Feb 19, 2019
519cf29
Add signal-protocol locking
paulfariello Feb 19, 2019
2602cbf
Move OMEMO initialization to profanity intialization
paulfariello Feb 19, 2019
bce1981
Add devicelist subscription
paulfariello Feb 21, 2019
fdc5f25
Add devicelist and bundle publication
paulfariello Feb 21, 2019
2d28725
Rename ProfIdCallback into ProfIqCallback
paulfariello Feb 22, 2019
1ae5d9f
Add pubsub event callback
paulfariello Feb 22, 2019
d8d7a53
Ensure OMEMO isn't started before starting OTR
paulfariello Feb 22, 2019
79bb501
Ensure not to generate omemo crypto twice
paulfariello Feb 22, 2019
756fefb
Fix devicelist subscription and handle pubsub event
paulfariello Feb 22, 2019
95da03a
Ensure received devicelist contains our own device id
paulfariello Feb 25, 2019
1f9d460
Request for device list when OMEMO is ready
paulfariello Feb 25, 2019
f9216fd
Add signal store backend and OMEMO start command
paulfariello Feb 25, 2019
b1ae220
Create signal session
paulfariello Feb 26, 2019
0fb27dc
Add OMEMO message encryption and decryption
paulfariello Feb 26, 2019
904904d
Add default body on OMEMO message
paulfariello Feb 28, 2019
d871efd
Add chat session state to OMEMO message stanza
paulfariello Feb 28, 2019
810ea32
Follow normal workflow for OMEMO message reception
paulfariello Mar 1, 2019
421d1b1
Add OMEMO identity materials long term storage
paulfariello Mar 1, 2019
20ed86c
Handle requested device list for session start
paulfariello Mar 4, 2019
9b8c1d7
Add support for encrypted carbon
paulfariello Mar 5, 2019
bcd582b
Don't explicitely disable carbons for OMEMO messages
paulfariello Mar 5, 2019
3d8c928
Use profanity logs for OMEMO logs
paulfariello Mar 5, 2019
1309405
Add log on OMEMO session start
paulfariello Mar 5, 2019
6956940
Remove hints preventing carbons to work properly
paulfariello Mar 6, 2019
605e064
Get rid of libsodium
paulfariello Mar 6, 2019
b0c52f8
Follow xep by putting gcm tag on encrypted key
paulfariello Mar 6, 2019
da0376a
Check received gcm tag
paulfariello Mar 6, 2019
2718183
Enable start of OMEMO in existing chat win
paulfariello Mar 6, 2019
ba0fa6e
Add OMEMO commands autocompletion
paulfariello Mar 6, 2019
bf8b89c
Randomly choose a prekey on session build
paulfariello Mar 6, 2019
1b5848f
Start new session upon prekey reception
paulfariello Mar 6, 2019
5eb66ae
Replace used prekey in bundle
paulfariello Mar 6, 2019
55407ee
Add OMEMO session long term storage
paulfariello Mar 7, 2019
b3be504
Add OMEMO fingerprint command
paulfariello Mar 7, 2019
97c6612
Add support for libsignal-protocol-c 2.3.2
paulfariello Mar 11, 2019
249701f
Add OMEMO status in build information
paulfariello Mar 11, 2019
23485eb
Don't trust unknown identity keys
paulfariello Mar 7, 2019
063a5d1
Add trust command
paulfariello Mar 7, 2019
dbf96dc
Allow to trust own device id
paulfariello Mar 13, 2019
36ce21f
Add store hints for OMEMO encrypted messages
paulfariello Mar 13, 2019
2622c2d
Add OMEMO untrust command
paulfariello Mar 13, 2019
89ece4f
Add UI feedback for OMEMO gen command
paulfariello Mar 13, 2019
5d90199
Avoid opening win if crypto materials are missing
paulfariello Mar 13, 2019
2455bcc
Avoid using xmpp_jid_bare
paulfariello Mar 13, 2019
8952684
Add hints about trust command when printing fingerprints
paulfariello Mar 14, 2019
4826da3
Don't rely on account name being jid
paulfariello Mar 14, 2019
197e098
Log device_id on startup
paulfariello Mar 14, 2019
6bb7dee
Add logs about crypto generation
paulfariello Mar 14, 2019
0dd5441
device_list iq should be from barejid or none
paulfariello Mar 14, 2019
3e325a6
Add support for OMEMO, OTR, PGP built together
paulfariello Mar 15, 2019
319fb85
Handle decrypted OMEMO messages as such
paulfariello Mar 15, 2019
33b0b46
Fix prekey handling after first use
paulfariello Mar 15, 2019
a3897ab
Add MUC message decryption
paulfariello Mar 14, 2019
21f247d
Handle window type MUC in OMEMO start command
paulfariello Mar 15, 2019
cf52838
Allow to start OMEMO in MUC
paulfariello Mar 15, 2019
031e906
Cosmetics rename variable barejid into roomjid
paulfariello Mar 15, 2019
f7ce160
Ensure saved_account is set before calling sv_ev_login_account_success
paulfariello Mar 15, 2019
a9d55de
Add support for sending encrypted message in MUC
paulfariello Mar 18, 2019
4e1ffa6
Log and print outgoing encrypted message
paulfariello Mar 18, 2019
88670a7
Add OMEMO state in titlebar
paulfariello Mar 19, 2019
e5b01ed
Add OMEMO state in titlebar in MUC
paulfariello Mar 19, 2019
9044e37
Ensure room isn't anonymous
paulfariello Mar 19, 2019
d8f0bce
Add publish option to OMEMO device list and bundle
paulfariello Mar 19, 2019
7010995
Revert "Ensure room isn't anonymous"
paulfariello Mar 19, 2019
9a66e74
Handle absent muc member
paulfariello Mar 19, 2019
bc541cb
Add OMEMO end command
paulfariello Mar 19, 2019
91ee289
Add support for disconnect in OMEMO
paulfariello Mar 21, 2019
dadd0c0
Add missing preferences for OMEMO logs
paulfariello Mar 22, 2019
306706b
Add OMEMO log command
paulfariello Mar 22, 2019
2fd2ca2
Use connection_support to check for publish-options support
paulfariello Mar 25, 2019
3d8f47a
Use /omemo fingerprint to show contact fingerprints
paulfariello Mar 25, 2019
678bff9
Add fingerprint autocompletion
paulfariello Mar 25, 2019
bc16ba1
Temporarly disable check for publish-options support
paulfariello Mar 25, 2019
ba9679a
Print fingerprint after trust and untrust command
paulfariello Mar 26, 2019
4a1c3c8
Show all device fingerprint for current account
paulfariello Mar 26, 2019
daf84ce
Add required OMEMO stub for unit-test
paulfariello Mar 26, 2019
2015ba2
Ensure encrypted carbon of own message are marked as encrypted
paulfariello Mar 27, 2019
075d4cf
Don't use glib 2.58 func
paulfariello Mar 27, 2019
904528b
Ensure signal context is built on connection
paulfariello Mar 27, 2019
5623028
Handle bundle publication error on publish-options
paulfariello Mar 28, 2019
0d0e2b2
Add support for missing from in bundle iq
paulfariello Mar 29, 2019
5cd2b8d
Permanently store pre keys
paulfariello Apr 1, 2019
8983022
Add clear_device_list command
paulfariello Apr 1, 2019
65b3f82
Fix devicelist notification handler
paulfariello Apr 1, 2019
e7be3a6
Add OMEMO in prefs command
paulfariello Apr 1, 2019
e69f947
Rework MUC reflected message filtering
paulfariello Apr 1, 2019
0f4dd61
Ensure pre keys are generated if missing from long term storage
paulfariello Apr 1, 2019
01e9676
Prefix static function with _
paulfariello Apr 1, 2019
edbc15f
Don't build OMEMO by default
paulfariello Apr 10, 2019
4ad6904
Wait for discovery end to publish omemo devicelist and bundle
paulfariello Apr 8, 2019
25eb138
Rework trusted fingerprint storage
paulfariello Apr 9, 2019
0bc6604
Automatically starts OMEMO if one identity is trusted
paulfariello Apr 9, 2019
277e8dc
Add /omemo char command
paulfariello Apr 10, 2019
381d85b
Fix build on travis
paulfariello Apr 10, 2019
f9b2fdc
OMEMO should be written uppercase
paulfariello Apr 10, 2019
df648ba
Try to start sessions with every jid in roster
paulfariello Apr 10, 2019
ad21021
Fix issue with first encrypted message
paulfariello Apr 10, 2019
f75e1d7
Support contact name in /omemo fingerprint command
paulfariello Apr 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ unittest_sources = \
src/ui/ui.h \
src/otr/otr.h \
src/pgp/gpg.h \
src/omemo/omemo.h \
src/omemo/crypto.h \
src/omemo/store.h \
src/command/cmd_defs.h src/command/cmd_defs.c \
src/command/cmd_funcs.h src/command/cmd_funcs.c \
src/command/cmd_ac.h src/command/cmd_ac.c \
Expand Down Expand Up @@ -168,6 +171,13 @@ otr3_sources = \
otr4_sources = \
src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c

omemo_sources = \
src/omemo/omemo.h src/omemo/omemo.c src/omemo/crypto.h src/omemo/crypto.c \
src/omemo/store.h src/omemo/store.c src/xmpp/omemo.h src/xmpp/omemo.c

omemo_unittest_sources = \
tests/unittests/omemo/stub_omemo.c

if BUILD_PYTHON_API
core_sources += $(python_sources)
unittest_sources += $(python_sources)
Expand Down Expand Up @@ -204,6 +214,11 @@ core_sources += $(otr4_sources)
endif
endif

if BUILD_OMEMO
core_sources += $(omemo_sources)
unittest_sources += $(omemo_unittest_sources)
endif

AM_CFLAGS = @AM_CFLAGS@ -I$(srcdir)/src

bin_PROGRAMS = profanity
Expand Down
26 changes: 26 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ AC_ARG_ENABLE([otr],
[AS_HELP_STRING([--enable-otr], [enable otr encryption])])
AC_ARG_ENABLE([pgp],
[AS_HELP_STRING([--enable-pgp], [enable pgp])])
AC_ARG_ENABLE([omemo],
[AS_HELP_STRING([--enable-omemo], [enable OMEMO encryption])])
AC_ARG_WITH([xscreensaver],
[AS_HELP_STRING([--with-xscreensaver], [use libXScrnSaver to determine idle time])])
AC_ARG_WITH([themes],
Expand Down Expand Up @@ -264,6 +266,30 @@ if test "x$enable_otr" != xno; then
[AC_MSG_NOTICE([libotr not found, otr encryption support not enabled])])])
fi

AM_CONDITIONAL([BUILD_OMEMO], [false])
if test "x$enable_omemo" != xno; then
AM_CONDITIONAL([BUILD_OMEMO], [true])
PKG_CHECK_MODULES([libsignal], [libsignal-protocol-c >= 2.3.2],
[LIBS="-lsignal-protocol-c $LIBS"],
[AC_MSG_NOTICE([libsignal >= 2.3.2 not found, checking for libsignal 2.3.x...])
PKG_CHECK_MODULES([libsignal], [libsignal-protocol-c >= 2.3.0],
[LIBS="-lsignal-protocol-c $LIBS"
AC_DEFINE([HAVE_LIBSIGNAL_LT_2_3_2], [1], [Have libsignal-protocol-c < 2.3.2])],
[AM_CONDITIONAL([BUILD_OMEMO], [false])
AS_IF([test "x$enable_omemo" = xyes],
[AC_MSG_ERROR([libsignal-protocol-c is required for OMEMO support])],
[AC_MSG_NOTICE([libsignal-protocol-c not found, OMEMO support not enabled])])])])

AC_CHECK_LIB([gcrypt], [gcry_check_version],
[LIBS="-lgcrypt $LIBS"],
[AM_CONDITIONAL([BUILD_OMEMO], [false])
AS_IF([test "x$enable_omemo" = xyes],
[AC_MSG_ERROR([gcrypt is required for OMEMO support])],
[AC_MSG_NOTICE([gcrypt not found, OMEMO support not enabled])])])

AM_COND_IF([BUILD_OMEMO], [AC_DEFINE([HAVE_OMEMO], [1], [Have OMEMO])])
fi

AS_IF([test "x$with_themes" = xno],
[THEMES_INSTALL="false"],
[THEMES_INSTALL="true"])
Expand Down
82 changes: 82 additions & 0 deletions src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
#include "pgp/gpg.h"
#endif

#ifdef HAVE_OMEMO
#include "omemo/omemo.h"
#endif

static char* _sub_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _notify_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _theme_autocomplete(ProfWin *window, const char *const input, gboolean previous);
Expand All @@ -69,6 +73,7 @@ static char* _group_autocomplete(ProfWin *window, const char *const input, gbool
static char* _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _connect_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _alias_autocomplete(ProfWin *window, const char *const input, gboolean previous);
static char* _join_autocomplete(ProfWin *window, const char *const input, gboolean previous);
Expand Down Expand Up @@ -157,6 +162,8 @@ static Autocomplete bookmark_property_ac;
static Autocomplete otr_ac;
static Autocomplete otr_log_ac;
static Autocomplete otr_policy_ac;
static Autocomplete omemo_ac;
static Autocomplete omemo_log_ac;
static Autocomplete connect_property_ac;
static Autocomplete tls_property_ac;
static Autocomplete alias_ac;
Expand Down Expand Up @@ -237,6 +244,7 @@ cmd_ac_init(void)
autocomplete_add(prefs_ac, "presence");
autocomplete_add(prefs_ac, "otr");
autocomplete_add(prefs_ac, "pgp");
autocomplete_add(prefs_ac, "omemo");

notify_ac = autocomplete_new();
autocomplete_add(notify_ac, "chat");
Expand Down Expand Up @@ -574,6 +582,21 @@ cmd_ac_init(void)
autocomplete_add(otr_policy_ac, "opportunistic");
autocomplete_add(otr_policy_ac, "always");

omemo_ac = autocomplete_new();
autocomplete_add(omemo_ac, "gen");
autocomplete_add(omemo_ac, "log");
autocomplete_add(omemo_ac, "start");
autocomplete_add(omemo_ac, "end");
autocomplete_add(omemo_ac, "trust");
autocomplete_add(omemo_ac, "untrust");
autocomplete_add(omemo_ac, "fingerprint");
autocomplete_add(omemo_ac, "clear_device_list");

omemo_log_ac = autocomplete_new();
autocomplete_add(omemo_log_ac, "on");
autocomplete_add(omemo_log_ac, "off");
autocomplete_add(omemo_log_ac, "redact");

connect_property_ac = autocomplete_new();
autocomplete_add(connect_property_ac, "server");
autocomplete_add(connect_property_ac, "port");
Expand Down Expand Up @@ -982,6 +1005,9 @@ cmd_ac_reset(ProfWin *window)
presence_reset_sub_request_search();
#ifdef HAVE_LIBGPGME
p_gpg_autocomplete_key_reset();
#endif
#ifdef HAVE_OMEMO
omemo_fingerprint_autocomplete_reset();
#endif
autocomplete_reset(help_ac);
autocomplete_reset(help_commands_ac);
Expand Down Expand Up @@ -1052,6 +1078,8 @@ cmd_ac_reset(ProfWin *window)
autocomplete_reset(otr_ac);
autocomplete_reset(otr_log_ac);
autocomplete_reset(otr_policy_ac);
autocomplete_reset(omemo_ac);
autocomplete_reset(omemo_log_ac);
autocomplete_reset(connect_property_ac);
autocomplete_reset(tls_property_ac);
autocomplete_reset(alias_ac);
Expand Down Expand Up @@ -1179,6 +1207,8 @@ cmd_ac_uninit(void)
autocomplete_free(otr_ac);
autocomplete_free(otr_log_ac);
autocomplete_free(otr_policy_ac);
autocomplete_free(omemo_ac);
autocomplete_free(omemo_log_ac);
autocomplete_free(connect_property_ac);
autocomplete_free(tls_property_ac);
autocomplete_free(alias_ac);
Expand Down Expand Up @@ -1438,6 +1468,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete);
g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete);
g_hash_table_insert(ac_funcs, "/pgp", _pgp_autocomplete);
g_hash_table_insert(ac_funcs, "/omemo", _omemo_autocomplete);
g_hash_table_insert(ac_funcs, "/connect", _connect_autocomplete);
g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete);
g_hash_table_insert(ac_funcs, "/join", _join_autocomplete);
Expand Down Expand Up @@ -2117,6 +2148,57 @@ _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous)
return NULL;
}

static char*
_omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
{
char *found = NULL;

jabber_conn_status_t conn_status = connection_get_status();

if (conn_status == JABBER_CONNECTED) {
found = autocomplete_param_with_func(input, "/omemo start", roster_contact_autocomplete, previous);
if (found) {
return found;
}
}

found = autocomplete_param_with_func(input, "/omemo fingerprint", roster_contact_autocomplete, previous);
if (found) {
return found;
}

#ifdef HAVE_OMEMO
if (window->type == WIN_CHAT) {
found = autocomplete_param_with_func(input, "/omemo trust", omemo_fingerprint_autocomplete, previous);
if (found) {
return found;
}
} else {
found = autocomplete_param_with_func(input, "/omemo trust", roster_contact_autocomplete, previous);
if (found) {
return found;
}

found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous);
if (found) {
return found;
}
}
#endif

found = autocomplete_param_with_ac(input, "/omemo log", omemo_log_ac, TRUE, previous);
if (found) {
return found;
}

found = autocomplete_param_with_ac(input, "/omemo", omemo_ac, TRUE, previous);
if (found) {
return found;
}

return NULL;
}

static char*
_plugins_autocomplete(ProfWin *window, const char *const input, gboolean previous)
{
Expand Down
51 changes: 48 additions & 3 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ static struct cmd_t command_defs[] =
CMD_MAINFUNC(cmd_prefs)
CMD_NOTAGS
CMD_SYN(
"/prefs [ui|desktop|chat|log|conn|presence|otr|pgp]")
"/prefs [ui|desktop|chat|log|conn|presence|otr|pgp|omemo]")
CMD_DESC(
"Show preferences for different areas of functionality. "
"Passing no arguments shows all preferences.")
Expand All @@ -2146,7 +2146,8 @@ static struct cmd_t command_defs[] =
{ "conn", "Connection handling preferences." },
{ "presence", "Chat presence preferences." },
{ "otr", "Off The Record preferences." },
{ "pgp", "OpenPGP preferences." })
{ "pgp", "OpenPGP preferences." },
{ "omemo", "OMEMO preferences." })
CMD_NOEXAMPLES
},

Expand Down Expand Up @@ -2328,7 +2329,51 @@ static struct cmd_t command_defs[] =
CMD_EXAMPLES(
"/cmd list",
"/cmd exec ping")
}
},

{ "/omemo",
parse_args, 1, 3, NULL,
CMD_SUBFUNCS(
{ "gen", cmd_omemo_gen },
{ "log", cmd_omemo_log },
{ "start", cmd_omemo_start },
{ "end", cmd_omemo_end },
{ "trust", cmd_omemo_trust },
{ "untrust", cmd_omemo_untrust },
{ "fingerprint", cmd_omemo_fingerprint },
{ "char", cmd_omemo_char },
{ "clear_device_list", cmd_omemo_clear_device_list })
CMD_NOMAINFUNC
CMD_TAGS(
CMD_TAG_CHAT,
CMD_TAG_UI)
CMD_SYN(
"/omemo gen",
"/omemo log on|off|redact",
"/omemo start [<contact>]",
"/omemo trust [<contact>] <fingerprint>",
"/omemo end",
"/omemo fingerprint [<contact>]",
"/omemo char <char>",
"/omemo clear_device_list")
CMD_DESC(
"OMEMO commands to manage keys, and perform encryption during chat sessions.")
CMD_ARGS(
{ "gen", "Generate OMEMO crytographic materials for current account." },
{ "start [<contact>]", "Start an OMEMO session with contact, or current recipient if omitted." },
{ "end", "End the current OMEMO session." },
{ "log on|off", "Enable or disable plaintext logging of OMEMO encrypted messages." },
{ "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." },
{ "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."})
CMD_EXAMPLES(
"/omemo gen",
"/omemo start buddy@buddychat.org",
"/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo untrust buddy@buddychat.org c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo char *")
},
};

static GHashTable *search_index;
Expand Down
Loading