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

Send and retrieve encrypted files when using OMEMO #1375

Merged
merged 31 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3370418
Initial /sendfile OMEMO encryption
wstrm Jun 11, 2020
39c3290
Refactor to use file stream
wstrm Jun 27, 2020
e9d5875
Reformat HTTP get URL to AESGCM scheme
wstrm Jun 27, 2020
d5b1dc0
Move setup for AESGCM to omemo/crypto
wstrm Jun 28, 2020
fc6136d
Remove unused #define's and move URL scheme define to omemo/crypto.h
wstrm Jun 28, 2020
e98644f
Add guards for OMEMO
wstrm Jun 28, 2020
f4ab1ca
Move file encryption function to public header
wstrm Jun 28, 2020
9d58472
Remove /omemo sendfile
wstrm Jun 28, 2020
04bfa23
Remove temporary ciphertext file when finished
wstrm Jun 28, 2020
362c697
Wording
wstrm Jun 28, 2020
9499df6
Add http_download tool
wstrm Jul 2, 2020
eebf54c
Infer filename from content-disposition or URL
wstrm Jul 5, 2020
a0cf084
Remove unsafe Conent-Disposition inferring
wstrm Jul 5, 2020
4711fc6
Run make format on rebase
wstrm Jul 20, 2020
fb002a5
Use fallback method when /executable urlsave is unset
wstrm Jul 20, 2020
73f313b
Refactor OMEMO download into AESGCMDownload tool
wstrm Jul 20, 2020
62cbad1
Add I/O error handling and use filenames instead of file descriptors
wstrm Jul 21, 2020
7a1eb73
Explicitly clear fragment from HTTP URL
wstrm Jul 21, 2020
3d344cf
Move common http tool code to http_common
wstrm Jul 21, 2020
ab83afe
Switch to g_strerror
wstrm Jul 21, 2020
be62b44
Add stubs
wstrm Jul 21, 2020
1bb6cec
Fix stubs and move some tests to http_common
wstrm Jul 21, 2020
3a6597e
Refactor for threaded external executable for built-in download methods
wstrm Dec 3, 2020
1d2c0a8
Move unique_filename_from_url functions to common
wstrm Dec 4, 2020
ac03037
Rework url to filename
wstrm Dec 6, 2020
4a1c118
Fix bad order of parameters for url save
wstrm Dec 7, 2020
867d895
Add tests for format_call_external_argv
wstrm Dec 7, 2020
5c5b4d7
Remove cmd_tiny, empty files and link nonce with IV
wstrm Dec 7, 2020
332dc87
Fix wrong order of arguments for _url_http_method
wstrm Dec 7, 2020
7f0165a
Fix segfault for urlopen[1]
wstrm Dec 7, 2020
d7848e3
Remove scheme and filetype matching for url (save|open)
wstrm Dec 8, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ breaks

*.tar.*
*.zip
*.log*
12 changes: 11 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ core_sources = \
src/command/cmd_ac.h src/command/cmd_ac.c \
src/tools/parser.c \
src/tools/parser.h \
src/tools/http_common.c \
src/tools/http_common.h \
src/tools/http_upload.c \
src/tools/http_upload.h \
src/tools/http_download.c \
src/tools/http_download.h \
src/tools/bookmark_ignore.c \
src/tools/bookmark_ignore.h \
src/tools/autocomplete.c src/tools/autocomplete.h \
Expand Down Expand Up @@ -89,6 +93,8 @@ unittest_sources = \
src/tools/clipboard.c src/tools/clipboard.h \
src/tools/bookmark_ignore.c \
src/tools/bookmark_ignore.h \
src/tools/http_download.c \
src/tools/http_download.h \
src/config/accounts.h \
src/config/account.c src/config/account.h \
src/config/files.c src/config/files.h \
Expand Down Expand Up @@ -119,6 +125,8 @@ unittest_sources = \
tests/unittests/database/stub_database.c \
tests/unittests/config/stub_accounts.c \
tests/unittests/tools/stub_http_upload.c \
tests/unittests/tools/stub_http_download.c \
tests/unittests/tools/stub_aesgcm_download.c \
tests/unittests/helpers.c tests/unittests/helpers.h \
tests/unittests/test_form.c tests/unittests/test_form.h \
tests/unittests/test_common.c tests/unittests/test_common.h \
Expand All @@ -145,6 +153,7 @@ unittest_sources = \
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \
tests/unittests/test_callbacks.c tests/unittests/test_callbacks.h \
tests/unittests/test_plugins_disco.c tests/unittests/test_plugins_disco.h \
tests/unittests/test_http_common.c tests/unittests/test_http_common.h \
tests/unittests/unittests.c

functionaltest_sources = \
Expand Down Expand Up @@ -189,7 +198,8 @@ otr4_sources = \

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
src/omemo/store.h src/omemo/store.c src/xmpp/omemo.h src/xmpp/omemo.c \
src/tools/aesgcm_download.h src/tools/aesgcm_download.c

omemo_unittest_sources = \
tests/unittests/omemo/stub_omemo.c
Expand Down
13 changes: 0 additions & 13 deletions src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ static Autocomplete otr_sendfile_ac;
static Autocomplete omemo_ac;
static Autocomplete omemo_log_ac;
static Autocomplete omemo_policy_ac;
static Autocomplete omemo_sendfile_ac;
#endif
static Autocomplete connect_property_ac;
static Autocomplete tls_property_ac;
Expand Down Expand Up @@ -683,7 +682,6 @@ cmd_ac_init(void)
autocomplete_add(omemo_ac, "clear_device_list");
autocomplete_add(omemo_ac, "policy");
autocomplete_add(omemo_ac, "char");
autocomplete_add(omemo_ac, "sendfile");

omemo_log_ac = autocomplete_new();
autocomplete_add(omemo_log_ac, "on");
Expand All @@ -694,10 +692,6 @@ cmd_ac_init(void)
autocomplete_add(omemo_policy_ac, "manual");
autocomplete_add(omemo_policy_ac, "automatic");
autocomplete_add(omemo_policy_ac, "always");

omemo_sendfile_ac = autocomplete_new();
autocomplete_add(omemo_sendfile_ac, "on");
autocomplete_add(omemo_sendfile_ac, "off");
#endif

connect_property_ac = autocomplete_new();
Expand Down Expand Up @@ -1292,7 +1286,6 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(omemo_ac);
autocomplete_reset(omemo_log_ac);
autocomplete_reset(omemo_policy_ac);
autocomplete_reset(omemo_sendfile_ac);
#endif
autocomplete_reset(connect_property_ac);
autocomplete_reset(tls_property_ac);
Expand Down Expand Up @@ -1450,7 +1443,6 @@ cmd_ac_uninit(void)
autocomplete_free(omemo_ac);
autocomplete_free(omemo_log_ac);
autocomplete_free(omemo_policy_ac);
autocomplete_free(omemo_sendfile_ac);
#endif
autocomplete_free(connect_property_ac);
autocomplete_free(tls_property_ac);
Expand Down Expand Up @@ -2510,11 +2502,6 @@ _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous)
return found;
}

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

jabber_conn_status_t conn_status = connection_get_status();

if (conn_status == JABBER_CONNECTED) {
Expand Down
95 changes: 46 additions & 49 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2274,55 +2274,52 @@ static struct cmd_t command_defs[] = {
},

{ "/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 },
{ "policy", cmd_omemo_policy },
{ "clear_device_list", cmd_omemo_clear_device_list },
{ "sendfile", cmd_omemo_sendfile })
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 policy manual|automatic|always",
"/omemo sendfile on|off",
"/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." },
{ "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." },
{ "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OMEMO session." },
{ "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 odin@valhalla.edda",
"/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo untrust loki@valhalla.edda c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo char *")
parse_args, 1, 3, NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation got changed here. I know.. its a bit of a problem because we don't use default here.. :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shouldn't do something here, right? :)

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 },
{ "policy", cmd_omemo_policy },
{ "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 policy manual|automatic|always",
"/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." },
{ "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." },
{ "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 odin@valhalla.edda",
"/omemo trust c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo untrust loki@valhalla.edda c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
"/omemo char *")
},

{ "/save",
Expand Down
Loading