]> cvs.zerfleddert.de Git - proxmark3-svn/blame - armsrc/emvutil.h
REM: "hf legic load" has been removed. It doesnt have a purpose anymore.
[proxmark3-svn] / armsrc / emvutil.h
CommitLineData
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
14#include <stdarg.h>
15#include <stdint.h>
16#include "iso14443a.h"
17#include "tlv.h"
18#include "emvtags.h"
19#include "emvdataels.h"
20// mifare 4bit card answers
21// reader voltage field detector
22#define EMV_MINFIELDV 4000
23
24// debug
25// 0 - no debug messages 1 - error messages 2 - all messages 4 - extended debug mode
26#define EMV_DBG_NONE 0
27#define EMV_DBG_ERROR 1
28#define EMV_DBG_ALL 2
29#define EMV_DBG_EXTENDED 4
30
31extern int EMV_DBGLEVEL;
32
33//EMV emulator states need to update
34#define EMVEMUL_NOFIELD 0
35#define EMVEMUL_IDLE 1
36#define EMVEMUL_SELECT1 2
37#define EMVEMUL_SELECT2 3
38#define EMVEMUL_SELECT3 4
39#define EMVEMUL_AUTH1 5
40#define EMVEMUL_AUTH2 6
41#define EMVEMUL_WORK 7
42#define EMVEMUL_HALTED 8
43#define EMVEMUL_ACK 9
44//#define cardSTATE_TO_IDLE() cardSTATE = EMVEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
45//grabbed from iso14443a.c
46//static int EmGetCmd(uint8_t *received, int *len);
47//int EmSendCmdEx(uint8_t *resp, size_t respLen, bool correctionNeeded);//tag types
48//int EmSendCmd(uint8_t *resp, size_t respLen);
49//#define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
50//extern int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data);
51
52//functions
53//int emv_sendapdu( uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint8_t lc, uint8_t* data, uint8_t le);
54int emv_select(uint8_t* AID, uint8_t AID_len, void* data);
55int emv_selectPPSE();
56int emv_readrecord(uint8_t recordnumber, uint8_t sfi, void* data);
57int emv_getprocessingoptions(uint8_t* pdol, uint8_t pdol_len, void* data
58);
59int emv_computecryptogram(uint8_t* UDOL, uint8_t UDOL_len, void *data);
60//return 8 8byte ICC random number.
61int emv_getchallenge(void *data);
62int emv_loopback(uint8_t* transData , uint8_t transData_len, void *data);
63int emv_generateAC(uint8_t refcontrolparam, uint8_t* cdolinput, uint8_t cdolinputlen, void* data);
64int emv_decodeAFL(uint8_t* AFL, uint8_t AFLlen);
65int emv_decodeAIP(uint8_t* AIP);
66int emv_decodeCVM(uint8_t* CVM, uint8_t CVMlen);
67//memory management
68//uint8_t* emv_get_bigbufptr(void);
69//uint8_t* emv_get_bigbufptr_sendbuf(void);
70//uint8_t* emv_get_bigbufptr_recbuf(void);
71
72//emulator
73//void EMVsim();
74
75//utils
76int emv_printtag(uint8_t* selected_tag,emvtags* inputcard, uint8_t* outputstring, uint8_t* outputlen);
77int emv_decode_field(uint8_t* inputfield,uint16_t inputlength, emvtags *result);
78int emv_emvtags_decode_tag(tlvtag* inputtag, emvtags* currentcard);
79//look up a tag in the current structure
80int emv_lookuptag(uint8_t* tag, emvtags* currentcard, uint8_t* outputval, uint8_t* outputvallen);
81//set a tag from external impurt
82int emv_settag(uint32_t tag, uint8_t *datain, emvtags *currentcard) ;
83void dumpCard(emvtags* currentcard);
84
85//generate a valid PDOL list from the returned card value, used in get processing options
86int emv_generateDOL(uint8_t* DOL, uint8_t DOLlen,emvtags* currentcard, uint8_t* DOLoutput, uint8_t* DOLoutputlen);
87
88int emv_generatetemplate(uint8_t* templateval,emvtags* currentcard, uint8_t* returnedval, uint8_t* returnedlen, uint8_t numtags, ...);
89#endif
Impressum, Datenschutz