0

I have an Desfire EV1 Smart Card and try to read it by DUALi reader. I'm aware that for the Desfire I need to wrap the command.

Tried sent the simple APDU command like this:

90 60 00 00 00 00

INT uiLen = 0;
BYTE pbData[256];
BYTE cmd[6] = {0x90,0x60,0x00,0x00,0x00,0x00};

iDERc = DE_APDU(
            m_sPortNoM,  
            6, cmd, 
            (LPINT)&uiLen, (LPBYTE)pbData);

but why the return always : DE_NACK_COUNT_ERROR?

Also tried to send some APDU command to the SAM, always encounter errors. the return code was 1 which is not defined in any Response code definitions.

already send the DE_InitPort and DE_IC_PowerOn command and the return was successful.

Thanks

EDIT :

For DE_APDU command and parameters explanation:

int DE_APDU(int nPort, BYTE datalen, LPBYTE data, LPINT outlen, LPBYTE lpRes)

  • It sends and receive data as APDU format defined by ISO7816. Device change it to ISO14443 protocol and send to card, so User can easily use this function without knowing of ISO14443 protocol.

- Parameters

  • int nPort[in] : Port number.
  • int datalen[in] : Length of LPBYTE data.
  • LPBYTE data[in] : APDU to send to card.
  • LPINT outlen[out] : Length of LPBYTE lpRes
  • LPBYTE lpRes[out] : Response data.
  • `90 60 00 00 00 00` is not a valid APDU command. Try sending `90 60 00 00 00` instead. – Michael Roland Nov 07 '16 at 08:22
  • And `uiLen` should probably be set to the length of `pbData`. – Michael Roland Nov 07 '16 at 08:25
  • Hi @MichaelRoland thanks for the suggestion but unfortunately still got same error. Based on post here : https://ridrix.wordpress.com/2009/09/19/mifare-desfire-communication-example/ I need to wrap the command to emulate ISO 7816. I also add some explanation about the DE_APDU command – Opik Taufik Nov 07 '16 at 09:57
  • 1
    I assume you did set `datalen` to 5 when you sent `90 60 00 00 00` (note that ridrix is partially wrong with his wrapping since Lc and DATA are simply not present when Lc = LEN(DATA) = 0), right? Also you clearly have to pass the initial size of the buffer `lpRes` in `outlen` (eventhough it's marked as "out") otherwise the method wouldn't know if the response fits into the buffer. – Michael Roland Nov 07 '16 at 10:09
  • Hi @MichaelRoland Yes already, tried `BYTE cmd[5] = {0x90, 0x60, 0x00, 0x00, 0x00};` the `datalen = 5` and `outlen = 10` error still same. – Opik Taufik Nov 07 '16 at 10:41
  • (I do not have this particular reader, but...) what @MichaelRoland says definitely makes sense (i.e. using `INT uiLen = 256;`, `BYTE cmd[5] = {0x90,0x60,0x00,0x00,0x00};` and `DE_APDU(m_sPortNoM, 5, ...)`. Did the reader send RATS (i.e. is the card in ISO-14443-4 mode)? – vlp Nov 07 '16 at 22:08
  • PS: Assuming you want to get the GetVersion command working I don't understand why are you mentioning SAM and emulation. Good luck! – vlp Nov 07 '16 at 22:09

0 Answers0