diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-06-29 02:04:58 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-06-29 15:21:41 +0200 |
commit | fdd46f1c913e9ca7e23643ed58b67900d7659a5d (patch) | |
tree | afe73379e696f757ebd23e9fb3b0cbf72f5f7ac9 /src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java | |
parent | 82714dedfe33651eff587e6fb0d2dc0fc4a5d3b8 (diff) |
added trigger to Config.java to always enable aes encryption for uploaded files
Diffstat (limited to 'src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java | 13 |
1 files changed, 13 insertions, 0 deletions
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()); |