The CAP File Format
6.4 Directory Component
The Directory Component lists the size of each of the components defined in this CAP file. When an optional component is not included, such as the Applet Component (§6.5), Export Component (§6.12), or Debug Component (§6.14), it is represented in the Directory Component with size equal to zero. The Directory Component also includes entries for new (or custom) components.
The Directory Component is described by the following variable-length structure: directory_component { u1 tag u2 size u2 component_sizes[12] static_field_size_info static_field_size u1 import_count u1 applet_count u1 custom_count custom_component_info custom_components[custom_count] }
The items in the directory_component structure are as follows: tag
The tag item has the value COMPONENT_Directory (2). size
The size item indicates the number of bytes in the directory_component structure, excluding the tag and size items. The value of the size item must be greater than zero.
component_sizes[]
The component_sizes item is an array representing the number of bytes in each of the components in this CAP file. All of the 12 components defined in this chapter are represented in the component_sizes array. The value of an index into the array is equal to the value of the tag of the component repre- sented at that entry, minus 1.
The value in each entry in the component_sizes array is the same as the size item in the corresponding component. It represents the number of bytes in the component, excluding the tag and size items.
The value of an entry in the component_sizes array is zero for components not included in this CAP file. Components that may not be included are the Applet Component (§6.5), the Export Component (§6.12), and the Debug Com- ponent (§6.14). For all other components the value is greater than zero.
static_field_size
The static_field_size item is a static_field_size_info structure. The structure is defined as:
static_field_size_info { u2 image_size u2 array_init_count u2 array_init_size }
The items in the static_field_size_info structure are the following: image_size
The image_size item has the same value as the image_size item in the Static Field Component (§6.10). It represents the total number of bytes in the static fields defined in this package, excluding final static fields of primitive types.
array_init_count
The array_init_count item has the same value as the
array_init_count item in the Static Field Component (§6.10). It rep- resents the number of arrays initialized in all of the <clinit> meth- ods in this package.
array_init_size
The array_init_size item represents the sum of the count items in the array_init table item of the Static Field Component (§6.10). It is the total number of bytes in all of the arrays initialized in all of the <clinit> methods in this package.
import_count
The import_count item indicates the number of packages imported by classes and interfaces in this package. This item has the same value as the count item in the Import Component (§6.6).
applet_count
The applet_count item indicates the number of applets defined in this pack- age. If an Applet Component (§6.5) is not included in this CAP file, the value of the applet_count item is zero. Otherwise the value of the applet_count item is the same as the value of the count item in the Applet Component (§6.5). custom_count
The custom_count item indicates the number of entries in the
custom_components table. Valid values are between 0 and 127, inclusive. custom_components[]
The custom_components item is a table of variable-length
CAP file must be represented in the table. These components are not defined in this standard.
The custom_component_info structure is defined as: custom_component_info { u1 component_tag u2 size u1 AID_length u1 AID[AID_length] }
The items in entries of the custom_component_info structure are: component_tag
The component_tag item represents the tag of the component. Valid values are between 128 and 255, inclusive.
size
The size item represents the number of bytes in the component, excluding the tag and size items.
AID_length
The AID_length item represents the number of bytes in the AID item. Valid values are between 5 and 16, inclusive.
AID[]
The AID item represents the Java Card name of the component. See ISO 7816-5 for the definition of an AID (§4.2).
Each component is assigned an AID conforming to the ISO 7816-5 standard. Beyond that, there are no constraints on the value of an AID of a custom component.
6.5
Applet Component
The Applet Component contains an entry for each of the applets defined in this package. Applets are defined by implementing a non-abstract subclass, direct or indirect, of the javacard.framework.Applet class.1 If no applets are defined, this component must not be present in this CAP file.
The Applet Component is described by the following variable-length structure: 1. Restrictions placed on an applet definition are imposed by the Java CardÔ 2.2 Runtime Environment (JCRE)
applet_component { u1 tag u2 size u1 count { u1 AID_length u1 AID[AID_length] u2 install_method_offset } applets[count] }
The items in the applet_component structure are as follows: tag
The tag item has the value COMPONENT_Applet (3). size
The size item indicates the number of bytes in the applet_component struc- ture, excluding the tag and size items. The value of the size item must be greater than zero.
count
The count item indicates the number of applets defined in this package. The value of the count item must be greater than zero.
applets[]
The applets item represents a table of variable-length structures each describ- ing an applet defined in this package.
The items in each entry of the applets table are defined as follows: AID_length
The AID_length item represents the number of bytes in the AID item. Valid values are between 5 and 16, inclusive.
AID[]
The AID item represents the Java Card name of the applet.
Each applet is assigned an AID conforming to the ISO 7816-5 standard (§4.2). The RID (first 5 bytes) of all of the applet AIDs must have the same value. In addition, the RID of each applet AIDs must have the same value as the RID of the package defined in this CAP file.
install_method_offset
The value of the install_method_offset item must be a 16-bit off- set into the info item of the Method Component (§6.9). The item at that offset must be a method_info structure that represents the static install(byte[],short,byte) method of the applet.1 The
install(byte[],short,byte) method must be defined in a class that extends the javacard.framework.applet class, directly or indi- rectly. The install(byte[],short,byte) method is called to initial- ize the applet.
1. Restrictions placed on the install(byte[],short,byte) method of an applet are imposed by the Java