TABLE OF CONTENTS

 

[Modules] SpringCardPCSC

NAME

   SpringCardPCSC

DESCRIPTION

   SpringCard's wrapper for PC/SC API

COPYRIGHT

AUTHOR

   Johann.D and Emilie.C / SpringCard

HISTORY

   ECL ../../2009 : early drafts
   JDA 21/04/2010 : first official release
   JDA 20/11/2010 : improved the SCardChannel object: implemented SCardControl, exported the hCard

PORTABILITY

   .NET on Win32 or Win64

[Functions] CardProtocolToString

NAME

   SCARD.CardProtocolToString

DESCRIPTION

   Translate the Protocol of the card into a user-readable string

SYNOPSIS

   string SCARD.CardProtocolToString( uint protocol );

[Functions] CardShareModeToString

NAME

   SCARD.CardShareModeToString

DESCRIPTION

   Translate the Share Mode of the card into a user-readable string

SYNOPSIS

   string SCARD.CardShareModeToString( uint share_mode );

[Functions] CardStatusWordsToString

NAME

   SCARD.CardStatusWordsToString

DESCRIPTION

   Translate the Status Word of the card into a user-readable string

SYNOPSIS

   string SCARD.CardStatusWordsToString( byte SW1, byte SW2 );
   string SCARD.CardStatusWordsToString( ushort SW );

[Functions] Connect

NAME

   SCARD.Connect

DESCRIPTION

   .NET wrapper for SCardConnect (UNICODE implementation)

[Functions] Control

NAME

   SCARD.Control

DESCRIPTION

   .NET wrapper for SCardControl

[Functions] Disconnect

NAME

   SCARD.Disconnect

DESCRIPTION

   .NET wrapper for SCardDisconnect

[Functions] ErrorToString

NAME

   SCARD.ErrorToString

DESCRIPTION

   Translate a PC/SC error code into a user-readable string

SYNOPSIS

   string SCARD.ErrorToString( uint code );

[Functions] EstablishContext

NAME

   SCARD.EstablishContext

DESCRIPTION

   .NET wrapper for SCardEstablishContext

[Functions] GetStatusChange

NAME

   SCARD.GetStatusChange

DESCRIPTION

   .NET wrapper for SCardGetStatusChange (UNICODE implementation)

[Functions] ListReaders

NAME

   SCARD.ListReaders

DESCRIPTION

   .NET wrapper for SCardListReaders (UNICODE implementation)

[Functions] Readers

NAME

   SCARD.Readers

DESCRIPTION

   Provides the list of the connected PC/SC readers

SYNOPSIS

   string[] SCARD.Readers

[Functions] ReaderStatusToString

NAME

   SCARD.ReaderStatusToString

DESCRIPTION

   Translate the Status of the reader into a user-readable string

SYNOPSIS

   string SCARD.ReaderStatusToString( uint state );

[Functions] Reconnect

NAME

   SCARD.Reconnect

DESCRIPTION

   .NET wrapper for SCardReconnect

[Functions] ReleaseContext

NAME

   SCARD.ReleaseContext

DESCRIPTION

   .NET wrapper for SCardReleaseContext

[Functions] Status

NAME

   SCARD.Status

DESCRIPTION

   .NET wrapper for SCardStatus (UNICODE version)

[Functions] Transmit

NAME

   SCARD.Transmit

DESCRIPTION

   .NET wrapper for SCardTransmit

[Variables] CardAtr

NAME

   SCardChannel.CardAtr

SYNOPSIS

   CardBuffer CardAtr

OUTPUT

   Returns the ATR of the smartcard in the reader, or null if no smartcard is present.

SEE ALSO

   SCardChannel.CardPresent

[Variables] CardAvailable

NAME

   SCardChannel.CardAvailable

SYNOPSIS

   bool CardAvailable

OUTPUT

   Returns true if a card is available in the reader associated to the SCardChannel object.
   Returns false if there's no smartcard in the reader, or if it is already used by another process/thread.

SEE ALSO

   SCardChannel.CardPresent
   SCardChannel.CardAtr

[Variables] CardPresent

NAME

   SCardChannel.CardPresent

SYNOPSIS

   bool CardPresent

OUTPUT

   Returns true if a card is present in the reader associated to the SCardChannel object.
   Returns false if there's no smartcard in the reader.

SEE ALSO

   SCardChannel.CardAvailable
   SCardChannel.CardAtr

[Variables] Command

NAME

   SCardChannel.Command

SYNOPSIS

   CAPDU Command

DESCRIPTION

   C-APDU to be sent to the card through SCardChannel.Transmit

[Methods] Connect

NAME

   SCardChannel.Connect()

SYNOPSIS

   bool Connect()

DESCRIPTION

   Open the connection channel to the smartcard (according to the specified Protocol, default is either T=0 or T=1)

OUTPUT

   Returns true if the connection has been successfully established.
   Returns false if not. See LastError for details.

SEE ALSO

   SCardChannel.CardPresent
   SCardChannel.CardAtr
   SCardChannel.Protocol
   SCardChannel.Transmit

[Variables] Connected

NAME

   SCardChannel.Connected

SYNOPSIS

   bool Connected

OUTPUT

   Returns true if the SCardChannel object is actually connected to a smartcard.
   Returns false if not.

[Methods] Disconnect

NAME

   SCardChannel.Disconnect()

SYNOPSIS

   void Disconnect()
   void Disconnect(uint disposition)

DESCRIPTION

   Close the connection channel

INPUTS

   The disposition parameter must take one of the following values:
   - SCARD.EJECT_CARD
   - SCARD.UNPOWER_CARD
   - SCARD.RESET_CARD
   - SCARD.LEAVE_CARD
   If this parameter is omitted, it defaults to SCARD.RESET_CARD

SEE ALSO

   SCardChannel.Connect

[Methods] DisconnectEject

NAME

   SCardChannel.DisconnectEject()

SYNOPSIS

   void DisconnectEject()

DESCRIPTION

   Same as SCardChannel.Disconnect(SCARD.EJECT_CARD)

[Methods] DisconnectLeave

NAME

   SCardChannel.DisconnectLeave()

SYNOPSIS

   void DisconnectLeave()

DESCRIPTION

   Same as SCardChannel.Disconnect(SCARD.LEAVE_CARD)

[Methods] DisconnectReset

NAME

   SCardChannel.DisconnectReset()

SYNOPSIS

   void DisconnectReset()

DESCRIPTION

   Same as SCardChannel.Disconnect(SCARD.RESET_CARD)

[Methods] DisconnectUnpower

NAME

   SCardChannel.DisconnectUnpower()

SYNOPSIS

   void DisconnectUnpower()

DESCRIPTION

   Same as SCardChannel.Disconnect(SCARD.UNPOWER_CARD)

[Variables] LastError

NAME

   SCardChannel.LastError

SYNOPSIS

   uint LastError

OUTPUT

   Returns the last error encountered by the object when working with SCARD functions.

SEE ALSO

   SCardChannel.LastErrorAsString

[Variables] LastErrorAsString

NAME

   SCardChannel.LastErrorAsString

SYNOPSIS

   string LastErrorAsString

OUTPUT

   Returns the last error encountered by the object when working with SCARD functions.

SEE ALSO

   SCardChannel.LastError

[Variables] Protocol

NAME

   SCardChannel.Protocol

SYNOPSIS

   uint Protocol

INPUTS

   Before the smartcard has been 
 
 
 , set Protocol to specify the communication protocol(s) to be used
   by Connect(). Allowed values are SCARD.PROTOCOL_T0, SCARD.PROTOCOL_T1 or SCARD.PROTOCOL_T0|SCARD.PROTOCOL_T1.

OUTPUT

   Once the smartcard has been connected (Connected == true), Protocol is the current communication protocol.
   Possible values are SCARD.PROTOCOL_T0 or SCARD.PROTOCOL_T1.

SEE ALSO

   SCardChannel.ProtocolAsString

[Variables] ProtocolAsString

NAME

   SCardChannel.ProtocolAsString

SYNOPSIS

   string ProtocolAsString

INPUTS

   Before the smartcard has been connected, set ProtocolAsString to specify the communication protocol(s) to be used
   by Connect(). Allowed values are "T=0", "T=1" or "*" (or "T=0|T=1").

OUTPUT

   Once the smartcard has been connected (Connected == true), ProtocolAsString is the current communication protocol.
   Possible values are "T=0" or "T=1".

SEE ALSO

   SCardChannel.Protocol

[Variables] Response

NAME

   SCardChannel.Response

SYNOPSIS

   RAPDU Response

DESCRIPTION

   R-APDU returned by the card after a succesfull call to SCardChannel.Transmit

[Variables] ShareMode

NAME

   SCardChannel.ShareMode

SYNOPSIS

   uint ShareMode

INPUTS

   Before the smartcard has been connected, set ShareMode to specify the sharing mode to be used
   by Connect(). Allowed values are SCARD.SHARE_EXCLUSIVE, SCARD.SHARE_SHARED or SCARD.SHARE_DIRECT.

SEE ALSO

   SCardChannel.ShareModeAsString

[Variables] ShareModeAsString

NAME

   SCardChannel.ShareModeAsString

SYNOPSIS

   string ShareModeAsString

INPUTS

   Before the smartcard has been connected, set ShareModeAsString to specify the sharing mode to be used
   by Connect(). Allowed values are "EXCLUSIVE", "SHARED" or "DIRECT".

SEE ALSO

   SCardChannel.ShareMode

[Methods] Transmit

NAME

   SCardChannel.Transmit()

SYNOPSIS

   bool  Transmit()
   RAPDU Transmit(CAPDU capdu)
   bool  Transmit(CAPDU capdu, ref RAPDU rapdu)
   void  Transmit(CAPDU capdu, TransmitDoneCallback callback)

DESCRIPTION

   Sends a command APDU (CAPDU) to the connected card, and retrieves its response APDU (RAPDU)

SOURCE

   SCardChannel card = new SCardChannel( ... reader ... );
   if (!card.Connect( SCARD.PROTOCOL_T0|SCARD.PROTOCOL_T1 ))
   {
     // handle error
   }


   // Example 1
   // ---------

   card.Command = new CAPDU("00 A4 00 00 02 3F 00");
   if (!card.Transmit())
   {
     // handle error
   } 
   MessageBox.Show("Card answered: " + card.Response.AsString(" "));


   // Example 2
   // ---------

   RAPDU response = card.Transmit(new CAPDU("00 A4 00 00 02 3F 00")))
   if (response == null)
   {
     // handle error
   }
   MessageBox.Show("Card answered: " + response.AsString(" "));


   // Example 3
   // ---------

   CAPDU command  = new CAPDU("00 A4 00 00 02 3F 00");
   RAPDU response = new RAPDU();
   if (!card.Transmit(command, ref response))
   {
     // handle error
   } 
   MessageBox.Show("Card answered: " + response.AsString(" "));


   // Example 4
   // ---------

   // In this example the Transmit is performed by a background thread
   // We supply a delegate so the main class (window/form) will be notified
   // when Transmit will return

   delegate void OnTransmitDoneInvoker(RAPDU response);

   void OnTransmitDone(RAPDU response)
   {
     // Ensure we're back in the context of the main thread (application's message pump)
     if (this.InvokeRequired)
     {
       this.BeginInvoke(new OnTransmitDoneInvoker(OnTransmitDone), response);
       return;
     }
                      
     if (response == null)
     {
       // handle error
     }

     MessageBox.Show("Card answered: " + response.AsString(" "));
   }

  card.Transmit(new CAPDU("00 A4 00 00 02 3F 00"), new SCardChannel.TransmitDoneCallback(OnTransmitDone));

SEE ALSO

   SCardChannel.Connect
   SCardChannel.Transmit
   SCardChannel.Command
   SCardChannel.Response

[Variables] CardAtr

NAME

   SCardReader.CardAtr

SYNOPSIS

   CardBuffer CardAtr

OUTPUT

   If a smartcard is present in the reader (SCardReader.CardPresent == true), returns the ATR of the card.
   Returns null overwise.

SEE ALSO

   SCardReader.CardPresent 
   SCardReader.Status

[Variables] CardAvailable

NAME

   SCardReader.CardAvailable

SYNOPSIS

   bool CardAvailable

OUTPUT

   Returns true if a card is available in the reader.
   Returns false if there's no smartcard in the reader, or if it is already used by another process/thread.

SEE ALSO

   SCardReader.CardAtr
   SCardReader.CardPresent 
   SCardReader.Status

[Variables] CardPresent

NAME

   SCardReader.CardPresent

SYNOPSIS

   bool CardPresent

OUTPUT

   Returns true if a card is present in the reader.
   Returns false if there's no smartcard in the reader.

SEE ALSO

   SCardReader.CardAtr
   SCardReader.CardAvailable
   SCardReader.Status

[Variables] LastError

NAME

   uint SCardReader.LastError

OUTPUT

   Returns the last error encountered by the object when working with SCARD functions.

SEE ALSO

   SCardReader.LastErrorAsString

[Variables] LastErrorAsString

NAME

   string SCardReader.LastErrorAsString

OUTPUT

   Returns the last error encountered by the object when working with SCARD functions.

SEE ALSO

   SCardReader.LastError

[Variables] Name

NAME

   SCardReader.Name

SYNOPSIS

   string Name

OUTPUT

   Return the name of the reader specified when instanciating the object.

[Methods] StartMonitor

NAME

   SCardReader.StartMonitor()

SYNOPSIS

   SCardReader.StartMonitor(SCardReader.StatusChangeCallback callback);

DESCRIPTION

   Create a background thread to monitor the reader associated to the object.
   Everytime the status of the reader is changed, the callback is invoked.

SEE ALSO

   SCardReader.StatusChangeCallback
   SCardReader.StopMonitor()

[Variables] Status

NAME

   SCardReader.Status

SYNOPSIS

   uint Status

OUTPUT

   Returns the current status of the reader.

SEE ALSO

   SCardReader.CardPresent
   SCardReader.StatusAsString

[Variables] StatusAsString

NAME

   SCardReader.StatusAsString

SYNOPSIS

   string StatusAsString

OUTPUT

   Returns the current status of the reader, using SCARD.ReaderStatusToString as formatter.

SEE ALSO

   SCardReader.Status

[Types] StatusChangeCallback

NAME

   SCardReader.StatusChangeCallback

SYNOPSIS

   delegate void StatusChangeCallback(uint ReaderState, CardBuffer CardAtr);

DESCRIPTION

   Typedef for the callback that will be called by the background thread launched
   by SCardReader.StartMonitor(), everytime the status of the reader is changed.

NOTES

   The callback is invoked in the context of a background thread. This implies that
   it is not allowed to access the GUI's components directly.

[Methods] StopMonitor

NAME

   SCardReader.StopMonitor()

DESCRIPTION

   Stop the background thread previously launched by SCardReader.StartMonitor().

[Classes] CAPDU

NAME

   CAPDU

DESCRIPTION

   The CAPDU object is used to format and send COMMAND APDUs (according to ISO 7816-4) to the smartcard

DERIVED FROM

   CardBuffer

[Classes] CardBuffer

NAME

   CardBuffer

DESCRIPTION

   The CardBuffer provides convenient access to byte-arrays

DERIVED BY

   CAPDU
   RAPDU

[Classes] RAPDU

NAME

   RAPDU

DESCRIPTION

   The RAPDU object is used to receive and decode RESPONSE APDUs (according to ISO 7816-4) from the smartcard

DERIVED FROM

   CardBuffer

[Classes] SCARD

NAME

   SCARD

DESCRIPTION

   Static class that gives access to PC/SC functions (SCard... provided by winscard.dll)

[Classes] SCardChannel

NAME

   SCardChannel

DESCRIPTION

   The SCardChannel object provides the actual connection to the smartcard through the PC/SC reader

SYNOPSIS

   SCardChannel( string reader_name );
   SCardChannel( SCardReader reader );

[Classes] SCardReader

NAME

   SCardReader

DESCRIPTION

   The SCardReader object is used to monitor a PC/SC reader (i.e. wait for card arrival)

SYNOPSIS

   SCardReader( string reader_name );

Generated from SpringCardPCSC.cs on Tue Jan 25 16:50:37 2011