diff options
Diffstat (limited to 'src')
5 files changed, 16 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java index 0fa79ff8f..04d56626d 100644 --- a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java +++ b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java @@ -118,7 +118,7 @@ public class HttpUploadConnection implements Transferable { if (method == Method.P1_S3) { try { - md5 = Checksum.md5(AbstractConnectionManager.upgrade(file, new FileInputStream(file), true)); + md5 = Checksum.md5(AbstractConnectionManager.upgrade(file, new FileInputStream(file))); } catch (Exception e) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to calculate md5()", e); fail(e.getMessage()); @@ -183,7 +183,7 @@ public class HttpUploadConnection implements Transferable { connection.setConnectTimeout(Config.SOCKET_TIMEOUT * 1000); connection.setReadTimeout(readTimeout); connection.connect(); - final InputStream innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream, true); + final InputStream innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream); os = connection.getOutputStream(); transmitted = 0; int count; diff --git a/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java b/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java index 4b2239895..3399b7861 100644 --- a/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java +++ b/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java @@ -39,20 +39,13 @@ public class AbstractConnectionManager { this.mXmppConnectionService = service; } - public static InputStream upgrade(DownloadableFile file, InputStream is, boolean gcm) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, NoSuchProviderException { + public static InputStream upgrade(DownloadableFile file, InputStream is) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, NoSuchProviderException { if (file.getKey() != null && file.getIv() != null) { - if (gcm) { - final Cipher cipher = Compatibility.twentyEight() ? 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 CipherInputStream(is, cipher); - } else { - IvParameterSpec ips = new IvParameterSpec(file.getIv()); - final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(file.getKey(), KEYTYPE), ips); - return new CipherInputStream(is, cipher); - } + final Cipher cipher = Compatibility.twentyEight() ? 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 CipherInputStream(is, cipher); } else { return is; } @@ -63,6 +56,10 @@ public class AbstractConnectionManager { return createOutputStream(file, false, true); } + public static OutputStream createOutputStream(DownloadableFile file) { + return createOutputStream(file, false); + } + public static OutputStream createOutputStream(DownloadableFile file, boolean gcm) { return createOutputStream(file, gcm, false); } diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java index e97b7f478..8e005cc60 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java @@ -204,7 +204,7 @@ public class JingleConnection implements Transferable { } this.file.getParentFile().mkdirs(); this.file.createNewFile(); - this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file, message.getEncryption() == Message.ENCRYPTION_AXOLOTL); + this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file); return this.mFileOutputStream; } @@ -648,7 +648,7 @@ public class JingleConnection implements Transferable { private boolean receiveAccept(JinglePacket packet) { if (this.mJingleStatus != JINGLE_STATUS_INITIATED) { - Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received out of order session-accept"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received out of order session-accept"); return false; } this.mJingleStatus = JINGLE_STATUS_ACCEPTED; diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java index aadfe0370..f3e7cc814 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java @@ -129,7 +129,7 @@ public class JingleInbandTransport extends JingleTransport { callback.onFileTransferAborted(); return; } - innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream, false); + innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream); if (this.connected) { this.sendNextBlock(); } diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java index 35498664f..15b811bf7 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java @@ -95,7 +95,7 @@ public class JingleSocks5Transport extends JingleTransport { callback.onFileTransferAborted(); return; } - final InputStream innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream, false); + final InputStream innerInputStream = AbstractConnectionManager.upgrade(file, fileInputStream); long size = file.getExpectedSize(); long transmitted = 0; int count; |