Token Class Reference

Collaboration diagram for Token:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class represents the Token (the Smart Card) we are connected to. This class could (and should) be changed to be an interface so that it can accommodate other Tokens.


Public Member Functions

CK_RV getInfo (CK_TOKEN_INFO_PTR infoOut)
string getManufacturer (void)
size_t getMechanismCount ()
list< Mechanism * > getMechanisms ()
list< CryptoObject * > findObjects (Session *session, CK_ATTRIBUTE_PTR attributes, CK_ULONG ulCount)
Session * openSession (CK_FLAGS flags, CK_VOID_PTR data, CK_NOTIFY notifyFunc)
void closeSession (Session *session)
list< Session * > getSessions ()
Mechanism * getMechanism (CK_MECHANISM_TYPE type)
Session * getSession (CK_SESSION_HANDLE handle)
CryptoObject * getCryptoObject (CK_OBJECT_HANDLE handle)
CryptoObject * addCryptoObject (CryptoObject *obj)
CK_RV sign (Session *sess, CK_BYTE *in, CK_ULONG inLen, CK_BYTE *out, CK_ULONG *outLen)
CK_RV decrypt (Session *sess, CK_BYTE *in, CK_ULONG inLen, CK_BYTE *out, CK_ULONG *outLen)
 Token (Slot *slot)
 ~Token (void)


Constructor & Destructor Documentation

Token::Token Slot *  slot  ) 
 

constructs a new Token and ties it to slot

Parameters:
slot the slot this token is inserted into

Token::~Token void   ) 
 

Cleanups up all the session and Objects associated with this token


Member Function Documentation

CK_RV Token::getInfo CK_TOKEN_INFO_PTR  infoOut  ) 
 

This method is necessary to support Cryptoki. Cryptoki queries the card for all kinds of information and this is how it get's direct information about the card and it's abilities.

Parameters:
infoOut a pointer to a struct that will receive the information
Returns:
the success/error code as defined in pkcs11t.h

string Token::getManufacturer void   ) 
 

Setters and getters. Their use should be obvious

size_t Token::getMechanismCount  ) 
 

returns the number of mechanism currently available. Right now, only 1 is supported: CKM_RSA_PKCS

Returns:
the number of mechanisms currently available

list< Mechanism * > Token::getMechanisms  ) 
 

returns a list of the currently available mechanisms.

Returns:
a mechanism list

list< CryptoObject * > Token::findObjects Session *  session,
CK_ATTRIBUTE_PTR  attributes,
CK_ULONG  ulCount
 

this method finds all objects registered on this token that match the atribute array 'attributes'

Parameters:
session a pointer to an active session object
attributes the attribute array that is the search criteria for the objects being sought

Session * Token::openSession CK_FLAGS  flags,
CK_VOID_PTR  data,
CK_NOTIFY  notifyFunc
 

Creates a new session object and connects to the card. Directly supports Cryptoki

Parameters:
flags specified by Cryptoki as to how this session should be openned. This is always be SERIAL_SESSION
data not used by us or Cryptoki. Future use
notifyFunc not used by us or Cryptoki. Future use along with data -- function for announcing a card has been inserted

void Token::closeSession Session *  session  ) 
 

let's us know that Cryptoki is done with 'session' and we can terminate it's usage.

Parameters:
session the session that Cryptoki is done with

list< Session * > Token::getSessions  ) 
 

returns a list of sessions current open

Returns:
a list of sessions current open

Mechanism * Token::getMechanism CK_MECHANISM_TYPE  type  ) 
 

This method fetches you the Mechanism object related to the Cryptoki type passed in

Parameters:
type the Cryptoki mechanism type
Returns:
a pointer to a mechanism indentified by the 'type'

Session * Token::getSession CK_SESSION_HANDLE  handle  ) 
 

This method fetches you the Session object related to the handle passed in by Cryptoki

Parameters:
handle the handle used to lookup the session
Returns:
the session for your handle, NULL if it doesn't exist

CryptoObject * Token::getCryptoObject CK_OBJECT_HANDLE  handle  ) 
 

This method fetches you the CryptoObject related to the handle passed in by Cryptoki

Parameters:
handle the handle used to lookup the Object. An example of this use is to get the X509 certs
Returns:
the CryptoObject for your handle, NULL if it doesn't exist

CryptoObject * Token::addCryptoObject CryptoObject *  obj  ) 
 

This method 'registers' a Crypto object with 'this' Token.

Parameters:
obj the objected to be added
Returns:
simply returns 'obj' for convenience

PIV_RV Token::sign Session *  sess,
CK_BYTE *  in,
CK_ULONG  inLen,
CK_BYTE *  out,
CK_ULONG *  outLen
 

Signs the input data.

Parameters:
sess and active session to access the card and determine all runtime needs to complete this call
in a pointer to the input data to sign
inLen the length of the data to sign
out a buffer to receive the output data
outLen (in/out) the length of the output buffer (in) and the length of data actually put into the buffer
Returns:
a value as define in pkcs11t.h

PIV_RV Token::decrypt Session *  sess,
CK_BYTE *  in,
CK_ULONG  inLen,
CK_BYTE *  out,
CK_ULONG *  outLen
 

Encrypts the input data.

Parameters:
sess and active session to access the card and determine all runtime needs to complete this call
in a pointer to the input data to sign
inLen the length of the data to sign
out a buffer to receive the output data
outLen (in/out) the length of the output buffer (in) and the length of data actually put into the buffer
Returns:
a value as define in pkcs11t.h


Generated on Fri Jan 12 15:48:46 2007 for NIST_PKCS11 by doxygen 1.3.1 using KingsTools