From 9129c9acded99d60b99ab8a86421a0c581889072 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 6 Sep 2019 13:11:37 +0200 Subject: [PATCH] JET uses plain text file size --- src/main/java/eu/siacs/conversations/Config.java | 2 +- .../conversations/xmpp/jingle/JingleConnection.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 75104500e..0b43675ad 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -102,7 +102,7 @@ public final class Config { public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb public static final boolean USE_DIRECT_JINGLE_CANDIDATES = true; - public static final boolean DISABLE_HTTP_UPLOAD = true; + public static final boolean DISABLE_HTTP_UPLOAD = false; public static final boolean EXTENDED_SM_LOGGING = false; // log stanza counts public static final boolean BACKGROUND_STANZA_LOGGING = false; //log all stanzas that were received while the app is in background public static final boolean RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE = true; //setting to true might increase power consumption diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 45539f8f5..919350ec8 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -430,13 +430,16 @@ public class JingleConnection implements Transferable { } this.fileOffer = content.getFileOffer(this.ftVersion); + if (fileOffer != null) { + boolean remoteIsUsingJet = false; Element encrypted = fileOffer.findChild("encrypted", AxolotlService.PEP_PREFIX); if (encrypted == null) { final Element security = content.findChild("security", Namespace.JINGLE_ENCRYPTED_TRANSPORT); if (security != null && AxolotlService.PEP_PREFIX.equals(security.getAttribute("type"))) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received jingle file offer with JET"); encrypted = security.findChild("encrypted", AxolotlService.PEP_PREFIX); + remoteIsUsingJet = true; } } if (encrypted != null) { @@ -479,7 +482,10 @@ public class JingleConnection implements Transferable { } } message.resetFileParams(); - this.file.setExpectedSize(size); + //legacy OMEMO encrypted file transfers reported the file size after encryption + //JET reports the plain text size. however lower levels of our receiving code still + //expect the cipher text size. so we just + 16 bytes (auth tag size) here + this.file.setExpectedSize(size + (remoteIsUsingJet ? 16 : 0)); if (mJingleConnectionManager.hasStoragePermission() && size < this.mJingleConnectionManager.getAutoAcceptFileSize() && mXmppConnectionService.isDataSaverDisabled()) { @@ -528,7 +534,9 @@ public class JingleConnection implements Transferable { if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) { this.file.setKey(mXmppAxolotlMessage.getInnerKey()); this.file.setIv(mXmppAxolotlMessage.getIV()); - this.file.setExpectedSize(file.getSize() + 16); + //legacy OMEMO encrypted file transfer reported file size of the encrypted file + //JET uses the file size of the plain text file. The difference is only 16 bytes (auth tag) + this.file.setExpectedSize(file.getSize() + (this.remoteSupportsOmemoJet ? 0 : 16)); final Element file = content.setFileOffer(this.file, false, this.ftVersion); if (remoteSupportsOmemoJet) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": remote announced support for JET");