report wrong file size in otr encrypted jingle file transfers to be compatible with conversations > 1.6

This commit is contained in:
Daniel Gultsch 2015-08-10 12:55:37 +02:00
parent b5e90850d8
commit d30515a85a
3 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -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<InputStream,Integer>(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<InputStream,Integer>(new CipherInputStream(is, cipher),s);
}
} catch (InvalidKeyException e) {
return null;

View File

@ -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();