Encrypt files for HTTP upload in encrypted chats

This commit is contained in:
Andreas Straub 2015-07-19 14:17:25 +02:00
parent 6f67469bda
commit ec0aff4ed7
2 changed files with 7 additions and 3 deletions

View file

@ -70,7 +70,8 @@ public class HttpDownloadConnection implements Transferable {
String secondToLast = parts.length >= 2 ? parts[parts.length -2] : null;
if ("pgp".equals(lastPart) || "gpg".equals(lastPart)) {
this.message.setEncryption(Message.ENCRYPTION_PGP);
} else if (message.getEncryption() != Message.ENCRYPTION_OTR) {
} else if (message.getEncryption() != Message.ENCRYPTION_OTR
&& message.getEncryption() != Message.ENCRYPTION_AXOLOTL) {
this.message.setEncryption(Message.ENCRYPTION_NONE);
}
String extension;
@ -86,7 +87,8 @@ public class HttpDownloadConnection implements Transferable {
this.file.setKey(CryptoHelper.hexToBytes(reference));
}
if (this.message.getEncryption() == Message.ENCRYPTION_OTR
if ((this.message.getEncryption() == Message.ENCRYPTION_OTR
|| this.message.getEncryption() == Message.ENCRYPTION_AXOLOTL)
&& this.file.getKey() == null) {
this.message.setEncryption(Message.ENCRYPTION_NONE);
}

View file

@ -88,7 +88,9 @@ public class HttpUploadConnection implements Transferable {
this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
this.file.setExpectedSize(this.file.getSize());
if (Config.ENCRYPT_ON_HTTP_UPLOADED) {
if (Config.ENCRYPT_ON_HTTP_UPLOADED
|| message.getEncryption() == Message.ENCRYPTION_AXOLOTL
|| message.getEncryption() == Message.ENCRYPTION_OTR) {
this.key = new byte[48];
mXmppConnectionService.getRNG().nextBytes(this.key);
this.file.setKey(this.key);