]>
Commit | Line | Data |
---|---|---|
9206d3b0 | 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 | |
53d5dc64 | 14 | |
9206d3b0 | 15 | #include <stdarg.h> |
16 | #include <stdint.h> | |
07bc72b8 | 17 | #include <inttypes.h> |
53d5dc64 | 18 | #include "proxmark3.h" |
19 | #include "apps.h" | |
9206d3b0 | 20 | #include "tlv.h" |
53d5dc64 | 21 | #include "util.h" |
22 | #include "string.h" | |
23 | #include "BigBuf.h" | |
24 | #include "iso14443crc.h" | |
25 | #include "iso14443a.h" | |
26 | #include "emvutil.h" | |
27 | #include "emvdataels.h" //EMV data elements | |
28 | #include "emvtags.h" //EMV card structure | |
29 | ||
9206d3b0 | 30 | // mifare 4bit card answers |
31 | // reader voltage field detector | |
32 | #define EMV_MINFIELDV 4000 | |
33 | ||
9206d3b0 | 34 | //EMV emulator states need to update |
35 | #define EMVEMUL_NOFIELD 0 | |
36 | #define EMVEMUL_IDLE 1 | |
37 | #define EMVEMUL_SELECT1 2 | |
38 | #define EMVEMUL_SELECT2 3 | |
39 | #define EMVEMUL_SELECT3 4 | |
40 | #define EMVEMUL_AUTH1 5 | |
41 | #define EMVEMUL_AUTH2 6 | |
42 | #define EMVEMUL_WORK 7 | |
43 | #define EMVEMUL_HALTED 8 | |
44 | #define EMVEMUL_ACK 9 | |
9206d3b0 | 45 | |
46 | //functions | |
47 | //int emv_sendapdu( uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint8_t lc, uint8_t* data, uint8_t le); | |
48 | int emv_select(uint8_t* AID, uint8_t AID_len, void* data); | |
49 | int emv_selectPPSE(); | |
50 | int emv_readrecord(uint8_t recordnumber, uint8_t sfi, void* data); | |
99136c6e | 51 | int emv_getprocessingoptions(uint8_t* pdol, uint8_t pdol_len, void* data); |
9206d3b0 | 52 | int emv_computecryptogram(uint8_t* UDOL, uint8_t UDOL_len, void *data); |
53 | //return 8 8byte ICC random number. | |
54 | int emv_getchallenge(void *data); | |
55 | int emv_loopback(uint8_t* transData , uint8_t transData_len, void *data); | |
56 | int emv_generateAC(uint8_t refcontrolparam, uint8_t* cdolinput, uint8_t cdolinputlen, void* data); | |
57 | int emv_decodeAFL(uint8_t* AFL, uint8_t AFLlen); | |
58 | int emv_decodeAIP(uint8_t* AIP); | |
59 | int emv_decodeCVM(uint8_t* CVM, uint8_t CVMlen); | |
9206d3b0 | 60 | |
99136c6e | 61 | //emulator |
62 | void EMVsim(); | |
63 | ||
9206d3b0 | 64 | //utils |
99136c6e | 65 | int emv_printtag(uint8_t* selected_tag, emvcard* inputcard, uint8_t* outputstring, uint8_t* outputlen); |
66 | int emv_decode_field(uint8_t* inputfield,uint16_t inputlength, emvcard *result); | |
67 | int emv_emvtags_decode_tag(tlvtag* inputtag, emvcard* currentcard); | |
9206d3b0 | 68 | //look up a tag in the current structure |
99136c6e | 69 | int emv_lookuptag(uint8_t* tag, emvcard* currentcard, uint8_t* outputval, uint8_t* outputvallen); |
9206d3b0 | 70 | //set a tag from external impurt |
99136c6e | 71 | int emv_settag(uint32_t tag, uint8_t *datain, emvcard *currentcard) ; |
72 | void dumpCard(emvcard* currentcard); | |
9206d3b0 | 73 | |
74 | //generate a valid PDOL list from the returned card value, used in get processing options | |
99136c6e | 75 | int emv_generateDOL(uint8_t* DOL, uint8_t DOLlen,emvcard* currentcard, uint8_t* DOLoutput, uint8_t* DOLoutputlen); |
9206d3b0 | 76 | |
99136c6e | 77 | int emv_generatetemplate(uint8_t* templateval,emvcard* currentcard, uint8_t* returnedval, uint8_t* returnedlen, uint8_t numtags, ...); |
9206d3b0 | 78 | #endif |