(6/6) bcm57xx: package
[openwrt/svn-archive/archive.git] / package / broadcom-57xx / src / proto / eapol.h
1 /*
2 * 802.1x EAPOL definitions
3 *
4 * See
5 * IEEE Std 802.1X-2001
6 * IEEE 802.1X RADIUS Usage Guidelines
7 *
8 * Copyright (C) 2002 Broadcom Corporation
9 *
10 * eapol.h,v 9.17 2004/12/13 22:36:09 davidm Exp
11 */
12
13 #ifndef _eapol_h_
14 #define _eapol_h_
15
16 /* enable structure packing */
17 #if defined(__GNUC__)
18 #define PACKED __attribute__((packed))
19 #else
20 #pragma pack(1)
21 #define PACKED
22 #endif
23
24 #include <bcmcrypto/aeskeywrap.h>
25
26 /* EAPOL for 802.3/Ethernet */
27 typedef struct {
28 struct ether_header eth; /* 802.3/Ethernet header */
29 unsigned char version; /* EAPOL protocol version */
30 unsigned char type; /* EAPOL type */
31 unsigned short length; /* Length of body */
32 unsigned char body[1]; /* Body (optional) */
33 } eapol_header_t;
34
35 #define EAPOL_HEADER_LEN 18
36
37 /* EAPOL version */
38 #define WPA2_EAPOL_VERSION 2
39 #define WPA_EAPOL_VERSION 1
40 #define LEAP_EAPOL_VERSION 1
41 #define SES_EAPOL_VERSION 1
42
43 /* EAPOL types */
44 #define EAP_PACKET 0
45 #define EAPOL_START 1
46 #define EAPOL_LOGOFF 2
47 #define EAPOL_KEY 3
48 #define EAPOL_ASF 4
49
50 /* EAPOL-Key types */
51 #define EAPOL_RC4_KEY 1
52 #ifdef BCMWPA2
53 #define EAPOL_WPA2_KEY 2 /* 802.11i/WPA2 */
54 #endif
55 #define EAPOL_WPA_KEY 254 /* WPA */
56
57 /* RC4 EAPOL-Key header field sizes */
58 #define EAPOL_KEY_REPLAY_LEN 8
59 #define EAPOL_KEY_IV_LEN 16
60 #define EAPOL_KEY_SIG_LEN 16
61
62 /* RC4 EAPOL-Key */
63 typedef struct {
64 unsigned char type; /* Key Descriptor Type */
65 unsigned short length; /* Key Length (unaligned) */
66 unsigned char replay[EAPOL_KEY_REPLAY_LEN]; /* Replay Counter */
67 unsigned char iv[EAPOL_KEY_IV_LEN]; /* Key IV */
68 unsigned char index; /* Key Flags & Index */
69 unsigned char signature[EAPOL_KEY_SIG_LEN]; /* Key Signature */
70 unsigned char key[1]; /* Key (optional) */
71 } PACKED eapol_key_header_t;
72
73 #define EAPOL_KEY_HEADER_LEN 44
74
75 /* RC4 EAPOL-Key flags */
76 #define EAPOL_KEY_FLAGS_MASK 0x80
77 #define EAPOL_KEY_BROADCAST 0
78 #define EAPOL_KEY_UNICAST 0x80
79
80 /* RC4 EAPOL-Key index */
81 #define EAPOL_KEY_INDEX_MASK 0x7f
82
83 /* WPA/802.11i/WPA2 EAPOL-Key header field sizes */
84 #define EAPOL_WPA_KEY_REPLAY_LEN 8
85 #define EAPOL_WPA_KEY_NONCE_LEN 32
86 #define EAPOL_WPA_KEY_IV_LEN 16
87 #define EAPOL_WPA_KEY_RSC_LEN 8
88 #define EAPOL_WPA_KEY_ID_LEN 8
89 #define EAPOL_WPA_KEY_MIC_LEN 16
90 #define EAPOL_WPA_KEY_DATA_LEN (EAPOL_WPA_MAX_KEY_SIZE + AKW_BLOCK_LEN)
91 #define EAPOL_WPA_MAX_KEY_SIZE 32
92
93 /* WPA EAPOL-Key */
94 typedef struct {
95 unsigned char type; /* Key Descriptor Type */
96 unsigned short key_info; /* Key Information (unaligned) */
97 unsigned short key_len; /* Key Length (unaligned) */
98 unsigned char replay[EAPOL_WPA_KEY_REPLAY_LEN]; /* Replay Counter */
99 unsigned char nonce[EAPOL_WPA_KEY_NONCE_LEN]; /* Nonce */
100 unsigned char iv[EAPOL_WPA_KEY_IV_LEN]; /* Key IV */
101 unsigned char rsc[EAPOL_WPA_KEY_RSC_LEN]; /* Key RSC */
102 unsigned char id[EAPOL_WPA_KEY_ID_LEN]; /* WPA:Key ID, 802.11i/WPA2: Reserved */
103 unsigned char mic[EAPOL_WPA_KEY_MIC_LEN]; /* Key MIC */
104 unsigned short data_len; /* Key Data Length */
105 unsigned char data[EAPOL_WPA_KEY_DATA_LEN]; /* Key data */
106 } PACKED eapol_wpa_key_header_t;
107
108 #define EAPOL_WPA_KEY_LEN 95
109
110 /* WPA/802.11i/WPA2 KEY KEY_INFO bits */
111 #define WPA_KEY_DESC_V1 0x01
112 #define WPA_KEY_DESC_V2 0x02
113 #define WPA_KEY_PAIRWISE 0x08
114 #define WPA_KEY_INSTALL 0x40
115 #define WPA_KEY_ACK 0x80
116 #define WPA_KEY_MIC 0x100
117 #define WPA_KEY_SECURE 0x200
118 #define WPA_KEY_ERROR 0x400
119 #define WPA_KEY_REQ 0x800
120
121 /* WPA-only KEY KEY_INFO bits */
122 #define WPA_KEY_INDEX_0 0x00
123 #define WPA_KEY_INDEX_1 0x10
124 #define WPA_KEY_INDEX_2 0x20
125 #define WPA_KEY_INDEX_3 0x30
126 #define WPA_KEY_INDEX_MASK 0x30
127 #define WPA_KEY_INDEX_SHIFT 0x04
128
129 #ifdef BCMWPA2
130 /* 802.11i/WPA2-only KEY KEY_INFO bits */
131 #define WPA_KEY_ENCRYPTED_DATA 0x1000
132
133 /* Key Data encapsulation */
134 typedef struct {
135 uint8 type;
136 uint8 length;
137 uint8 oui[3];
138 uint8 subtype;
139 uint8 data[1];
140 } PACKED eapol_wpa2_encap_data_t;
141
142 #define EAPOL_WPA2_ENCAP_DATA_HDR_LEN 6
143
144 #define WPA2_KEY_DATA_SUBTYPE_GTK 1
145 #define WPA2_KEY_DATA_SUBTYPE_STAKEY 2
146 #define WPA2_KEY_DATA_SUBTYPE_MAC 3
147 #define WPA2_KEY_DATA_SUBTYPE_PMKID 4
148
149 /* GTK encapsulation */
150 typedef struct {
151 uint8 flags;
152 uint8 reserved;
153 uint8 gtk[EAPOL_WPA_MAX_KEY_SIZE];
154 } PACKED eapol_wpa2_key_gtk_encap_t;
155
156 #define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN 2
157
158 #define WPA2_GTK_INDEX_MASK 0x03
159 #define WPA2_GTK_INDEX_SHIFT 0x00
160
161 #define WPA2_GTK_TRANSMIT 0x04
162
163 /* STAKey encapsulation */
164 typedef struct {
165 uint8 reserved[2];
166 uint8 mac[ETHER_ADDR_LEN];
167 uint8 stakey[EAPOL_WPA_MAX_KEY_SIZE];
168 } PACKED eapol_wpa2_key_stakey_encap_t;
169
170 #define WPA2_KEY_DATA_PAD 0xdd
171
172 #endif /* BCMWPA2 */
173
174 #undef PACKED
175 #if !defined(__GNUC__)
176 #pragma pack()
177 #endif
178
179 #endif /* _eapol_h_ */