diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index cd64bcda5..0948280e6 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -119,7 +119,7 @@ public class HttpUploadConnection implements Transferable { if (method == Method.P1_S3) { try { - md5 = Checksum.md5(AbstractConnectionManager.createInputStream(file, true).first); + md5 = Checksum.md5(AbstractConnectionManager.createInputStream(file).first); } catch (Exception e) { Log.d(Config.LOGTAG, account.getJid().asBareJid()+": unable to calculate md5()", e); fail(e.getMessage()); @@ -131,7 +131,7 @@ public class HttpUploadConnection implements Transferable { Pair pair; try { - pair = AbstractConnectionManager.createInputStream(file, true); + pair = AbstractConnectionManager.createInputStream(file); } catch (FileNotFoundException e) { Log.d(Config.LOGTAG, account.getJid().asBareJid()+": could not find file to upload - "+e.getMessage()); fail(e.getMessage()); diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java index ae0245ecf..860e91ab7 100644 --- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java @@ -39,7 +39,7 @@ public class AbstractConnectionManager { this.mXmppConnectionService = service; } - public static Pair createInputStream(DownloadableFile file, boolean gcm) throws FileNotFoundException { + public static Pair createInputStream(DownloadableFile file) throws FileNotFoundException { FileInputStream is; int size; is = new FileInputStream(file); @@ -48,18 +48,11 @@ public class AbstractConnectionManager { return new Pair<>(is, size); } try { - if (gcm) { - Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER); - SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE); - IvParameterSpec ivSpec = new IvParameterSpec(file.getIv()); - cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec); - return new Pair<>(new CipherInputStream(is, cipher), cipher.getOutputSize(size)); - } else { - IvParameterSpec ips = new IvParameterSpec(file.getIv()); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(file.getKey(), KEYTYPE), ips); - return new Pair<>(new CipherInputStream(is, cipher), (size / 16 + 1) * 16); - } + Cipher cipher = Cipher.getInstance(CIPHERMODE); + SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE); + IvParameterSpec ivSpec = new IvParameterSpec(file.getIv()); + cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec); + return new Pair<>(new CipherInputStream(is, cipher), cipher.getOutputSize(size)); } catch (Exception e) { throw new AssertionError(e); } 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 5be45db7d..7fb1ee4e4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -476,11 +476,11 @@ public class JingleConnection implements Transferable { if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) { this.file.setKey(mXmppAxolotlMessage.getInnerKey()); this.file.setIv(mXmppAxolotlMessage.getIV()); - pair = AbstractConnectionManager.createInputStream(this.file, true); + pair = AbstractConnectionManager.createInputStream(this.file); this.file.setExpectedSize(pair.second); content.setFileOffer(this.file, false, this.ftVersion).addChild(mXmppAxolotlMessage.toElement()); } else { - pair = AbstractConnectionManager.createInputStream(this.file, false); + pair = AbstractConnectionManager.createInputStream(this.file); this.file.setExpectedSize(pair.second); content.setFileOffer(this.file, false, this.ftVersion); }