made a multi threaded version of ht2crack2search since the file lookups should benefi...
[RRG-proxmark3.git] / include / protocols.h
blob23ee85f6bdf5cc4ff6c28b2e5cecec1d24eb8dc3
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
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.
8 //
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 #ifndef PROTOCOLS_H
17 #define PROTOCOLS_H
19 #include "common.h"
21 //The following data is taken from http://www.proxmark.org/forum/viewtopic.php?pid=13501#p13501
23 ISO14443A (usually NFC tags)
24 26 (7bits) = REQA
25 30 = Read (usage: 30+1byte block number+2bytes ISO14443A-CRC - answer: 16bytes)
26 A2 = Write (usage: A2+1byte block number+4bytes data+2bytes ISO14443A-CRC - answer: 0A [ACK] or 00 [NAK])
27 52 (7bits) = WUPA (usage: 52(7bits) - answer: 2bytes ATQA)
28 93 20 = Anticollision (usage: 9320 - answer: 4bytes UID+1byte UID-bytes-xor)
29 93 70 = Select (usage: 9370+5bytes 9320 answer - answer: 1byte SAK)
30 95 20 = Anticollision of cascade level2
31 95 70 = Select of cascade level2
32 50 00 = Halt (usage: 5000+2bytes ISO14443A-CRC - no answer from card)
34 E0 = RATS
35 D0 = PPS
36 Mifare
37 60 = Authenticate with KeyA
38 61 = Authenticate with KeyB
39 40 (7bits) = Used to put Chinese Changeable UID cards in special mode (must be followed by 43 (8bits) - answer: 0A)
40 C0 = Decrement
41 C1 = Increment
42 C2 = Restore
43 B0 = Transfer
44 Ultralight C
45 A0 = Compatibility Write (to accommodate MIFARE commands)
46 1A = Step1 Authenticate
47 AF = Step2 Authenticate
49 NTAG i2c 2K
50 C2 = SECTOR_SELECT
52 ISO14443B
53 05 = REQB
54 1D = ATTRIB
55 50 = HALT
57 BA = PING (reader -> tag)
58 AB = PONG (tag -> reader)
59 SRIX4K (tag does not respond to 05)
60 06 00 = INITIATE
61 0E xx = SELECT ID (xx = Chip-ID)
62 0B = Get UID
63 08 yy = Read Block (yy = block number)
64 09 yy dd dd dd dd = Write Block (yy = block number; dd dd dd dd = data to be written)
65 0C = Reset to Inventory
66 0F = Completion
67 0A 11 22 33 44 55 66 = Authenticate (11 22 33 44 55 66 = data to authenticate)
70 ISO15693
71 MANDATORY COMMANDS (all ISO15693 tags must support those)
72 01 = Inventory (usage: 260100+2bytes ISO15693-CRC - answer: 12bytes)
73 02 = Stay Quiet
74 OPTIONAL COMMANDS (not all tags support them)
75 20 = Read Block (usage: 0220+1byte block number+2bytes ISO15693-CRC - answer: 4bytes)
76 21 = Write Block (usage: 0221+1byte block number+4bytes data+2bytes ISO15693-CRC - answer: 4bytes)
77 22 = Lock Block
78 23 = Read Multiple Blocks (usage: 0223+1byte 1st block to read+1byte last block to read+2bytes ISO15693-CRC)
79 24 = Write Multiple Blocks
80 25 = Select
81 26 = Reset to Ready
82 27 = Write AFI
83 28 = Lock AFI
84 29 = Write DSFID
85 2A = Lock DSFID
86 2B = Get_System_Info (usage: 022B+2bytes ISO15693-CRC - answer: 14 or more bytes)
87 2C = Read Multiple Block Security Status (usage: 022C+1byte 1st block security to read+1byte last block security to read+2bytes ISO15693-CRC)
89 EM Microelectronic CUSTOM COMMANDS
90 A5 = Active EAS (followed by 1byte IC Manufacturer code+1byte EAS type)
91 A7 = Write EAS ID (followed by 1byte IC Manufacturer code+2bytes EAS value)
92 B8 = Get Protection Status for a specific block (followed by 1byte IC Manufacturer code+1byte block number+1byte of how many blocks after the previous is needed the info)
93 E4 = Login (followed by 1byte IC Manufacturer code+4bytes password)
94 NXP/Philips CUSTOM COMMANDS
95 A0 = Inventory Read
96 A1 = Fast Inventory Read
97 A2 = Set EAS
98 A3 = Reset EAS
99 A4 = Lock EAS
100 A5 = EAS Alarm
101 A6 = Password Protect EAS
102 A7 = Write EAS ID
103 A8 = Read EPC
104 B0 = Inventory Page Read
105 B1 = Fast Inventory Page Read
106 B2 = Get Random Number
107 B3 = Set Password
108 B4 = Write Password
109 B5 = Lock Password
110 B6 = Bit Password Protection
111 B7 = Lock Page Protection Condition
112 B8 = Get Multiple Block Protection Status
113 B9 = Destroy SLI
114 BA = Enable Privacy
115 BB = 64bit Password Protection
116 40 = Long Range CMD (Standard ISO/TR7003:1990)
118 ISO 7816-4 Basic interindustry commands. For command APDU's.
119 B0 = READ BINARY
120 D0 = WRITE BINARY
121 D6 = UPDATE BINARY
122 0E = ERASE BINARY
123 B2 = READ RECORDS
124 D2 = WRITE RECORDS
125 E2 = APPEND RECORD
126 DC = UPDATE RECORD
127 CA = GET DATA
128 DA = PUT DATA
129 A4 = SELECT FILE
130 20 = VERIFY
131 88 = INTERNAL AUTHENTICATION
132 82 = EXTERNAL AUTHENTICATION
133 B4 = GET CHALLENGE
134 70 = MANAGE CHANNEL
136 For response APDU's
137 90 00 = OK
138 6x xx = ERROR
140 // these cmds are adjusted to ISO15693 and Manchester encoding requests.
141 // for instance ICLASS_CMD_SELECT 0x81 tells if ISO14443b/BPSK coding/106 kbits/s
142 // for instance ICLASS_CMD_SELECT 0x41 tells if ISO14443b/BPSK coding/423 kbits/s
144 #define ICLASS_CMD_HALT 0x0
145 #define ICLASS_CMD_SELECT 0x1
146 #define ICLASS_CMD_ACTALL 0xA
147 #define ICLASS_CMD_DETECT 0xF
149 #define ICLASS_CMD_PAGESEL 0x4
150 #define ICLASS_CMD_CHECK 0x5
151 #define ICLASS_CMD_READ4 0x6
152 #define ICLASS_CMD_UPDATE 0x7
153 #define ICLASS_CMD_READCHECK 0x8
154 #define ICLASS_CMD_READ_OR_IDENTIFY 0xC
155 #define ICLASS_CMD_ACT 0xE
157 #define ICLASS_CREDIT(x) (((x) & 0x10) == 0x10)
158 #define ICLASS_DEBIT(x) (((x) & 0x80) == 0x80)
161 #define ECP_HEADER 0x6A
163 // 7bit Apple Magsafe wake up command
164 #define MAGSAFE_CMD_WUPA_1 0x7A
165 #define MAGSAFE_CMD_WUPA_2 0x7B
166 #define MAGSAFE_CMD_WUPA_3 0x7C
167 #define MAGSAFE_CMD_WUPA_4 0x7D
169 #define ISO14443A_CMD_REQA 0x26
170 #define ISO14443A_CMD_READBLOCK 0x30
171 #define ISO14443A_CMD_WUPA 0x52
172 #define ISO14443A_CMD_OPTS 0x35
173 #define ISO14443A_CMD_ANTICOLL_OR_SELECT 0x93
174 #define ISO14443A_CMD_ANTICOLL_OR_SELECT_2 0x95
175 #define ISO14443A_CMD_ANTICOLL_OR_SELECT_3 0x97
176 #define ISO14443A_CMD_WRITEBLOCK 0xA0
177 #define ISO14443A_CMD_HALT 0x50
178 #define ISO14443A_CMD_RATS 0xE0
179 #define ISO14443A_CMD_PPS 0xD0
180 #define ISO14443A_CMD_NXP_DESELECT 0xC2
181 #define ISO14443A_CMD_WTX 0xF2
183 #define MIFARE_SELECT_CT 0x88
184 #define MIFARE_AUTH_KEYA 0x60
185 #define MIFARE_AUTH_KEYB 0x61
186 #define MIFARE_MAGICWUPC1 0x40
187 #define MIFARE_MAGICWUPC2 0x43
188 #define MIFARE_MAGICWIPEC 0x41
189 #define MIFARE_CMD_DEC 0xC0
190 #define MIFARE_CMD_INC 0xC1
191 #define MIFARE_CMD_RESTORE 0xC2
192 #define MIFARE_CMD_TRANSFER 0xB0
194 #define MIFARE_MAGIC_GDM_WUPC1 0x20
195 #define MIFARE_MAGIC_GDM_WUPC2 0x23
196 #define MIFARE_MAGIC_GDM_AUTH_KEY 0x80
197 #define MIFARE_MAGIC_GDM_READBLOCK 0x38
198 #define MIFARE_MAGIC_GDM_WRITEBLOCK 0xA8
199 #define MIFARE_MAGIC_GDM_READ_CFG 0xE0
200 #define MIFARE_MAGIC_GDM_WRITE_CFG 0xE1
202 #define MIFARE_EV1_PERSONAL_UID 0x40
203 #define MIFARE_EV1_SETMOD 0x43
204 #define MIFARE_EV1_UIDF0 0x00
205 #define MIFARE_EV1_UIDF1 0x40
206 #define MIFARE_EV1_UIDF2 0x20
207 #define MIFARE_EV1_UIDF3 0x60
209 #define MIFARE_ULC_WRITE 0xA2
210 #define MIFARE_ULC_COMP_WRITE 0xA0
211 #define MIFARE_ULC_AUTH_1 0x1A
212 #define MIFARE_ULC_AUTH_2 0xAF
214 #define MIFARE_ULEV1_AUTH 0x1B
215 #define MIFARE_ULEV1_VERSION 0x60
216 #define MIFARE_ULEV1_FASTREAD 0x3A
217 #define MIFARE_ULEV1_READ_CNT 0x39
218 #define MIFARE_ULEV1_INCR_CNT 0xA5
219 #define MIFARE_ULEV1_READSIG 0x3C
220 #define MIFARE_ULEV1_CHECKTEAR 0x3E
221 #define MIFARE_ULEV1_VCSL 0x4B
223 // New Mifare UL Nano commands. Ref:: (https://www.nxp.com/docs/en/data-sheet/MF0UN_H_00.pdf)
224 #define MIFARE_ULNANO_WRITESIG 0xA9
225 #define MIFARE_ULNANO_LOCKSIG 0xAC
227 #define MIFARE_ULAES_AUTH_1 0x1A
228 #define MIFARE_ULAES_AUTH_2 0xAF
230 // NTAG i2k 2K uses sector 0, and sector 1 to have access to
231 // block 0x00-0xFF.
232 #define NTAG_I2C_SELECT_SECTOR 0xC2
233 #define NTAG_I2C_FASTWRITE 0xA6
235 //NTAG 213TT (tamper) command
236 #define NTAGTT_CMD_READ_TT 0xA4
238 // mifare 4bit card answers
239 #define CARD_ACK 0x0A // 1010 - ACK
240 #define CARD_NACK_IV 0x00 // 0000 - NACK, invalid argument (invalid page address)
241 #define CARD_NACK_PA 0x01 // 0001 - NACK, parity / crc error
242 #define CARD_NACK_NA 0x04 // 0100 - NACK, not allowed (command not allowed)
243 #define CARD_NACK_TR 0x05 // 0101 - NACK, transmission error
244 #define CARD_NACK_EE 0x07 // 0111 - NACK, EEPROM write error
246 // Magic Generation 1, parameter "work flags"
247 // bit 0 - need get UID
248 // bit 1 - send wupC (wakeup chinese)
249 // bit 2 - send HALT cmd after sequence
250 // bit 3 - turn on FPGA
251 // bit 4 - turn off FPGA
252 // bit 5 - set datain instead of issuing USB reply (called via ARM for StandAloneMode14a)
253 #define MAGIC_UID 0x01
254 #define MAGIC_WUPC 0x02
255 #define MAGIC_HALT 0x04
256 #define MAGIC_INIT 0x08
257 #define MAGIC_OFF 0x10
258 #define MAGIC_DATAIN 0x20
259 #define MAGIC_WIPE 0x40
260 #define MAGIC_SINGLE (MAGIC_WUPC | MAGIC_HALT | MAGIC_INIT | MAGIC_OFF) //0x1E
262 // by CMD_HF_MIFARE_CIDENT / Flags
263 #define MAGIC_FLAG_NONE 0x0000
264 #define MAGIC_FLAG_GEN_1A 0x0001
265 #define MAGIC_FLAG_GEN_1B 0x0002
266 #define MAGIC_FLAG_GEN_2 0x0004
267 #define MAGIC_FLAG_GEN_UNFUSED 0x0008
268 #define MAGIC_FLAG_SUPER_GEN1 0x0010
269 #define MAGIC_FLAG_SUPER_GEN2 0x0020
270 #define MAGIC_FLAG_NTAG21X 0x0040
271 #define MAGIC_FLAG_GEN_3 0x0080
272 #define MAGIC_FLAG_GEN_4GTU 0x0100
273 #define MAGIC_FLAG_GDM_AUTH 0x0200
274 #define MAGIC_FLAG_QL88 0x0400
275 #define MAGIC_FLAG_GDM_WUP_20 0x0800
276 #define MAGIC_FLAG_GDM_WUP_40 0x1000
279 // Commands for configuration of Gen4 GTU cards.
280 // see https://github.com/RfidResearchGroup/proxmark3/blob/master/doc/magic_cards_notes.md
281 #define GEN_4GTU_CMD 0xCF // Prefix for all commands, followed by pasword (4b)
282 #define GEN_4GTU_SHADOW 0x32 // Configure GTU shadow mode
283 #define GEN_4GTU_ATS 0x34 // Configure ATS
284 #define GEN_4GTU_ATQA 0x35 // Configure ATQA/SAK (swap ATQA bytes)
285 #define GEN_4GTU_UIDLEN 0x68 // Configure UID length
286 #define GEN_4GTU_ULEN 0x69 // (De)Activate Ultralight mode
287 #define GEN_4GTU_ULMODE 0x6A // Select Ultralight mode
288 #define GEN_4GTU_GETCNF 0xC6 // Dump configuration
289 #define GEN_4GTU_TEST 0xCC // Factory test, returns 6666
290 #define GEN_4GTU_WRITE 0xCD // Backdoor write 16b block
291 #define GEN_4GTU_READ 0xCE // Backdoor read 16b block
292 #define GEN_4GTU_SETCNF 0xF0 // Configure all params in one cmd
293 #define GEN_4GTU_FUSCNF 0xF1 // Configure all params in one cmd and fuse the configuration permanently
294 #define GEN_4GTU_CHPWD 0xFE // change password
297 06 00 = INITIATE
298 0E xx = SELECT ID (xx = Chip-ID)
299 0B = Get UID
300 08 yy = Read Block (yy = block number)
301 09 yy dd dd dd dd = Write Block (yy = block number; dd dd dd dd = data to be written)
302 0C = Reset to Inventory
303 0F = Completion
304 0A 11 22 33 44 55 66 = Authenticate (11 22 33 44 55 66 = data to authenticate)
307 #define ISO14443B_REQB 0x05
308 #define ISO14443B_ATTRIB 0x1D
309 #define ISO14443B_HALT 0x50
310 #define ISO14443B_INITIATE 0x06
311 #define ISO14443B_SELECT 0x0E
312 #define ISO14443B_GET_UID 0x0B
313 #define ISO14443B_READ_BLK 0x08
314 #define ISO14443B_WRITE_BLK 0x09
315 #define ISO14443B_RESET 0x0C
316 #define ISO14443B_COMPLETION 0x0F
317 #define ISO14443B_AUTHENTICATE 0x0A
318 #define ISO14443B_PING 0xBA
319 #define ISO14443B_PONG 0xAB
321 // XEROX Commands
322 #define ISO14443B_XEROX_PWD 0x38
323 #define ISO14443B_XEROX_WUP1 0x0D
324 #define ISO14443B_XEROX_WUP2 0x5D
325 #define ISO14443B_XEROX_EXT_READ_BLK 0x20
326 #define ISO14443B_XEROX_READ_BLK 0x30
328 // ASK C-ticket
329 #define ASK_REQT 0x10
330 #define ASK_IDENTIFY 0x0F
331 #define ASK_SELECT 0x9F
332 #define ASK_MULTREAD (0x1 << 4) // High nibble
333 #define ASK_UPDATE (0x3 << 4) // High nibble
334 #define ASK_WRITE (0x5 << 4) // High nibble
335 #define ASK_READ (0x6 << 4) // High nibble
336 #define ASK_DESACTIVATE 0xF0
339 // defined crypto RF commands
340 // only interpreting channel 1 communication
341 #define CRYPTORF_SET_USER_ZONE 0x11
342 #define CRYPTORF_READ_USER_ZONE 0x12
343 #define CRYPTORF_WRITE_USER_ZONE 0x13
344 #define CRYPTORF_WRITE_SYSTEM_ZONE 0x14
345 #define CRYPTORF_READ_SYSTEM_ZONE 0x16
346 #define CRYPTORF_VERIFY_CRYPTO 0x18
347 #define CRYPTORF_SEND_CHECKSUM 0x19
348 #define CRYPTORF_DESELECT 0x1A
349 #define CRYPTORF_IDLE 0x1B
350 #define CRYPTORF_CHECK_PASSWORD 0x1C
352 // defined Crypto RF errors
353 #define CRYPTORF_ERR_ACCESS_DENIED_ZONE 0x99
354 #define CRYPTORF_ERR_PARAM_INVALID 0xA1
355 #define CRYPTORF_ERR_ADDRES_INVALID 0xA2
356 #define CRYPTORF_ERR_LENGTH_INVALID 0xA3
357 #define CRYPTORF_ERR_AUTH_ENC_REQ 0xA9
358 #define CRYPTORF_ERR_ACCESS_DENIED_WLOCK 0xB9
359 #define CRYPTORF_ERR_BYTE_ACCESS_DENIED_NOT_ALLOWED 0xBA
360 #define CRYPTORF_ERR_ACCESS_DENIED_NOT_ALLOWED 0xBA
361 #define CRYPTORF_ERR_BYTE_ACCESS_DENIED_PASSWD_REQ 0xBC
362 #define CRYPTORF_ERR_CHECKSUM_FAIL2 0xC8
363 #define CRYPTORF_ERR_CHECKSUM_FAIL 0xC9
364 #define CRYPTORF_ERR_PASSWD_REQ 0xD9
365 #define CRYPTORF_ERR_FUSE_ACCESS_DENIED 0xDF
366 #define CRYPTORF_ERR_MODIFY_FORBIDDEN 0xE9
367 #define CRYPTORF_ERR_ACCESS_DENIED_FUSE_ORDR 0xE9
368 #define CRYPTORF_ERR_MEMORY_WRITE_DATA_M 0xED
369 #define CRYPTORF_ERR_MEMORY_ACCESS 0xEE
370 #define CRYPTORF_ERR_MEMORY_ACCESS_SEC 0xF9
372 // First byte is 26
373 #define ISO15693_INVENTORY 0x01
374 #define ISO15693_STAYQUIET 0x02
375 // First byte is 02
376 #define ISO15693_READBLOCK 0x20
377 #define ISO15693_WRITEBLOCK 0x21
378 #define ISO15693_LOCKBLOCK 0x22
379 #define ISO15693_READ_MULTI_BLOCK 0x23
380 #define ISO15693_WRITE_MULTI_BLOCK 0x24
381 #define ISO15693_SELECT 0x25
382 #define ISO15693_RESET_TO_READY 0x26
383 #define ISO15693_WRITE_AFI 0x27
384 #define ISO15693_LOCK_AFI 0x28
385 #define ISO15693_WRITE_DSFID 0x29
386 #define ISO15693_LOCK_DSFID 0x2A
387 #define ISO15693_GET_SYSTEM_INFO 0x2B
388 #define ISO15693_READ_MULTI_SECSTATUS 0x2C
389 // NXP/Philips custom commands
390 #define ISO15693_INVENTORY_READ 0xA0
391 #define ISO15693_FAST_INVENTORY_READ 0xA1
392 #define ISO15693_SET_EAS 0xA2
393 #define ISO15693_RESET_EAS 0xA3
394 #define ISO15693_LOCK_EAS 0xA4
395 #define ISO15693_EAS_ALARM 0xA5
396 #define ISO15693_PASSWORD_PROTECT_EAS 0xA6
397 #define ISO15693_WRITE_EAS_ID 0xA7
398 #define ISO15693_READ_EPC 0xA8
399 #define ISO15693_GET_NXP_SYSTEM_INFO 0xAB
400 #define ISO15693_INVENTORY_PAGE_READ 0xB0
401 #define ISO15693_FAST_INVENTORY_PAGE_READ 0xB1
402 #define ISO15693_GET_RANDOM_NUMBER 0xB2
403 #define ISO15693_SET_PASSWORD 0xB3
404 #define ISO15693_WRITE_PASSWORD 0xB4
405 #define ISO15693_LOCK_PASSWORD 0xB5
406 #define ISO15693_PROTECT_PAGE 0xB6
407 #define ISO15693_LOCK_PAGE_PROTECTION 0xB7
408 #define ISO15693_GET_MULTI_BLOCK_PROTECTION 0xB8
409 #define ISO15693_DESTROY 0xB9
410 #define ISO15693_ENABLE_PRIVACY 0xBA
411 #define ISO15693_64BIT_PASSWORD_PROTECTION 0xBB
412 #define ISO15693_STAYQUIET_PERSISTENT 0xBC
413 #define ISO15693_READ_SIGNATURE 0xBD
416 #define ISO15693_MAGIC_WRITE 0xE0
418 // Topaz command set:
419 #define TOPAZ_REQA 0x26 // Request
420 #define TOPAZ_WUPA 0x52 // WakeUp
421 #define TOPAZ_RID 0x78 // Read ID
422 #define TOPAZ_RALL 0x00 // Read All (all bytes)
423 #define TOPAZ_READ 0x01 // Read (a single byte)
424 #define TOPAZ_WRITE_E 0x53 // Write-with-erase (a single byte)
425 #define TOPAZ_WRITE_NE 0x1a // Write-no-erase (a single byte)
426 // additional commands for Dynamic Memory Model
427 #define TOPAZ_RSEG 0x10 // Read segment
428 #define TOPAZ_READ8 0x02 // Read (eight bytes)
429 #define TOPAZ_WRITE_E8 0x54 // Write-with-erase (eight bytes)
430 #define TOPAZ_WRITE_NE8 0x1B // Write-no-erase (eight bytes)
432 // Definitions of which protocol annotations there are available
433 #define ISO_14443A 0
434 #define ICLASS 1
435 #define ISO_14443B 2
436 #define TOPAZ 3
437 #define ISO_7816_4 4
438 #define MFDES 5
439 #define LEGIC 6
440 #define ISO_15693 7
441 #define FELICA 8
442 #define PROTO_MIFARE 9
443 #define PROTO_HITAG1 10
444 #define THINFILM 11
445 #define LTO 12
446 #define PROTO_HITAG2 13
447 #define PROTO_HITAGS 14
448 #define PROTO_CRYPTORF 15
449 #define SEOS 16
450 #define PROTO_MFPLUS 17
451 #define PROTO_TEXKOM 18
452 #define PROTO_XEROX 19
454 // Picopass fuses
455 #define FUSE_FPERS 0x80
456 #define FUSE_CODING1 0x40
457 #define FUSE_CODING0 0x20
458 #define FUSE_CRYPT1 0x10
459 #define FUSE_CRYPT0 0x08
460 #define FUSE_FPROD1 0x04
461 #define FUSE_FPROD0 0x02
462 #define FUSE_RA 0x01
464 // Picopass Pagemode fuses
465 #define PICOPASS_SECURE_PAGEMODE_AUTH_DISABLED 0x00
466 #define PICOPASS_NON_SECURE_PAGEMODE 0x01
467 #define PICOPASS_SECURE_PAGEMODE_KEYS_LOCKED 0x02
468 #define PICOPASS_SECURE_PAGEMODE_KEYS_MODIFIABLE 0x03
470 // ISO 7816-4 Basic interindustry commands. For command APDU's.
471 #define ISO7816_READ_BINARY 0xB0
472 #define ISO7816_WRITE_BINARY 0xD0
473 #define ISO7816_UPDATE_BINARY 0xD6
474 #define ISO7816_ERASE_BINARY 0x0E
475 #define ISO7816_READ_RECORDS 0xB2
476 #define ISO7816_WRITE_RECORDS 0xD2
477 #define ISO7816_APPEND_RECORD 0xE2
478 #define ISO7816_UPDATE_RECORD 0xDC
479 #define ISO7816_GET_DATA 0xCA
480 #define ISO7816_PUT_DATA 0xDA
481 #define ISO7816_SELECT_FILE 0xA4
482 #define ISO7816_VERIFY 0x20
483 #define ISO7816_INTERNAL_AUTHENTICATION 0x88
484 #define ISO7816_EXTERNAL_AUTHENTICATION 0x82
485 #define ISO7816_GET_CHALLENGE 0x84
486 #define ISO7816_MANAGE_CHANNEL 0x70
488 #define ISO7816_GET_RESPONSE 0xC0
490 // ISO7816-4 For response APDU's
491 #define ISO7816_OK 0x9000
493 // 6x xx = APDU ERROR CODES
495 // 61 xx
496 #define ISO7816_BYTES_REMAINING_00 0x6100 // Response bytes remaining
498 // 62 xx
499 #define ISO7816_WARNING_STATE_UNCHANGED 0x6200 // Warning, card state unchanged
500 #define ISO7816_DATA_CORRUPT 0x6281 // Returned data may be corrupted
501 #define ISO7816_FILE_EOF 0x6282 // The end of the file has been reached before the end of reading
502 #define ISO7816_INVALID_DF 0x6283 // Invalid DF
503 #define ISO7816_INVALID_FILE 0x6284 // Selected file is not valid
504 #define ISO7816_FILE_TERMINATED 0x6285 // File is terminated
506 // 63 xx
507 #define ISO7816_AUTH_FAILED 0x6300 // Authentification failed
508 #define ISO7816_FILE_FILLED 0x6381 // File filled up by the last write
510 // 65 xx
511 #define ISO7816_MEMORY_FULL 0x6501 // Memory failure
512 #define ISO7816_WRITE_MEMORY_ERR 0x6581 // Write problem / Memory failure / Unknown mode
514 // 67 xx
515 #define ISO7816_WRONG_LENGTH 0x6700 // Wrong length
517 // 68 xx
518 #define ISO7816_LOGICAL_CHANNEL_NOT_SUPPORTED 0x6881 // Card does not support the operation on the specified logical channel
519 #define ISO7816_SECURE_MESSAGING_NOT_SUPPORTED 0x6882 // Card does not support secure messaging
520 #define ISO7816_LAST_COMMAND_EXPECTED 0x6883 // Last command in chain expected
521 #define ISO7816_COMMAND_CHAINING_NOT_SUPPORTED 0x6884 // Command chaining not supported
523 // 69 xx
524 #define ISO7816_TRANSACTION_FAIL 0x6900 // No successful transaction executed during session
525 #define ISO7816_SELECT_FILE_ERR 0x6981 // Cannot select indicated file, command not compatible with file organization
526 #define ISO7816_SECURITY_STATUS_NOT_SATISFIED 0x6982 // Security condition not satisfied
527 #define ISO7816_FILE_INVALID 0x6983 // File invalid
528 #define ISO7816_DATA_INVALID 0x6984 // Data invalid
529 #define ISO7816_CONDITIONS_NOT_SATISFIED 0x6985 // Conditions of use not satisfied
530 #define ISO7816_COMMAND_NOT_ALLOWED 0x6986 // Command not allowed (no current EF)
531 #define ISO7816_SM_DATA_MISSING 0x6987 // Expected SM data objects missing
532 #define ISO7816_SM_DATA_INCORRECT 0x6988 // SM data objects incorrect
533 #define ISO7816_APPLET_SELECT_FAILED 0x6999 // Applet selection failed
535 // 6A xx
536 #define ISO7816_INVALID_P1P2 0x6A00 // Bytes P1 and/or P2 are invalid
537 #define ISO7816_WRONG_DATA 0x6A80 // Wrong data
538 #define ISO7816_FUNC_NOT_SUPPORTED 0x6A81 // Function not supported
539 #define ISO7816_FILE_NOT_FOUND 0x6A82 // File not found
540 #define ISO7816_RECORD_NOT_FOUND 0x6A83 // Record not found
541 #define ISO7816_FILE_FULL 0x6A84 // Not enough memory space in the file
542 #define ISO7816_LC_TLV_CONFLICT 0x6A85 // LC / TLV conlict
543 #define ISO7816_INCORRECT_P1P2 0x6A86 // Incorrect parameters (P1,P2)
544 #define ISO7816_FILE_EXISTS 0x6A89 // File exists
545 #define ISO7816_NOT_IMPLEMENTED 0x6AFF //
547 // 6x 00
548 #define ISO7816_WRONG_P1P2 0x6B00 // Incorrect parameters (P1,P2)
549 #define ISO7816_CORRECT_LENGTH_00 0x6C00 // Correct Expected Length (Le)
550 #define ISO7816_INS_NOT_SUPPORTED 0x6D00 // INS value not supported
551 #define ISO7816_CLA_NOT_SUPPORTED 0x6E00 // CLA value not supported
552 #define ISO7816_UNKNOWN 0x6F00 // No precise diagnosis
555 // MIFARE DESFire command set:
556 #define MFDES_AUTHENTICATE 0x0A // AUTHENTICATE_NATIVE
557 #define MFDES_AUTHENTICATE_ISO 0x1A // AUTHENTICATE_STANDARD
558 #define MFDES_AUTHENTICATE_AES 0xAA
560 // Leakage Resilient Primitive (LRP)
561 #define MFDES_AUTHENTICATE_EV2F 0x71 // LRP, AuthenticateLRPFirst
562 #define MFDES_AUTHENTICATE_EV2NF 0x77 // LRP, AuthenticateLRPNonFirst
564 #define MFDES_CREDIT 0x0C
565 #define MFDES_LIMITED_CREDIT 0x1C
566 #define MFDES_WRITE_RECORD 0x3B
567 #define MFDES_READSIG 0x3C
568 #define MFDES_WRITE_DATA 0x3D
569 #define MFDES_GET_KEY_SETTINGS 0x45
570 #define MFDES_GET_UID 0x51
571 #define MFDES_CHANGE_KEY_SETTINGS 0x54
572 #define MFDES_ROLL_KEY_SETTINGS 0x55
573 #define MFDES_INIT_KEY_SETTINGS 0x56
574 #define MFDES_FINALIZE_KEY_SETTINGS 0x57
575 #define MFDES_SELECT_APPLICATION 0x5A
576 #define MFDES_CHANGE_CONFIGURATION 0x5C
577 #define MFDES_CHANGE_FILE_SETTINGS 0x5F
578 #define MFDES_GET_VERSION 0x60
579 #define MFDES_GET_ISOFILE_IDS 0x61
580 #define MFDES_GET_KEY_VERSION 0x64
581 #define MFDES_GET_DELEGATE_INFO 0x69
582 #define MFDES_GET_APPLICATION_IDS 0x6A
583 #define MFDES_GET_VALUE 0x6C
584 #define MFDES_GET_FREE_MEMORY 0x6E
585 #define MFDES_GET_DF_NAMES 0x6D
586 #define MFDES_GET_FILE_IDS 0x6F
587 #define MFDES_WRITE_RECORD2 0x8B
588 #define MFDES_WRITE_DATA2 0x8D
589 #define MFDES_ABORT_TRANSACTION 0xA7
590 #define MFDES_READ_RECORDS2 0xAB
591 #define MFDES_READ_DATA2 0xAD
592 #define MFDES_ADDITIONAL_FRAME 0xAF
593 #define MFDES_UPDATE_RECORD2 0xBA
594 #define MFDES_READ_RECORDS 0xBB
595 #define MFDES_READ_DATA 0xBD
596 #define MFDES_CREATE_CYCLIC_RECORD_FILE 0xC0
597 #define MFDES_CREATE_LINEAR_RECORD_FILE 0xC1
598 #define MFDES_CHANGE_KEY 0xC4
599 #define MFDES_CHANGE_KEY_EV2 0xC6
600 #define MFDES_COMMIT_TRANSACTION 0xC7
601 #define MFDES_COMMIT_READER_ID 0xC8
602 #define MFDES_CREATE_DELEGATE_APP 0xC9
603 #define MFDES_CREATE_APPLICATION 0xCA
604 #define MFDES_CREATE_BACKUP_DATA_FILE 0xCB
605 #define MFDES_CREATE_VALUE_FILE 0xCC
606 #define MFDES_CREATE_STD_DATA_FILE 0xCD
607 #define MFDES_CREATE_TRANS_MAC_FILE 0xCE
608 #define MFDES_DELETE_APPLICATION 0xDA
609 #define MFDES_UPDATE_RECORD 0xDB
610 #define MFDES_DEBIT 0xDC
611 #define MFDES_DELETE_FILE 0xDF
612 #define MFDES_CLEAR_RECORD_FILE 0xEB
613 #define MFDES_NOTIFY_TRANSACTION_SUCCESS 0xEE // New command. Used by Apple-ECP-compliant DESFire readers to signify successful transaction
614 #define MFDES_PREPARE_PC 0xF0
615 #define MFDES_PROXIMITY_CHECK 0xF2
616 #define MFDES_GET_FILE_SETTINGS 0xF5
617 #define MFDES_FORMAT_PICC 0xFC
618 #define MFDES_VERIFY_PC 0xFD
619 #define MFDES_NATIVE_ISO7816_WRAP_CLA 0x90
622 // MIFARE DESFire status & error codes:
623 #define MFDES_S_OPERATION_OK 0x00
624 #define MFDES_S_NO_CHANGES 0x0C
625 #define MFDES_S_SIGNATURE 0x90
626 #define MFDES_S_ADDITIONAL_FRAME 0xAF
628 #define MFDES_E_OUT_OF_EEPROM 0x0E
629 #define MFDES_E_ILLEGAL_COMMAND_CODE 0x1C
630 #define MFDES_E_INTEGRITY_ERROR 0x1E
631 #define MFDES_E_NO_SUCH_KEY 0x40
632 #define MFDES_E_LENGTH 0x7E
633 #define MFDES_E_PERMISSION_DENIED 0x9D
634 #define MFDES_E_PARAMETER_ERROR 0x9E
635 #define MFDES_E_APPLICATION_NOT_FOUND 0xA0
636 #define MFDES_E_APPL_INTEGRITY 0xA1
637 #define MFDES_E_AUTHENTICATION_ERROR 0xAE
638 #define MFDES_E_BOUNDARY 0xBE
639 #define MFDES_E_PICC_INTEGRITY 0xC1
640 #define MFDES_E_COMMAND_ABORTED 0xCA
641 #define MFDES_E_PICC_DISABLED 0xCD
642 #define MFDES_E_COUNT 0xCE
643 #define MFDES_E_DUPLICATE 0xDE
644 #define MFDES_E_EEPROM 0xEE
645 #define MFDES_E_FILE_NOT_FOUND 0xF0
646 #define MFDES_E_FILE_INTEGRITY 0xF1
649 // MIFARE PLus EV2 Command set
650 // source: https://www.nxp.com/docs/en/data-sheet/MF1P(H)x2.pdf in Look-Up Tables
652 #define MFP_READ_SIG 0x3C // same as DESFIRE
653 #define MFP_WRITEPERSO 0xA8
654 #define MFP_COMMITPERSO 0xAA
656 #define MFP_AUTHENTICATEFIRST 0x70
657 #define MFP_AUTHENTICATEFIRST_VARIANT 0x73
658 #define MFP_AUTHENTICATENONFIRST 0x76
659 #define MFP_AUTHENTICATECONTINUE 0x72
660 #define MFP_AUTHENTICATESECTORSWITCH 0x7A
661 #define MFP_RESETAUTH 0x78
663 #define MFP_VCSUPPORTLASTISOL3 0x4B
664 #define MFP_ISOSELECT 0xA4
666 #define MFP_GETVERSION 0x60 // same as DESFIRE
667 #define MFP_ADDITIONALFRAME 0xAF
668 #define MFP_SETCONFIGSL1 0x44
669 #define MFP_MF_PERSONALIZEUIDUSAGE 0x40
671 // read commands
672 #define MFP_READENCRYPTEDNOMAC_MACED 0X30
673 #define MFP_READENCRYPTEDMAC_MACED 0x31
674 #define MFP_READPLAINNOMAC_MACED 0x32
675 #define MFP_READPLAINMAC_MACED 0x33
676 #define MFP_READENCRYPTEDNOMAC_UNMACED 0x34
677 #define MFP_READENCRYPTEDMAC_UNMACED 0X35
678 #define MFP_READPLAINNOMAC_UNMACED 0x36
679 #define MFP_READPLAINMAC_UNMACED 0x37
681 // write commands
682 #define MFP_WRITEENCRYPTEDNOMAC 0xA0
683 #define MFP_WRITEENCRYPTEDMAC 0xA1
684 #define MFP_WRITEPLAINNOMAC 0xA2
685 #define MFP_WRITEPLAINMAC 0xA3
687 // value commands
688 #define MFP_INCREMENTNOMAC 0xB0
689 #define MFP_INCREMENTMAC 0xB1
690 #define MFP_DECREMENTNOMAC 0xB2
691 #define MFP_DECREMENTMAC 0xB3
692 #define MFP_TRANSFERNOMAC 0xB4
693 #define MFP_TRANSFERMAC 0xB5
694 #define MFP_INCREMENTTRANSFERNOMAC 0xB6
695 #define MFP_INCREMENTTRANSFERMAC 0xB7
696 #define MFP_DECREMENTTRANSFERNOMAC 0xB8
697 #define MFP_DECREMENTTRANSFERMAC 0xB9
698 #define MFP_RESTORENOMAC 0xC2
699 #define MFP_RESTOREMAC 0xC3
702 // LEGIC Commands
703 #define LEGIC_MIM_22 0x0D
704 #define LEGIC_MIM_256 0x1D
705 #define LEGIC_MIM_1024 0x3D
706 #define LEGIC_ACK_22 0x19
707 #define LEGIC_ACK_256 0x39
708 #define LEGIC_READ 0x01
709 #define LEGIC_WRITE 0x00
711 /* T55x7 configuration register definitions */
712 #define T55x7_POR_DELAY 0x00000001
713 #define T55x7_ST_TERMINATOR 0x00000008
714 #define T55x7_PWD 0x00000010
715 #define T55x7_MAXBLOCK_SHIFT 5
716 #define T55x7_AOR 0x00000200
717 #define T55x7_PSKCF_RF_2 0
718 #define T55x7_PSKCF_RF_4 0x00000400
719 #define T55x7_PSKCF_RF_8 0x00000800
720 #define T55x7_MODULATION_DIRECT 0
721 #define T55x7_MODULATION_PSK1 0x00001000
722 #define T55x7_MODULATION_PSK2 0x00002000
723 #define T55x7_MODULATION_PSK3 0x00003000
724 #define T55x7_MODULATION_FSK1 0x00004000
725 #define T55x7_MODULATION_FSK2 0x00005000
726 #define T55x7_MODULATION_FSK1a 0x00006000
727 #define T55x7_MODULATION_FSK2a 0x00007000
728 #define T55x7_MODULATION_MANCHESTER 0x00008000
729 #define T55x7_MODULATION_BIPHASE 0x00010000
730 #define T55x7_MODULATION_DIPHASE 0x00018000
731 #define T55x7_X_MODE 0x00020000
732 #define T55x7_BITRATE_RF_8 0
733 #define T55x7_BITRATE_RF_16 0x00040000
734 #define T55x7_BITRATE_RF_32 0x00080000
735 #define T55x7_BITRATE_RF_40 0x000C0000
736 #define T55x7_BITRATE_RF_50 0x00100000
737 #define T55x7_BITRATE_RF_64 0x00140000
738 #define T55x7_BITRATE_RF_100 0x00180000
739 #define T55x7_BITRATE_RF_128 0x001C0000
740 #define T55x7_TESTMODE_DISABLED 0x60000000
742 /* T5555 (Q5) configuration register definitions */
743 #define T5555_ST_TERMINATOR 0x00000001
744 #define T5555_MAXBLOCK_SHIFT 0x00000001
745 #define T5555_MODULATION_MANCHESTER 0
746 #define T5555_MODULATION_PSK1 0x00000010
747 #define T5555_MODULATION_PSK2 0x00000020
748 #define T5555_MODULATION_PSK3 0x00000030
749 #define T5555_MODULATION_FSK1 0x00000040
750 #define T5555_MODULATION_FSK2 0x00000050
751 #define T5555_MODULATION_BIPHASE 0x00000060
752 #define T5555_MODULATION_DIRECT 0x00000070
753 #define T5555_INVERT_OUTPUT 0x00000080
754 #define T5555_PSK_RF_2 0
755 #define T5555_PSK_RF_4 0x00000100
756 #define T5555_PSK_RF_8 0x00000200
757 #define T5555_USE_PWD 0x00000400
758 #define T5555_USE_AOR 0x00000800
759 #define T5555_SET_BITRATE(x) (((x-2)/2)<<12)
760 #define T5555_GET_BITRATE(x) ((((x >> 12) & 0x3F)*2)+2)
761 #define T5555_BITRATE_SHIFT 12 //(RF=2n+2) ie 64=2*0x1F+2 or n = (RF-2)/2
762 #define T5555_FAST_WRITE 0x00004000
763 #define T5555_PAGE_SELECT 0x00008000
764 #define T5555_FIXED 0x60000000
766 #define T55XX_WRITE_TIMEOUT 1500
768 // em4x05 & em4x69 chip configuration register definitions
769 #define EM4x05_GET_BITRATE(x) ((((x) & 0x3F) * 2) + 2)
770 // Note: only data rates 8, 16, 32, 40(*) and 64 are supported. (*) only with EM4305 330pF
771 #define EM4x05_SET_BITRATE(x) (((x) - 2) / 2)
772 #define EM4x05_MODULATION_NRZ 0x00000000
773 #define EM4x05_MODULATION_MANCHESTER 0x00000040
774 #define EM4x05_MODULATION_BIPHASE 0x00000080
775 #define EM4x05_MODULATION_MILLER 0x000000C0 //not supported by all 4x05/4x69 chips
776 #define EM4x05_MODULATION_PSK1 0x00000100 //not supported by all 4x05/4x69 chips
777 #define EM4x05_MODULATION_PSK2 0x00000140 //not supported by all 4x05/4x69 chips
778 #define EM4x05_MODULATION_PSK3 0x00000180 //not supported by all 4x05/4x69 chips
779 #define EM4x05_MODULATION_FSK1 0x00000200 //not supported by all 4x05/4x69 chips
780 #define EM4x05_MODULATION_FSK2 0x00000240 //not supported by all 4x05/4x69 chips
781 #define EM4x05_PSK_RF_2 0
782 #define EM4x05_PSK_RF_4 0x00000400
783 #define EM4x05_PSK_RF_8 0x00000800
784 #define EM4x05_MAXBLOCK_SHIFT 14
785 #define EM4x05_FIRST_USER_BLOCK 5
786 #define EM4x05_SET_NUM_BLOCKS(x) (( (x) + 4) << 14) //# of blocks sent during default read mode
787 #define EM4x05_GET_NUM_BLOCKS(x) ((( (x) >> 14) & 0xF) - 4)
788 #define EM4x05_READ_LOGIN_REQ (1 << 18)
789 #define EM4x05_READ_HK_LOGIN_REQ (1 << 19)
790 #define EM4x05_WRITE_LOGIN_REQ (1 << 20)
791 #define EM4x05_WRITE_HK_LOGIN_REQ (1 << 21)
792 #define EM4x05_READ_AFTER_WRITE (1 << 22)
793 #define EM4x05_DISABLE_ALLOWED (1 << 23)
794 #define EM4x05_READER_TALK_FIRST (1 << 24)
795 #define EM4x05_INVERT (1 << 25)
796 #define EM4x05_PIGEON (1 << 26)
799 // FeliCa protocol
800 #define FELICA_POLL_REQ 0x00
801 #define FELICA_POLL_ACK 0x01
803 #define FELICA_REQSRV_REQ 0x02
804 #define FELICA_REQSRV_ACK 0x03
806 #define FELICA_REQRESP_REQ 0x04
807 #define FELICA_REQRESP_ACK 0x05
809 #define FELICA_RDBLK_REQ 0x06
810 #define FELICA_RDBLK_ACK 0x07
812 #define FELICA_WRTBLK_REQ 0x08
813 #define FELICA_WRTBLK_ACK 0x09
815 #define FELICA_SRCHSYSCODE_REQ 0x0a
816 #define FELICA_SRCHSYSCODE_ACK 0x0b
818 #define FELICA_REQSYSCODE_REQ 0x0c
819 #define FELICA_REQSYSCODE_ACK 0x0d
821 #define FELICA_AUTH1_REQ 0x10
822 #define FELICA_AUTH1_ACK 0x11
824 #define FELICA_AUTH2_REQ 0x12
825 #define FELICA_AUTH2_ACK 0x13
827 #define FELICA_RDSEC_REQ 0x14
828 #define FELICA_RDSEC_ACK 0x15
830 #define FELICA_WRTSEC_REQ 0x16
831 #define FELICA_WRTSEC_ACK 0x17
833 #define FELICA_REQSRV2_REQ 0x32
834 #define FELICA_REQSRV2_ACK 0x33
836 #define FELICA_GETSTATUS_REQ 0x38
837 #define FELICA_GETSTATUS_ACK 0x39
839 #define FELICA_OSVER_REQ 0x3c
840 #define FELICA_OSVER_ACK 0x3d
842 #define FELICA_RESET_MODE_REQ 0x3e
843 #define FELICA_RESET_MODE_ACK 0x3f
845 #define FELICA_AUTH1V2_REQ 0x40
846 #define FELICA_AUTH1V2_ACK 0x41
848 #define FELICA_AUTH2V2_REQ 0x42
849 #define FELICA_AUTH2V2_ACK 0x43
851 #define FELICA_RDSECV2_REQ 0x44
852 #define FELICA_RDSECV2_ACK 0x45
853 #define FELICA_WRTSECV2_REQ 0x46
854 #define FELICA_WRTSECV2_ACK 0x47
856 #define FELICA_UPDATE_RNDID_REQ 0x4C
857 #define FELICA_UPDATE_RNDID_ACK 0x4D
859 // FeliCa SYSTEM list
860 #define SYSTEMCODE_ANY 0xffff // ANY
861 #define SYSTEMCODE_FELICA_LITE 0x88b4 // FeliCa Lite
862 #define SYSTEMCODE_COMMON 0xfe00 // Common
863 #define SYSTEMCODE_EDY 0xfe00 // Edy
864 #define SYSTEMCODE_CYBERNE 0x0003 // Cyberne
865 #define SYSTEMCODE_SUICA 0x0003 // Suica
866 #define SYSTEMCODE_PASMO 0x0003 // Pasmo
868 //FeliCa Service list Suica/pasmo (little endian)
869 #define SERVICE_SUICA_INOUT 0x108f // SUICA/PASMO
870 #define SERVICE_SUICA_HISTORY 0x090f // SUICA/PASMO
871 #define SERVICE_FELICA_LITE_READONLY 0x0b00 // FeliCa Lite RO
872 #define SERVICE_FELICA_LITE_READWRITE 0x0900 // FeliCa Lite RW
874 // Calypso protocol
875 #define CALYPSO_GET_RESPONSE 0xC0
876 #define CALYPSO_SELECT 0xA4
877 #define CALYPSO_INVALIDATE 0x04
878 #define CALYPSO_REHABILITATE 0x44
879 #define CALYPSO_APPEND_RECORD 0xE2
880 #define CALYPSO_DECREASE 0x30
881 #define CALYPSO_INCREASE 0x32
882 #define CALYPSO_READ_BINARY 0xB0
883 #define CALYPSO_READ_RECORD 0xB2
884 #define CALYPSO_UPDATE_BINARY 0xD6
885 #define CALYPSO_UPDATE_RECORD 0xDC
886 #define CALYPSO_WRITE_RECORD 0xD2
887 #define CALYPSO_OPEN_SESSION 0x8A
888 #define CALYPSO_CLOSE_SESSION 0x8E
889 #define CALYPSO_GET_CHALLENGE 0x84
890 #define CALYPSO_CHANGE_PIN 0xD8
891 #define CALYPSO_VERIFY_PIN 0x20
892 #define CALYPSO_SV_GET 0x7C
893 #define CALYPSO_SV_DEBIT 0xBA
894 #define CALYPSO_SV_RELOAD 0xB8
895 #define CALYPSO_SV_UN_DEBIT 0xBC
896 #define CALYPSO_SAM_SV_DEBIT 0x54
897 #define CALYPSO_SAM_SV_RELOAD 0x56
899 // HITAG 1 commands
900 #define HITAG1_SET_CC 0x30 // higher 5 bits only
901 #define HITAG1_SET_CCNEW 0xC8 // higher 5 bits only
902 #define HITAG1_READ_ID 0x00 // not a real command, consists of 5 bits length, <length> bits partial SN, 8 bits CRC
903 #define HITAG1_SELECT 0x00 // higher 5 bits only, followed by 32 bits SN and 8 bits CRC
904 #define HITAG1_WRPPAGE 0x80 // higher 4 bits only, followed by 8 bits page and 8 bits CRC
905 #define HITAG1_WRPBLK 0x90 // higher 4 bits only, followed by 8 bits block and 8 bits CRC
906 #define HITAG1_WRCPAGE 0xA0 // higher 4 bits only, followed by 8 bits page or key information and 8 bits CRC
907 #define HITAG1_WRCBLK 0xB0 // higher 4 bits only, followed by 8 bits block and 8 bits CRC
908 #define HITAG1_RDPPAGE 0xC0 // higher 4 bits only, followed by 8 bits page and 8 bits CRC
909 #define HITAG1_RDPBLK 0xD0 // higher 4 bits only, followed by 8 bits block and 8 bits CRC
910 #define HITAG1_RDCPAGE 0xE0 // higher 4 bits only, followed by 8 bits page and 8 bits CRC
911 #define HITAG1_RDCBLK 0xF0 // higher 4 bits only, followed by 8 bits block and 8 bits CRC
912 #define HITAG1_HALT 0x70 // higher 4 bits only, followed by 8 bits (dummy) page and 8 bits CRC
914 // HITAG 2 commands
915 #define HITAG2_START_AUTH 0xC0 // left 5 bits only
916 #define HITAG2_READ_PAGE 0xC0 // page number in bits 5 to 3, page number inverted in bit 0 and following 2 bits
917 #define HITAG2_READ_PAGE_INVERTED 0x44 // page number in bits 5 to 3, page number inverted in bit 0 and following 2 bits
918 #define HITAG2_WRITE_PAGE 0x82 // page number in bits 5 to 3, page number inverted in bit 0 and following 2 bits
919 #define HITAG2_HALT 0x00 // left 5 bits only
922 // HITAG S commands
923 #define HITAGS_UID_REQ_STD 0x30 // 00110 UID REQUEST Std
924 #define HITAGS_UID_REQ_ADV 0xC0 // 11000 UID REQUEST Adv
925 #define HITAGS_UID_REQ_ADV2 0xC8 // 11001 UID REQUEST Adv
926 #define HITAGS_UID_REQ_FADV 0xD0 // 11010 UID REQUEST FAdv
927 #define HITAGS_SELECT 0x00 // 00000 SELECT (UID)
928 #define HITAGS_READ_PAGE 0xC0 // 1100 READ PAGE
929 #define HITAGS_READ_BLOCK 0xD0 // 1101 READ BLOCK
930 #define HITAGS_WRITE_PAGE 0x80 // 1000 WRITE PAGE
931 #define HITAGS_WRITE_BLOCK 0x90 // 1001 WRITE BLOCK
932 #define HITAGS_QUIET 0x70 // 0111 QUIET
934 // LTO-CM commands
935 #define LTO_REQ_STANDARD 0x45
936 #define LTO_REQ_ALL 0x4A
937 #define LTO_READWORD 0x40 // read 2 bytes (word)
938 #define LTO_READBLOCK 0x30
939 #define LTO_READBLOCK_CONT 0x80
940 #define LTO_SELECT 0x93
941 #define LTO_WRITEWORD 0xB0 // write 2 bytes (word)
942 #define LTO_WRITEBLOCK 0xA0
943 #define LTO_HALT 0x50
944 #define LTO_TEST_CMD_1 0x0E
945 #define LTO_TEST_CMD_2 0x6C
947 // 0x0A = ACK
948 // 0x05 = NACK
950 #endif
951 // PROTOCOLS_H