aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/logic
diff options
context:
space:
mode:
authoreerielili <lionel@les-miquelots.net>2024-08-25 13:32:38 +0000
committerGitHub <noreply@github.com>2024-08-25 13:32:38 +0000
commit45755727db79a2935376d24e7bde7eadb0f2f7ca (patch)
tree73715da99c9d980079df6f2d561822364655e04d /plugins/omemo/src/logic
parent62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72 (diff)
parent51252f74c94c17d56aa75534652bdc5d43a504cb (diff)
downloaddino-45755727db79a2935376d24e7bde7eadb0f2f7ca.tar.gz
dino-45755727db79a2935376d24e7bde7eadb0f2f7ca.zip
Merge branch 'master' into add-yourselfadd-yourself
Diffstat (limited to 'plugins/omemo/src/logic')
-rw-r--r--plugins/omemo/src/logic/decrypt.vala13
-rw-r--r--plugins/omemo/src/logic/manager.vala7
2 files changed, 13 insertions, 7 deletions
diff --git a/plugins/omemo/src/logic/decrypt.vala b/plugins/omemo/src/logic/decrypt.vala
index 561e557b..04339c93 100644
--- a/plugins/omemo/src/logic/decrypt.vala
+++ b/plugins/omemo/src/logic/decrypt.vala
@@ -28,9 +28,6 @@ namespace Dino.Plugins.Omemo {
StanzaNode? encrypted_node = stanza.stanza.get_subnode("encrypted", NS_URI);
if (encrypted_node == null || MessageFlag.get_flag(stanza) != null || stanza.from == null) return false;
- if (message.body == null && Xep.ExplicitEncryption.get_encryption_tag(stanza) == NS_URI) {
- message.body = "[This message is OMEMO encrypted]"; // TODO temporary
- }
if (!Plugin.ensure_context()) return false;
int identity_id = db.identity.get_id(conversation.account.id);
@@ -38,7 +35,7 @@ namespace Dino.Plugins.Omemo {
stanza.add_flag(flag);
Xep.Omemo.ParsedData? data = parse_node(encrypted_node);
- if (data == null || data.ciphertext == null) return false;
+ if (data == null) return false;
foreach (Bytes encr_key in data.our_potential_encrypted_keys.keys) {
@@ -52,14 +49,16 @@ namespace Dino.Plugins.Omemo {
foreach (Jid possible_jid in possible_jids) {
try {
uint8[] key = decrypt_key(data, possible_jid);
- string cleartext = arr_to_str(aes_decrypt(Cipher.AES_GCM_NOPADDING, key, data.iv, data.ciphertext));
+ if (data.ciphertext != null) {
+ string cleartext = arr_to_str(aes_decrypt(Cipher.AES_GCM_NOPADDING, key, data.iv, data.ciphertext));
+ message.body = cleartext;
+ }
// If we figured out which real jid a message comes from due to decryption working, save it
if (conversation.type_ == Conversation.Type.GROUPCHAT && message.real_jid == null) {
message.real_jid = possible_jid;
}
- message.body = cleartext;
message.encryption = Encryption.OMEMO;
trust_manager.message_device_id_map[message] = data.sid;
@@ -71,7 +70,7 @@ namespace Dino.Plugins.Omemo {
}
if (
- encrypted_node.get_deep_string_content("payload") != null && // Ratchet forwarding doesn't contain payload and might not include us, which is ok
+ data.ciphertext != null && // Ratchet forwarding doesn't contain payload and might not include us, which is ok
data.our_potential_encrypted_keys.size == 0 && // The message was not encrypted to us
stream_interactor.module_manager.get_module(message.account, StreamModule.IDENTITY).store.local_registration_id != data.sid // Message from this device. Never encrypted to itself.
) {
diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala
index 5552e212..ba02bab5 100644
--- a/plugins/omemo/src/logic/manager.vala
+++ b/plugins/omemo/src/logic/manager.vala
@@ -66,6 +66,7 @@ public class Manager : StreamInteractionModule, Object {
this.trust_manager = trust_manager;
this.encryptors = encryptors;
+ stream_interactor.account_added.connect(on_account_added);
stream_interactor.stream_negotiated.connect(on_stream_negotiated);
stream_interactor.get_module(MessageProcessor.IDENTITY).pre_message_send.connect(on_pre_message_send);
stream_interactor.get_module(RosterManager.IDENTITY).mutual_subscription.connect(on_mutual_subscription);
@@ -182,6 +183,12 @@ public class Manager : StreamInteractionModule, Object {
StreamModule module = stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY);
if (module != null) {
module.request_user_devicelist.begin(stream, account.bare_jid);
+ }
+ }
+
+ private void on_account_added(Account account) {
+ StreamModule module = stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY);
+ if (module != null) {
module.device_list_loaded.connect((jid, devices) => on_device_list_loaded(account, jid, devices));
module.bundle_fetched.connect((jid, device_id, bundle) => on_bundle_fetched(account, jid, device_id, bundle));
module.bundle_fetch_failed.connect((jid) => continue_message_sending(account, jid));