AT-NFC 2.1 (win) AT-NFC kernel set

emv_data.h
Go to the documentation of this file.
1 #ifndef EMV_DATA_H
2 #define EMV_DATA_H
3
4 /* ************************ EMV KERNEL data processing functions *************************** */
8 /* ***************************************************************************************** */
9
10 /* set struct alignment */
11 #include <emv_platform_set_align.h>
12
13 /* ******************************** Search mode definition ********************************* */
14 #define KER_FIND_LAST 0x01
16 /* ******************************** Selected CVM definition ******************************** */
17 #define KER_CVM_FAIL 0x00
18 #define KER_CVM_SKIP 0x01
19 #define KER_CVM_NO_CVM 0x02
20 #define KER_CVM_ONLINE_PIN 0x03
21 #define KER_CVM_PLAIN_PIN 0x04
22 #define KER_CVM_ENC_PIN 0x05
23 #define KER_CVM_PLAIN_PIN_SIG 0x06
24 #define KER_CVM_ENC_PIN_SIG 0x07
25 #define KER_CVM_SIGNATURE 0x08
26 #define KER_CVM_CUSTOM 0xFF
28 /* ******************************** CVM Results definition ********************************* */
29 #define KER_CVM_RES_OK 0x00
30 #define KER_CVM_RES_FAIL 0x01
31 #define KER_CVM_RES_BYPASS 0x02
32 #define KER_CVM_RES_UNKNOWN 0x03
33 #define KER_CVM_RES_UNSUPP 0x04
34 #define KER_CVM_RES_UNREC 0x05
35 #define KER_CVM_RES_CANCEL 0x06
36 #define KER_CVM_RES_HW_ERR 0x07
38 /* ****************************** Referral Results definition ****************************** */
39 #define KER_REFFERAL_RES_NA 0x00
40 #define KER_REFFERAL_RES_APPROVE 0x01
41 #define KER_REFFERAL_RES_DECLINE 0x02
43 /* ********************************* TAA mode definition *********************************** */
44 #define KER_TAA_MODE_CHECK_OFFLINE_DECL 0x00
45 #define KER_TAA_MODE_FINAL_BEFORE_CAA 0x01
46 #define KER_TAA_MODE_UNABLE_TO_GO_ONLINE 0x02
48 /* ************************************ KernelContTLV ************************************** */
53 /* ****************************** BER-TLV container structure ****************************** */
54 typedef struct tag_KER_TLV KER_TLV;
62 typedef struct tag_KER_TLV
63 {
64 KER_BYTE* pbtTlv;
65 KER_INT16U usTlvLen;
67 KER_TLV* pNext;
68 } KER_TLV;
69
70 /* ********************************** PIN data structure *********************************** */
78 typedef struct tag_KER_OFFLINE_PIN_DATA
79 {
80 KER_INT16U usSize;
82 KER_BYTE btPinTryCount;
83 KER_BYTE btOdeScheme;
85 KER_BYTE ar_btOdeUN[8];
86 KER_INT16U usOdeUNLen;
87
88 union
89 {
90 struct
91 {
92 KER_BYTE btAlg;
93 const KER_BYTE* pbtOdePK;
94 KER_INT16U usOdePKLen;
95 const KER_BYTE* pbtOdePKExp;
96 KER_INT16U usOdePKExpLen;
97 }RSA;
98 struct
99 {
100 KER_BYTE btASI;
101 const KER_BYTE* pbtOdePK;
102 KER_INT16U usOdePKLen;
103 }ECC;
104 }ODE;
105 } KER_OFFLINE_PIN_DATA;
106
107 /* ******************************** kerContTlvCreateByTag ********************************** */
124 extern KER_RES KER_API kerContTlvCreateByTag(KER_CTX_PARAM const KER_BYTE* pbtTag, KER_BYTE btTagLen, const KER_BYTE* pbtValue, KER_INT16U usValueLen, KER_TLV** ppTlv);
125
126 /* ******************************** kerContTlvCreateByTLV ********************************** */
141 extern KER_RES KER_API kerContTlvCreateByTLV(KER_CTX_PARAM const KER_BYTE* pbtTlv, KER_INT16U usTlvLen, KER_TLV** ppTlv);
142
143 /* ******************************** kerContTlvListAddByTLV ********************************* */
159 extern KER_RES KER_API kerContTlvListAddByTLV(KER_CTX_PARAM const KER_BYTE* pbtTlv, KER_INT16U usTlvLen, KER_TLV** ppTlv);
160
161 /* ********************************* kerContTlvRelease ************************************* */
172 extern KER_BOOL KER_API kerContTlvRelease(KER_CTX_PARAM KER_TLV* pTlv);
173
174 /* ******************************* kerContTlvListRelease *********************************** */
185 extern KER_BOOL KER_API kerContTlvListRelease(KER_CTX_PARAM KER_TLV* pTlvList);
186
187 /* ********************************* kerContTlvListPush ************************************ */
199 extern KER_BOOL KER_API kerContTlvListPush(KER_CTX_PARAM KER_TLV** ppTlv, KER_TLV* pTlvToPush);
200
201 /* ******************************* kerContTlvListPushLast ********************************** */
213 extern KER_BOOL KER_API kerContTlvListPushLast(KER_CTX_PARAM KER_TLV** ppTlv, KER_TLV* pTlvToPush);
214
215 /* ******************************** kerContTlvListGetNext ********************************** */
224 extern KER_TLV* KER_API kerContTlvListGetNext(KER_CTX_PARAM KER_TLV* pTlvListEntry);
225
226 /* ********************************* kerContTlvListPop ************************************* */
238 extern KER_BOOL KER_API kerContTlvListPop(KER_CTX_PARAM KER_TLV** ppTlv, KER_TLV* pTlvToPop);
239
240 /* ************************************* KernelTRAN **************************************** */
245 /* ****************************** Transaction data structure ******************************* */
251 typedef struct tag_KER_TRAN KER_TRAN;
252
253 /* *********************************** kerTranRelease ************************************** */
262 extern KER_BOOL KER_API kerTranRelease(KER_CTX_PARAM KER_TRAN* pTran);
263
264 /* ******************************** kerTranGetDataByTag ************************************ */
278 extern KER_BOOL KER_API kerTranGetDataByTag(KER_CTX_PARAM KER_TRAN* pTran, const KER_BYTE* pbtTag, KER_BYTE btTagLen, KER_BYTE* pbtData, KER_INT16U* pusDataLen, KER_INT16U usDataMax);
279
280 /* ****************************** kerTranGetCustDataByTag ********************************** */
294 extern KER_BOOL KER_API kerTranGetCustDataByTag(KER_CTX_PARAM KER_TRAN* pTran, const KER_BYTE* pbtTag, KER_BYTE btTagLen, KER_BYTE* pbtData, KER_INT16U* pusDataLen, KER_INT16U usDataMax);
295
296 /* ******************************** kerTranGetDataByDOL ************************************ */
311 extern KER_BOOL KER_API kerTranGetDataByDOL(KER_CTX_PARAM KER_TRAN* pTran, const KER_BYTE* pbtDol, KER_INT16U usDolLen, KER_BYTE* pbtData, KER_INT16U* pusDataLen, KER_INT16U usDataMax);
312
313 /* ******************************** kerTranGetCardData ************************************* */
327 extern KER_BOOL KER_API kerTranGetCardData(KER_CTX_PARAM KER_TRAN* pTran, const KER_BYTE* pbtTag, KER_BYTE btTagLen, KER_BYTE* pbtData, KER_INT16U* pusDataLen, KER_INT16U usDataMax);
328
329 /* ****************************** kerTranGetScriptResults ********************************** */
342 extern KER_BOOL KER_API kerTranGetScriptResults(KER_CTX_PARAM KER_TRAN* pTran, KER_BYTE* pbtData, KER_INT16U* pusDataLen, KER_INT16U usDataMax);
343
344 /* **************************** kerTranGetScriptResultsRef ********************************* */
358 extern KER_BOOL KER_API kerTranGetScriptResultsRef(KER_CTX_PARAM KER_TRAN* pTran, KER_INT16U usScriptIndex, KER_BYTE* pbtData, KER_INT16U* pusDataLen, KER_INT16U usDataMax);
359
360 /* ********************************** kerTranGetFlags ************************************** */
365 #define KER_TRAN_FL_SIGNATURE_CVM_REQUESTED 0x0001
366 #define KER_TRAN_FL_APP_VER_MISMATCH 0x0002
367 #define KER_TRAN_FL_TAA_OFFLINE_DECLINED 0x0004
368 #define KER_TRAN_FL_TAA_ONLINE_REQUEST 0x0008
369 #define KER_TRAN_FL_TAA_OFFLINE_APPROVE 0x0010
370 #define KER_TRAN_FL_CAA_OFFLINE_DECLINED 0x0020
371 #define KER_TRAN_FL_CAA_ONLINE_REQUEST 0x0040
372 #define KER_TRAN_FL_CAA_OFFLINE_APPROVED 0x0080
373 #define KER_TRAN_FL_TAA_DEFAULT_APPROVE 0x0100
374 #define KER_TRAN_FL_TAA_DEFAULT_DECLINED 0x0200
375 #define KER_TRAN_FL_CAA_SKIP_GAC2_BY_XDA 0x0400
376 #define KER_TRAN_FL_ADVICE_REQUIRED 0x1000
377 #define KER_TRAN_FL_SERVICE_NOT_ALLOWWED 0x2000
378 #define KER_TRAN_FL_PIN_TRY_EXCEEDED 0x4000
379 #define KER_TRAN_FL_ISS_AUTH_FAILED 0x8000
391 extern KER_INT16U KER_API kerTranGetFlags(KER_CTX_PARAM KER_TRAN* pTran);
392
393 /* ******************************* kerTranGetErrorFlags ************************************ */
398 #define KER_TRAN_ERR_FL_PAN_MISMATCH 0x0001
399 #define KER_TRAN_ERR_FL_EXP_DATE_MISMATCH 0x0002
400 #define KER_TRAN_ERR_FL_INV_AUTH_DATA 0x0004
401 #define KER_TRAN_ERR_FL_PDOL_MAND_AMOUNT_MISSED 0x0008
413 extern KER_INT16U KER_API kerTranGetErrorFlags(KER_CTX_PARAM KER_TRAN* pTran);
414
415 /* ********************************** kerTranGetStatus ************************************* */
420 #define KER_TRAN_STAT_APP_SELECTED 0x0001
421 #define KER_TRAN_STAT_PROC_INITIATED 0x0002
422 #define KER_TRAN_STAT_READ_DATA 0x0004
423 #define KER_TRAN_STAT_OFFLINE_AUTH 0x0008
424 #define KER_TRAN_STAT_PROC_RESTR 0x0010
425 #define KER_TRAN_STAT_CV 0x0020
426 #define KER_TRAN_STAT_RISK_MANAGEMENT 0x0040
427 #define KER_TRAN_STAT_CAA 0x0080
428 #define KER_TRAN_STAT_ONLINE 0x0100
440 extern KER_INT16U KER_API kerTranGetStatus(KER_CTX_PARAM KER_TRAN* pTran);
441
442 /* restore struct alignment */
443 #include <emv_platform_restore_align.h>
444
445 #endif /* EMV_DATA_H */
emv_platform_restore_align.h
emv_platform_set_align.h
KER_BOOL
KER_INT8U KER_BOOL
Definition: emv_platform.h:67
KER_BYTE
uint8_t KER_BYTE
Definition: emv_platform.h:70
KER_RES
KER_INT16U KER_RES
Definition: emv_platform.h:68
KER_INT16U
unsigned short KER_INT16U
Definition: emv_platform.h:61
KER_OFFLINE_PIN_DATA
struct tag_KER_OFFLINE_PIN_DATA KER_OFFLINE_PIN_DATA
offline PIN cvm related data structure
KER_CTX_PARAM
#define KER_CTX_PARAM
Definition: emv_context.h:53
kerContTlvListAddByTLV
KER_RES KER_API kerContTlvListAddByTLV(KER_CTX_PARAM const KER_BYTE *pbtTlv, KER_INT16U usTlvLen, KER_TLV **ppTlv)
Creates TLV container structure from provided TLV buffer and addes it to provided TLV List.
kerContTlvListPushLast
KER_BOOL KER_API kerContTlvListPushLast(KER_CTX_PARAM KER_TLV **ppTlv, KER_TLV *pTlvToPush)
Add TLV container structure to list (to the end of list)
kerContTlvRelease
KER_BOOL KER_API kerContTlvRelease(KER_CTX_PARAM KER_TLV *pTlv)
Releases TLV container structure.
kerContTlvCreateByTag
KER_RES KER_API kerContTlvCreateByTag(KER_CTX_PARAM const KER_BYTE *pbtTag, KER_BYTE btTagLen, const KER_BYTE *pbtValue, KER_INT16U usValueLen, KER_TLV **ppTlv)
Creates TLV container structure from provided tag & value.
kerContTlvListGetNext
KER_TLV *KER_API kerContTlvListGetNext(KER_CTX_PARAM KER_TLV *pTlvListEntry)
Returns next TLV container structure in list.
kerContTlvCreateByTLV
KER_RES KER_API kerContTlvCreateByTLV(KER_CTX_PARAM const KER_BYTE *pbtTlv, KER_INT16U usTlvLen, KER_TLV **ppTlv)
Creates TLV container structure from provided TLV buffer.
kerContTlvListPop
KER_BOOL KER_API kerContTlvListPop(KER_CTX_PARAM KER_TLV **ppTlv, KER_TLV *pTlvToPop)
Pop TLV container structure from list.
kerContTlvListRelease
KER_BOOL KER_API kerContTlvListRelease(KER_CTX_PARAM KER_TLV *pTlvList)
Releases TLV container structure list.
kerContTlvListPush
KER_BOOL KER_API kerContTlvListPush(KER_CTX_PARAM KER_TLV **ppTlv, KER_TLV *pTlvToPush)
Add TLV container structure to list (to the start of list)
KER_TLV
struct tag_KER_TLV KER_TLV
TLV container structure.
Definition: emv_data.h:54
kerTranGetCardData
KER_BOOL KER_API kerTranGetCardData(KER_CTX_PARAM KER_TRAN *pTran, const KER_BYTE *pbtTag, KER_BYTE btTagLen, KER_BYTE *pbtData, KER_INT16U *pusDataLen, KER_INT16U usDataMax)
Obtain tag value from card by GET_DATA command.
kerTranGetScriptResults
KER_BOOL KER_API kerTranGetScriptResults(KER_CTX_PARAM KER_TRAN *pTran, KER_BYTE *pbtData, KER_INT16U *pusDataLen, KER_INT16U usDataMax)
Obtain data as tlv buffer by provided tag list.
kerTranGetErrorFlags
KER_INT16U KER_API kerTranGetErrorFlags(KER_CTX_PARAM KER_TRAN *pTran)
Obtain some specific errors as bitmask.
kerTranGetStatus
KER_INT16U KER_API kerTranGetStatus(KER_CTX_PARAM KER_TRAN *pTran)
Obtain transaction progress status.
kerTranGetCustDataByTag
KER_BOOL KER_API kerTranGetCustDataByTag(KER_CTX_PARAM KER_TRAN *pTran, const KER_BYTE *pbtTag, KER_BYTE btTagLen, KER_BYTE *pbtData, KER_INT16U *pusDataLen, KER_INT16U usDataMax)
Obtain tag value from to transaction data structure (from unrecognized/unexpected ICC data)
kerTranGetScriptResultsRef
KER_BOOL KER_API kerTranGetScriptResultsRef(KER_CTX_PARAM KER_TRAN *pTran, KER_INT16U usScriptIndex, KER_BYTE *pbtData, KER_INT16U *pusDataLen, KER_INT16U usDataMax)
Obtain data as tlv buffer by provided tag list.
kerTranGetDataByTag
KER_BOOL KER_API kerTranGetDataByTag(KER_CTX_PARAM KER_TRAN *pTran, const KER_BYTE *pbtTag, KER_BYTE btTagLen, KER_BYTE *pbtData, KER_INT16U *pusDataLen, KER_INT16U usDataMax)
Obtain tag value from transaction data structure.
kerTranGetDataByDOL
KER_BOOL KER_API kerTranGetDataByDOL(KER_CTX_PARAM KER_TRAN *pTran, const KER_BYTE *pbtDol, KER_INT16U usDolLen, KER_BYTE *pbtData, KER_INT16U *pusDataLen, KER_INT16U usDataMax)
Obtain data according to the DOL provided.
KER_TRAN
struct tag_KER_TRAN KER_TRAN
Kernel internal transaction data structure.
Definition: emv_data.h:251
kerTranGetFlags
KER_INT16U KER_API kerTranGetFlags(KER_CTX_PARAM KER_TRAN *pTran)
Obtain some specific conditions as bitmask.
kerTranRelease
KER_BOOL KER_API kerTranRelease(KER_CTX_PARAM KER_TRAN *pTran)
Releases Transaction container structure.
tag_KER_OFFLINE_PIN_DATA
offline PIN cvm related data structure
Definition: emv_data.h:79
tag_KER_OFFLINE_PIN_DATA::pbtOdePK
const KER_BYTE * pbtOdePK
Definition: emv_data.h:93
tag_KER_OFFLINE_PIN_DATA::usSize
KER_INT16U usSize
Definition: emv_data.h:80
tag_KER_OFFLINE_PIN_DATA::btOdeScheme
KER_BYTE btOdeScheme
Definition: emv_data.h:83
tag_KER_OFFLINE_PIN_DATA::ar_btOdeUN
KER_BYTE ar_btOdeUN[8]
Definition: emv_data.h:85
tag_KER_OFFLINE_PIN_DATA::btASI
KER_BYTE btASI
Definition: emv_data.h:100
tag_KER_OFFLINE_PIN_DATA::btAlg
KER_BYTE btAlg
Definition: emv_data.h:92
tag_KER_OFFLINE_PIN_DATA::btPinTryCount
KER_BYTE btPinTryCount
Definition: emv_data.h:82
tag_KER_OFFLINE_PIN_DATA::pbtOdePKExp
const KER_BYTE * pbtOdePKExp
Definition: emv_data.h:95
tag_KER_TLV
TLV container structure.
Definition: emv_data.h:63
tag_KER_TLV::usTlvLen
KER_INT16U usTlvLen
Definition: emv_data.h:65
tag_KER_TLV::pNext
KER_TLV * pNext
Definition: emv_data.h:67
tag_KER_TLV::pbtTlv
KER_BYTE * pbtTlv
Definition: emv_data.h:64