libchipcard  5.1.6
Typedefs | Functions
Collaboration diagram for Basic Chipcard Functions:

Typedefs

typedef struct LC_CARD LC_CARD
 

Functions

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectEfById (LC_CARD *card, const int sid)
 

Flags for ISO Commands

#define LC_CARD_ISO_FLAGS_EFID_MASK   0x00000001f
 
#define LC_CARD_ISO_FLAGS_RECSEL_MASK   0x0000000e0
 
#define LC_CARD_ISO_FLAGS_RECSEL_FIRST   (0 << 5)
 
#define LC_CARD_ISO_FLAGS_RECSEL_LAST   (1 << 5)
 
#define LC_CARD_ISO_FLAGS_RECSEL_NEXT   (2 << 5)
 
#define LC_CARD_ISO_FLAGS_RECSEL_PREV   (3 << 5)
 
#define LC_CARD_ISO_FLAGS_RECSEL_GIVEN   (4 << 5)
 

Opening, Closing, Destroying

CHIPCARD_API void LC_Card_free (LC_CARD *cd)
 
CHIPCARD_API void LC_Card_List2_freeAll (LC_CARD_LIST2 *l)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_Open (LC_CARD *card)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_Close (LC_CARD *card)
 

Executing Card Commands

There are two ways of letting Libchipcard execute card commands:

  • directly sending a prebuilt APDU
  • referencing a command by name so that Libchipcard can built the APDU for the particular reader and card combination.

When working with Libchipcard the latter method is preferred since only in this case Libchipcard can adapt APDUs in order to make them work with a given combination of card and reader. Otherwise the application has to take care of the specialties of a given reader or card by itself.

CHIPCARD_API LC_CLIENT_RESULT LC_Card_ExecApdu (LC_CARD *card, const char *apdu, unsigned int len, GWEN_BUFFER *rbuf, LC_CLIENT_CMDTARGET t)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_ExecCommand (LC_CARD *card, const char *commandName, GWEN_DB_NODE *cmdData, GWEN_DB_NODE *rspData)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_BuildApdu (LC_CARD *card, const char *command, GWEN_DB_NODE *cmdData, GWEN_BUFFER *gbuf)
 

Select Card/Application Type

Functions in this group tell Libchipcard which instruction set is to be used for LC_Card_ExecApdu(). It also selects the XML descriptions appropriate for the card application to be used by the functions LC_Card_SelectDf() and LC_Card_SelectEf().

A card can contain multiple applications, e.g. some HBCI cards additionally contain the GeldKarte application. Different card applications contain different files/folders (EF/DF), so Libchipcard needs to be told which card application is to be used.

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectCard (LC_CARD *card, const char *s)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectApp (LC_CARD *card, const char *appName)
 

Select MF/DF/EF

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectMf (LC_CARD *card)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectDf (LC_CARD *card, const char *fname)
 
CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectEf (LC_CARD *card, const char *fname)
 

Detailed Description

Macro Definition Documentation

◆ LC_CARD_ISO_FLAGS_EFID_MASK

#define LC_CARD_ISO_FLAGS_EFID_MASK   0x00000001f

◆ LC_CARD_ISO_FLAGS_RECSEL_MASK

#define LC_CARD_ISO_FLAGS_RECSEL_MASK   0x0000000e0

Mask for flags used with record based functions (like LC_Card_IsoReadRecord)

◆ LC_CARD_ISO_FLAGS_RECSEL_FIRST

#define LC_CARD_ISO_FLAGS_RECSEL_FIRST   (0 << 5)

Select first record (used with record based functions like LC_Card_IsoReadRecord)

◆ LC_CARD_ISO_FLAGS_RECSEL_LAST

#define LC_CARD_ISO_FLAGS_RECSEL_LAST   (1 << 5)

Select last record (used with record based functions like LC_Card_IsoReadRecord)

◆ LC_CARD_ISO_FLAGS_RECSEL_NEXT

#define LC_CARD_ISO_FLAGS_RECSEL_NEXT   (2 << 5)

Select next record (used with record based functions like LC_Card_IsoReadRecord)

◆ LC_CARD_ISO_FLAGS_RECSEL_PREV

#define LC_CARD_ISO_FLAGS_RECSEL_PREV   (3 << 5)

Select previous record (used with record based functions like LC_Card_IsoReadRecord)

◆ LC_CARD_ISO_FLAGS_RECSEL_GIVEN

#define LC_CARD_ISO_FLAGS_RECSEL_GIVEN   (4 << 5)

Select given record (used with record based functions like LC_Card_IsoReadRecord)

Typedef Documentation

◆ LC_CARD

typedef struct LC_CARD LC_CARD

Function Documentation

◆ LC_Card_free()

CHIPCARD_API void LC_Card_free ( LC_CARD cd)

Release all ressources associated with the given card. You must call this function in order to avoid memory leaks.

◆ LC_Card_List2_freeAll()

CHIPCARD_API void LC_Card_List2_freeAll ( LC_CARD_LIST2 *  l)

◆ LC_Card_Open()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_Open ( LC_CARD card)

Opens a card obtained via LC_Client_GetNextCard. The action taken here depends on the derived card class (e.g. LC_DdvCard).

◆ LC_Card_Close()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_Close ( LC_CARD card)

Closes the given card. The action taken here depends on the derived card class (e.g. LC_DdvCard).

◆ LC_Card_ExecApdu()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_ExecApdu ( LC_CARD card,
const char *  apdu,
unsigned int  len,
GWEN_BUFFER *  rbuf,
LC_CLIENT_CMDTARGET  t 
)

Execute a prebuilt APDU and return the result. This function can be used when relaying APDUs from other APIs (such as the CTAPI shipped with Libchipcard which allows to access the service of Libchipcard via CTAPI).

◆ LC_Card_ExecCommand()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_ExecCommand ( LC_CARD card,
const char *  commandName,
GWEN_DB_NODE *  cmdData,
GWEN_DB_NODE *  rspData 
)

Executes a command referenced by name. This function looks for the given command in the description files of the currently selected card and reader which holds the card. This way the resulting APDU will work with that particular combination.

This function only works after the functions LC_Card_SelectApp and LC_Card_SelectCard have been called (which is done implicitly by the open-functions set by e.g. LC_DDVCard_ExtendCard() etc.

◆ LC_Card_BuildApdu()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_BuildApdu ( LC_CARD card,
const char *  command,
GWEN_DB_NODE *  cmdData,
GWEN_BUFFER *  gbuf 
)

This function is used internally by LC_Card_ExecCommand to create an APDU from a command for a particular combination of card and reader.

◆ LC_Card_SelectCard()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectCard ( LC_CARD card,
const char *  s 
)

◆ LC_Card_SelectApp()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectApp ( LC_CARD card,
const char *  appName 
)

◆ LC_Card_SelectMf()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectMf ( LC_CARD card)

This function selects the master file (corresponds to root on a filesystem).

◆ LC_Card_SelectDf()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectDf ( LC_CARD card,
const char *  fname 
)

Select a dedicated file below the currently selected one (or the master file). A DF can be thought of as a folder in a filesystem. Libchipcard looks this DF up in the XML description files of the current card and application an creates the appropriate APDU to select the DF either by short or long id (as determined by the XML files).

◆ LC_Card_SelectEf()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectEf ( LC_CARD card,
const char *  fname 
)

Select an elementary file below the currently selected DF (or MF). An EF can be thought of as a file in a filesystem. Libchipcard looks this EF up in the XML description files of the current card and application an creates the appropriate APDU to select the EF either by short or long id (as determined by the XML files).

◆ LC_Card_SelectEfById()

CHIPCARD_API LC_CLIENT_RESULT LC_Card_SelectEfById ( LC_CARD card,
const int  sid 
)

Select an elementary file below the currently selected DF (or MF). An EF can be thought of as a file in a filesystem. Libchipcard looks this EF up in the XML description files of the current card and application an creates the appropriate APDU to select the EF either by short or long id (as determined by the XML files).