From d30515a85acaedb57d0d4308aeb72d96074f729a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 10 Aug 2015 12:55:37 +0200 Subject: report wrong file size in otr encrypted jingle file transfers to be compatible with conversations > 1.6 --- src/main/java/eu/siacs/conversations/Config.java | 2 ++ .../siacs/conversations/services/AbstractConnectionManager.java | 3 ++- .../java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index d1cb3cc1..f3cbffe6 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -42,6 +42,8 @@ public final class Config { public static final boolean ENCRYPT_ON_HTTP_UPLOADED = false; + public static final boolean REPORT_WRONG_FILESIZE_IN_OTR_JINGLE = true; + public static final boolean SHOW_REGENERATE_AXOLOTL_KEYS_BUTTON = false; public static final long MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000; diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java index b7e7c8d3..dbd7f376 100644 --- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java @@ -72,7 +72,8 @@ public class AbstractConnectionManager { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(file.getKey(), "AES"), ips); Log.d(Config.LOGTAG, "opening encrypted input stream"); - return new Pair(new CipherInputStream(is, cipher),(size / 16 + 1) * 16); + final int s = Config.REPORT_WRONG_FILESIZE_IN_OTR_JINGLE ? size : (size / 16 + 1) * 16; + return new Pair(new CipherInputStream(is, cipher),s); } } catch (InvalidKeyException e) { return null; 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 29aafcce..d074bf9c 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -272,7 +272,7 @@ public class JingleConnection implements Transferable { }); mergeCandidate(candidate); } else { - Log.d(Config.LOGTAG,"no primary candidate of our own was found"); + Log.d(Config.LOGTAG, "no primary candidate of our own was found"); sendInitRequest(); } } @@ -391,7 +391,11 @@ public class JingleConnection implements Transferable { } } this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file,message.getEncryption() == Message.ENCRYPTION_AXOLOTL); - this.file.setExpectedSize(size); + if (message.getEncryption() == Message.ENCRYPTION_OTR && Config.REPORT_WRONG_FILESIZE_IN_OTR_JINGLE) { + this.file.setExpectedSize((size / 16 + 1) * 16); + } else { + this.file.setExpectedSize(size); + } Log.d(Config.LOGTAG, "receiving file: expecting size of " + this.file.getExpectedSize()); } else { this.sendCancel(); -- cgit v1.2.3