Question

I am writing a C++ code using winscard. I noticed that, if I send a command with Scardtransmit where only data is sent or only data received, there is no problem. I can send data or get correct response. However, when the command both sends data and expects a response then I always get 61xx. I know the error code 61xx means there is an xx bytes response where Le is not correct, and checked every possible Le, including the returned value xx, but nothing changes. For example let the Apdu be in the form CLA INS P1 P2 Lc Data Le, and I get 61XX, then I send CLA INS P1 P2 Lc Data XX, again I get 61XX.

I checked the card using java and other tools and verified that there is nothing with the card.

As far as I understand, there is a single byte P3 allocated for Lc and Le. Is there a way to get responses (apart from the SW1SW2) from the DATADATA commands?

Was it helpful?

Solution

When you send a command that has Command Data and the command is expecting Result Data as well, and the communication is made using T=0 protocol, then you need to send two APDUs. One for the command itself, and another one to retrieve the result.

61XX is not an error. It is a (successful) Status Word that indicates you have XX bytes of response which you can retrieve using GET RESPONSE (INS=0xC0).

Here is the reference of the command.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top