]> git.zerfleddert.de Git - proxmark3-svn/blob - include/hitag.h
chg 'hf mf chk':
[proxmark3-svn] / include / hitag.h
1 //-----------------------------------------------------------------------------
2 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
3 // at your option, any later version. See the LICENSE.txt file for the text of
4 // the license.
5 //-----------------------------------------------------------------------------
6 // Hitag2, HitagS
7 //
8 // (c) 2012 Roel Verdult
9 // (c) 2016 Oguzhan Cicek, Hendrik Schwartke, Ralf Spenneberg
10 // <info@os-s.de>
11 //-----------------------------------------------------------------------------
12
13
14 #ifndef HITAG_H__
15 #define HITAG_H__
16
17 #ifdef _MSC_VER
18 #define PACKED
19 #else
20 #define PACKED __attribute__((packed))
21 #endif
22
23 typedef enum {
24 RHTSF_CHALLENGE = 01,
25 RHTSF_KEY = 02,
26 WHTSF_CHALLENGE = 03,
27 WHTSF_KEY = 04,
28 RHT2F_PASSWORD = 21,
29 RHT2F_AUTHENTICATE = 22,
30 RHT2F_CRYPTO = 23,
31 WHT2F_CRYPTO = 24,
32 RHT2F_TEST_AUTH_ATTEMPTS = 25,
33 RHT2F_UID_ONLY = 26,
34 } hitag_function;
35
36 typedef struct {
37 uint8_t password[4];
38 } PACKED rht2d_password;
39
40 typedef struct {
41 uint8_t NrAr[8];
42 uint8_t data[4];
43 } PACKED rht2d_authenticate;
44
45 typedef struct {
46 uint8_t key[6];
47 uint8_t data[4];
48 } PACKED rht2d_crypto;
49
50 typedef union {
51 rht2d_password pwd;
52 rht2d_authenticate auth;
53 rht2d_crypto crypto;
54 } hitag_data;
55
56
57 //---------------------------------------------------------
58 // Hitag S
59 //---------------------------------------------------------
60 typedef enum PROTO_STATE {READY=0,INIT,AUTHENTICATE,SELECTED,QUIET,TTF,FAIL} PSTATE; //protocol-state
61 typedef enum TAG_STATE {NO_OP=0,READING_PAGE,READING_BLOCK,WRITING_PAGE_ACK,WRITING_PAGE_DATA,WRITING_BLOCK_DATA} TSATE; //tag-state
62 typedef enum SOF_TYPE {STANDARD=0,ADVANCED,FAST_ADVANCED,ONE,NO_BITS} stype; //number of start-of-frame bits
63
64 struct hitagS_tag {
65 PSTATE pstate; //protocol-state
66 TSATE tstate; //tag-state
67 uint32_t uid;
68 uint8_t pages[64][4];
69 uint64_t key;
70 uint8_t pwdl0, pwdl1, pwdh0;
71 //con0
72 int max_page;
73 stype mode;
74 //con1
75 bool auth; //0=Plain 1=Auth
76 bool TTFC; //Transponder Talks first coding. 0=Manchester 1=Biphase
77 int TTFDR; //data rate in TTF Mode
78 int TTFM; //the number of pages that are sent to the RWD
79 bool LCON; //0=con1/2 read write 1=con1 read only and con2 OTP
80 bool LKP; //0=page2/3 read write 1=page2/3 read only in Plain mode and no access in authenticate mode
81 //con2
82 //0=read write 1=read only
83 bool LCK7; //page4/5
84 bool LCK6; //page6/7
85 bool LCK5; //page8-11
86 bool LCK4; //page12-15
87 bool LCK3; //page16-23
88 bool LCK2; //page24-31
89 bool LCK1; //page32-47
90 bool LCK0; //page48-63
91 } ;
92
93 #endif
Impressum, Datenschutz