我有一个 JCOP V2.4.2 R3 java 卡,它在其数据表“该卡同时支持T=1
和T=0
通信协议”中提到
我还有一个 ACR38 智能卡读卡器,它支持 T=0 和 T=1 协议。(我与一张卡成功T=0通信,与这张卡成功T=1通信。)
我编写了以下程序并将其上传到卡上以发送和接收扩展 APDU:
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));
}
}
在 CAD 方面,我使用 python 脚本将不同的 APDU 发送到卡。问题是:
1-为什么我无法使用 T=0 协议开始通信(虽然提到卡支持此协议):
蟒蛇脚本:
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)
输出:
>>> ================================ 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-为什么卡不能在 T=1 协议的扩展形式中使用 Select APDU 命令正常工作:
蟒蛇脚本:
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)
输出 :
>>> ================================ RESTART ================================
>>>
['ACS CCID USB Reader 0']
SW for Normal Command:
[] 0x67 0x0
>>>
我想我误解了这个概念,我将扩展 APDU 与T=1
协议混为一谈T=0
!
每个T=1
兼容的智能卡,都可以发送和接收扩展 APDU 吗?我们不能通过T=0
协议发送和接收扩展的 APDU?如果我们想向安全域发送扩展的 SELECT APDU 命令,SD 必须实现ExtendedLength
接口吗?
对于扩展 APDU 传输有什么要求?
- AT=1 兼容读卡器
- AT=1 兼容智能卡
- 一个实现
ExtendedLength
接口的小程序
这样对吗?
T=0/1
我对智能卡中的扩展兼容性和兼容性感到非常困惑。任何光线都会受到赞赏。
请注意,我可以使用协议成功地将扩展 APDU 发送到上述小程序T=1
!