Hello,

I have written a card abstraction layer that sits on top of pcsc-lite.  It
is a separate package so I can keep the whole project as modular as
possible.  It makes calls on the libpcsclite that comes with pcsc-lite.
Right now I have abstracted the basic file operations (SSP) in C style
functions.  The following is the API used.  Please submit API suggestions
for Java type cards if you have any ideas such as SCardLoadApplet etc.  I
will have a SSP supporting the following functions by next week.  I will
pre-release this week with one that will open, read, and write to files.

So a basic smartcard transaction includes the following:

SCARDCONTEXT hContext;
SCARDCHANNEL sChannel;

SCardEstablishContext( SCARD_SCOPE_SYSTEM, 0, 0, &hContext );
SCardAttachByIFD( hContext, "Reader Name", &sChannel );
  // Then do some card commands
SCardChangeDir( &sChannel, SC_TYPE_RELATIVE, "/3F00/00AB" );
....
SCardReleaseContext( hContext );

It is really easy.  Basically the SCardAttachByIFD function will call
connect and store the handle in the SCARDCHANNEL structure.  It then calls
SCardStatus
to get the ATR and it's state and size.  After that it looks for a matching
card in the /etc/card.conf file and load the appropriate library for that
card.  It all happens in the background.  This package will be called
pcsc-lite-ssp-0.1.0
and will require pcsc-lite.  The card abstraction library is under 10k and
with the pcsclite library both are still under 20k and closer to 10k when
stripped.


Here is the API

LONG SCardAttachByIFD( SCARDCONTEXT, LPSTR, PSCARDCHANNEL );
LONG SCardGetCurrentDir( PSCARDCHANNEL, LPSTR* );
LONG SCardChangeDir( PSCARDCHANNEL, DWORD, LPCSTR );
LONG SCardCreate( PSCARDCHANNEL, DWORD, LPCSTR, TLV_TABLE,
                  DWORD, PUCHAR, DWORD );
LONG SCardInvalidate( PSCARDCHANNEL, LPCSTR, DWORD );
LONG SCardRehabilitate( PSCARDCHANNEL, LPCSTR, DWORD );
LONG SCardGetProperties( PSCARDCHANNEL, DWORD, LPCSTR, DWORD, LPTLV_TABLE* );
LONG SCardSetProperties( PSCARDCHANNEL, DWORD, LPCSTR, DWORD, LPTLV_TABLE );
LONG SCardOpen( PSCARDCHANNEL, DWORD, LPCSTR, SCARDFILE* );
LONG SCardClose( PSCARDCHANNEL, SCARDFILE );
LONG SCardRead( PSCARDCHANNEL, SCARDFILE, DWORD, PUCHAR, DWORD* );
LONG SCardWrite( PSCARDCHANNEL, SCARDFILE, DWORD, PUCHAR, DWORD );
LONG SCardSeek( PSCARDCHANNEL, SCARDFILE, DWORD, DWORD );

The SSP driver basically is all the function above except instead of SCard****
it is ISFA***** so SCardOpen calls IFSAOpen through the dynamic library
loading interface.  This is all done for you when you call SCard****.

Regards,
Dave

David Corcoran                                  Purdue University

1008 Cherry Lane                                MUSCLE Smartcard Developers
West Lafayette, IN 47906                        http://www.linuxnet.com
765-463-0096                                    765-427-5147 cellular



***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to