aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities/DownloadableFile.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-08-13 23:11:47 +0200
committerChristian Schneppe <christian@pix-art.de>2017-08-13 23:11:47 +0200
commit24c47c0bbb56f7e0d14b9555cb99b8e683cc2652 (patch)
treeb4f679d85e2dbeb78bda960ad4536290603f3cc4 /src/main/java/de/pixart/messenger/entities/DownloadableFile.java
parentd31dd9cbe497f23e44ef92d09c5b13446f4c856f (diff)
Read support for 12-byte IVs in addition to 16-byte IVs
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities/DownloadableFile.java')
-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);