// Work with mifare cards.\r
//-----------------------------------------------------------------------------\r
\r
+#include "mifareutil.h"\r
#include "proxmark3.h"\r
#include "apps.h"\r
#include "util.h"\r
\r
#include "iso14443crc.h"\r
#include "iso14443a.h"\r
-#include "crapto1.h"\r
-#include "mifareutil.h"\r
+#include "crapto1/crapto1.h"\r
#include "des.h"\r
\r
int MF_DBGLEVEL = MF_DBG_ALL;\r
return bt;\r
}\r
\r
-// send 2 byte commands\r
-int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing)\r
-{\r
- return mifare_sendcmd_shortex(pcs, crypted, cmd, data, answer, answer_parity, timing);\r
-}\r
-\r
// send X byte basic commands\r
int mifare_sendcmd(uint8_t cmd, uint8_t* data, uint8_t data_size, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing)\r
{\r
return len;\r
}\r
\r
-/*\r
-int mifare_sendcmd_short_mfucauth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
-{\r
- uint8_t dcmd[19];\r
- int len; \r
- dcmd[0] = cmd;\r
- memcpy(dcmd+1,data,16);\r
- AppendCrc14443a(dcmd, 17);\r
- \r
- ReaderTransmit(dcmd, sizeof(dcmd), timing);\r
- len = ReaderReceive(answer, answer_parity);\r
- if(!len) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Authentication failed. Card timeout.");\r
- len = ReaderReceive(answer,answer_parity);\r
- }\r
- if(len==1) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("NAK - Authentication failed.");\r
- return 1;\r
- }\r
- return len;\r
-}\r
-\r
-int mifare_sendcmd_short_mfuev1auth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
-{\r
- uint8_t dcmd[7];\r
- int len; \r
- dcmd[0] = cmd;\r
- memcpy(dcmd+1,data,4);\r
- AppendCrc14443a(dcmd, 5);\r
-\r
- ReaderTransmit(dcmd, sizeof(dcmd), timing);\r
- len = ReaderReceive(answer, answer_parity);\r
- if(!len) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Authentication failed. Card timeout.");\r
- len = ReaderReceive(answer,answer_parity);\r
- }\r
- if(len==1) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("NAK - Authentication failed.");\r
- return 1;\r
- }\r
- return len;\r
-}\r
-*/\r
-\r
// send 2 byte commands\r
-int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
+int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing)\r
{\r
uint8_t dcmd[4], ecmd[4];\r
uint16_t pos, res;\r
uint8_t key[4] = {0x00};\r
memcpy(key, keybytes, 4);\r
\r
- Dbprintf("EV1 Auth : %02x%02x%02x%02x", key[0], key[1], key[2], key[3]);\r
+ if (MF_DBGLEVEL >= MF_DBG_EXTENDED)\r
+ Dbprintf("EV1 Auth : %02x%02x%02x%02x", key[0], key[1], key[2], key[3]);\r
len = mifare_sendcmd(0x1B, key, sizeof(key), resp, respPar, NULL);\r
//len = mifare_sendcmd_short_mfuev1auth(NULL, 0, 0x1B, key, resp, respPar, NULL);\r
if (len != 4) {\r