detect is estkme card
This commit is contained in:
parent
3913e2f5d4
commit
fd13867615
1 changed files with 11 additions and 4 deletions
|
@ -4,7 +4,6 @@ import android.util.Log
|
|||
import im.angry.openeuicc.core.ApduInterfaceAtrProvider
|
||||
import im.angry.openeuicc.util.TAG
|
||||
import im.angry.openeuicc.util.decodeHex
|
||||
import im.angry.openeuicc.util.encodeHex
|
||||
import net.typeblog.lpac_jni.ApduInterface
|
||||
|
||||
data class ESTKmeInfo(
|
||||
|
@ -14,11 +13,19 @@ data class ESTKmeInfo(
|
|||
val skuName: String?,
|
||||
)
|
||||
|
||||
fun isESTKmeATR(atr: ByteArray?): Boolean =
|
||||
atr != null && atr.encodeHex().contains("estk.me".encodeToByteArray().encodeHex())
|
||||
fun isESTKmeATR(iface: ApduInterface): Boolean {
|
||||
if (iface !is ApduInterfaceAtrProvider) return false
|
||||
val atr = iface.atr ?: return false
|
||||
val fpr = "estk.me".encodeToByteArray()
|
||||
for (index in atr.indices) {
|
||||
if (atr.size - index < fpr.size) break
|
||||
if (atr.sliceArray(index until index + fpr.size).contentEquals(fpr)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun getESTKmeInfo(iface: ApduInterface): ESTKmeInfo? {
|
||||
if (!isESTKmeATR((iface as ApduInterfaceAtrProvider?)?.atr)) return null
|
||||
if (!isESTKmeATR(iface)) return null
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue