From 4b4f43cc2766ff1d183cf128d673ad0a7bd57807 Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Wed, 9 Oct 2019 18:30:12 +0800 Subject: [PATCH 1/2] InternalEventListeners: typo --- .../{InternalEventListenres.kt => InternalEventListeners.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/{InternalEventListenres.kt => InternalEventListeners.kt} (100%) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/InternalEventListenres.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/InternalEventListeners.kt similarity index 100% rename from mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/InternalEventListenres.kt rename to mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/InternalEventListeners.kt From 79e211256e0a7cb609f969cb7689788e1e26e689 Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Wed, 9 Oct 2019 18:44:53 +0800 Subject: [PATCH 2/2] ECDH: remove --- mirai-core/build.gradle | 1 - .../kotlin/net/mamoe/mirai/utils/ECDH.kt | 42 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/ECDH.kt diff --git a/mirai-core/build.gradle b/mirai-core/build.gradle index d73a560d7..b098e1adb 100644 --- a/mirai-core/build.gradle +++ b/mirai-core/build.gradle @@ -25,7 +25,6 @@ kotlin { implementation rootProject.ext.coroutine - implementation group: 'net.java.dev.jna', name: 'jna', version: '5.4.0' implementation 'org.yaml:snakeyaml:1.18' implementation 'org.jsoup:jsoup:1.12.1' implementation 'org.ini4j:ini4j:0.5.2' diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/ECDH.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/ECDH.kt deleted file mode 100644 index 818abb485..000000000 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/ECDH.kt +++ /dev/null @@ -1,42 +0,0 @@ -@file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS") - -package net.mamoe.mirai.utils - -import com.sun.jna.Library -import com.sun.jna.Native -import net.mamoe.mirai.network.protocol.tim.TIMProtocol -import sun.misc.Unsafe - -/** - * @author Him188moe - */ -object ECDH : IECDH by Native.load("ecdhdll64", IECDH::class.java) - -interface IECDH : Library { - //fun encrypt(publicKey: UByteArray, shaKey: UByteArray): UByteArray - fun encrypt(publicKey: Long, shaKey: Long): Long -} - -fun main() { - // - // ECDH.encrypt(TIMProtocol.publicKey.hexToUBytes(), TIMProtocol.key0836.hexToUBytes()) - val unsafe = Unsafe::class.java.getDeclaredField("theUnsafe").also { it.trySetAccessible() }.get(null) as Unsafe - - val publicKeyAddress = unsafe.allocateMemory(25) - TIMProtocol.publicKey.hexToUBytes().forEachIndexed { index, value -> - unsafe.setMemory(publicKeyAddress + index, 1, value.toByte()) - } - - val key0836Address = unsafe.allocateMemory(16) - TIMProtocol.key0836.hexToUBytes().forEachIndexed { index, value -> - unsafe.setMemory(key0836Address + index, 1, value.toByte()) - } - - val encrypt = ECDH.encrypt(publicKeyAddress, key0836Address) - // - val bytes = mutableListOf() - repeat(16) { - bytes += unsafe.getByte(encrypt + it) - } - println(bytes.toByteArray().toUHexString()) -}