JDK¶
The JDK provider wraps Java’s built-in JCA and is the default for JVM targets.
ProGuard / R8 (desktop JVM)
The JDK provider uses Java ServiceLoader for auto-discovery. ProGuard on desktop JVM (e.g.
Compose Desktop) removes the provider classes because they are only referenced by name in
service descriptor files.
See ProGuard / R8 — providers not found
for the required keep rules.
Using in your projects¶
dependencies {
implementation("dev.whyoleg.cryptography:cryptography-provider-jdk:0.6.0")
}
Access via CryptographyProvider.JDK (available on JVM targets only).
Custom Java providers¶
In addition to this, there is a possibility to create CryptographyProvider from java.util.Provider, f.e. using BouncyCastle:
// any other JCA provider could be used
val provider = CryptographyProvider.JDK(BouncyCastleProvider())
// get some algorithm which not supported on a JDK version or platform (in case of Android)
provider.get(SHA512)
Android support¶
JDK provider is also tested via Android emulator on API level 35. Supported algorithms on Android highly depend on Android API level and used provider.
For better compatibility, you can use BouncyCastle provider as shown in BouncyCastle.
BouncyCastle¶
Some algorithms or parameters may not be supported by the default JDK provider depending on JDK version or platform (e.g., Android). The library provides an ability to use BouncyCastle as the default provider via an additional dependency:
dependencies {
implementation("dev.whyoleg.cryptography:cryptography-provider-jdk-bc:0.6.0")
}
See the algorithm support tables for specific limitations and Working with Keys for key format restrictions.