STEST - SIO Test / TSCAM

SIO.002 (Initial)
T J Hudson tjh@cryptsoft.com
15 March 1998


Table of Contents


1. stest

stest is built on top of sio which a library of routines for doing cross-platform serial I/O between most Unix varients and WIN32.

The version at the time of last update of this document was 0.11.

stest takes a pile of options:

In SCAM mode the interactive commands are:

1.1. base commands

To run with debug switched on, logging the data going to/from the serial port in interactive SCAM emulation mode:

stest -d 1 -l trace -s - -
h<ENTER> should display help
r<ENTER> should reset the Smartcard and a valid ATR should be displayed


Note: scanning can take a while - you might want to run with debug on to check that things are working (via -d 1 on the command line) and then switch to running without debug for the actual scan.

1.2. smartcard commands

Internal Command Description
list list supported Smartcard commands
desc cmd_name describe Smartcard command parameters
ascii display last result in ASCII with non-printable chars as .
get var_name get the value of a variable
set var_name value set the value of a variable
vars display the value of all vars
clear clear all variables
parse pattern_name parse the last command using the specified pattern
plist list supported patterns
pdesc pattern_name describe pattern
scan fileid_start scan for files of the form fileid_start[00-FF]
scan all [fileid_start] scan starting with fileid_start00
scan all fileid_start fileid_end scan from fileid_start00 to fileid_endFF
ilist list supported internal commands

The result of the in, out, or exe commands are of the following forms (with no whitespace between items):

 RSPCODE SW1 SW2
 RSPCODE SW1 SW2 LEN DATA

Each item is represented as two character ASCII hexadecimal for each byte of the item. RSPCODE, SW1, SW2 and LEN are all single bytes, and DATA is LEN bytes long.

RSPCODE is a card independant mapping of the card dependant "switches" SW1 and SW2.

Where it makes sense commands may be chained. The normal use of chaining is to call the GET RESPONSE function if the result of a function that returns data via GET RESPONSE indicates that the function succeeded.

The parameters of a command (via /exe command or /whatever) are specified as HEX bytes. However data enclosed in angle brackets (< and >) is converted from ASCII into the corresponding HEX bytes. Backslash ( \ ) can be used to escape the angle brackets if desired or to specify the following characters \0, \n, \r

# the following three commands are identical
/exe unlock <TESTCODE>
/exe unlock 54 45 53 54 43 4F 44 45
/unlock 54455354434F4445

Additionally, parameters enclosed in curly braces ( { and } ) are interpreted as patterns specifying a set of variables that hold the relevant values.

# display the vars that make up the create pattern
/!pdesc create
# clear out any current var information
/!clear
# now set the ones that we want to be non-zero
/!set FILE_SIZE 0010
/!set FILE_ID 0005
/!set FILE_TYPE 01
/!set AC 0001FF11
/!set FILE_STATUS 01
/!set DATA_LEN 03
/!set ACCESS_KEYS 111111
# now execute the command getting the data from the pattern
/CreateFile 00 00 10 {create}

1.2.1. Supported Cards and Readers

The init command reader and card parameters have to be one of the values in the appropriate tables below.

Reader Description
DUMBMOUSE Dumbmouse
GCR Gemplus GCR series reader
SCT Schlumberger SCT series
PE Philips PE122 reader
Card Description Comms Setting
CRYPTOFLEX Schlumberger Cryptoflex 9600 8E2 D
DX Philips DX 9600 8E2 D
CHIPKNIP Chipknip/Proton/CC60 etc 9600 8O2 I

1.2.2. Example session

# read the manufacturer file (0002) off a Schlumberger Cryptoflex card
# using a Dumbmouse as the reader
#
# stest commands entered are in italics
#

# start the session
/init DUMBMOUSE CRYPTOFLEX
READER DUMBMOUSE CARD CRYPTOFLEX
ATR DIRECT PROTOCOL=0 TB1=00 TC1=00 TC2=20 HISTORICAL 49 03

# check what commands are available
/!list
RSP SelectFile,GetResponse,ReadBinary,ReadDirectory,VerifyKey,GetRandom

# find out what parameters are required for ReadBinary
/!desc ReadBinary
RSP Offset:2,Len

# Select file 0002
/SelectFile 0002
RSP 0090000f000000080002010004FFFF01010000

# read the file (all 8 bytes)
/ReadBinary 0000 08
RSP 0090000800000A4B01000000

# finish the session
/final

2. Commands

2.1. General

The following commands are supported on most cards. For those cards that don't support a required feature for implementation UNSUPPORTED will be returned.

2.1.1. sc_sel

sc_sel selects a specified file supporting / as a path separator.

 sc_sel /
 sc_sel /3F11/0005
 sc_sel 0000

2.1.2. sc_dir

sc_dir returns a directory listing detailing the FILE_ID and FILE_SIZE of each file in the current DF. If a path is provided then the specified DF is selected first.

 sc_dir
 sc_dir /
 sc_dir /3F11

2.2. Chipknip

The Chipknip is a specific instance of a smartcard that supports the Intersector Electronic Purse standard.

2.2.1. ck_investigate

ck_investigate uses the other Chipknip specific commands to extract the most useful information about the current card in a summary format.

2.2.2. ck_id

ck_id returns the Purse Identifier.

2.2.3. ck_balance

ck_balance returns the card balance (and currency).

2.2.4. ck_purse

ck_purse extracts the card details into variables for interpretation.

2.2.5. ck_trans

ck_trans returns the specified transaction from the log, where transactions are identified by their index into the log (from 1 to 11) with 1 being the most recent transaction.

2.2.6. ck_transactions

ck_transactions displays a summary of the entire transaction log.