diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-09-26 21:34:37 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-09-26 21:34:37 +0200 |
commit | 3237fc518d4025a6e39786a5e443b9dcb144e431 (patch) | |
tree | 9f4e7bba4696780935a24aed2882749325829c96 /src/main | |
parent | 0e0e93a312fa3e091c4113dc4ef9b8d7b521f034 (diff) |
do not use BC provider on android 22+
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java | 5 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/Compatibility.java | 4 |
2 files changed, 7 insertions, 2 deletions
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 0adbbe51f..f9b2539c3 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java @@ -21,6 +21,7 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import de.pixart.messenger.Config; +import de.pixart.messenger.utils.Compatibility; import de.pixart.messenger.xml.Element; import rocks.xmpp.addr.Jid; @@ -177,7 +178,7 @@ public class XmppAxolotlMessage { try { SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE); 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); this.ciphertext = cipher.doFinal(Config.OMEMO_PADDING ? getPaddedBytes(plaintext) : plaintext.getBytes()); if (Config.PUT_AUTH_TAG_INTO_KEY && this.ciphertext != null) { @@ -293,7 +294,7 @@ public class XmppAxolotlMessage { 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); IvParameterSpec ivSpec = new IvParameterSpec(iv); diff --git a/src/main/java/de/pixart/messenger/utils/Compatibility.java b/src/main/java/de/pixart/messenger/utils/Compatibility.java index 95d7b4ef2..640a74083 100644 --- a/src/main/java/de/pixart/messenger/utils/Compatibility.java +++ b/src/main/java/de/pixart/messenger/utils/Compatibility.java @@ -30,6 +30,10 @@ public class Compatibility { 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) { return getPreferences(context).getBoolean(name, context.getResources().getBoolean(res)); } |