ISO 7816 smartcards are typically used in EMV transactions. I know that the card can perform arbitrary actions before sending a response to the terminal in a typical EMV transaction (e.g. signing dynamic data to generate SDAD). However, is it possible that the card perform a certain action while waiting for a command APDU from the terminal? That is the command APDU serves as an interrupt that is handled when it reaches the card, the card will stop what it was doing and service this command by sending a response. Is this possible?
EMV Book 1, 184.108.40.206.1 Procedure Byte
The procedure byte indicates to the TTL (Terminal Transport Layer) what action it shall take next. Procedure Byte Value
60, the TTL shall provide additional work waiting time.
ICC can instruct terminal to wait by using this byte. The time is calculated as an elementary time unit (etu). A linear relationship exists between the etu on the I/O line and CLK frequency (f).
etu cannot be used by ICC to count seconds. It sets duration of I/O line for transmission and reception mode as explained in EMV Book 1, 7 Physical Transportation of Characters and it's follow-up subsections.
During the transaction process, data is passed bi-directionally between the terminal and the ICC over the I/O line in an asynchronous half duplex manner. A clock signal is provided to the ICC by the terminal, and this shall be used to control the timing of this exchange.
I put forward your question to @Steven Murdoch (the researcher behind vulnerabilities in chip and PIN) to know if the reverse happens.
I don't think so, but I'm not aware of situations where it is necessary for the card to wait for the terminal. It's the terminal which is driving the exchange, so the card just waits for the terminal to do the next thing.
I think that something like that could be done but it might be unreliable if the terminal is not specifically designed to support this use case. Normally once terminals have completed their transaction, they turn off the clock so the card won't be able to do further processing.
Theoretical possibilities aside: A typical smart card will do nothing before starting to receive a command APDU and after having sent the response APDU. Chances are, it even is in sleep mode to reduce power consumption (due to pressure on SIM cards by mobile phone manufacturers).
Signals on I/O port may trigger interrupts, but this is the wake-up type of interrupt and not the type "stop what you are doing right now to handle this".