|
|
This class takes care of communicating to the PC/SC middleware and accessing the features of the Cambridge University smartcard.
| static const vector | MF |
| static const vector | CHUBB |
| static const vector | PLAYPEN |
| static const vector | DF_AUT |
| static const vector | MAIN_PUB_KEY |
| static const vector | MAIN_CERT |
| static const vector | SUMMARY |
| static const vector | CARD_INFO |
| static const vector | EF_LIST |
| CamCard ()
| CamCard |
Default constructor.
| ~CamCard ()
| ~CamCard |
Default destructor.
| string stringifyError (long errno)
| stringifyError |
[static]
Convert an error code to human-readable string.
Returns: a string describing the error code passed.
| long connect (string host = "")
| connect |
Connect to the PC/SC middleware. You must call this method before doing anything else.
Parameters:
| host | (optional) The hostname of the machine you wish to connect to. If not specified, the PC/SC middleware on the local machine is contacted. By default, the first reported smartcard reader is used. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: disconnect
| long disconnect ()
| disconnect |
Disconnects from the PC/SC middleware peviously connected to with connect().
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: connect
| bool isConnected ()
| isConnected |
See if a connection has been established to the PC/SC middleware.
Returns: true if a connection is present, false otherwise.
| vector | readers |
Returns: A vector of strings containing a description of each smartcard reader connected to the PC/SC middleware. Indices into this vector are what you should pass to setReader() when changing readers.
See also: setReader
| bool setReader (int reader)
| setReader |
Set the smartcard reader which should be used. Disconnects from a card if you were connected.
Parameters:
| reader | A number from 0 to the number of elements in vector returned by readers(). |
Returns: true if successful, false otherwise.
See also: readers
| string reader ()
| reader |
Query the name of the current reader.
Returns: A string containing the smartcard reader which is being used.
| long connectCard ()
| connectCard |
Connects to the smartcard in the currently selected reader.
Returns: SCARD_S_SUCCESS if successful, -1 if there is no card, an error code otherwise.
See also: disconnectCard
| long disconnectCard ()
| disconnectCard |
Disconnects ftom a previously connected to card.
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: connectCard
| bool isConnectedCard ()
| isConnectedCard |
Query the connection state to the card.
Returns: tru is connected to a card, false otherwise
| bool cardPresent ()
| cardPresent |
Query the presence of a card in the currently selected reader.
Returns: true if there is a card present, false otherwise.
| int cardVersion ()
| cardVersion |
Query the card version (only returns meaningful results after a call to connectCard().
Returns: the version of the card currently connected to.
| long beginTransaction ()
| beginTransaction |
Starts a transaction with the card. This must be called before doing anthing with the card after connectCard().
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
| long endTransaction ()
| endTransaction |
Finishes a transaction with the card. This must be called after doing anthing with the card.
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: beginTransaction
| long sendAPDU (vector | sendAPDU |
Sends an APDU to the card, writing the result into the vector passed by reference.
Parameters:
| apdu | The APDU to send. |
| resp | The vector to write the response into. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
| unsigned long APDUReturnCode ()
| APDUReturnCode |
Get the return code from last APDU.
Returns: 16-bit return code.
| long selectFile (const vector | selectFile |
Selects a file by the fileID passed.
Parameters:
| fileID | A vector containing the two-byte file ID of the file to select. |
| header | A vector of undigned char's to write the file header into. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
| long readFile (const vector | readFile |
Reads a file previously selected with selectFile().
Parameters:
| header | A vector containing the fileheader returned by selectFile(). |
| file | A vector to write the file contents into. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
| bool presentPIN (string pin)
| presentPIN |
Presents the PIN specified.
Parameters:
| pin | String containing PIN |
Returns: true if PIN accepted, false otherwise
| bool changePIN (string old_pin, string new_pin)
| changePIN |
Chenges the current PIN
Parameters:
| old_pin | The original PIN. |
| new_pin | The new PIN. |
Returns: true if PIN accepted, false otherwise
| long sign (int keyID, const vector | sign |
Digitally 'sign' some data using a specified key. The correct PIN must have been presented during the transaction using presentPIN();
Parameters:
| data | The data to be signed. |
| signature | The vector to write the signature into. |
| keyID | keyID of key to use. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: presentPIN, keyIDs
| vector | keyIDs |
Returns: a vector of valid keyIDs
| long readCertificate (int keyID, vector | readCertificate |
Write the certificate asssociated with the keyID specified into a vector.
Parameters:
| keyID | the keyID of required key. |
| cert | the vector to write the certificate into. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: keyIDs
| long readModulus (int keyID, vector | readModulus |
Write the public modulus of the specidied key into a vector.
Parameters:
| keyID | the keyID of required key. |
| modulus | the vector to write the modulus into. |
Returns: SCARD_S_SUCCESS if successful, an error code otherwise.
See also: keyIDs
| string vec2str (const vector | vec2str |
[static]
Converts a vector into a string of two-character hex values.
| vector | str2vec |
[static]
Converts a string of two-character hex values into a vector.