Move GCM tag into per-device-encrypted area to be compatible with current OMEMO version, fixes #514

This commit is contained in:
Marvin W 2019-03-07 20:17:56 +01:00
parent 6de86c2733
commit cc7b0aa7bd
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -99,7 +99,12 @@ public class TrustManager {
uint8[] iv = new uint8[16]; uint8[] iv = new uint8[16];
Plugin.get_context().randomize(iv); 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 header;
StanzaNode encrypted = new StanzaNode.build("encrypted", NS_URI).add_self_xmlns() StanzaNode encrypted = new StanzaNode.build("encrypted", NS_URI).add_self_xmlns()
@ -121,7 +126,7 @@ public class TrustManager {
try { try {
address.name = recipient.bare_jid.to_string(); address.name = recipient.bare_jid.to_string();
address.device_id = (int) device_id; 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); header.put_node(key_node);
status.other_success++; status.other_success++;
} catch (Error e) { } catch (Error e) {
@ -139,7 +144,7 @@ public class TrustManager {
if (device_id != module.store.local_registration_id) { if (device_id != module.store.local_registration_id) {
address.device_id = (int) device_id; address.device_id = (int) device_id;
try { 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); header.put_node(key_node);
status.own_success++; status.own_success++;
} catch (Error e) { } catch (Error e) {