removed unused code (otr jingle encrypted file transfer)

This commit is contained in:
Daniel Gultsch 2018-09-30 13:48:11 +02:00
parent 653cb152e2
commit 1cbb60d7ed
4 changed files with 16 additions and 25 deletions

View File

@ -405,7 +405,7 @@ public class HttpDownloadConnection implements Transferable {
if (!file.exists() && !file.createNewFile()) { if (!file.exists() && !file.createNewFile()) {
throw new FileWriterException(); throw new FileWriterException();
} }
os = AbstractConnectionManager.createOutputStream(file, true); os = AbstractConnectionManager.createOutputStream(file);
} }
int count; int count;
byte[] buffer = new byte[4096]; byte[] buffer = new byte[4096];

View File

@ -66,14 +66,14 @@ public class AbstractConnectionManager {
} }
public static OutputStream createAppendedOutputStream(DownloadableFile file) { public static OutputStream createAppendedOutputStream(DownloadableFile file) {
return createOutputStream(file, false, true); return createOutputStream(file, true);
} }
public static OutputStream createOutputStream(DownloadableFile file, boolean gcm) { public static OutputStream createOutputStream(DownloadableFile file) {
return createOutputStream(file, gcm, false); return createOutputStream(file, false);
} }
private static OutputStream createOutputStream(DownloadableFile file, boolean gcm, boolean append) { private static OutputStream createOutputStream(DownloadableFile file, boolean append) {
FileOutputStream os; FileOutputStream os;
try { try {
os = new FileOutputStream(file, append); os = new FileOutputStream(file, append);
@ -84,20 +84,13 @@ public class AbstractConnectionManager {
return null; return null;
} }
try { try {
if (gcm) { Cipher cipher = Cipher.getInstance(CIPHERMODE);
Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE); SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE);
IvParameterSpec ivSpec = new IvParameterSpec(file.getIv()); IvParameterSpec ivSpec = new IvParameterSpec(file.getIv());
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
return new CipherOutputStream(os, cipher); return new CipherOutputStream(os, cipher);
} else {
IvParameterSpec ips = new IvParameterSpec(file.getIv());
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(file.getKey(), KEYTYPE), ips);
return new CipherOutputStream(os, cipher);
}
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError(e); return null;
} }
} }

View File

@ -151,18 +151,18 @@ public class JingleConnection implements Transferable {
} }
}; };
public InputStream getFileInputStream() { InputStream getFileInputStream() {
return this.mFileInputStream; return this.mFileInputStream;
} }
public OutputStream getFileOutputStream() throws IOException { OutputStream getFileOutputStream() throws IOException {
if (this.file == null) { if (this.file == null) {
Log.d(Config.LOGTAG,"file object was not assigned"); Log.d(Config.LOGTAG,"file object was not assigned");
return null; return null;
} }
this.file.getParentFile().mkdirs(); this.file.getParentFile().mkdirs();
this.file.createNewFile(); this.file.createNewFile();
this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file,message.getEncryption() == Message.ENCRYPTION_AXOLOTL); this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file);
return this.mFileOutputStream; return this.mFileOutputStream;
} }

View File

@ -94,8 +94,7 @@ public class JingleInbandTransport extends JingleTransport {
} }
@Override @Override
public void receive(DownloadableFile file, public void receive(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
OnFileTransmissionStatusChanged callback) {
this.onFileTransmissionStatusChanged = callback; this.onFileTransmissionStatusChanged = callback;
this.file = file; this.file = file;
try { try {
@ -115,8 +114,7 @@ public class JingleInbandTransport extends JingleTransport {
} }
@Override @Override
public void send(DownloadableFile file, public void send(DownloadableFile file, OnFileTransmissionStatusChanged callback) {
OnFileTransmissionStatusChanged callback) {
this.onFileTransmissionStatusChanged = callback; this.onFileTransmissionStatusChanged = callback;
this.file = file; this.file = file;
try { try {