aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities/DownloadableFile.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/entities/DownloadableFile.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/DownloadableFile.java b/src/main/java/de/pixart/messenger/entities/DownloadableFile.java
index 94fae97a4..6993b6b38 100644
--- a/src/main/java/de/pixart/messenger/entities/DownloadableFile.java
+++ b/src/main/java/de/pixart/messenger/entities/DownloadableFile.java
@@ -50,11 +50,18 @@ public class DownloadableFile extends File {
}
public void setKeyAndIv(byte[] keyIvCombo) {
+ // originally, we used a 16 byte IV, then found for aes-gcm a 12 byte IV is ideal
+ // this code supports reading either length, with sending 12 byte IV to be done in future
if (keyIvCombo.length == 48) {
this.aeskey = new byte[32];
this.iv = new byte[16];
System.arraycopy(keyIvCombo, 0, this.iv, 0, 16);
System.arraycopy(keyIvCombo, 16, this.aeskey, 0, 32);
+ } else if (keyIvCombo.length == 44) {
+ this.aeskey = new byte[32];
+ this.iv = new byte[12];
+ System.arraycopy(keyIvCombo, 0, this.iv, 0, 12);
+ System.arraycopy(keyIvCombo, 12, this.aeskey, 0, 32);
} else if (keyIvCombo.length >= 32) {
this.aeskey = new byte[32];
System.arraycopy(keyIvCombo, 0, aeskey, 0, 32);