1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // MIFARE type prototyping
17 //-----------------------------------------------------------------------------
26 #define MF_KEY_BD08S 2
30 #define MF_MAD1_SECTOR 0x00
31 #define MF_MAD2_SECTOR 0x10
33 //-----------------------------------------------------------------------------
34 // Common types, used by client and ARM
35 //-----------------------------------------------------------------------------
36 // New Ultralight/NTAG dump file format
37 // Length must be aligned to 4 bytes (UL/NTAG page)
38 #define MFU_DUMP_PREFIX_LENGTH 56
44 uint8_t pages
; // max page number in dump
45 uint8_t signature
[32];
46 uint8_t counter_tearing
[3][4]; // 3 bytes counter, 1 byte tearing flag
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
60 } PACKED iso14a_card_select_t
;
69 uint8_t signature
[32];
70 } PACKED iso14a_card_select_ev1_t
;
73 iso14a_card_select_t card_info
;
76 } iso14a_mf_extdump_t
;
80 iso14a_card_select_t mfc
;
81 iso14a_card_select_ev1_t ev1
;
85 } iso14a_mf_dump_ev1_t
;
89 uint8_t nt_enc
[17][2][4];
90 uint8_t par_err
[17][2];
91 uint8_t blocks
[64][16]; // [MIFARE_1K_MAXSECTOR * 4][MFBLOCK_SIZE]
92 } iso14a_fm11rf08s_nonces_with_data_t
;
94 typedef enum ISO14A_COMMAND
{
95 ISO14A_CONNECT
= (1 << 0),
96 ISO14A_NO_DISCONNECT
= (1 << 1),
97 ISO14A_APDU
= (1 << 2),
98 ISO14A_RAW
= (1 << 3),
99 ISO14A_REQUEST_TRIGGER
= (1 << 4),
100 ISO14A_APPEND_CRC
= (1 << 5),
101 ISO14A_SET_TIMEOUT
= (1 << 6),
102 ISO14A_NO_SELECT
= (1 << 7),
103 ISO14A_TOPAZMODE
= (1 << 8),
104 ISO14A_NO_RATS
= (1 << 9),
105 ISO14A_SEND_CHAINING
= (1 << 10),
106 ISO14A_USE_ECP
= (1 << 11),
107 ISO14A_USE_MAGSAFE
= (1 << 12),
108 ISO14A_USE_CUSTOM_POLLING
= (1 << 13),
109 ISO14A_CRYPTO1MODE
= (1 << 14)
112 // Defines a frame that will be used in a polling sequence
113 // ECP Frames are up to (7 + 16) bytes long, 24 bytes should cover future and other cases
116 uint8_t frame_length
;
117 uint8_t last_byte_bits
;
118 uint16_t extra_delay
;
119 } PACKED iso14a_polling_frame_t
;
121 // Defines polling sequence configuration
122 // 6 would be enough for 4 magsafe, 1 wupa, 1 ecp,
124 iso14a_polling_frame_t frames
[6];
126 uint16_t extra_timeout
;
127 } PACKED iso14a_polling_parameters_t
;
133 uint16_t modulation_n
;
134 uint32_t ProxToAirDuration
;
135 uint8_t par
; // enough for precalculated parity of 8 Byte responses
136 } PACKED tag_response_info_t
;
138 // DESFIRE_RAW flag enums
139 typedef enum DESFIRE_COMMAND
{
152 } mifare_des_authmode_t
;
157 MFDES_ALGO_3K3DES
= 3,
159 } mifare_des_authalgo_t
;
162 MFDES_KDF_ALGO_NONE
= 0,
163 MFDES_KDF_ALGO_AN10922
= 1,
164 MFDES_KDF_ALGO_GALLAGHER
= 2,
165 } mifare_des_kdf_algo_t
;
167 //-----------------------------------------------------------------------------
168 // "hf 14a sim -x", "hf mf sim -x" attacks
169 //-----------------------------------------------------------------------------