projects techreports press lab location staff
citi top.2 top.3
citi mid.3
bot.1 bot.2 bot.3
star

Projects : Smart Cards : ISO 7816 Library and Applications

This package is obsolete. It has been replaced by the Sectok (SECure TOKen) Library and Applications.

Applications: citi-apps.tar.gz
Library: sc7816.tar.gz
Todos card reader driver: todos.tar.gz
Source and binaries for OpenBSD 2.8 i386: obsd-sc7816.tar.gz

copyright © 1997, 1998, 1999, 2000
the regents of the university of michigan
all rights reserved

permission is granted to use, copy, create derivative works and redistribute this software and such derivative works for any purpose, so long as the name of the university of michigan is not used in any advertising or publicity pertaining to the use or distribution of this software without specific, written prior authorization. if the above copyright notice or any other identification of the university of michigan is included in any copy of any portion of this software, then the disclaimer below must also be included.

this software is provided as is, without representation from the university of michigan as to its fitness for any purpose, and without warranty by the university of michigan of any kind, either express or implied, including without limitation the implied warranties of merchantability and fitness for a particular purpose. the regents of the university of michigan shall not be liable for any damages, including special, indirect, incidental, or consequential damages, with respect to any claim arising out of or in connection with the use of the software, even if it has been or is hereafter advised of the possibility of such damages.


This is a set of applications and a package of routines for talking to ISO 7816 smart cards. The application run on Unix (linux and bsd) and PalmOS. The applications require the sc7816 library and at least one card reader driver. The library makes use of drivers that are dynamically loaded and export the IFD interface used by MUSCLE pc/sc.

We supply a driver for the Todos Argos Mini reader, or you can get more drivers from the MUSCLE web site.

For a working reader and driver for the Palm, see the Palmreader.

The applications include:

'atr' parses a card atr and displays protocol parameters. 'balance' checks the balance on a Payflex, Mondex, or Visacash card. 'pay' is used to send commands to a smartcard. 'lewis' is like 'pay' but for Palm. 'decard' aka the reaper extracts personal info from a Cardtech card and adds it to your Palm address book. 'secb' encrypts address book entries on the Palm. 'dogg' makes a trace of a smartcard transaction. You need a card extender to use 'dogg'. 'compost' translates the output of 'dogg' to a more readable form.

For more information about smartcard research at the University of Michigan CITI, see our web page at http://www.citi.umich.edu/projects/smartcard/.

Jim Rees <rees@umich.edu>
November 1997
Updated October 1999, July 2000, August 2000.

----------------------------------------------------------------------------
int scopen(int ttyn, int flags, int *ep);

Open a connection to a smart card via serial port number 'ttyn'.  Ports are
numbered from 0, which corresponds to /dev/tty00 on unix.  Use flag SCODSR
if your reader, like ours, uses DSR to indicate that a card is present, else
use SCODCD.  'ep' points to an int in which an error code is returned (see
scrw.h).  Returns an fd or -1 on error.


----------------------------------------------------------------------------
int screset(int fd, char *atr, int *ep);

Reset the card and return the ATR in the buffer pointed to by 'atr' if
non-NULL.  'ep' points to an int in which an error code is returned (see
scrw.h).


----------------------------------------------------------------------------
int scclose(int fd);

Close a connection to a smart card, and reset the port parameters.


----------------------------------------------------------------------------
int scread(int fd, int cla, int ins, int p1, int p2, int p3, char *buf, int *sw1p, int *sw2p);

Issue an "OUT" command to a smart card and read the resulting data.

cla: application class
ins: instruction code
p1, p2: per 7816-3 or application dependent
p3: length of data
buf: return data read from card
sw1p, sw2p: pointers to ints in which SW1 and SW2 are returned

Returns the number of bytes actually read, or -1 on error.


----------------------------------------------------------------------------
int scwrite(int fd, int cla, int ins, int p1, int p2, int p3, char *buf, int *sw1p, int *sw2p);

Issue an "IN" command to a smart card and write some data.

cla: application class
ins: instruction code
p1, p2: per 7816-3 or application dependent
p3: length of data
buf: data to write to card
sw1p, sw2p: pointers to ints in which SW1 and SW2 are returned

Returns the number of bytes actually written, or -1 on error.


----------------------------------------------------------------------------
int sccardpresent(int fd);

Find out whether a card is present.


How to do performance evaluation with the sc7816 library

Oct., 2000, Naomaru Itoi (itoi@eecs.umich.edu)

  1. include /usr/local/include/scrw.h from the programs you want to measure.
  2. put SetTime() macro at the point you want to print time.
    Because libsc7816_perf.a will automatically obtain start and end of scopen(), scxreset(), scwrite(), and scread(), you may not have to add a lot of SetTime(). However, if desired, add it to wherever you want to measure.
    e.g., SetTime ("start program"), SetTime ("end program")
  3. put pritn_time() macro at the end of the program.
  4. compile your programs with -DSCPERF.
  5. link the programs you want to measure with libsc7816_perf.a instead of libsc7816.a.
  6. run the programs

    % ./kinit -C 0 itoi@UMICH.EDU > 1

  7. run time.pl in this directory on the output.

    e.g., % ~/smartcards/src/sc7816/time.pl 1

blank.space
b.star projects | techreports | press | lab | location | staff Email address
or call +1 734 763 2929
Copyright © 1996-2013
The Regents of the University of Michigan
bottom.line
citi