Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

RSACard Class Reference
[Special Card Classes]

#include <rsacard.h>

Inheritance diagram for RSACard:

CTProcessorCard CTCard CTCardBase List of all members.

Public Member Functions

Constructors and Destructors
Methods to connect and disconnect the card. Most other methods only work if the card is open.

 RSACard (const CTCard &c)
 ~RSACard ()
Opening and closing operations
Methods to connect and disconnect the card. Most other methods only work if the card is open.

virtual CTError reopenCard ()
virtual CTError openCard ()
virtual CTError closeCard (bool force=false)
Informational methods
These methods tell you about the type and the status of the card.

virtual string cardType ()
virtual string cardTypes ()
const string & initialPin () const
string cardNumber () const
Pin Verification and Changes
These method allow verifying and changing the pin. There are methods for terminals with keypads, too. On these you can enter the pin directly into the card readers keypad (secure mode).

CTError verifyPin (int kid, const string &pin)
CTError changePin (int kid, const string &oldpin, const string &newpin)
CTError changePin (int kid)
CTError verifyPin (int kid)
CTError pinStatus (int &maxerr, int &errleft)
Key Management
This group contains methods to create, read, write, inspect and update keys on the card.

CTError deleteKeyDescriptor (int kid)
unsigned int readKeyStatus (int kid)
CTError writeKeyStatus (int kid, unsigned int st)
CTError writeKeyDescriptor (int kid, const string &kd)
string readKeyDescriptor (int kid)
string readPublicKey (int kid)
CTError writePublicKey (int kid, const string &modulus)
string createKey (int kid, bool overwrite)
CTError activateKey (int kid, int num, int ver)
bool isBankKey (int kid)
bool isSignKey (int kid)
int getKeyId (int bank, bool pub, bool sign)
KeyLogStatus readKeyLogStatus ()
CTError writeKeyLogStatus (KeyLogStatus st)
Bank Descriptions
Methods of this group read, delete and update bank descriptions on the card.

BankDescription readBankDescription (int idx)
CTError writeBankDescription (int idx, const BankDescription &bd)
CTError deleteBankDescription (int idx)
int findFreeBankDescription ()
Cryptographic Methods
Methods of this group allow signing, verifying a signature, encrypting and decrypting data.

string getRandom (int s)
string sign (int kid, const string &data)
CTError verify (int kid, const string &data, const string &signature)
string encrypt (int kid, const string &data)
string decrypt (int kid, const string &data)
Signature Sequence Counter
This group contains methods concerning the signature sequence counter. This can only be read (not written) and is updated automatically upon sign(). When creating keys for a bank context then this counter is reset to 0.

unsigned int readSeq (int bank)
CTError writeSeq (int bank, unsigned int seq)

Constructor & Destructor Documentation

RSACard::RSACard const CTCard c  ) 
 

RSACard::~RSACard  ) 
 


Member Function Documentation

CTError RSACard::activateKey int  kid,
int  num,
int  ver
 

This activates a previously created key pair. After this method has been called the new keys are stored at their final destination and used by all subsequent calls to cryptographic methods with this key id.

string RSACard::cardNumber  )  const [inline]
 

Returns the cards serial number.

virtual string RSACard::cardType  )  [virtual]
 

This method returns a short name of the class which handles this card. A HBCI card for example returns "HBCICard". So you can use this method to check for the type of the card.

Reimplemented from CTProcessorCard.

virtual string RSACard::cardTypes  )  [virtual]
 

This method returns a comma separated list of all card types this card inherits including the type of this card, e.g. a HBCI card would return "CTProcessorCard, HBCICard". If you overload this method in your own class (you SHOULD) you simply have to call this method of the class it directly inherits. That class will then do the same, so that there is a list upon return.

Reimplemented from CTProcessorCard.

CTError RSACard::changePin int  kid  ) 
 

Changes the pin using the keypad of your reader. This is the recommended method of changing the pin, since no trojan horse can spy out your pin !

Returns:
error code
Parameters:
kid key id (0x90 for Keyholder pin, 0x91 for device pin)

CTError RSACard::changePin int  kid,
const string &  oldpin,
const string &  newpin
 

Changes the pin without using the keypad. If your reader has a keypad I recommend using the secure method !!

Returns:
error code
Parameters:
kid key id (0x90 for Keyholder pin, 0x91 for device pin)
oldpin old pin (ASCII)
newpin new pin (ASCII)

virtual CTError RSACard::closeCard bool  force = false  )  [virtual]
 

Call this if you have finished working with the card. After this method is called you may safely remove the card from the reader.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)

Reimplemented from CTCard.

string RSACard::createKey int  kid,
bool  overwrite
 

Creates a keypair for the given key id. This can take some seconds (up to a minute). The key pair created is not automatically activated.

Returns:
modulus of the key created

string RSACard::decrypt int  kid,
const string &  data
 

CTError RSACard::deleteBankDescription int  idx  ) 
 

CTError RSACard::deleteKeyDescriptor int  kid  ) 
 

Deletes a key descriptor. This allows overwriting a key stored on the card.

Parameters:
kid key id

string RSACard::encrypt int  kid,
const string &  data
 

int RSACard::findFreeBankDescription  ) 
 

int RSACard::getKeyId int  bank,
bool  pub,
bool  sign
 

Translates the given information about a key into a key id which can then be used for the other methods of this class.

string RSACard::getRandom int  s  ) 
 

const string& RSACard::initialPin  )  const [inline]
 

Returns the initial pin of a pristine card. On such a card verifying the pin does not work as long as you did not change the pin using changePin(). The initial pin (which MUST be changed) is the serial number of the card stored in one of the files on it. With this method here you get that number. This method is only valid after openCard() has been called successfully.

bool RSACard::isBankKey int  kid  ) 
 

Checks whether the given key id belongs to a partner of to us.

bool RSACard::isSignKey int  kid  ) 
 

Checks whether the given key id belongs to a signature key.

virtual CTError RSACard::openCard  )  [virtual]
 

Opens the card for usage. This way the card is powered on. This method does some basic checks and retrieves basic information about the card (whether it is a memory card or a processor card, the size of the memory etc). When this method successfully returns the card may be used.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)

Reimplemented from CTCard.

CTError RSACard::pinStatus int &  maxerr,
int &  errleft
 

Get the pin status of the card.

Parameters:
maxerr reference to an integer to receive the maximum number of bad tries for pin verification
errleft reference to an integer to receive the number of bad tries left for pin verification

BankDescription RSACard::readBankDescription int  idx  ) 
 

string RSACard::readKeyDescriptor int  kid  ) 
 

Reads a fully 8 byte key descriptor.

KeyLogStatus RSACard::readKeyLogStatus  ) 
 

The keylog status contains information about how many bank descriptions are in use and about whether there are newly generated but not yet activated keys.

unsigned int RSACard::readKeyStatus int  kid  ) 
 

Reads the key status for the given key.

string RSACard::readPublicKey int  kid  ) 
 

Reads the modulus of a public key. The exponent is defined to be always 0x010001.

unsigned int RSACard::readSeq int  bank  ) 
 

virtual CTError RSACard::reopenCard  )  [virtual]
 

When this method is called normally the card is already opened by means of openCard(). However, it is likely that openCard() has been called assuming this card is only a CTCard() object, nothing special. You may then call THIS method here on all known card classes to check for the type of this card. This method must assume that any file on the card is already selected, so it is in most cases a good idea to select the MF as the first action of this method. If the executing class finds that the card inserted is not of a type it can handle then it MUST return an error.

Reimplemented from CTProcessorCard.

string RSACard::sign int  kid,
const string &  data
 

CTError RSACard::verify int  kid,
const string &  data,
const string &  signature
 

CTError RSACard::verifyPin int  kid  ) 
 

Verifies the pin using the keypad of your reader. This is the recommended method of verifying the pin, since no trojan horse can spy out your pin !

Returns:
error code
Parameters:
kid key id (0x90 for Keyholder pin, 0x91 for device pin)

CTError RSACard::verifyPin int  kid,
const string &  pin
 

Verifies the pin without using the keypad. If your reader has a key pad I recommend using the secure method !!

Returns:
error code
Parameters:
kid key id (0x90 for Keyholder pin, 0x91 for device pin)
pin pin (ASCII)

CTError RSACard::writeBankDescription int  idx,
const BankDescription bd
 

CTError RSACard::writeKeyDescriptor int  kid,
const string &  kd
 

This method updates a full 8 byte key descriptor.

CTError RSACard::writeKeyLogStatus KeyLogStatus  st  ) 
 

Updates the keylog status.

CTError RSACard::writeKeyStatus int  kid,
unsigned int  st
 

Updates the key status for the given key.

CTError RSACard::writePublicKey int  kid,
const string &  modulus
 

Updates the modulus of a public key. This is used to store the partners public keys on the card (like the pulic keys of the bank).

CTError RSACard::writeSeq int  bank,
unsigned int  seq
 


The documentation for this class was generated from the following file:
Generated on Wed Jul 28 14:56:50 2004 for libchipcard by doxygen 1.3.7