Description
After upgrading from bcprov/bcpkix/bcutil-jdk18on 1.84 → 1.85, loading a PKCS12
keystore via KeyStore.getInstance("PKCS12", BouncyCastleProvider()).load(...)
crashes at runtime on Android API 29 with:
FATAL EXCEPTION: main
java.lang.NoSuchMethodError: No virtual method intValueExact()I in class Ljava/math/BigInteger; or its super classes (declaration of 'java.math.BigInteger' appears in /apex/com.android.runtime/javalib/core-libart.jar)
at org.bouncycastle.util.BigIntegers.intValueExact(Unknown Source:0)
at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12Util.validateIterationCount(Unknown Source:30)
at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(Unknown Source:82)
at org.bouncycastle.jcajce.provider.keystore.util.AdaptingKeyStoreSpi.engineLoad(Unknown Source:70)
at java.security.KeyStore.load(KeyStore.java:1484)
This reproduces only on the second keystore I load in my app, but not on the first keystore I load (independently of the order I load the two keystores). Both KeyStores load use the same BouncyCastleProvider instance (but not the same KeyStore instance).
Environment
- org.bouncycastle:bcprov-jdk18on / bcutil-jdk18on / bcpkix-jdk18on: 1.85 (works fine on 1.84)
- Android device: Android 10 (API 29) physical device
- compileAndroidSdk: 36
- Kotlin 2.4.10, JVM target 17
- Java compileOptions sourceCompatibility and targetCompatibility: Java 17
Workaround
Pinning back to 1.84 avoids the crash.
Description
After upgrading from bcprov/bcpkix/bcutil-jdk18on 1.84 → 1.85, loading a PKCS12
keystore via
KeyStore.getInstance("PKCS12", BouncyCastleProvider()).load(...)crashes at runtime on Android API 29 with:
This reproduces only on the second keystore I load in my app, but not on the first keystore I load (independently of the order I load the two keystores). Both KeyStores load use the same BouncyCastleProvider instance (but not the same KeyStore instance).
Environment
Workaround
Pinning back to 1.84 avoids the crash.