I have a JCOP V2.4.2 R3 java card that it is mentioned in its datasheet "The card support both T=1
and T=0
communication protocols"
I have also an ACR38 smart card reader that it support both T=0 and T=1 protocols. (I have T=0 communication with one card successfully and T=1 communication with this card successfully.)
I wrote the below program and upload it on the card to send and receive extended APDUs:
package extAPDU;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacardx.apdu.ExtendedLength;
public class ExAPDU extends Applet implements ExtendedLength {
private ExAPDU() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new ExAPDU().register();
}
public void process(APDU arg0) throws ISOException {
short number = arg0.setIncomingAndReceive();
arg0.setOutgoingAndSend((short)0, (short)(number+7));
}
}
In the CAD-side I used python scripts to send different APDUs to card. The questions is:
1- Why I can't start communication with T=0 protocol(While it is mentioned that the card support this protocol):
The python script:
from smartcard.scard import *
import smartcard.util
from smartcard.System import readers
from smartcard.CardConnection import CardConnection
r=readers()
print r
connection =r[0].createConnection()
connection.connect(CardConnection.T0_protocol)
normalCommand=[0x00,0xa4,0x04,0x00,0x06,0x01,0x02,0x03,0x04,0x05,0x06]
data,sw1,sw2=connection.transmit(normalCommand)
print "SW for Normal Command:"
print data,hex(sw1),hex(sw2)
Output:
>>> ================================ RESTART ================================
>>>
['ACS CCID USB Reader 0']
Traceback (most recent call last):
File "C:\extAPDU.py", line 13, in <module>
connection.connect(CardConnection.T0_protocol)
File "D:\PythonX\Lib\site-packages\smartcard\CardConnectionDecorator.py", line 54, in connect
self.component.connect(protocol, mode, disposition)
File "D:\PythonX\Lib\site-packages\smartcard\pcsc\PCSCCardConnection.py", line 118, in connect
raise CardConnectionException('Unable to connect with protocol: ' + dictProtocol[pcscprotocol] + '. ' + SCardGetErrorMessage(hresult))
CardConnectionException: Unable to connect with protocol: T0. The requested protocols are incompatible with the protocol currently in use with the smart card.
>>>
2- Why the card doesn't work fine with the Select APDU commands in the extended form on the T=1 protocol :
The python script:
from smartcard.scard import *
import smartcard.util
from smartcard.CardConnection import CardConnection
from smartcard.System import readers
r=readers()
print r
connection =r[0].createConnection()
connection.connect(CardConnection.T1_protocol)
normalCommand=[0x00,0xa4,0x04,0x00,0x00,0x00,0x06,0x01,0x02,0x03,0x04,0x05,0x06]
data,sw1,sw2=connection.transmit(normalCommand)
print "SW for Normal Command:"
print data,hex(sw1),hex(sw2)
Output :
>>> ================================ RESTART ================================
>>>
['ACS CCID USB Reader 0']
SW for Normal Command:
[] 0x67 0x0
>>>
I think I misunderstood this concept and I mixed up Extended APDUs with T=1
and T=0
protocols!
Every T=1
compatible smart card, can send and receive Extended APDUs? and we can't send and receive extended APDUs over T=0
protocols? If we want to send Extended SELECT APDU commands to the Security Domain, the SD must implement ExtendedLength
interface?
For an Extended APDU transmission what are the requirements?
- A T=1 compatible card reader
- A T=1 compatible smart card
- An applet that implemented
ExtendedLength
interface
Is it right?
I am really confused about Extended compatibility and T=0/1
compatibility in smart cards. Any light will appreciated.
Note that, I can successfully send Extended APDUs to the above applet with T=1
protocol!