Extended APDUs and T=0/1 communication protocols

*爱你&永不变心* 提交于 2019-12-04 11:48:18

Q1: Changing Protocol is possible. Information which protocols are supported by hte card is transceived via ATR/ATS. The terminal then can decide which one to use. So it is dependend from your Terminal shell if protocols are selectable or not. For JCOP Shell this is /change-protocol. However is do not recommend T=0 in general.

Q2: If you start the card via sending ATR/ATS the Card Manager is active which only supports Global Platform commands. Global Platform does not support Extended Length what so ever. By sending a Select command(which must be simple length because of that) the applet gets selected and that actual Select commands is also forwarded into your Applet's process() method (and can be detected by the selectingApplet() method). Now that you are in your Applet you can send as many Extended Length commands as you want. You can bypass the initial Non-Extended-Length-Select by installing your applet as default selected.

It is not the case that every ISO-compatible card can send and receive extended APDUs. It is very much an optional feature. What version of JCOP does your card implement?

As for T=0 vs T=1: when a card indicates support for both protocols, it is the card reader that decides which one to use. If it's a PC/SC card reader, there is not much you can do about this.

Updated to add: Now you say that you can successfully send extended APDUs to the above applet. So it appears that the card does support extended APDUs. But perhaps the built-in SELECT command doesn't allow them if Le is absent, because there is no use case for them.

Java Card itself already handles the T=0 specific commands, so a T=0/T=1 APDU will look pretty much the same to a programmer. There are of course differences, but those are pretty well explained in the APDU class.

T=0 is a byte based protocol while T=1 uses frames underneath. Most cards with T=0 don't support extended length. Note that to get extended length functionality that the javacardx.apdu.ExtendedLength tagging interface needs to be implemented.

JCOP cards can be configured to use T=0/T=1/T=CL and others. You need however to have access to the card (and probably the user manual) to configure the cards. The Java Card API doesn't contain any commands to change the support for protocols or the transport protocol parameters within the cold or warm ATR.

You are correct with regards to the requirements for extended length. Note that card readers not capable of T=1 will probably be hard to find by now. T=0 is an old protocol, T=1 should be preferred.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!