From eed9c5340d287a098e95e1709ac06e45953ab1ae Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 20 Oct 2018 14:00:33 +0200 Subject: go back to 16 byte IVs for OMEMO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clients like Dino can’t handle 12 byte IVs --- .../messenger/crypto/axolotl/AxolotlService.java | 2 +- .../crypto/axolotl/XmppAxolotlMessage.java | 24 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java index 9957aa0e0..cc9d85008 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java @@ -550,7 +550,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { } else { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": own device " + session.getFingerprint() + " was active " + hours + " hours ago"); } - } + } //TODO print last activation diff } } return devices; diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java index 1f7df2bba..4b4395e60 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java @@ -27,12 +27,12 @@ import rocks.xmpp.addr.Jid; public class XmppAxolotlMessage { public static final String CONTAINERTAG = "encrypted"; - public static final String HEADER = "header"; - public static final String SOURCEID = "sid"; - public static final String KEYTAG = "key"; - public static final String REMOTEID = "rid"; - public static final String IVTAG = "iv"; - public static final String PAYLOAD = "payload"; + private static final String HEADER = "header"; + private static final String SOURCEID = "sid"; + private static final String KEYTAG = "key"; + private static final String REMOTEID = "rid"; + private static final String IVTAG = "iv"; + private static final String PAYLOAD = "payload"; private static final String KEYTYPE = "AES"; private static final String CIPHERMODE = "AES/GCM/NoPadding"; @@ -50,7 +50,7 @@ public class XmppAxolotlMessage { private final String plaintext; private final String fingerprint; - public XmppAxolotlPlaintextMessage(String plaintext, String fingerprint) { + XmppAxolotlPlaintextMessage(String plaintext, String fingerprint) { this.plaintext = plaintext; this.fingerprint = fingerprint; } @@ -70,7 +70,7 @@ public class XmppAxolotlMessage { private final byte[] key; private final byte[] iv; - public XmppAxolotlKeyTransportMessage(String fingerprint, byte[] key, byte[] iv) { + XmppAxolotlKeyTransportMessage(String fingerprint, byte[] key, byte[] iv) { this.fingerprint = fingerprint; this.key = key; this.iv = iv; @@ -140,7 +140,7 @@ public class XmppAxolotlMessage { } } - public XmppAxolotlMessage(Jid from, int sourceDeviceId) { + XmppAxolotlMessage(Jid from, int sourceDeviceId) { this.from = from; this.sourceDeviceId = sourceDeviceId; this.keys = new SparseArray<>(); @@ -165,7 +165,7 @@ public class XmppAxolotlMessage { private static byte[] generateIv() { SecureRandom random = new SecureRandom(); - byte[] iv = new byte[12]; + byte[] iv = new byte[16]; random.nextBytes(iv); return iv; } @@ -174,7 +174,7 @@ public class XmppAxolotlMessage { return ciphertext != null; } - public void encrypt(String plaintext) throws CryptoFailedException { + void encrypt(String plaintext) throws CryptoFailedException { try { SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE); IvParameterSpec ivSpec = new IvParameterSpec(iv); @@ -273,7 +273,7 @@ public class XmppAxolotlMessage { return session.processReceiving(encryptedKey); } - public XmppAxolotlKeyTransportMessage getParameters(XmppAxolotlSession session, Integer sourceDeviceId) throws CryptoFailedException { + XmppAxolotlKeyTransportMessage getParameters(XmppAxolotlSession session, Integer sourceDeviceId) throws CryptoFailedException { return new XmppAxolotlKeyTransportMessage(session.getFingerprint(), unpackKey(session, sourceDeviceId), getIV()); } -- cgit v1.2.3