go back to 16 byte IVs for OMEMO
clients like Dino can’t handle 12 byte IVs
This commit is contained in:
parent
0e3be466ad
commit
ce46b36c33
|
@ -550,7 +550,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": own device " + session.getFingerprint() + " was active " + hours + " hours ago");
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": own device " + session.getFingerprint() + " was active " + hours + " hours ago");
|
||||||
}
|
}
|
||||||
}
|
} //TODO print last activation diff
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
|
|
|
@ -4,15 +4,12 @@ import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
|
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.NoSuchProviderException;
|
import java.security.NoSuchProviderException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
|
@ -30,12 +27,12 @@ import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class XmppAxolotlMessage {
|
public class XmppAxolotlMessage {
|
||||||
public static final String CONTAINERTAG = "encrypted";
|
public static final String CONTAINERTAG = "encrypted";
|
||||||
public static final String HEADER = "header";
|
private static final String HEADER = "header";
|
||||||
public static final String SOURCEID = "sid";
|
private static final String SOURCEID = "sid";
|
||||||
public static final String KEYTAG = "key";
|
private static final String KEYTAG = "key";
|
||||||
public static final String REMOTEID = "rid";
|
private static final String REMOTEID = "rid";
|
||||||
public static final String IVTAG = "iv";
|
private static final String IVTAG = "iv";
|
||||||
public static final String PAYLOAD = "payload";
|
private static final String PAYLOAD = "payload";
|
||||||
|
|
||||||
private static final String KEYTYPE = "AES";
|
private static final String KEYTYPE = "AES";
|
||||||
private static final String CIPHERMODE = "AES/GCM/NoPadding";
|
private static final String CIPHERMODE = "AES/GCM/NoPadding";
|
||||||
|
@ -53,7 +50,7 @@ public class XmppAxolotlMessage {
|
||||||
private final String plaintext;
|
private final String plaintext;
|
||||||
private final String fingerprint;
|
private final String fingerprint;
|
||||||
|
|
||||||
public XmppAxolotlPlaintextMessage(String plaintext, String fingerprint) {
|
XmppAxolotlPlaintextMessage(String plaintext, String fingerprint) {
|
||||||
this.plaintext = plaintext;
|
this.plaintext = plaintext;
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +70,7 @@ public class XmppAxolotlMessage {
|
||||||
private final byte[] key;
|
private final byte[] key;
|
||||||
private final byte[] iv;
|
private final byte[] iv;
|
||||||
|
|
||||||
public XmppAxolotlKeyTransportMessage(String fingerprint, byte[] key, byte[] iv) {
|
XmppAxolotlKeyTransportMessage(String fingerprint, byte[] key, byte[] iv) {
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
|
@ -143,7 +140,7 @@ public class XmppAxolotlMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmppAxolotlMessage(Jid from, int sourceDeviceId) {
|
XmppAxolotlMessage(Jid from, int sourceDeviceId) {
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.sourceDeviceId = sourceDeviceId;
|
this.sourceDeviceId = sourceDeviceId;
|
||||||
this.keys = new SparseArray<>();
|
this.keys = new SparseArray<>();
|
||||||
|
@ -168,7 +165,7 @@ public class XmppAxolotlMessage {
|
||||||
|
|
||||||
private static byte[] generateIv() {
|
private static byte[] generateIv() {
|
||||||
SecureRandom random = new SecureRandom();
|
SecureRandom random = new SecureRandom();
|
||||||
byte[] iv = new byte[12];
|
byte[] iv = new byte[16];
|
||||||
random.nextBytes(iv);
|
random.nextBytes(iv);
|
||||||
return iv;
|
return iv;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +174,7 @@ public class XmppAxolotlMessage {
|
||||||
return ciphertext != null;
|
return ciphertext != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encrypt(String plaintext) throws CryptoFailedException {
|
void encrypt(String plaintext) throws CryptoFailedException {
|
||||||
try {
|
try {
|
||||||
SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE);
|
SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE);
|
||||||
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||||
|
@ -276,7 +273,7 @@ public class XmppAxolotlMessage {
|
||||||
return session.processReceiving(encryptedKey);
|
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());
|
return new XmppAxolotlKeyTransportMessage(session.getFingerprint(), unpackKey(session, sourceDeviceId), getIV());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue