do not use BC provider on android 22+
This commit is contained in:
parent
4bc9713b80
commit
67e7d2cf9e
|
@ -24,6 +24,7 @@ import javax.crypto.spec.IvParameterSpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
|
import eu.siacs.conversations.utils.Compatibility;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@ public class XmppAxolotlMessage {
|
||||||
try {
|
try {
|
||||||
SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE);
|
SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE);
|
||||||
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||||
Cipher cipher = Cipher.getInstance(CIPHERMODE, PROVIDER);
|
Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivSpec);
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivSpec);
|
||||||
this.ciphertext = cipher.doFinal(Config.OMEMO_PADDING ? getPaddedBytes(plaintext) : plaintext.getBytes());
|
this.ciphertext = cipher.doFinal(Config.OMEMO_PADDING ? getPaddedBytes(plaintext) : plaintext.getBytes());
|
||||||
if (Config.PUT_AUTH_TAG_INTO_KEY && this.ciphertext != null) {
|
if (Config.PUT_AUTH_TAG_INTO_KEY && this.ciphertext != null) {
|
||||||
|
@ -296,7 +297,7 @@ public class XmppAxolotlMessage {
|
||||||
key = newKey;
|
key = newKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance(CIPHERMODE, PROVIDER);
|
Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||||
SecretKeySpec keySpec = new SecretKeySpec(key, KEYTYPE);
|
SecretKeySpec keySpec = new SecretKeySpec(key, KEYTYPE);
|
||||||
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@ public class Compatibility {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean twentyTwo() {
|
||||||
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean getBooleanPreference(Context context, String name, @BoolRes int res) {
|
private static boolean getBooleanPreference(Context context, String name, @BoolRes int res) {
|
||||||
return getPreferences(context).getBoolean(name, context.getResources().getBoolean(res));
|
return getPreferences(context).getBoolean(name, context.getResources().getBoolean(res));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue