This content has been marked as final. Show 4 replies
0x45D is a pcsc error caused often by a slow apdu (usually something like a genkeypair), that causes a protocol drop.
You can try to optimize the apdu on the card side and try to manage the connection protocol on the other side.
Try also to change the connection parameters manually to detect if you can find a workaround.
If you are lucky, you can solve just upgrading the reader drivers.
The symptom you describe would be typical of a non-conformance to the relevant communication protocol (ISO 7816-3 T=0, ISO 7816-3 T=1, ISO 14443-4...) of either the card or the reader. All these protocol have a mechanism which, when working, allows the card to ask for more time to perform its duties. Java Card platforms are supposed to do that negotiation in the background when necessary, and things often work for the best unless the reader/driver/PCSC has a bug. On the other hand I once met a Java Card runtime platform with broken implementation of that mechanism that would often stop working for no apparent reason; and another where this mechanism would not work during certain primitives, like RSA key generation.
Still, I think there are ways an applet can make a well-behaved Java Card runtime platform break the communication protocol due to slow processing. In particular, due to a limitation of the ISO 7816-3 T=0 protocol, when not using block chaining, it is difficult to perform this negotiation for more processing time between segments of the outgoing data of the same R-APDU. Thus an applet using multiple sendBytes() during the same APDU, with a delay between them, is not unlikely to cause what you observe when the delay exceeds a certain time limit (and bound to do so unless the runtime makes either under-the-hood buffering, or use an highly unusual option of the T=0 protocol where there is an ACK byte equal to the complement of INS for each payload byte transfered). That time limit defaults to 9600*372/Fclk where Fclk is the clock frequency, often 3.5 to 5 MHz, and that makes the limit not far from 800 ms. I do not know if some Java Card runtime platforms have this failure mode for a delay between setOutgoing() and a single sendBytes(), but would not be too surprised if that was.
AFAIK neither usual Java Card runtime platforms nor the ISO 7816-3 or ISO 14443-4 communication standards define a maximum overall delay for the card's APDU processing time. However some readers/driver/PCSC/utilities/applications do have such an overall timeout (sometime parameterized somewhere), usually of several seconds or several negotiations of additional delay. That's another limit sometime met, but likely that's NOT the one your are meeting.