File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
androidMain/kotlin/utils/crypto Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ kotlin {
82
82
implementation(kotlin(" test-junit5" , Versions .kotlinCompiler))
83
83
implementation(kotlin(" test-annotations-common" ))
84
84
implementation(kotlin(" test-common" ))
85
- // implementation("org. bouncycastle:bcprov-jdk15on:1.64" )
85
+ implementation(bouncycastle)
86
86
}
87
87
}
88
88
Original file line number Diff line number Diff line change @@ -11,9 +11,11 @@ package net.mamoe.mirai.internal.utils.crypto
11
11
12
12
import java.security.Security
13
13
14
-
15
14
internal actual fun ECDH.Companion.create (): ECDH <* , * > =
16
- if (android.os.Build .VERSION .SDK_INT >= 23 ){
15
+ if (kotlin.runCatching {
16
+ // When running tests on JVM desktop, `ClassNotFoundException` will be got
17
+ android.os.Build .VERSION .SDK_INT >= 23
18
+ }.getOrDefault(false )) {
17
19
// For newer Android, BC is deprecated, but AndroidKeyStore (default) handles ECDH well
18
20
// Do not specify a provider as Google recommends
19
21
JceECDH ()
Original file line number Diff line number Diff line change 10
10
package net.mamoe.mirai.internal.test
11
11
12
12
import net.mamoe.mirai.utils.MiraiLogger
13
+ import org.bouncycastle.jce.provider.BouncyCastleProvider
14
+ import java.security.Security
13
15
import kotlin.test.Test
14
16
import kotlin.test.assertTrue
15
17
16
18
internal actual fun initPlatform () {
19
+ init
20
+ }
21
+
22
+ private val init : Unit by lazy {
23
+ if (Security .getProvider(BouncyCastleProvider .PROVIDER_NAME ) != null ) {
24
+ Security .removeProvider(BouncyCastleProvider .PROVIDER_NAME )
25
+ }
26
+ Security .addProvider(BouncyCastleProvider ())
17
27
28
+ Unit
18
29
}
19
30
20
31
internal actual class PlatformInitializationTest : AbstractTest () {
@@ -26,4 +37,4 @@ internal actual class PlatformInitializationTest : AbstractTest() {
26
37
MiraiLogger .Factory .create(this ::class , " 1" ) is net.mamoe.mirai.internal.utils.StdoutLogger
27
38
}
28
39
}
29
- }
40
+ }
You can’t perform that action at this time.
0 commit comments