C H A P T E R  10

Producing a Mask File from Java Card Assembly Files

This chapter describes how to use the maskgen tool to create a mask from Java Card Assembly files. The maskgen tool is not available or of use outside of a source release bundle, so you can disregard this chapter if you do not have a source release of the development kit. If you have a source release, you can localize locale-specific data associated with the maskgen tool, see Chapter 14.

The maskgen tool produces a mask file from a set of Java Card Assembly files produced by the Converter. The format of the output mask file is targeted to a specific platform. The plug-ins that produce each different maskgen output format are called generators. The supported generators are cref, which supports the Java Card RE, and size, which reports size statistics for the mask. Other generators that are not supported in this release include jref, which supports the Java programming language Java Card RE, and a51, which supports the Keil A51 assembly language interpreter.

For more information on the contents of a Java Card Assembly file, see Appendix A.


Running maskgen

You invoke maskgen at the command line as follows (see TABLE 10-30 for a description of the options):

maskgen [options] generator filename [filename ...]



Note - The file to invoke the maskgen is a batch file (maskgen.bat) that must be run from a working directory of JC_CLASSIC_HOME\bin in order for the code to execute properly.


 


TABLE 10-30 Command Line Arguments for the maskgen Tool

Argument

Description

-help

Prints a help message.

generator

Specifies the generator, the plug-in that formats the output for a specific target platform. The generators are:

  • a51 - Output for the Keil A51 assembly language interpreter (not supported for this release).
  • cref - Output for the cref interpreter.
  • jref - Output for the Java programming language Java Card RE interpreter (not supported for this release).
  • size - Outputs mask size statistics.

In this release, the only supported generator is cref.

filename [filename...]

Any number of Java Card Assembly files can be input to maskgen as a whitespace-separated list.

 

You can also create a text file containing a list of Java Card Assembly file names for a new mask, and prepend an “@” character to the name of this text file as an argument to maskgen.

-c filename

Specifies a configuration file, which contains generator-specific settings. For example, the following line maps a native Java Card API method to a native label:
javacard/framework/JCSystem/beginTransaction()V=beginTransaction_NM

cref_mask.cfg is an example of a maskgen configuration file.

-debuginfo

Generates debug information for the generated mask. This option is available only with the jref generator.

-nobanner

Suppresses all banner messages.

-o filename

Specifies the file name output from maskgen. If the output file is not specified, output defaults to a.out.

-version

Prints the version number of maskgen, then exits.


Order of Packages on the Command Line

The Java Card Assembly files that can be listed on the command line can belong to API packages, the installer package, or the user’s library and applet packages. The Java Card Assembly files that belong to API packages must be listed first on the command line, followed by the Java Card Assembly files belonging to any applets.

If you include the installer package’s Java Card Assembly file on the command line, it must be listed after all of the Assembly files belonging to API packages and before the Assembly files of any other applet packages.

For example:

maskgen -nobanner cref API_package_1.jca .... API_package_n.jca 		installer_package.jca applet_package_1.jca ... 	applet_package_n.jca

Version Numbers for Processed Packages

The packages that you specify to generate a mask can import other packages. These imported packages must share the same major and minor version number as the specified packages.

For example, presume that you are using Package A, version 1.1 to create a mask, and that Package A imports Package B, version 1.1. Then you must ensure that Package B, version 1.1 is listed in the import component of the Package A .jca file.

maskgen Example

This example uses a text file (args.txt) to pass command line arguments to maskgen:

maskgen -o mask.c cref @args.txt

where the contents of the file args.txt is:

first.jca second.jca third.jca

This is equivalent to the command line:

maskgen -o mask.c cref first.jca second.jca third.jca

This command produces an output file mask.c that is compiled with a C compiler to produce mask.o, which is linked with the Java Card RE interpreter. Refer to Chapter 9 for more information about this target platform.