Hi Everyone , I need to make a function which can communicate with NTAG 424 and can authenticate it also. I tried the but got length error 917E. Please take a look and help me on it where I did mistake.
Code is in android kotlin
fun selectApdu(): ByteArray {
val cmd = "9071000002000000"
val selectaId = "D2760000850101"
val selectAID = byteArrayOf(
0xD2.toByte(), 0x76.toByte(), 0x00.toByte(), 0x00.toByte(),
0x85.toByte(), 0x01.toByte(), 0x01.toByte()
)
Log.i(TAG, "selectApdu: ${selectAID.size}")
try {
val commandApdu = ByteArray(11 + selectAID.size)
commandApdu[0] = 0x90.toByte() // CLA
commandApdu[1] = 0x71.toByte() // INS
commandApdu[2] = 0x00.toByte() // P1
commandApdu[3] = 0x00.toByte() // P2
commandApdu[4] = 0x02.toByte() // Lc (fixed at 2 bytes for the AID length)
selectAID.copyInto(commandApdu, 7)
// Replace the last three bytes
commandApdu[commandApdu.size - 3] = 0x00.toByte()
commandApdu[commandApdu.size - 2] = 0x00.toByte()
commandApdu[commandApdu.size - 1] = 0x00.toByte()
Log.e(TAG, "selectApdu: ${getByteArrayToString(commandApdu)}" )
return commandApdu
} catch (e: Exception) {
e.printStackTrace()
Log.e(TAG, "selectApdu: ${e.message}" )
return byteArrayOf()
}
}Thanks in advance.