remove more legacy otr decryption code
This commit is contained in:
parent
7fa8811f64
commit
9ca636589c
|
@ -119,7 +119,7 @@ public class HttpUploadConnection implements Transferable {
|
||||||
|
|
||||||
if (method == Method.P1_S3) {
|
if (method == Method.P1_S3) {
|
||||||
try {
|
try {
|
||||||
md5 = Checksum.md5(AbstractConnectionManager.createInputStream(file, true).first);
|
md5 = Checksum.md5(AbstractConnectionManager.createInputStream(file).first);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": unable to calculate md5()", e);
|
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": unable to calculate md5()", e);
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
|
@ -131,7 +131,7 @@ public class HttpUploadConnection implements Transferable {
|
||||||
|
|
||||||
Pair<InputStream,Integer> pair;
|
Pair<InputStream,Integer> pair;
|
||||||
try {
|
try {
|
||||||
pair = AbstractConnectionManager.createInputStream(file, true);
|
pair = AbstractConnectionManager.createInputStream(file);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": could not find file to upload - "+e.getMessage());
|
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": could not find file to upload - "+e.getMessage());
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class AbstractConnectionManager {
|
||||||
this.mXmppConnectionService = service;
|
this.mXmppConnectionService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<InputStream, Integer> createInputStream(DownloadableFile file, boolean gcm) throws FileNotFoundException {
|
public static Pair<InputStream, Integer> createInputStream(DownloadableFile file) throws FileNotFoundException {
|
||||||
FileInputStream is;
|
FileInputStream is;
|
||||||
int size;
|
int size;
|
||||||
is = new FileInputStream(file);
|
is = new FileInputStream(file);
|
||||||
|
@ -48,18 +48,11 @@ public class AbstractConnectionManager {
|
||||||
return new Pair<>(is, size);
|
return new Pair<>(is, size);
|
||||||
}
|
}
|
||||||
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.ENCRYPT_MODE, keySpec, ivSpec);
|
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
|
||||||
return new Pair<>(new CipherInputStream(is, cipher), cipher.getOutputSize(size));
|
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);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,11 +476,11 @@ public class JingleConnection implements Transferable {
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
||||||
this.file.setKey(mXmppAxolotlMessage.getInnerKey());
|
this.file.setKey(mXmppAxolotlMessage.getInnerKey());
|
||||||
this.file.setIv(mXmppAxolotlMessage.getIV());
|
this.file.setIv(mXmppAxolotlMessage.getIV());
|
||||||
pair = AbstractConnectionManager.createInputStream(this.file, true);
|
pair = AbstractConnectionManager.createInputStream(this.file);
|
||||||
this.file.setExpectedSize(pair.second);
|
this.file.setExpectedSize(pair.second);
|
||||||
content.setFileOffer(this.file, false, this.ftVersion).addChild(mXmppAxolotlMessage.toElement());
|
content.setFileOffer(this.file, false, this.ftVersion).addChild(mXmppAxolotlMessage.toElement());
|
||||||
} else {
|
} else {
|
||||||
pair = AbstractConnectionManager.createInputStream(this.file, false);
|
pair = AbstractConnectionManager.createInputStream(this.file);
|
||||||
this.file.setExpectedSize(pair.second);
|
this.file.setExpectedSize(pair.second);
|
||||||
content.setFileOffer(this.file, false, this.ftVersion);
|
content.setFileOffer(this.file, false, this.ftVersion);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue