Contents Previous Next Index

Chapter   13

Sending and Receiving APDU Commands

The apdutool reads a script file containing Application Protocol Data Unit commands (APDUs) and sends them to the C-language Java Card RE (or other Java Card RE) or the Java Card WDE. Each APDU is processed and returned to apdutool, which displays both the command and response APDUs on the console. Optionally, apdutool can write this information to a log file.

Running apdutool

The file to invoke apdutool is a shell script (apdutool) on the Solaris or Linux platform, and a batch file (apdutool.bat) on the Microsoft Windows 2000 platform.

The command line usage for apdutool is:

apdutool [-h hostname] [-nobanner] [-noatr] [-o <outputFile>] 	[-p port] [-s serialPort] [-version] 	<inputFile> [<inputFile> ...] 

The option values and their actions are:

TABLE 35  –  apdutool Command Line Options
Specifies the host name on which the TCP/IP socket port is found. (See the flag -p.)
Displays online documentation for this command.
Suppresses outputting an ATR (answer to reset).
Suppresses all banner messages.
Specifies an output file. If an output file is not specified with the -o flag, output defaults to standard output.
Specifies a TCP/IP socket port other than the default port (which is 9025).
-s serialPort
Specifies the serial port to use for communication, rather than a TCP/IP socket port. For example, serialPort can be COM1 on a Microsoft Windows 2000 system and /dev/term/a on a Solaris system.
Currently, this option is not supported on the Linux platform.
To use this option, the javax.comm package must be installed on your system. For more information on installing this package, see "Prerequisites for Installing the Binary Release".
If you enter the name of a serial port that does not exist on your system, apdutool will respond by printing the names of available ports.
Outputs the version information.
Allows you to specify the input script (or scripts).

apdutool Examples

Directing Output to the Console

The following is a command line invocation sample:

apdutool example.scr 

This command runs apdutool with the file example.scr as input. Output is sent to the console. The default TCP port (9025) is used.

Directing Output to a File

apdutool –o example.scr.out example.scr 

This command runs apdutool with the file example.scr as input. Output is written to the file example.scr.out.

Using APDU Script Files

An APDU script file is a protocol-independent APDU format containing comments, script file commands, and C-APDUs. Script file commands and C-APDUs are terminated with a semicolon (;). Comments can be of any of the three Java-style comment formats (//, /*, or /**).

APDUs are represented by decimal, hex or octal digits, UTF-8 quoted literals or UTF-8 quoted strings. C-APDUs may extend across multiple lines.

C-APDU syntax for apdutool is as follows:

<CLA> <INS> <P1> <P2> <LC> [<byte 0> <byte 1> ... <byte LC-1>] <LE> ; 


<CLA> :: ISO 7816-4 class byte.
<INS> :: ISO 7816-4 instruction byte.
<P1> :: ISO 7816-4 P1 parameter byte.
<P2> :: ISO 7816-4 P2 parameter byte.
<LC> :: ISO 7816-4 input byte count.
<byte 0> ... <byte LC-1> :: input data bytes.
<LE> :: ISO 7816- 4 expected output length byte. 0 implies 256.

The following script file commands are supported:

TABLE 36  –  Supported APDU Script File Commands
delay <Integer>;
Pauses execution of the script for the number of milliseconds specified by <Integer>.
echo "string";
Echoes the quoted string to the output file. The leading and trailing quote characters are removed.
output off;
Suppresses printing of the output.
output on;
Restores printing of the output.
Sends a powerdown command to the reader.
Sends a power up command to the reader. A powerup command must be executed prior to sending any C-APDUs to the reader.


Contents Previous Next Index Development Kit User's Guide for the Binary Release with Cryptography Extensions
Java Card Platform, Version 2.2.1