Hi Dave

I have a problem using SCardTransmit() to transmit a case 4 command to a T=1
card. For some reason, SCardTransmit() does it's own calculation for the
length expected in the response APDU from the card. Somewhere in the code it
says

dwRxLength = pbSendBuffer[4] + 2;    /* CLA INS P1 P2 Lr Data SW1 SW2 */

This may work in T=0, were a case 4 command is split into the command itself
and a subsequent GET REPONSE, but it fails for T=1.

In the later case, the APDU is CLA INS P1 P2 Lc Data Le.

I would completely remove the variable dwRxLength and pass pcbRecvLength
directly to IFDTransmit. Otherwise things would get even more complicated for
APDU's with extensed length fields or for command APDU's that use Le=00.

I'm using a SELECT FILE with FID=3F 00 in a command APDU

CLA     INS     P1      P2      Lc      Data    Le
00      A4      00      00      02      3F 00   00

which will return the File Control Information (FCI) for most MFCs using T=1.
In T=0 this would map io

CLA     INS     P1      P2      P3      Data
00      A4      00      00      02      3F 00

GET RESPONSE
CLA     INS     P1      P2      P3      Data
00      C0      00      00      (SW2)   <fci>

Andreas

--
Andreas Schwier     Tel. +49 171 8334920
CardContact Software & System Consulting
http://www.cardcontact.de
***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to