aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java21
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java2
2 files changed, 8 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java b/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java
index 7414c40c7..19a7341f8 100644
--- a/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java
+++ b/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java
@@ -64,11 +64,11 @@ public class AbstractConnectionManager {
return createOutputStream(file, gcm, false);
}
- private static OutputStream createOutputStream(DownloadableFile file, boolean gcm, boolean append) {
+ public static OutputStream createOutputStream(DownloadableFile file, boolean append, boolean decrypt) {
FileOutputStream os;
try {
os = new FileOutputStream(file, append);
- if (file.getKey() == null) {
+ if (file.getKey() == null || !decrypt) {
return os;
}
} catch (FileNotFoundException e) {
@@ -76,18 +76,11 @@ public class AbstractConnectionManager {
return null;
}
try {
- 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.DECRYPT_MODE, keySpec, ivSpec);
- return new CipherOutputStream(os, cipher);
- } else {
- IvParameterSpec ips = new IvParameterSpec(file.getIv());
- final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
- cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(file.getKey(), KEYTYPE), ips);
- return new CipherOutputStream(os, 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.DECRYPT_MODE, keySpec, ivSpec);
+ return new CipherOutputStream(os, cipher);
} catch (Exception e) {
Log.d(Config.LOGTAG, "unable to create cipher output stream", e);
return null;
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 2d9abc562..478c8c992 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
@@ -215,7 +215,7 @@ public class JingleConnection implements Transferable {
}
this.file.getParentFile().mkdirs();
this.file.createNewFile();
- this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file);
+ this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file, false, true);
return this.mFileOutputStream;
}