About Get Response command in javacard

两盒软妹~` 提交于 2019-12-11 02:37:20

问题


I'm confused about Get Response command. I thought I know it but actually I don't.

I wanna know the mechanism in which the card returns 1000-bytes data in case 4. I guess the command is as follows. Please let me know the correct one if it is wrong.

(Card) <== [CLA] [INS] [P1] [P2] [Lc] [Data] [Le] // response data size is 1000 bytes
(Card) ==> 6100

(Card) <== 00 C0 00 00 00
(Card) ==> [Data(256)] 6100

(Card) <== 00 C0 00 00 00
(Card) ==> [Data(256)] 6100

(Card) <== 00 C0 00 00 00
(Card) ==> [Data(256)] 61E8

(Card) <== 00 C0 00 00 E8
(Card) ==> [Data(232)] 9000 (61E8 was my mistake)

Questions

  1. Is the above APDU correct ?
  2. What is the [Le] in first command ?
  3. How to implement the GET RESPONSE in java applet ?
  4. How is the method to implement different according to T=0/T=1 card ? (When I googled, I saw the information about the T=0/T=1 card but I don't understand.)

I hope any response or URL of the related information.


回答1:


To answer your questions:

  1. It seems largely correct to me, except for (2) and the final remark;
  2. You don't send both a Lc and Le field for T=0, in a case 4 command (command data and response data) only Lc and the command data is send - you could also say that Le is empty as it is an encoding in bytes;
  3. T=0 is handled by the Java Card OS, you should not have to implement this yourself;
  4. T=1 does not use or need GET RESPONSE as both T=1 and T=CL are higher level protocols - the layer beneath APDU's already take care of this. Furthermore extended length support may have been implemented.

Finally, the card should of course return 9000 or a status word indicating a warning or error instead of 61E8 for the last command (this was subsequently fixed in the question as mistake in the question).

Note that you should not blindly assume that the response will contain the amount of bytes requested. An Le byte with value 00 for instance indicates a maximum response size of 256 bytes.

This is all defined in ISO/IEC 7816-4, chapter 5.3.4: Response chaining

The current version is 2013(E) at the time of writing. It's payware (but Google isn't).



来源:https://stackoverflow.com/questions/24711277/about-get-response-command-in-javacard

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