Site Tools

Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcre:4._logical_channels_and_applet_selection

4. Logical Channels and Applet Selection

Java Card platform, version 2.2.2, provides support for logical channels: The ability to allow a terminal to open up to twenty sessions into the smart card over any I/O interface, one session per logical channel. Logical channels functionality is described in detail in the ISO 7816-4:2005 Specification.

Cards receive requests for service from the CAD in the form of APDUs. The SELECT FILE APDU and MANAGE CHANNEL OPEN APDU are used by the Java Card RE to designate the active applet instance for a logical channel session. Once selected, an applet instance receives all subsequent APDUs dispatched to that logical channel, until the applet instance becomes deselected.

Some cards support only the contacted I/O interface conforming to ISO 7816 specifications, and some support only the contactless I/O interface based on the ISO 14443 specifications. Yet others are able to support both types of I/O interfaces. Logical channel sessions as described in this chapter may be supported over either interface. In addition, a card may be able to sustain logical channel sessions over both interfaces simultaneously.

An implementation may support between 1 and 20 logical channels over the contacted I/O interface. Similarly, an implementation may support between 1 and 20 logical channels over the contactless I/O interface. When both I/O interfaces are concurrently active, the number of logical channels supported on each of the two interfaces is also implementation specific.

Note - To establish a card session over both contacted and contactless interfaces concurrently, the CAD must initiate the contacted session first. A power loss or card reset on the contacted interface results in a card tear and card reset event even if a contactless session is in progress. An RF signal loss on the contactless interface must not affect an ongoing contacted session.

The Java Card RE processes APDUs sequentially whether received over the same I/O interface or over two different I/O interfaces. The I/O subsystem must present concurrently received APDUs to the Java Card RE command dispatcher sequentially. The arbitration required to make concurrently received APDU commands sequential, as well as the mechanisms used to ensure proper synchronization with the CAD (for contact) and with the proximity coupling device, PCD (for contactless), are not specified in this specification. The I/O subsystem must ensure that APDU commands received over the contactless I/O interface are given higher priority, but without causing a timeout on any concurrently received APDU command over the contacted I/O interface. The algorithm used for this purpose is not specified in this specification.

A new applet written for version 2.2.* of the Java Card platform can be designed to take advantage of logical channel support. Such an applet can take advantage of multi-session functionality, can be concurrently selected alongside another applet on a different logical channel, and even be selected multiple times simultaneously on different logical channels. As shown in FIGURE 4-1, an implementation may support from one to twenty logical channels on each I/O interface, each with its own distinct CLEAR_ON_DESELECT memory segment.

Only one logical channel, logical channel number 0 (the basic logical channel) becomes active on the contacted I/O interface following a card reset. Similarly, only one logical channel, logical 0 (the basic logical channel) becomes active on the contactless I/O interface following a PICC activation sequence. A MANAGE CHANNEL APDU command may be issued on this logical channel to instruct the card to open a new logical channel. Applet instances can be selected on different logical channels using the SELECT FILE APDU command, just as they would in a single logical channel environment. The MANAGE CHANNEL APDU command is also used for closing a logical channel. Note that the basic logical channel is permanent and can never be closed as long as the I/O interface remains activated.

On a card that is able to sustain logical channel sessions over both interfaces simultaneously, there are two sets of twenty logical channels possible. A logical channel number 0 on the contacted I/O interface is not the same as the logical channel number 0 on the contactless I/O interface. An applet instance selected on a logical channel on the contacted I/O interface would normally receive APDUs only from the contacted I/O interface. However, it can receive APDUs from the contactless I/O interface also, only if the applet instance is concurrently selected on a logical channel on the contactless I/O interface. Rules of multiselection apply as described in Section 4.2, Multiselectable Applets.

Legacy applets (written for version 2.1 of the Java Card platform) running on version 2.2.*, need not be aware of logical channel support to work correctly. The Java Card RE must guarantee that an applet that was not designed to be aware of multiple sessions is not selected more than once or concurrently with another applet from the same package.

FIGURE 4-1 Logical Channels for Distinct Applets

Support for multiple logical channels (with multiple selected applet instances) requires a change to the Java Card platform version 2.1.* concept of selected applet. Because more than one applet instance can be selected at the same time, and one applet instance can be selected on different logical channels simultaneously, it is necessary to differentiate the state of the applet instances in more detail.

An applet instance is be considered an active applet instance if it is currently selected in at least one logical channel, up to a maximum of forty. Each active applet instance from a distinct package executes with a distinct CLEAR_ON_DESELECT transient memory segment, see FIGURE 4-1. An applet instance is the currently selected applet instance only if it is processing the current command. There can only be one currently selected applet instance at a given time.

Applets with the capability of being selected on multiple logical channels at the same time, or accepting other applets belonging to the same package being selected simultaneously, are referred to as multiselectable applets. (Refer to FIGURE 4-2 below.)

No applet is active on the new (or only) logical channel when one of the following occurs:

  • The card is reset and no applet is designated as the default applet instance for the basic channel on the contacted I/O interface, or the default applet instance for the basic channel on the contacted I/O interface rejects selection.
  • The card successfully completes its PICC activation sequence and no applet is designated as the default applet instance for the basic channel on the contactless I/O interface, or the default applet instance for the basic channel on the contactless I/O interface rejects selection.
  • A MANAGE CHANNEL OPEN command on the basic channel opens a new channel, and no applet is designated as the default applet instance for that logical channel.
  • A new logical channel is opened when a MANAGE CHANNEL OPEN command is issued on a logical channel other than the basic channel, on which there is no active applet.
  • A SELECT FILE command fails when attempting to select an applet instance.
javacard/jcre/4._logical_channels_and_applet_selection.txt · Last modified: 2017/05/13 04:07 (external edit)