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:
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
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}
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 |
# 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
The following commands are supported on most cards. For those cards that don't support a required feature for implementation UNSUPPORTED will be returned.
sc_sel selects a specified file supporting / as a path separator.
sc_sel / sc_sel /3F11/0005 sc_sel 0000
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
The Chipknip is a specific instance of a smartcard that supports the Intersector Electronic Purse standard.
ck_investigate uses the other Chipknip specific commands to extract the most useful information about the current card in a summary format.
ck_id returns the Purse Identifier.
ck_balance returns the card balance (and currency).
ck_purse extracts the card details into variables for interpretation.
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.
ck_transactions displays a summary of the entire transaction log.