//-----------------------------------------------------------------------------
#ifndef __EMVUTIL_H
#define __EMVUTIL_H
+
#include <stdarg.h>
#include <stdint.h>
-#include "iso14443a.h"
+#include "proxmark3.h"
+#include "apps.h"
#include "tlv.h"
-#include "emvtags.h"
-#include "emvdataels.h"
+#include "util.h"
+#include "string.h"
+#include "BigBuf.h"
+#include "iso14443crc.h"
+#include "iso14443a.h"
+#include "emvutil.h"
+#include "emvdataels.h" //EMV data elements
+#include "emvtags.h" //EMV card structure
+
// mifare 4bit card answers
// reader voltage field detector
#define EMV_MINFIELDV 4000
#define EMVEMUL_WORK 7
#define EMVEMUL_HALTED 8
#define EMVEMUL_ACK 9
-//#define cardSTATE_TO_IDLE() cardSTATE = EMVEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
-//grabbed from iso14443a.c
-//static int EmGetCmd(uint8_t *received, int *len);
-//int EmSendCmdEx(uint8_t *resp, size_t respLen, bool correctionNeeded);//tag types
-//int EmSendCmd(uint8_t *resp, size_t respLen);
-//#define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
-//extern int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data);
//functions
//int emv_sendapdu( uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint8_t lc, uint8_t* data, uint8_t le);
int emv_decodeAFL(uint8_t* AFL, uint8_t AFLlen);
int emv_decodeAIP(uint8_t* AIP);
int emv_decodeCVM(uint8_t* CVM, uint8_t CVMlen);
-//memory management
-//uint8_t* emv_get_bigbufptr(void);
-//uint8_t* emv_get_bigbufptr_sendbuf(void);
-//uint8_t* emv_get_bigbufptr_recbuf(void);
-
-//emulator
-//void EMVsim();
//utils
int emv_printtag(uint8_t* selected_tag,emvtags* inputcard, uint8_t* outputstring, uint8_t* outputlen);