sc-hsm-embedded
src/ctccid/ccid_usb.h File Reference
#include "scr.h"

Defines

#define ERR_ICC_MUTE   0xFE
#define ERR_XFR_OVERRUN   0xFC
#define ERR_HW_ERROR   0xFB
#define MSG_TYPE_PC_to_RDR_SetParameters   0x61
#define MSG_TYPE_PC_to_RDR_IccPowerOn   0x62
#define MSG_TYPE_PC_to_RDR_IccPowerOff   0x63
#define MSG_TYPE_PC_to_RDR_GetSlotStatus   0x65
#define MSG_TYPE_PC_to_RDR_XfrBlock   0x6F
#define MSG_TYPE_RDR_to_PC_DataBlock   0x80
#define MSG_TYPE_RDR_to_PC_SlotStatus   0x81
#define MSG_TYPE_RDR_to_PC_Parameters   0x82
#define ICC_PRESENT_AND_ACTIVE   0x00
#define ICC_PRESENT_AND_INACTIVE   0x01
#define NO_ICC_PRESENT   0x02
#define ICC_STATUS_MASK   0x03
#define MATCH(x, y)   ((x >= (y - y / 20)) && (x <= (y + y / 20)))

Functions

int PC_to_RDR_IccPowerOn (scr_t *ctx)
int PC_to_RDR_IccPowerOff (scr_t *ctx)
int PC_to_RDR_XfrBlock (scr_t *ctx, unsigned int outlen, unsigned char *outbuf)
int RDR_to_PC_DataBlock (scr_t *ctx, unsigned int *inlen, unsigned char *inbuf)
int PC_to_RDR_GetSlotStatus (scr_t *ctx)
int DetermineBaudrate (int F, int D)
int DecodeATRValues (scr_t *ctx)
int PC_to_RDR_SetParameters (scr_t *ctx)

Define Documentation

#define ERR_HW_ERROR   0xFB
#define ERR_ICC_MUTE   0xFE
#define ERR_XFR_OVERRUN   0xFC
#define ICC_PRESENT_AND_ACTIVE   0x00
#define ICC_PRESENT_AND_INACTIVE   0x01
#define ICC_STATUS_MASK   0x03
#define MATCH (   x,
 
)    ((x >= (y - y / 20)) && (x <= (y + y / 20)))
#define MSG_TYPE_PC_to_RDR_IccPowerOff   0x63
#define MSG_TYPE_PC_to_RDR_IccPowerOn   0x62
#define MSG_TYPE_PC_to_RDR_XfrBlock   0x6F
#define MSG_TYPE_RDR_to_PC_DataBlock   0x80
#define MSG_TYPE_RDR_to_PC_Parameters   0x82
#define MSG_TYPE_RDR_to_PC_SlotStatus   0x81
#define NO_ICC_PRESENT   0x02

Function Documentation

int DecodeATRValues ( scr_t ctx)

Decode protocol specified ATR values and store them in the reader context

Parameters:
ctxReader context
Returns:
0 on success, negative value otherwise
int DetermineBaudrate ( int  F,
int  D 
)

Calculate the current baudrate depending on the values of F and D

Parameters:
FClock rate conversion integer
DBaud rate adjustment integer
Returns:
Calculated baudrate

Get the current state of the reader slot

Parameters:
ctxReader context
Returns:
ICC_PRESENT_AND_INACTIVE, ICC_PRESENT_AND_ACTIVE, NO_ICC_PRESENT or -1 on error
int PC_to_RDR_IccPowerOff ( scr_t ctx)

Power off the ICC in the reader

Parameters:
ctxReader context
Returns:
0 on success, negative value otherwise
int PC_to_RDR_IccPowerOn ( scr_t ctx)

Power on the ICC in the reader and set the ATR and the communication parameters as specified

Parameters:
ctxReader context
Returns:
0 on success, negative value otherwise

Set communication protocol parameters (guard time, FI, DI, IFSC)

Parameters:
ctxReader context
Returns:
0 on success, negative value otherwise
int PC_to_RDR_XfrBlock ( scr_t ctx,
unsigned int  outlen,
unsigned char *  outbuf 
)

Exchange data block between PC and reader

Parameters:
ctxReader context
outlenLength of outgoing data
outbufOutgoing data buffer
Returns:
0 on success, negative value otherwise
int RDR_to_PC_DataBlock ( scr_t ctx,
unsigned int *  inlen,
unsigned char *  inbuf 
)

Exchange data block between reader and PC

Parameters:
ctxReader context
inlenLength of data buffer/actual length of incoming data
inbufIncoming data buffer
Returns:
0 on success, negative value otherwise