]>
Commit | Line | Data |
---|---|---|
1 | // ISO15693 commons | |
2 | // Adrian Dabrowski 2010 and others, GPLv2 | |
3 | ||
4 | #ifndef ISO15693_H__ | |
5 | #define ISO15693_H__ | |
6 | ||
7 | #include "proxmark3.h" | |
8 | #include <stdint.h> | |
9 | #include <stdlib.h> | |
10 | ||
11 | #define POLY 0x8408 | |
12 | ||
13 | ||
14 | // ISO15693 CRC | |
15 | #define ISO15_CRC_PRESET (uint16_t)0xFFFF | |
16 | #define ISO15_CRC_POLY (uint16_t)0x8408 | |
17 | #define ISO15_CRC_CHECK ((uint16_t)(~0xF0B8 & 0xFFFF)) // use this for checking of a correct crc | |
18 | ||
19 | // REQUEST FLAGS | |
20 | ||
21 | #define ISO15_REQ_SUBCARRIER_SINGLE 0x00 // Tag should respond using one subcarrier (ASK) | |
22 | #define ISO15_REQ_SUBCARRIER_TWO 0x01 // Tag should respond using two subcarriers (FSK) | |
23 | #define ISO15_REQ_DATARATE_LOW 0x00 // Tag should respond using low data rate | |
24 | #define ISO15_REQ_DATARATE_HIGH 0x02 // Tag should respond using high data rate | |
25 | #define ISO15_REQ_NONINVENTORY 0x00 | |
26 | #define ISO15_REQ_INVENTORY 0x04 // This is an inventory request - see inventory flags | |
27 | #define ISO15_REQ_PROTOCOL_NONEXT 0x00 | |
28 | #define ISO15_REQ_PROTOCOL_EXT 0x08 // RFU | |
29 | ||
30 | // REQUEST FLAGS when INVENTORY is not set | |
31 | ||
32 | #define ISO15_REQ_SELECT 0x10 // only selected cards response | |
33 | #define ISO15_REQ_ADDRESS 0x20 // this req contains an address | |
34 | #define ISO15_REQ_OPTION 0x40 // Command specific option selector | |
35 | ||
36 | //REQUEST FLAGS when INVENTORY is set | |
37 | ||
38 | #define ISO15_REQINV_AFI 0x10 // AFI Field is present | |
39 | #define ISO15_REQINV_SLOT1 0x20 // 1 Slot | |
40 | #define ISO15_REQINV_SLOT16 0x00 // 16 Slots | |
41 | #define ISO15_REQINV_OPTION 0x40 // Command specific option selector | |
42 | ||
43 | //RESPONSE FLAGS | |
44 | #define ISO15_RES_ERROR 0x01 | |
45 | #define ISO15_RES_EXT 0x08 // Protocol Extention | |
46 | ||
47 | // RESPONSE ERROR CODES | |
48 | #define ISO15_NOERROR 0x00 | |
49 | #define ISO15_ERROR_CMD_NOT_SUP 0x01 // Command not supported | |
50 | #define ISO15_ERROR_CMD_NOT_REC 0x02 // Command not recognized (eg. parameter error) | |
51 | #define ISO15_ERROR_CMD_OPTION 0x03 // Command option not supported | |
52 | #define ISO15_ERROR_GENERIC 0x0F // No additional Info about this error | |
53 | #define ISO15_ERROR_BLOCK_UNAVAILABLE 0x10 | |
54 | #define ISO15_ERROR_BLOCK_LOCKED_ALREADY 0x11 // cannot lock again | |
55 | #define ISO15_ERROR_BLOCK_LOCKED 0x12 // cannot be changed | |
56 | #define ISO15_ERROR_BLOCK_WRITE 0x13 // Writing was unsuccessful | |
57 | #define ISO15_ERROR_BLOCL_WRITELOCK 0x14 // Locking was unsuccessful | |
58 | ||
59 | // COMMAND CODES | |
60 | #define ISO15_CMD_INVENTORY 0x01 | |
61 | #define ISO15_CMD_STAYQUIET 0x02 | |
62 | #define ISO15_CMD_READ 0x20 | |
63 | #define ISO15_CMD_WRITE 0x21 | |
64 | #define ISO15_CMD_LOCK 0x22 | |
65 | #define ISO15_CMD_READMULTI 0x23 | |
66 | #define ISO15_CMD_WRITEMULTI 0x24 | |
67 | #define ISO15_CMD_SELECT 0x25 | |
68 | #define ISO15_CMD_RESET 0x26 | |
69 | #define ISO15_CMD_WRITEAFI 0x27 | |
70 | #define ISO15_CMD_LOCKAFI 0x28 | |
71 | #define ISO15_CMD_WRITEDSFID 0x29 | |
72 | #define ISO15_CMD_LOCKDSFID 0x2A | |
73 | #define ISO15_CMD_SYSINFO 0x2B | |
74 | #define ISO15_CMD_SECSTATUS 0x2C | |
75 | ||
76 | ||
77 | uint16_t Iso15693Crc(uint8_t *v, int n); | |
78 | int Iso15693AddCrc(uint8_t *req, int n); | |
79 | char* Iso15693sprintUID(char *target,uint8_t *uid); | |
80 | unsigned short iclass_crc16(char *data_p, unsigned short length); | |
81 | ||
82 | //----------------------------------------------------------------------------- | |
83 | // Map a sequence of octets (~layer 2 command) into the set of bits to feed | |
84 | // to the FPGA, to transmit that command to the tag. | |
85 | // Mode: highspeed && one subcarrier (ASK) | |
86 | //----------------------------------------------------------------------------- | |
87 | ||
88 | // The sampling rate is 106.353 ksps/s, for T = 18.8 us | |
89 | ||
90 | // SOF defined as | |
91 | // 1) Unmodulated time of 56.64us | |
92 | // 2) 24 pulses of 423.75khz | |
93 | // 3) logic '1' (unmodulated for 18.88us followed by 8 pulses of 423.75khz) | |
94 | ||
95 | static const int Iso15693FrameSOF[] = { | |
96 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |
97 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |
98 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
99 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
100 | -1, -1, -1, -1, | |
101 | -1, -1, -1, -1, | |
102 | 1, 1, 1, 1, | |
103 | 1, 1, 1, 1 | |
104 | }; | |
105 | static const int Iso15693Logic0[] = { | |
106 | 1, 1, 1, 1, | |
107 | 1, 1, 1, 1, | |
108 | -1, -1, -1, -1, | |
109 | -1, -1, -1, -1 | |
110 | }; | |
111 | static const int Iso15693Logic1[] = { | |
112 | -1, -1, -1, -1, | |
113 | -1, -1, -1, -1, | |
114 | 1, 1, 1, 1, | |
115 | 1, 1, 1, 1 | |
116 | }; | |
117 | ||
118 | // EOF defined as | |
119 | // 1) logic '0' (8 pulses of 423.75khz followed by unmodulated for 18.88us) | |
120 | // 2) 24 pulses of 423.75khz | |
121 | // 3) Unmodulated time of 56.64us | |
122 | ||
123 | static const int Iso15693FrameEOF[] = { | |
124 | 1, 1, 1, 1, | |
125 | 1, 1, 1, 1, | |
126 | -1, -1, -1, -1, | |
127 | -1, -1, -1, -1, | |
128 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
129 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
130 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |
131 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 | |
132 | }; | |
133 | ||
134 | ||
135 | #endif |