class CamCard

Wrapper object to abstract the PC/SC API and access the filesystem on the card. More...

Definition#include <camcard.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Public Members


Detailed Description

This class takes care of communicating to the PC/SC middleware and accessing the features of the Cambridge University smartcard.

static const vector MF

MF

static const vector CHUBB

CHUBB

static const vector PLAYPEN

PLAYPEN

static const vector DF_AUT

DF_AUT

static const vector MAIN_PUB_KEY

MAIN_PUB_KEY

static const vector MAIN_CERT

MAIN_CERT

static const vector SUMMARY

SUMMARY

static const vector CARD_INFO

CARD_INFO

static const vector EF_LIST

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 ()

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:
readerA 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 apdu, vector &resp)

sendAPDU

Sends an APDU to the card, writing the result into the vector passed by reference.

Parameters:
apduThe APDU to send.
respThe 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 fileID, vector &header)

selectFile

Selects a file by the fileID passed.

Parameters:
fileIDA vector containing the two-byte file ID of the file to select.
headerA 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 header, vector &file)

readFile

Reads a file previously selected with selectFile().

Parameters:
headerA vector containing the fileheader returned by selectFile().
fileA 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:
pinString containing PIN

Returns: true if PIN accepted, false otherwise

bool  changePIN (string old_pin, string new_pin)

changePIN

Chenges the current PIN

Parameters:
old_pinThe original PIN.
new_pinThe new PIN.

Returns: true if PIN accepted, false otherwise

long  sign (int keyID, const vector data, vector &signature)

sign

Digitally 'sign' some data using a specified key. The correct PIN must have been presented during the transaction using presentPIN();

Parameters:
dataThe data to be signed.
signatureThe vector to write the signature into.
keyIDkeyID of key to use.

Returns: SCARD_S_SUCCESS if successful, an error code otherwise.

See also: presentPIN, keyIDs

vector  keyIDs ()

keyIDs

Returns: a vector of valid keyIDs

long  readCertificate (int keyID, vector &cert)

readCertificate

Write the certificate asssociated with the keyID specified into a vector.

Parameters:
keyIDthe keyID of required key.
certthe vector to write the certificate into.

Returns: SCARD_S_SUCCESS if successful, an error code otherwise.

See also: keyIDs

long  readModulus (int keyID, vector &modulus)

readModulus

Write the public modulus of the specidied key into a vector.

Parameters:
keyIDthe keyID of required key.
modulusthe vector to write the modulus into.

Returns: SCARD_S_SUCCESS if successful, an error code otherwise.

See also: keyIDs

string  vec2str (const vector vec)

vec2str

[static]

Converts a vector into a string of two-character hex values.

vector  str2vec (string str)

str2vec

[static]

Converts a string of two-character hex values into a vector.