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 // iCLASS type prototyping
17 //-----------------------------------------------------------------------------
19 #ifndef _ICLASS_CMD_H_
20 #define _ICLASS_CMD_H_
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
27 #define PICOPASS_BLOCK_SIZE 8
29 // iCLASS reader flags
30 #define FLAG_ICLASS_READER_INIT 0x01
31 #define FLAG_ICLASS_READER_CLEARTRACE 0x02
32 //#define FLAG_ICLASS_READER_ONLY_ONCE 0x04
33 #define FLAG_ICLASS_READER_CREDITKEY 0x08
34 #define FLAG_ICLASS_READER_AIA 0x10
35 #define FLAG_ICLASS_READER_SHALLOW_MOD 0x20
37 // iCLASS reader status flags
38 #define FLAG_ICLASS_NULL 0x00
39 #define FLAG_ICLASS_CSN 0x01
40 #define FLAG_ICLASS_CC 0x02
41 #define FLAG_ICLASS_CONF 0x04
42 #define FLAG_ICLASS_AIA 0x08
44 // iCLASS simulation modes
45 #define ICLASS_SIM_MODE_CSN 0
46 #define ICLASS_SIM_MODE_CSN_DEFAULT 1
47 #define ICLASS_SIM_MODE_READER_ATTACK 2
48 #define ICLASS_SIM_MODE_FULL 3
49 #define ICLASS_SIM_MODE_READER_ATTACK_KEYROLL 4
50 #define ICLASS_SIM_MODE_EXIT_AFTER_MAC 5 // note: device internal only
51 #define ICLASS_SIM_MODE_CONFIG_CARD 6
54 // iCLASS auth request data structure
55 // used with read block, dump, write block
66 } PACKED iclass_auth_req_t
;
68 // iCLASS read block response data structure
74 } PACKED iclass_readblock_resp_t
;
76 // iCLASS dump data structure
78 iclass_auth_req_t req
;
81 } PACKED iclass_dump_req_t
;
83 // iCLASS write block request data structure
85 iclass_auth_req_t req
;
88 } PACKED iclass_writeblock_req_t
;
90 // iCLASS write block request data structure
92 iclass_auth_req_t req
;
94 } PACKED iclass_credit_epurse_t
;
96 // iCLASS dump data structure
100 } PACKED iclass_restore_item_t
;
103 iclass_auth_req_t req
;
105 iclass_restore_item_t blocks
[];
106 } PACKED iclass_restore_req_t
;
109 iclass_auth_req_t req
;
110 iclass_auth_req_t req2
;
111 } PACKED iclass_recover_req_t
;
113 typedef struct iclass_premac
{
115 } PACKED iclass_premac_t
;
121 iclass_premac_t items
[];
122 } PACKED iclass_chk_t
;
124 typedef struct iclass_block
{
128 typedef struct iclass_prekey
{
136 } iclass_config_card_item_t
;
139 // iclass / picopass chip config structures and shared routines
141 uint8_t app_limit
; //[8]
142 uint8_t otp
[2]; //[9-10]
143 uint8_t block_writelock
;//[11]
144 uint8_t chip_config
; //[12]
145 uint8_t mem_config
; //[13]
147 uint8_t fuses
; //[15]
148 } PACKED picopass_conf_block_t
;
150 // iCLASS secure mode memory mapping
153 picopass_conf_block_t conf
;
157 uint8_t app_issuer_area
[8];
158 } PACKED picopass_hdr_t
;
160 // iCLASS non-secure mode memory mapping
163 picopass_conf_block_t conf
;
164 uint8_t app_issuer_area
[8];
165 } PACKED picopass_ns_hdr_t
;
170 } PACKED iclass_card_select_t
;
177 picopass_ns_hdr_t ns_hdr
;
179 } PACKED iclass_card_select_resp_t
;