mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 11:42:15 -05:00
added trigger to Config.java to always enable aes encryption for uploaded files
This commit is contained in:
parent
82714dedfe
commit
fdd46f1c91
@ -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;
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user