5 Verifying CAP and Export Files
This chapter describes off-card verification as a means for evaluating CAP and export files in a desktop environment.
When applied to the set of CAP files that reside on a Java Card technology compliant secure element and the set of export files used to construct those CAP files, the Java Card technology-enabled off-card verifier provides the means to assert that the content of the secure element has been verified.
Oracle’s Off-Card Verifier supports incremental verification and resolution of the set of CAP files that are installed on a Java Card technology-compliant device in a desktop environment. The unit of verification is a single CAP file. The context in which a CAP file can be executed is provided through the Application Programming Interface (API) of referenced packages as defined in their export files. Resolution is validated off-card by examining the export files of referenced packages.
Oracle’s Off-Card Verifier uses a bottom-up approach to verify the CAP files. In a nutshell, once a CAP file and its corresponding export file, if any, have been verified, it is not examined the succeeding times it is referenced. This is analogous to the process performed by an optimized Java virtual machine where, once the java.lang package has been loaded, verified, resolved, and initialized, it is not examined the succeeding times it is referenced. The same is true for a Java Card technology-compliant device.
A Java Card technology-enabled device is a secure environment. Additional security measures, such as the firewall, prevent a library from being corrupted. Once a verified CAP file has been installed on a Java Card technology-compliant device its state cannot be changed. This includes both its internal state and its context.
Off-Card verification provides a complete solution for Java Card technology-based applications when additional security constructs are applied. For more information on security measures and other details on working of the Off-Card Verifier, refer to the Off-card Verifier White paper.
This chapter contains the following sections:
Overview of Verifying CAP and Export Files
The off-card verifier is a combination of three tools, verifycap, verifyexp, and verifyrev. The following sections describe how to use each tool.
-
verifycap- Verifying CAP Files -
verifyexp- Verifying Export Files -
verifyrev- Verifying Binary Compatibility
Verifying CAP Files
The verifycap tool is used to verify a CAP file within the context of packages’ export files (if any) and the export files of imported packages. This verification confirms whether a CAP file is internally consistent, as defined in the Java Card Platform Virtual Machine Specification, Classic Edition, Version 3.2, and consistent with a context in which it can reside in a Java Card technology-enabled device.
To ensure the integrity of the CAP file to be downloaded on a card, the verifier computes and outputs hash values for each of the required CAP file components. To output the hash values in a text file, specify the command line parameter -outfile hash-file-path. If the -outfile parameter is not specified, the verifier outputs the hash values on the console. A CAP file loader should compute the hash values for each of the required CAP components and verify them against the hash values produced by the verifier to assert the integrity of the CAP file being loaded on the card.
Each individual export file is verified as a single unit. The scenario is shown in Verifying a CAP File. In the figure, the package p2 CAP file is being verified. Package p2 has a dependency on package p1, so the export file from package p1 is also input. The p2.exp file is only required if p2.cap exports any of its elements.
Figure 5-1 Verifying a CAP File

Description of the illustration verifying-cap-file.png
Running verifycap
The file to invoke verifycap is a script file (verifycap.[sh|bat]). It is located under [$JC_HOME_TOOLS/bin | %JC_HOME_TOOLS%\bin] and needs to be executed from there.
To run verifycap:
-
Enter the following command (verifycap Command Line Arguments describes the available options):
verifycap.[sh|bat] [options]export-filesCAP-file
Table 5-1 verifycap Command Line Arguments
| Argument | Description |
|---|---|
|
|
A list of export files of the packages that this CAP file uses could be either one of the following:
Note that, when using this option in conjunction with the For more information, see the |
|
|
Name of the CAP file to be verified. |
|
|
Specifies the digest algorithm to use for computing hash values for required CAP components. If this option is not specified or an invalid algorithm name is specified, the verifier uses SHA-256 as the default algorithm. |
|
|
Specifies the path to the text file that the verifier uses to output the computed hash values for the required CAP components. If this option is not specified, hash values are output to the system console. |
Command Line Options for Off-Card Verifier Tools describes additional verifycap options.
Verifying Export Files
The verifyexp tool is used to verify an export file as a single unit. This verification is “shallow”, examining only the content of a single export file, not including export files of packages referenced by the package of the export file. The verification determines whether an export file is internally consistent and viable as defined in the Java Card Platform Virtual Machine Specification, Classic Edition, Version 3.2.
Figure 5-2 Verifying an Export File

Description of the illustration tools-62.png
Running verifyexp
The file to invoke verifyexp is a script file (verifyexp.[sh|bat]). It is located under [$JC_HOME_TOOLS/bin | %JC_HOME_TOOLS%\bin] and needs to be executed from there.
To run verifyexp:
-
Enter the following command (verifyexp Command Line Argument describes the available options):
verifyexp.[sh|bat] [options]export-file
Table 5-2 verifyexp Command Line Argument
| Argument | Description |
|---|---|
|
|
Fully qualified path and name of the export file. |
Command Line Options for Off-Card Verifier Tools describes additional verifyexp options.
Verifying Binary Compatibility
The verifyrev tool checks for binary compatibility between two revisions of the same package by comparing the respective export files. This scenario is illustrated in Verifying Binary Compatibility of Export Files. The export files from version 1.0 and 1.1 of package p1 are input to verifyrev. The verification examines whether the Java Card platform version rules, including those imposed for binary compatibility as defined in the Java Card Platform Virtual Machine Specification, Classic Edition, Version 3.2, have been followed.
Figure 5-3 Verifying Binary Compatibility of Export Files

Description of the illustration 63.png
Running verifyrev
The file to invoke verifyrev is a script file (verifyrev.[sh|bat]). It is located under [$JC_HOME_TOOLS/bin | %JC_HOME_TOOLS%\bin] and needs to be executed from there.
To run verifyrev:
-
Enter the following command:
verifyrev.[sh|bat] [options] old-export-file new-export-fileThe
new-export-fileargument on the command line represents the fully qualified path to the new export file version of the package to be compared, whileold-export-filerepresents the fully qualified path to the old export file version of the package to be compared to. The comparison and binary compatibility checks are done based on the order and version of the export files (the version can be identical). Both export files must have the same name, for example (for Unix/Linux OS replace \ with / ):verifyrev.bat d:\testing\old\crypto.exp d:\testing\new\crypto.exp
Command Line Options for Off-Card Verifier Tools describes additional command-line options for the off-card verifier tools.
Command Line Options for Off-Card Verifier Tools
The verifycap, verifyexp, and verifyrev, off-card verifier tools share many of the same command line options. The only exceptions are the -package, -outfile, -digest, and -target options that are available for verifycap only.
These options exhibit the same behavior regardless of the tool that calls them.
Table 5-3 verifycap, verifyexp, verifyrev Command Line Options
| Option | Description |
|---|---|
|
|
Prints help message. |
|
|
Suppresses banner message. |
|
|
Suppresses warning messages. |
|
|
(Available for |
|
|
(Available for |
|
|
(Available for |
|
|
(Available for
When a target is specified, the Note that using this option to specify the target still requires that you provide the export files for all other packages used by the CAP file. If no target is specified, the export files for all the packages used by the CAP file must be provided on the command line. |
|
|
Enables verbose mode. |
|
|
Prints version number and exits. |
|
or
|
Optional. Specifies a file containing command-line options. |
-enable-preview [final|all] |
Enables verification against a target platform that implements Java Card preview features. The following variants are supported:
-enable-preview is specified, the verifier only supports targeting the latest Java Card platform version. Any other value provided for the -target option in combination with -enable-preview is rejected. If neither -enable-preview nor -target is specified, export files for all packages used by the CAP file must be provided on the command line. Note: This option is available with verifycap only.
|