From cc7b0aa7bd5b6599159f654fdd8a2fd111e16a3e Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 7 Mar 2019 20:17:56 +0100 Subject: Move GCM tag into per-device-encrypted area to be compatible with current OMEMO version, fixes #514 --- plugins/omemo/src/trust_manager.vala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'plugins/omemo') diff --git a/plugins/omemo/src/trust_manager.vala b/plugins/omemo/src/trust_manager.vala index cd0971f8..4ec141f0 100644 --- a/plugins/omemo/src/trust_manager.vala +++ b/plugins/omemo/src/trust_manager.vala @@ -99,7 +99,12 @@ public class TrustManager { uint8[] iv = new uint8[16]; Plugin.get_context().randomize(iv); - uint8[] ciphertext = aes_encrypt(Cipher.AES_GCM_NOPADDING, key, iv, message.body.data); + uint8[] aes_encrypt_result = aes_encrypt(Cipher.AES_GCM_NOPADDING, key, iv, message.body.data); + uint8[] ciphertext = aes_encrypt_result[0:aes_encrypt_result.length-16]; + uint8[] tag = aes_encrypt_result[aes_encrypt_result.length-16:aes_encrypt_result.length]; + uint8[] keytag = new uint8[key.length + tag.length]; + Memory.copy(keytag, key, key.length); + Memory.copy((uint8*)keytag + key.length, tag, tag.length); StanzaNode header; StanzaNode encrypted = new StanzaNode.build("encrypted", NS_URI).add_self_xmlns() @@ -121,7 +126,7 @@ public class TrustManager { try { address.name = recipient.bare_jid.to_string(); address.device_id = (int) device_id; - StanzaNode key_node = create_encrypted_key(key, address, module.store); + StanzaNode key_node = create_encrypted_key(keytag, address, module.store); header.put_node(key_node); status.other_success++; } catch (Error e) { @@ -139,7 +144,7 @@ public class TrustManager { if (device_id != module.store.local_registration_id) { address.device_id = (int) device_id; try { - StanzaNode key_node = create_encrypted_key(key, address, module.store); + StanzaNode key_node = create_encrypted_key(keytag, address, module.store); header.put_node(key_node); status.own_success++; } catch (Error e) { -- cgit v1.2.3-70-g09d2