问题
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
- Is the above APDU correct ?
- What is the [Le] in first command ?
- How to implement the GET RESPONSE in java applet ?
- 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:
- It seems largely correct to me, except for (2) and the final remark;
- 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;
- T=0 is handled by the Java Card OS, you should not have to implement this yourself;
- 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