]> cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/emvutil.h
CHG: fiddled with the headerfiles... and makefile... Tried to make them behave...
[proxmark3-svn] / armsrc / emvutil.h
1 //-----------------------------------------------------------------------------
2 // Peter Fillmore 2014
3 // code derived off merloks mifare code
4 //
5 //
6 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
7 // at your option, any later version. See the LICENSE.txt file for the text of
8 // the license.
9 //-----------------------------------------------------------------------------
10 // code for work with EMV cards.
11 //-----------------------------------------------------------------------------
12 #ifndef __EMVUTIL_H
13 #define __EMVUTIL_H
14
15 #include <stdarg.h>
16 #include <stdint.h>
17 #include "proxmark3.h"
18 #include "apps.h"
19 #include "tlv.h"
20 #include "util.h"
21 #include "string.h"
22 #include "BigBuf.h"
23 #include "iso14443crc.h"
24 #include "iso14443a.h"
25 #include "emvutil.h"
26 #include "emvdataels.h" //EMV data elements
27 #include "emvtags.h" //EMV card structure
28
29 // mifare 4bit card answers
30 // reader voltage field detector
31 #define EMV_MINFIELDV 4000
32
33 // debug
34 // 0 - no debug messages 1 - error messages 2 - all messages 4 - extended debug mode
35 #define EMV_DBG_NONE 0
36 #define EMV_DBG_ERROR 1
37 #define EMV_DBG_ALL 2
38 #define EMV_DBG_EXTENDED 4
39
40 extern int EMV_DBGLEVEL;
41
42 //EMV emulator states need to update
43 #define EMVEMUL_NOFIELD 0
44 #define EMVEMUL_IDLE 1
45 #define EMVEMUL_SELECT1 2
46 #define EMVEMUL_SELECT2 3
47 #define EMVEMUL_SELECT3 4
48 #define EMVEMUL_AUTH1 5
49 #define EMVEMUL_AUTH2 6
50 #define EMVEMUL_WORK 7
51 #define EMVEMUL_HALTED 8
52 #define EMVEMUL_ACK 9
53 //#define cardSTATE_TO_IDLE() cardSTATE = EMVEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
54 //grabbed from iso14443a.c
55 //static int EmGetCmd(uint8_t *received, int *len);
56 //int EmSendCmdEx(uint8_t *resp, size_t respLen, bool correctionNeeded);//tag types
57 //int EmSendCmd(uint8_t *resp, size_t respLen);
58 //#define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
59 //extern int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data);
60
61 //functions
62 //int emv_sendapdu( uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint8_t lc, uint8_t* data, uint8_t le);
63 int emv_select(uint8_t* AID, uint8_t AID_len, void* data);
64 int emv_selectPPSE();
65 int emv_readrecord(uint8_t recordnumber, uint8_t sfi, void* data);
66 int emv_getprocessingoptions(uint8_t* pdol, uint8_t pdol_len, void* data
67 );
68 int emv_computecryptogram(uint8_t* UDOL, uint8_t UDOL_len, void *data);
69 //return 8 8byte ICC random number.
70 int emv_getchallenge(void *data);
71 int emv_loopback(uint8_t* transData , uint8_t transData_len, void *data);
72 int emv_generateAC(uint8_t refcontrolparam, uint8_t* cdolinput, uint8_t cdolinputlen, void* data);
73 int emv_decodeAFL(uint8_t* AFL, uint8_t AFLlen);
74 int emv_decodeAIP(uint8_t* AIP);
75 int emv_decodeCVM(uint8_t* CVM, uint8_t CVMlen);
76 //memory management
77 //uint8_t* emv_get_bigbufptr(void);
78 //uint8_t* emv_get_bigbufptr_sendbuf(void);
79 //uint8_t* emv_get_bigbufptr_recbuf(void);
80
81 //emulator
82 //void EMVsim();
83
84 //utils
85 int emv_printtag(uint8_t* selected_tag,emvtags* inputcard, uint8_t* outputstring, uint8_t* outputlen);
86 int emv_decode_field(uint8_t* inputfield,uint16_t inputlength, emvtags *result);
87 int emv_emvtags_decode_tag(tlvtag* inputtag, emvtags* currentcard);
88 //look up a tag in the current structure
89 int emv_lookuptag(uint8_t* tag, emvtags* currentcard, uint8_t* outputval, uint8_t* outputvallen);
90 //set a tag from external impurt
91 int emv_settag(uint32_t tag, uint8_t *datain, emvtags *currentcard) ;
92 void dumpCard(emvtags* currentcard);
93
94 //generate a valid PDOL list from the returned card value, used in get processing options
95 int emv_generateDOL(uint8_t* DOL, uint8_t DOLlen,emvtags* currentcard, uint8_t* DOLoutput, uint8_t* DOLoutputlen);
96
97 int emv_generatetemplate(uint8_t* templateval,emvtags* currentcard, uint8_t* returnedval, uint8_t* returnedlen, uint8_t numtags, ...);
98 #endif
Impressum, Datenschutz