When an APDU command is received, the card processes it and determines whether the command has logical channel information encoding. If logical channel information is encoded, then the card sends the APDU command to the respective channel. All other APDU commands are forwarded to the card's basic channel (0
).
The X
nibble is responsible for logical channels and secure message encoding. Only the two least significant bits of the nibble are used for channel encoding, which ranges from 0
to 3
. For example, the command 0x21
forwards the command to the card's basic channel (0
), because the CLA byte with the nibble 0x2X
does not contain logical channel information.
Just as the deselection and selection mechanisms must be written to take into consideration a multiple-channel environment, it is important to write the Applet.process()
method so that it handles channel information correctly. Due to the fact that some APDUs can be digitally signed, the APDU command is passed to the applet's process
method as it is sent by the terminal. That means any logical channel information is not cleared and is passed intact to the applet. The applet must deal with this situation.