use bouncycastle provider up to api 27
apparently using conscrypt on Android below version 7? throws an exception when using 16 byte IVs. so we now use BC when ever possible (excluding api 28) we don’t know why Conscrypt behaves differently on various android versions
This commit is contained in:
parent
7c5af89c89
commit
409bf3c0cb
|
@ -178,7 +178,7 @@ public class XmppAxolotlMessage {
|
|||
try {
|
||||
SecretKey secretKey = new SecretKeySpec(innerKey, KEYTYPE);
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||
Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
Cipher cipher = Compatibility.twentyEight() ? 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) {
|
||||
|
@ -294,7 +294,7 @@ public class XmppAxolotlMessage {
|
|||
key = newKey;
|
||||
}
|
||||
|
||||
Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
Cipher cipher = Compatibility.twentyEight() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
SecretKeySpec keySpec = new SecretKeySpec(key, KEYTYPE);
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
package eu.siacs.conversations.services;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -47,7 +42,7 @@ public class AbstractConnectionManager {
|
|||
|
||||
public static InputStream upgrade(DownloadableFile file, InputStream is) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, NoSuchProviderException {
|
||||
if (file.getKey() != null && file.getIv() != null) {
|
||||
final Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
final Cipher cipher = Compatibility.twentyEight() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE);
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(file.getIv());
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
|
||||
|
@ -78,7 +73,7 @@ public class AbstractConnectionManager {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
final Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
final Cipher cipher = Compatibility.twentyEight() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER);
|
||||
SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE);
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(file.getIv());
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
|
||||
|
|
|
@ -37,8 +37,8 @@ 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;
|
||||
public static boolean twentyEight() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
|
||||
}
|
||||
|
||||
private static boolean getBooleanPreference(Context context, String name, @BoolRes int res) {
|
||||
|
|
Loading…
Reference in New Issue