aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-06-29 02:04:58 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-06-29 15:21:41 +0200
commitfdd46f1c913e9ca7e23643ed58b67900d7659a5d (patch)
treeafe73379e696f757ebd23e9fb3b0cbf72f5f7ac9 /src/main/java/eu/siacs
parent82714dedfe33651eff587e6fb0d2dc0fc4a5d3b8 (diff)
added trigger to Config.java to always enable aes encryption for uploaded files
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java2
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java13
2 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java
index 779cbbe8..f6ff00cf 100644
--- a/src/main/java/eu/siacs/conversations/Config.java
+++ b/src/main/java/eu/siacs/conversations/Config.java
@@ -32,6 +32,8 @@ public final class Config {
public static final boolean EXTENDED_SM_LOGGING = true; // log stanza counts
public static final boolean RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE = true; //setting to true might increase power consumption
+ public static final boolean ENCRYPT_ON_HTTP_UPLOADED = true;
+
public static final long MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000;
public static final long MAM_MAX_CATCHUP = MILLISECONDS_IN_DAY / 2;
public static final int MAM_MAX_MESSAGES = 500;
diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
index 32e8cdff..25d8d6fa 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
@@ -16,6 +16,7 @@ import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.services.XmppConnectionService;
+import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.Xmlns;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
@@ -34,6 +35,8 @@ public class HttpUploadConnection implements Downloadable {
private URL mGetUrl;
private URL mPutUrl;
+ private byte[] key = null;
+
private long transmitted = 0;
private long expected = 1;
@@ -80,6 +83,13 @@ public class HttpUploadConnection implements Downloadable {
this.account = message.getConversation().getAccount();
this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
this.file.setExpectedSize(this.file.getSize());
+
+ if (Config.ENCRYPT_ON_HTTP_UPLOADED) {
+ this.key = new byte[48];
+ mXmppConnectionService.getRNG().nextBytes(this.key);
+ this.file.setKey(this.key);
+ }
+
Jid host = account.getXmppConnection().findDiscoItemByFeature(Xmlns.HTTP_UPLOAD);
IqPacket request = mXmppConnectionService.getIqGenerator().requestHttpUploadSlot(host,file);
mXmppConnectionService.sendIqPacket(account, request, new OnIqPacketReceived() {
@@ -143,6 +153,9 @@ public class HttpUploadConnection implements Downloadable {
if (code == 200) {
Log.d(Config.LOGTAG, "finished uploading file");
Message.ImageParams params = message.getImageParams();
+ if (key != null) {
+ mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key));
+ }
message.setBody(mGetUrl.toString()+"|"+String.valueOf(params.size)+"|"+String.valueOf(params.width)+"|"+String.valueOf(params.height));
message.setDownloadable(null);
message.setCounterpart(message.getConversation().getJid().toBareJid());