Commit cde55162 authored by Him188's avatar Him188

Fix ecdh availability detect

parent b3c97c16
...@@ -42,14 +42,13 @@ actual fun ECDH() = ECDH(ECDH.generateKeyPair()) ...@@ -42,14 +42,13 @@ actual fun ECDH() = ECDH(ECDH.generateKeyPair())
actual class ECDH actual constructor(actual val keyPair: ECDHKeyPair) { actual class ECDH actual constructor(actual val keyPair: ECDHKeyPair) {
actual companion object { actual companion object {
private var isECDHAvailable = false private var isECDHAvailable = true
init { init {
if (kotlin.runCatching { isECDHAvailable = kotlin.runCatching {
Security.addProvider(BouncyCastleProvider()) Security.addProvider(BouncyCastleProvider())
generateKeyPair() // try if it is working generateKeyPair() // try if it is working
}.isSuccess) { }.isSuccess
isECDHAvailable = true
}
} }
actual fun generateKeyPair(): ECDHKeyPair { actual fun generateKeyPair(): ECDHKeyPair {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment