maur keys
[RRG-proxmark3.git] / include / mifare.h
blobe38c7eb456195722d0ad723c1c998d86ef22b0dc
1 //-----------------------------------------------------------------------------
2 // (c) 2012 Roel Verdult
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 // MIFARE type prototyping
9 //-----------------------------------------------------------------------------
11 #ifndef _MIFARE_H_
12 #define _MIFARE_H_
14 #include "common.h"
16 #define MF_KEY_A 0
17 #define MF_KEY_B 1
19 #define MF_MAD1_SECTOR 0x00
20 #define MF_MAD2_SECTOR 0x10
22 //-----------------------------------------------------------------------------
23 // Common types, used by client and ARM
24 //-----------------------------------------------------------------------------
25 // New Ultralight/NTAG dump file format
26 // Length must be aligned to 4 bytes (UL/NTAG page)
27 #define MFU_DUMP_PREFIX_LENGTH 56
29 typedef struct {
30 uint8_t version[8];
31 uint8_t tbo[2];
32 uint8_t tbo1[1];
33 uint8_t pages; // max page number in dump
34 uint8_t signature[32];
35 uint8_t counter_tearing[3][4]; // 3 bytes counter, 1 byte tearing flag
36 uint8_t data[1024];
37 } PACKED mfu_dump_t;
39 //-----------------------------------------------------------------------------
40 // ISO 14443A
41 //-----------------------------------------------------------------------------
42 typedef struct {
43 uint8_t uid[10];
44 uint8_t uidlen;
45 uint8_t atqa[2];
46 uint8_t sak;
47 uint8_t ats_len;
48 uint8_t ats[256];
49 } PACKED iso14a_card_select_t;
51 typedef enum ISO14A_COMMAND {
52 ISO14A_CONNECT = (1 << 0),
53 ISO14A_NO_DISCONNECT = (1 << 1),
54 ISO14A_APDU = (1 << 2),
55 ISO14A_RAW = (1 << 3),
56 ISO14A_REQUEST_TRIGGER = (1 << 4),
57 ISO14A_APPEND_CRC = (1 << 5),
58 ISO14A_SET_TIMEOUT = (1 << 6),
59 ISO14A_NO_SELECT = (1 << 7),
60 ISO14A_TOPAZMODE = (1 << 8),
61 ISO14A_NO_RATS = (1 << 9),
62 ISO14A_SEND_CHAINING = (1 << 10)
63 } iso14a_command_t;
65 typedef struct {
66 uint8_t *response;
67 uint8_t *modulation;
68 uint16_t response_n;
69 uint16_t modulation_n;
70 uint32_t ProxToAirDuration;
71 uint8_t par; // enough for precalculated parity of 8 Byte responses
72 } PACKED tag_response_info_t;
74 // DESFIRE_RAW flag enums
75 typedef enum DESFIRE_COMMAND {
76 NONE = 0x00,
77 INIT = 0x01,
78 DISCONNECT = 0x02,
79 CLEARTRACE = 0x04,
80 BAR = 0x10,
81 } desfire_command_t;
83 typedef enum {
84 MFDES_AUTH_DES = 1,
85 MFDES_AUTH_ISO = 2,
86 MFDES_AUTH_AES = 3,
87 MFDES_AUTH_PICC = 4
88 } mifare_des_authmode_t;
90 typedef enum {
91 MFDES_ALGO_DES = 1,
92 MFDES_ALGO_3DES = 2,
93 MFDES_ALGO_3K3DES = 3,
94 MFDES_ALGO_AES = 4
95 } mifare_des_authalgo_t;
97 typedef enum {
98 MFDES_KDF_ALGO_NONE = 0,
99 MFDES_KDF_ALGO_AN10922 = 1,
100 MFDES_KDF_ALGO_GALLAGHER = 2,
101 } mifare_des_kdf_algo_t;
103 //-----------------------------------------------------------------------------
104 // "hf 14a sim -x", "hf mf sim -x" attacks
105 //-----------------------------------------------------------------------------
106 typedef struct {
107 uint32_t cuid;
108 uint32_t nonce;
109 uint32_t ar;
110 uint32_t nr;
111 uint32_t at;
112 uint32_t nonce2;
113 uint32_t ar2;
114 uint32_t nr2;
115 uint8_t sector;
116 uint8_t keytype;
117 enum {
118 EMPTY,
119 FIRST,
120 SECOND,
121 } state;
122 } PACKED nonces_t;
125 #endif // _MIFARE_H_