copyright © 1997
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 package currently only supports non-inverted (TS=3b), T=0 protocol, with default timings (WI=10, D=1, 9600 bps with 3.58 MHz clock).
Two sample applications are included with this package.
'lewis' is used with a dumb card reader to send commands to a smartcard. 'clark' emulates a smartcard. You need an inverse reader to use 'clark'.
There is also a gif file, sleonschem.gif, that contains a schematic of the circuit we use for our inverse reader.
For more information about smartcard research at the University of Michigan CITI, see our web page at http://www.citi.umich.edu/projects/sinciti/smartcard/.
Jim Rees <rees@umich.edu>
November 1997
---------------------------------------------------------------------------- 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 scfdopen(int fd, int flags, int *ep); Open a connection to a smart card given an fd already open on a serial port. This just sets the proper port parameters (9600 bps, 8/E/1). 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 scdsr(int fd); Return the state of DSR, which usually indicates whether a card is present. ---------------------------------------------------------------------------- int scdtr(int fd, int cmd); Raise or lower DTR depending on whether 'cmd' is 1 or 0. ---------------------------------------------------------------------------- int scgetc(int fd, char *cp, int ms); Get one byte from the card into buffer pointed to by 'cp'. Time out after 'ms' milliseconds. 'ms' can be 0 for poll or -1 for infinite. ---------------------------------------------------------------------------- int scputc(int fd, int ic); Put one byte to the card. ---------------------------------------------------------------------------- void scsleep(int ms); Delay for 'ms' milliseconds.
Center for Information
Technology Integration
http://citi.umich.edu/
Send e-mail to info@citi.umich.edu
, or call +1 (313) 764-5440.
All contents copyright © 1997 University of Michigan. All
rights reserved.