Using the On-card Installer for Deletion
The on-card installer in the simulator provides the ability to delete CAP file and applet instances from the card's memory. Once the on-card installer is selected, it can receive deletion requests from the terminal in the form of ADPU commands. Requests to delete an applet or CAP file cannot be sent from an applet on the card. For more information on CAP file and applet deletion, see the Java Card Platform Runtime Environment Specification, Classic Edition, Version 3.1.
How to Send a Deletion Request
-
Select the on-card installer applet on the card.
-
Send the ADPU for the appropriate deletion request to the installer. The requests that you can send are described in the following sections:
For information on the responses that the ADPU requests can return, see APDU Responses to Deletion Requests.
APDU Requests to Delete CAP Files and Applets
You can send requests to delete a CAP file, a CAP file and its applets, and individual applets.
Note:
In the following APDU commands, the x in the second nibble of the class byte indicates that the installer can be invoked on channels 0, 1, or 2. For example, 0x8x
.
Delete CAP File
In this request, the Data field contains the size of the CAP file AID and the AID of the CAP file to be deleted. Table 8-15 shows the format of the Delete CAP File request and the expected response.
Table 8-15 Delete CAP File Command
Command | Lc | data | Le |
---|---|---|---|
|
Lc field |
Data field |
Le field |
The value of 0xXX can be any value for the P1
and P2
parameters. The installer ignores the 0xXX values. An example of a delete package request on channel 1 would be:
//Delete CAP File Request: 0x81 0xC0 0x00 0x00 0x08 0x07 0xa0 0x00 0x00 0x00 0x62 0x12 0x34 0x7F;
In this example, 0x07
is the AID length and 0xa0 0x00 0x00 0x00 0x62 0x12 0x34
is the CAP file AID.
Delete CAP File and Applets
This request is similar to the Delete CAP file command. In this case the CAP file and applets are removed simultaneously. The data field contains the size of the CAP file AID and the AID of the CAP file to be deleted. Table 8-16 shows the format of the Delete CAP File and Applets request and the expected response.
Table 8-16 Delete CAP File and Applets Command
Command | Lc | data | Le |
---|---|---|---|
0x8x, 0xc2, 0xXX, 0xXX |
Lc field |
Data field |
Le field |
The value of 0xXX can be any value for the P1
and P2
parameters. The installer ignores the 0xXX values. An example of a CAP file and applets deletion request on channel 1 would be:
//Delete CAP file And Applets request 0x81 0xC2 0x00 0x00 0x08 0x07 0xa0 0x00 0x00 0x00 0x62 0x12 0x34 0x7F;
In this example, 0x07
is the AID length and 0xa0 0x00 0x00 0x00 0x62 0x12 0x34
is the CAP file AID.
Delete Applets
In this request, the "#" symbol in the P1
byte indicates the number of applets to be deleted, which can have a maximum value of eight. The Lc
field contains the size of the data field. Data field contains a list of AID size and AID pairs. Table 8-17 shows the format of the Delete Applet request and the expected response.
Table 8-17 Delete Applet Command
Command | Lc | data | Le |
---|---|---|---|
|
Lc field |
Data field |
Le field |
The value of 0xXX can be any value for the P2
parameter. The installer ignores the 0xXX values. An example of a applet deletion request on channel 1 would be:
//Delete the applet's request for two applets 0x81 0xC4 0x02 0x00 0x12 0x08 0xa0 0x00 0x00 0x00 0x62 0x12 0x34 0x12 0x08 0xa0 0x00 0x00 0x00 0x62 0x12 0x34 0x13 0x7F;
In this example, the "#" symbol is replaced with "2" (0x02
) indicating that there are two applets to be deleted. The first applet is 0xa0 0x00 0x00 0x00 0x62 0x12 0x34 0x12
and the second applet is 0xa0 0x00 0x00 0x00 0x62 0x12 0x34 0x13
.
APDU Responses to Deletion Requests
When the on-card installer receives the request from the terminal, it can return any of the responses shown in Table 8-18.
Table 8-18 APDU Responses to Deletion Requests
Response Code | Description |
---|---|
|
Invalid value for
|
|
Applet not found for deletion.
|
|
Package not found.
|
|
Dependencies on package.
|
|
One or more applet instances of this package are present.
|
|
Package is ROM package.
|
|
Dependencies on applet.
|
|
Internal memory constraints.
|
|
Cannot delete applet; the applet is currently active on one of the logical channels.
|
|
Invalid value for
|
The response has the format shown in Table 8-19.
Table 8-19 APDU Response Format
data | Response |
---|---|
[optional response data] |
SW1SW2 |
On-Card Installer Limits
The limits for the on-card installer are as follows.
-
The maximum length of the parameter in the applet creation APDU command is 110.
-
The maximum number of CAP files to be downloaded is 32, including up to 16 CAP files with applets.
-
The maximum number of applet instances to be created is 16.
-
The maximum length of data in the installer APDU commands is 128.
-
No on-card CAP file verification is supported.
-
All subsequent APDU commands enclosed in a
CAP Begin
,CAP End
APDU pair continue to fail after an error occurs. -
The maximum number of applets that can be deleted using one command is eight.