diff options
author | cyBerta <cyberta@riseup.net> | 2019-10-20 17:49:58 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-10-20 17:49:58 +0200 |
commit | 30b3f419c1c0f9c5d74453e51d5300c8c108872b (patch) | |
tree | 8859e79b9d086bc6b6e3121eff4a748fdba35e77 | |
parent | 7f79f764d51f8b1d7dc3fd9458373baccd0cc06c (diff) |
fix endless setup loop on pre-P devices, differentiate security provider between P and pre-P devices
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java index ca76a799..d4a640bb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java @@ -18,6 +18,7 @@ package se.leap.bitmaskclient.utils; import android.content.Context; import android.content.res.Resources; +import android.os.Build; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -117,7 +118,12 @@ public class ConfigHelper { public static RSAPrivateKey parseRsaKeyFromString(String rsaKeyString) { RSAPrivateKey key; try { - KeyFactory kf = KeyFactory.getInstance("RSA"); + KeyFactory kf; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { + kf = KeyFactory.getInstance("RSA", "BC"); + } else { + kf = KeyFactory.getInstance("RSA"); + } rsaKeyString = rsaKeyString.replaceFirst("-----BEGIN RSA PRIVATE KEY-----", "").replaceFirst("-----END RSA PRIVATE KEY-----", ""); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decode(rsaKeyString)); key = (RSAPrivateKey) kf.generatePrivate(keySpec); @@ -132,6 +138,9 @@ public class ConfigHelper { } catch (NullPointerException e) { e.printStackTrace(); return null; + } catch (NoSuchProviderException e) { + e.printStackTrace(); + return null; } return key; |