From 6891ca336b64dc00a9f4a964c28b85c492401cb8 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Tue, 25 Jun 2019 11:05:25 +0200 Subject: fix jingle file transfer fixes #360 --- .../services/AbstractConnectionManager.java | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java') 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); } -- cgit v1.2.3