sc-hsm-embedded
src/ctccid/ccid_usb.c File Reference
#include <stdint.h>
#include <string.h>
#include "ccid_usb.h"
#include "scr.h"

Functions

int PC_to_RDR_IccPowerOn (scr_t *ctx)
int DetermineBaudrate (int F, int D)
int DecodeATRValues (scr_t *ctx)
int PC_to_RDR_SetParameters (scr_t *ctx)
int PC_to_RDR_GetSlotStatus (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)

Variables

int FTable [] = { 372, 372, 558, 744, 1116, 1488, 1860, -1, -1, 512, 768, 1024, 1536, 2048, -1, -1}
int DTable [] = { -1, 1, 2, 4, 8, 16, 32, -1, 12, 20, -1, -1, -1, -1, -1, -1}

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

Variable Documentation

int DTable[] = { -1, 1, 2, 4, 8, 16, 32, -1, 12, 20, -1, -1, -1, -1, -1, -1}
int FTable[] = { 372, 372, 558, 744, 1116, 1488, 1860, -1, -1, 512, 768, 1024, 1536, 2048, -1, -1}