Skip to content

NoSuchMethodError on BigInteger.intValueExact() when loading PKCS12 keystore on Android API 29 #2369

Description

@alexisdelage

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions