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
;
116 } PACKED iclass_recover_req_t
;
118 typedef struct iclass_premac
{
120 } PACKED iclass_premac_t
;
126 iclass_premac_t items
[];
127 } PACKED iclass_chk_t
;
129 typedef struct iclass_block
{
133 typedef struct iclass_prekey
{
141 } iclass_config_card_item_t
;
144 // iclass / picopass chip config structures and shared routines
146 uint8_t app_limit
; //[8]
147 uint8_t otp
[2]; //[9-10]
148 uint8_t block_writelock
;//[11]
149 uint8_t chip_config
; //[12]
150 uint8_t mem_config
; //[13]
152 uint8_t fuses
; //[15]
153 } PACKED picopass_conf_block_t
;
155 // iCLASS secure mode memory mapping
157 uint8_t csn
[PICOPASS_BLOCK_SIZE
];
158 picopass_conf_block_t conf
;
159 uint8_t epurse
[PICOPASS_BLOCK_SIZE
];
160 uint8_t key_d
[PICOPASS_BLOCK_SIZE
];
161 uint8_t key_c
[PICOPASS_BLOCK_SIZE
];
162 uint8_t app_issuer_area
[PICOPASS_BLOCK_SIZE
];
163 } PACKED picopass_hdr_t
;
165 // iCLASS non-secure mode memory mapping
168 picopass_conf_block_t conf
;
169 uint8_t app_issuer_area
[8];
170 } PACKED picopass_ns_hdr_t
;
175 } PACKED iclass_card_select_t
;
182 picopass_ns_hdr_t ns_hdr
;
184 } PACKED iclass_card_select_resp_t
;