00001
00024
00025
00026
00027
00032 typedef enum {
00033 PDO_ATC = 0x36,
00034 PDO_LAST_ATC = 0x13,
00035 PDO_PIN_TRY_COUNTER = 0x17,
00036 PDO_LOG_FORMAT = 0x4F
00037 } CARD_PDO;
00038
00042 typedef enum{
00043 AC_REQ_AAC = 0,
00044 AC_REQ_ARQC = 0x80,
00045 AC_REQ_TC = 0x40
00046 } AC_REQ_TYPE;
00047
00051 typedef struct {
00052 uint8_t tag1;
00053 uint8_t tag2;
00054 uint8_t len;
00055 uint8_t *value;
00056 } TLV;
00057
00061 typedef struct {
00062 uint8_t count;
00063 TLV **objects;
00064 } RECORD;
00065
00069 typedef struct {
00070 uint8_t lenDFName;
00071 uint8_t* dfName;
00072 RECORD* fciData;
00073 } FCITemplate;
00074
00078 typedef struct {
00079 uint8_t count;
00080 FCITemplate** objects;
00081 } FCIList;
00082
00086 typedef struct {
00087 uint8_t count;
00088 RECORD** objects;
00089 } RECORDList;
00090
00094 typedef struct {
00095 uint8_t sfi;
00096 uint8_t recordStart;
00097 uint8_t recordEnd;
00098 uint8_t recordsOfflineAuth;
00099 } AFL;
00100
00104 typedef struct {
00105 uint8_t count;
00106 uint8_t aip[2];
00107 AFL** aflList;
00108 } APPINFO;
00109
00118 typedef struct {
00119 uint8_t amount[6];
00120 uint8_t amountOther[6];
00121 uint8_t terminalCountryCode[2];
00122 uint8_t tvr[5];
00123 uint8_t terminalCurrencyCode[2];
00124 uint8_t transactionDate[3];
00125 uint8_t transactionType;
00126 uint8_t unpredictableNumber[4];
00127 uint8_t terminalType;
00128 uint8_t dataAuthCode[2];
00129 uint8_t iccDynamicNumber[8];
00130 uint8_t cvmResults[3];
00131 } GENERATE_AC_PARAMS;
00132
00133
00134
00135
00136
00138 RAPDU* TerminalSendT0Command(CAPDU* cmd, uint8_t inverse_convention,
00139 uint8_t TC1);
00140
00142 FCITemplate* ApplicationSelection(uint8_t convention, uint8_t TC1);
00143
00145 APPINFO* InitializeTransaction(uint8_t convention, uint8_t TC1,
00146 const FCITemplate *fci);
00147
00149 RECORD* GetTransactionData(uint8_t convention, uint8_t TC1,
00150 const APPINFO* appInfo, ByteArray *offlineAuthData);
00151
00153 FCITemplate* SelectFromAID(uint8_t convention, uint8_t TC1);
00154
00156 FCITemplate* SelectFromPSE(uint8_t convention, uint8_t TC1,
00157 uint8_t sfiPSE);
00158
00160 uint8_t VerifyPlaintextPIN(uint8_t convention, uint8_t TC1,
00161 const ByteArray *pin);
00162
00164 RAPDU* SendGenerateAC(uint8_t convention, uint8_t TC1, AC_REQ_TYPE acType,
00165 const TLV* cdol, const GENERATE_AC_PARAMS *params);
00166
00168 RAPDU* SignDynamicData(uint8_t convention, uint8_t TC1, const ByteArray *data);
00169
00171 uint8_t GetSFIFromSELECT(const RAPDU *response);
00172
00174 TLV* GetPDOLFromFCI(const FCITemplate *fci);
00175
00177 TLV* GetPDOL(const FCITemplate *fci);
00178
00180 ByteArray* GetDataObject(uint8_t convention, uint8_t TC1,
00181 CARD_PDO pdo);
00182
00184 const TLV* GetTLVFromRECORD(RECORD *rec, uint8_t tag1, uint8_t tag2);
00185
00187 uint8_t AmountPositionInCDOLRecord(const RECORD *record);
00188
00190 FCITemplate* ParseFCI(const uint8_t *data, uint8_t lenData);
00191
00193 TLV* ParseTLV(const uint8_t *data, uint8_t lenData, uint8_t includeValue);
00194
00196 TLV* CopyTLV(const TLV *data);
00197
00199 RECORD* ParseRECORD(const uint8_t *data, uint8_t lenData);
00200
00202 uint8_t AddRECORD(RECORD *dest, const RECORD *src);
00203
00205 RECORD* ParseManyTLV(const uint8_t *data, uint8_t lenData);
00206
00208 uint8_t ParsePSD(RECORDList *rlist, const uint8_t *data, uint8_t lenData);
00209
00211 APPINFO* ParseApplicationInfo(const uint8_t* data, uint8_t len);
00212
00214 ByteArray* SerializeTLV(const TLV* tlv);
00215
00217 void FreeTLV(TLV *data);
00218
00220 void FreeRECORD(RECORD *data);
00221
00223 void FreeRECORDList(RECORDList *data);
00224
00226 void FreeFCITemplate(FCITemplate *data);
00227
00229 void FreeFCIList(FCIList *data);
00230
00232 void FreeAPPINFO(APPINFO *data);
00233