refactor: simplify atr check #252
1 changed files with 4 additions and 13 deletions
|
|
@ -24,21 +24,12 @@ interface EuiccVendor {
|
|||
private class ESTKme : EuiccVendor {
|
||||
companion object {
|
||||
private val PRODUCT_AID = "A06573746B6D65FFFFFFFFFFFF6D6774".decodeHex()
|
||||
private val PRODUCT_ATR_FPR = "estk.me".encodeToByteArray()
|
||||
}
|
||||
|
||||
private fun checkAtr(channel: EuiccChannel): Boolean {
|
||||
val iface = channel.apduInterface
|
||||
if (iface !is ApduInterfaceAtrProvider) return false
|
||||
val atr = iface.atr ?: return false
|
||||
for (index in atr.indices) {
|
||||
if (atr.size - index < PRODUCT_ATR_FPR.size) break
|
||||
if (atr.sliceArray(index until index + PRODUCT_ATR_FPR.size)
|
||||
.contentEquals(PRODUCT_ATR_FPR)
|
||||
) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
private fun checkAtr(channel: EuiccChannel): Boolean =
|
||||
(channel.apduInterface as? ApduInterfaceAtrProvider)
|
||||
?.atr?.decodeToString()?.contains("estk.me")
|
||||
?: false
|
||||
|
||||
private fun decodeAsn1String(b: ByteArray): String? {
|
||||
if (b.size < 2) return null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue