1 //-----------------------------------------------------------------------------
2 // (c) 2012 Roel Verdult
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
7 //-----------------------------------------------------------------------------
8 // MIFARE type prototyping
9 //-----------------------------------------------------------------------------
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
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
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
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)
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
{
88 } mifare_des_authmode_t
;
93 MFDES_ALGO_3K3DES
= 3,
95 } mifare_des_authalgo_t
;
98 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
107 } PACKED iso14b_card_select_t
;
109 typedef enum ISO14B_COMMAND
{
110 ISO14B_CONNECT
= (1 << 0),
111 ISO14B_DISCONNECT
= (1 << 1),
112 ISO14B_APDU
= (1 << 2),
113 ISO14B_RAW
= (1 << 3),
114 ISO14B_REQUEST_TRIGGER
= (1 << 4),
115 ISO14B_APPEND_CRC
= (1 << 5),
116 ISO14B_SELECT_STD
= (1 << 6),
117 ISO14B_SELECT_SR
= (1 << 7),
118 ISO14B_SET_TIMEOUT
= (1 << 8),
121 typedef enum ISO15_COMMAND
{
122 ISO15_CONNECT
= (1 << 0),
123 ISO15_NO_DISCONNECT
= (1 << 1),
124 ISO15_RAW
= (1 << 2),
125 ISO15_APPEND_CRC
= (1 << 3),
126 ISO15_HIGH_SPEED
= (1 << 4),
127 ISO15_READ_RESPONSE
= (1 << 5)
130 //-----------------------------------------------------------------------------
131 // "hf 14a sim x", "hf mf sim x" attacks
132 //-----------------------------------------------------------------------------
151 //-----------------------------------------------------------------------------
152 // ISO 7618 Smart Card
153 //-----------------------------------------------------------------------------
157 } PACKED smart_card_atr_t
;
159 typedef enum SMARTCARD_COMMAND
{
160 SC_CONNECT
= (1 << 0),
161 SC_NO_DISCONNECT
= (1 << 1),
163 SC_SELECT
= (1 << 3),
164 SC_RAW_T0
= (1 << 4),
165 } smartcard_command_t
;
167 //-----------------------------------------------------------------------------
169 //-----------------------------------------------------------------------------
170 // IDm = ID manufacturer
171 // mc = manufactureCode
172 // mc1 mc2 u1 u2 u3 u4 u5 u6
173 // PMm = Product manufacturer
177 // maximum response time =
178 // B3(request service)
179 // B4(request response)
185 // ServiceCode 2bytes (access-rights)
186 // FileSystem = 1 Block = 16 bytes
194 uint8_t servicecode
[2];
195 } PACKED felica_card_select_t
;
202 } PACKED felica_frame_response_t
;
205 uint8_t status_flag1
[1];
206 uint8_t status_flag2
[1];
207 } PACKED felica_status_flags_t
;
210 felica_frame_response_t frame_response
;
211 uint8_t node_number
[1];
212 uint8_t node_key_versions
[2];
213 } PACKED felica_request_service_response_t
;
216 felica_frame_response_t frame_response
;
218 } PACKED felica_request_request_response_t
;
221 felica_frame_response_t frame_response
;
222 felica_status_flags_t status_flags
;
223 uint8_t number_of_block
[1];
224 uint8_t block_data
[16];
225 uint8_t block_element_number
[1];
226 } PACKED felica_read_without_encryption_response_t
;
229 felica_frame_response_t frame_response
;
230 felica_status_flags_t status_flags
;
231 } PACKED felica_status_response_t
;
234 felica_frame_response_t frame_response
;
235 uint8_t number_of_systems
[1];
236 uint8_t system_code_list
[32];
237 } PACKED felica_syscode_response_t
;
240 felica_frame_response_t frame_response
;
241 felica_status_flags_t status_flags
;
242 uint8_t format_version
[1];
243 uint8_t basic_version
[2];
244 uint8_t number_of_option
[1];
245 uint8_t option_version_list
[4];
246 } PACKED felica_request_spec_response_t
;
249 felica_frame_response_t frame_response
;
252 } PACKED felica_auth1_response_t
;
259 } PACKED felica_auth2_response_t
;
262 typedef enum FELICA_COMMAND
{
263 FELICA_CONNECT
= (1 << 0),
264 FELICA_NO_DISCONNECT
= (1 << 1),
265 FELICA_RAW
= (1 << 3),
266 FELICA_APPEND_CRC
= (1 << 5),
267 FELICA_NO_SELECT
= (1 << 6),