This commit is contained in:
septs 2025-02-26 12:06:47 +08:00
parent eb7d21c8d6
commit 262ede94bc
Signed by: septs
SSH key fingerprint: SHA256:ElK0p6DNkbsqYUdJ3I9QHDVf21SQD0c2r+hd7s/r5Co
2 changed files with 13 additions and 13 deletions

6
.idea/AndroidProjectSystem.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

View file

@ -2,6 +2,7 @@ package im.angry.openeuicc.vendored
import android.util.Log
import im.angry.openeuicc.util.TAG
import im.angry.openeuicc.util.decodeHex
import net.typeblog.lpac_jni.ApduInterface
data class ESTKmeInfo(
@ -12,15 +13,13 @@ data class ESTKmeInfo(
)
fun getESTKmeInfo(iface: ApduInterface): ESTKmeInfo? {
// @formatter:off
val aid = byteArrayOf(
0xA0.toByte(), 0x65.toByte(), 0x73.toByte(), 0x74.toByte(), 0x6B.toByte(), 0x6D.toByte(),
0x65.toByte(), 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte(),
0xFF.toByte(), 0x6D.toByte(), 0x67.toByte(), 0x74.toByte(),
)
// @formatter:on
fun decode(b: ByteArray): String? {
if (b.size < 2) return null
if (b[b.size - 2] != 0x90.toByte() || b[b.size - 1] != 0x00.toByte()) return null
return b.sliceArray(0 until b.size - 2).decodeToString()
}
return try {
iface.openChannel(aid) { transmit ->
iface.openChannel("A06573746B6D65FFFFFFFFFFFF6D6774".decodeHex()) { transmit ->
fun invoke(p1: Byte) =
decode(transmit(byteArrayOf(0x00, 0x00, p1, 0x00, 0x00)))
ESTKmeInfo(
@ -36,8 +35,3 @@ fun getESTKmeInfo(iface: ApduInterface): ESTKmeInfo? {
}
}
private fun decode(b: ByteArray): String? {
if (b.size < 2) return null
if (b[b.size - 2] != 0x90.toByte() || b[b.size - 1] != 0x00.toByte()) return null
return b.sliceArray(0 until b.size - 2).decodeToString()
}