]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/mifarehost.h
CHG: applied some of the changes unto "hf 14b snoop" *untested* Hard to test without...
[proxmark3-svn] / client / mifarehost.h
1 // Merlok, 2011
2 // people from mifare@nethemba.com, 2010
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // High frequency ISO14443A commands
9 //-----------------------------------------------------------------------------
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <string.h>
15 #include <pthread.h>
16 #include "proxmark3.h"
17 //#include "radixsort.h"
18 #include <time.h>
19 #include "common.h"
20 #include "cmdmain.h"
21 #include "ui.h"
22 #include "data.h"
23 #include "util.h"
24 //#include "nonce2key/nonce2key.h"
25 #include "nonce2key/crapto1.h"
26 #include "iso14443crc.h"
27 #include "protocols.h"
28
29 #define NESTED_SECTOR_RETRY 10
30
31 // mifare tracer flags
32 #define TRACE_IDLE 0x00
33 #define TRACE_AUTH1 0x01
34 #define TRACE_AUTH2 0x02
35 #define TRACE_AUTH_OK 0x03
36 #define TRACE_READ_DATA 0x04
37 #define TRACE_WRITE_OK 0x05
38 #define TRACE_WRITE_DATA 0x06
39 #define TRACE_ERROR 0xFF
40
41 typedef struct {
42 union {
43 struct Crypto1State *slhead;
44 uint64_t *keyhead;
45 } head;
46 union {
47 struct Crypto1State *sltail;
48 uint64_t *keytail;
49 } tail;
50 uint32_t len;
51 uint32_t uid;
52 uint32_t blockNo;
53 uint32_t keyType;
54 uint32_t nt;
55 uint32_t ks1;
56 } StateList_t;
57
58 typedef struct {
59 uint64_t Key[2];
60 int foundKey[2];
61 } sector;
62
63 extern int compar_int(const void * a, const void * b);
64 extern char logHexFileName[FILE_PATH_SIZE];
65
66 int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t * ResultKeys, bool calibrate);
67 int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key);
68
69 int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount);
70 int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount);
71 int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
72
73 int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_t wipecard);
74 int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params);
75 int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);
76
77 int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);
78 int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile);
79
80 int isTraceCardEmpty(void);
81 int isBlockEmpty(int blockN);
82 int isBlockTrailer(int blockN);
83 int loadTraceCard(uint8_t *tuid, uint8_t uidlen);
84 int saveTraceCard(void);
85 int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);
Impressum, Datenschutz