0

I have nfc tag cards of Desfire 8k EV1, which is nfc forum type4

The smart card also has three technologies: IsoDep, NfcA, and NdefFormatable.

The card can accept read/write with it NdefFormatable without any initial setup by my hand.

So I consider that some initial file or application may already exist that allows me to read or write some Ndef records.

So for the purpose of my application, I need to enable security on the card and add some access controls.

I can not found a clear documentation for my smart card the only steps I followed from the NXP Datasheet helped me to use GetVersion and Identify my smart card. But for the security it is not clear to me.

What I need to do first should be Changing the KeySetting, or Changing the key, or maybe adding new application first I don't really know.

And also here https://www.nxp.com/docs/en/data-sheet/MF3ICDX21_41_81_SDS.pdf. all the command shown doesn't have any related byte representing each command name.

My Application is about credit or debit a traveler card for transport ticket payment. So my app must be the only one to read/write it (using shared secret key between the reader and the card)

Bellow are the steps I could achieve so far:

private fun getVersion(intent: Intent){
    val isoDep =IsoDep.get(intent.getParcelableExtra<Parcelable>(NfcAdapter.EXTRA_TAG) as Tag)

    isoDep.connect()

    // GetVersion command
    //val getVersionCommand = byteArrayOf(0x60.toByte(), 0x60.toByte(), 0x00.toByte(), 0x00.toByte())
    val getVersionCommand = byteArrayOf(
        0x90.toByte(),
        0x60.toByte(),
        0x00.toByte(),
        0x00.toByte(),
        0x00.toByte(),
        )
    val getAFCommand = byteArrayOf(
        0x90.toByte(),
        0xAF.toByte(),
        0x00.toByte(),
        0x00.toByte(),
        0x00.toByte(),
    )

    val getVersionResponse = isoDep.transceive(getVersionCommand)
    //04 01 01 01 00 1a 05 91 af
    val getAF1Response = isoDep.transceive(getAFCommand)
    //04 01 01 01 04 1a 05 91 af
    val getAF2Response = isoDep.transceive(getAFCommand)
    //04 3c 38 ba 15 4e 80 b9 0c 16 4d 40 35 16 91 00

    isoDep.close()
}


private fun getAIDs(intent: Intent) {
    val isoDep =IsoDep.get(intent.getParcelableExtra<Parcelable>(NfcAdapter.EXTRA_TAG) as Tag)
    isoDep.connect()

    // Select MF
    val selectMfCommand = byteArrayOf(
        0x00.toByte(),
        0xA4.toByte(),
        0x04.toByte(),
        0x00.toByte(),
        0x07.toByte(),
        0xD2.toByte(),
        0x76.toByte(),
        0x00.toByte(),
        0x00.toByte(),
        0x85.toByte(),
        0x01.toByte(),
        0x01.toByte()
    )
    val selectMfResponse = isoDep.transceive(selectMfCommand)

    // Select DF
    val selectDfCommand = byteArrayOf(
        0x00.toByte(),
        0xA4.toByte(),
        0x04.toByte(),
        0x00.toByte(),
        0x07.toByte(),
        0xD2.toByte(),
        0x76.toByte(),
        0x00.toByte(),
        0x00.toByte(),
        0x85.toByte(),
        0x01.toByte(),
        0x02.toByte()
    )
    val selectDfResponse = isoDep.transceive(selectDfCommand)

    // Get Application IDs (AIDs)
    val getAidsCommand = byteArrayOf(
        0x00.toByte(),
        0xA4.toByte(),
        0x04.toByte(),
        0x00.toByte(),
        0x00.toByte()
    )
    val getAidsResponse = isoDep.transceive(getAidsCommand)
    
     //selectMfResponse: 90 00
    //selectDfResponse: 6a 82
    //getAidsResponse: 6d 00

    isoDep.close()
}

I'm really stacked on this for several days any help would be appreciated

Thank you in advance.

  • As NXP is providing the **TapLinx** library (available after a simple registration) I'm recommending to use this for your task. You can use **Value files** for crediting and debiting the stored value and **Cyclic Record file** for some logging purposes, all secured by (different) Write and Read Access keys. – Michael Fehr Jul 09 '23 at 06:43

0 Answers0