Commit | Line | Data |
---|---|---|
1cac41cb MB |
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) 1999-2019, Broadcom. | |
9 | * | |
10 | * Unless you and Broadcom execute a separate written software license | |
11 | * agreement governing use of this software, this software is licensed to you | |
12 | * under the terms of the GNU General Public License version 2 (the "GPL"), | |
13 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the | |
14 | * following added to such license: | |
15 | * | |
16 | * As a special exception, the copyright holders of this software give you | |
17 | * permission to link this software with independent modules, and to copy and | |
18 | * distribute the resulting executable under terms of your choice, provided that | |
19 | * you also meet, for each linked independent module, the terms and conditions of | |
20 | * the license of that module. An independent module is a module which is not | |
21 | * derived from this software. The special exception does not apply to any | |
22 | * modifications of the software. | |
23 | * | |
24 | * Notwithstanding the above, under no circumstances may you combine this | |
25 | * software in any way with any other Broadcom software provided under a license | |
26 | * other than the GPL, without Broadcom's express prior written consent. | |
27 | * | |
28 | * | |
29 | * <<Broadcom-WL-IPTag/Open:>> | |
30 | * | |
5a068558 | 31 | * $Id: eapol.h 767212 2018-06-13 00:17:23Z $ |
1cac41cb MB |
32 | */ |
33 | ||
34 | #ifndef _eapol_h_ | |
35 | #define _eapol_h_ | |
36 | ||
37 | #ifndef _TYPEDEFS_H_ | |
38 | #include <typedefs.h> | |
39 | #endif // endif | |
40 | ||
41 | /* This marks the start of a packed structure section. */ | |
42 | #include <packed_section_start.h> | |
43 | ||
44 | #if !defined(BCMCRYPTO_COMPONENT) | |
45 | #include <bcmcrypto/aeskeywrap.h> | |
46 | #endif /* !BCMCRYPTO_COMPONENT */ | |
47 | ||
48 | /* EAPOL for 802.3/Ethernet */ | |
49 | typedef BWL_PRE_PACKED_STRUCT struct { | |
50 | struct ether_header eth; /* 802.3/Ethernet header */ | |
51 | unsigned char version; /* EAPOL protocol version */ | |
52 | unsigned char type; /* EAPOL type */ | |
53 | unsigned short length; /* Length of body */ | |
54 | unsigned char body[1]; /* Body (optional) */ | |
55 | } BWL_POST_PACKED_STRUCT eapol_header_t; | |
56 | ||
57 | #define EAPOL_HEADER_LEN 18 | |
58 | ||
59 | typedef struct { | |
60 | unsigned char version; /* EAPOL protocol version */ | |
61 | unsigned char type; /* EAPOL type */ | |
62 | unsigned short length; /* Length of body */ | |
63 | } eapol_hdr_t; | |
64 | ||
5a068558 | 65 | #define EAPOL_HDR_LEN 4u |
1cac41cb MB |
66 | |
67 | /* EAPOL version */ | |
5a068558 MB |
68 | #define WPA2_EAPOL_VERSION 2u |
69 | #define WPA_EAPOL_VERSION 1u | |
70 | #define LEAP_EAPOL_VERSION 1u | |
71 | #define SES_EAPOL_VERSION 1u | |
1cac41cb MB |
72 | |
73 | /* EAPOL types */ | |
74 | #define EAP_PACKET 0 | |
5a068558 MB |
75 | #define EAPOL_START 1u |
76 | #define EAPOL_LOGOFF 2u | |
77 | #define EAPOL_KEY 3u | |
78 | #define EAPOL_ASF 4u | |
1cac41cb MB |
79 | |
80 | /* EAPOL-Key types */ | |
5a068558 MB |
81 | #define EAPOL_RC4_KEY 1u |
82 | #define EAPOL_WPA2_KEY 2u /* 802.11i/WPA2 */ | |
83 | #define EAPOL_WPA_KEY 254u /* WPA */ | |
1cac41cb MB |
84 | |
85 | /* RC4 EAPOL-Key header field sizes */ | |
5a068558 MB |
86 | #define EAPOL_KEY_REPLAY_LEN 8u |
87 | #define EAPOL_KEY_IV_LEN 16u | |
88 | #define EAPOL_KEY_SIG_LEN 16u | |
1cac41cb MB |
89 | |
90 | /* RC4 EAPOL-Key */ | |
91 | typedef BWL_PRE_PACKED_STRUCT struct { | |
92 | unsigned char type; /* Key Descriptor Type */ | |
93 | unsigned short length; /* Key Length (unaligned) */ | |
94 | unsigned char replay[EAPOL_KEY_REPLAY_LEN]; /* Replay Counter */ | |
95 | unsigned char iv[EAPOL_KEY_IV_LEN]; /* Key IV */ | |
96 | unsigned char index; /* Key Flags & Index */ | |
97 | unsigned char signature[EAPOL_KEY_SIG_LEN]; /* Key Signature */ | |
98 | unsigned char key[1]; /* Key (optional) */ | |
99 | } BWL_POST_PACKED_STRUCT eapol_key_header_t; | |
100 | ||
5a068558 | 101 | #define EAPOL_KEY_HEADER_LEN 44u |
1cac41cb MB |
102 | |
103 | /* RC4 EAPOL-Key flags */ | |
5a068558 MB |
104 | #define EAPOL_KEY_FLAGS_MASK 0x80u |
105 | #define EAPOL_KEY_BROADCAST 0u | |
106 | #define EAPOL_KEY_UNICAST 0x80u | |
1cac41cb MB |
107 | |
108 | /* RC4 EAPOL-Key index */ | |
5a068558 | 109 | #define EAPOL_KEY_INDEX_MASK 0x7fu |
1cac41cb MB |
110 | |
111 | /* WPA/802.11i/WPA2 EAPOL-Key header field sizes */ | |
112 | #define EAPOL_AKW_BLOCK_LEN 8 | |
5a068558 MB |
113 | #define EAPOL_WPA_KEY_REPLAY_LEN 8u |
114 | #define EAPOL_WPA_KEY_NONCE_LEN 32u | |
115 | #define EAPOL_WPA_KEY_IV_LEN 16u | |
116 | #define EAPOL_WPA_KEY_RSC_LEN 8u | |
117 | #define EAPOL_WPA_KEY_ID_LEN 8u | |
1cac41cb | 118 | #define EAPOL_WPA_KEY_DATA_LEN (EAPOL_WPA_MAX_KEY_SIZE + EAPOL_AKW_BLOCK_LEN) |
5a068558 MB |
119 | #define EAPOL_WPA_MAX_KEY_SIZE 32u |
120 | #define EAPOL_WPA_KEY_MAX_MIC_LEN 32u | |
121 | #define EAPOL_WPA_ENCR_KEY_MAX_LEN 64u | |
122 | #define EAPOL_WPA_TEMP_ENCR_KEY_MAX_LEN 32u | |
123 | ||
124 | #define EAPOL_WPA_PMK_MAX_LEN 64u | |
125 | #define EAPOL_WPA_PMK_SHA384_LEN 48u | |
126 | #define EAPOL_WPA_PMK_DEFAULT_LEN 32u | |
127 | #define EAPOL_WPA_KCK_DEFAULT_LEN 16u | |
128 | #define EAPOL_WPA_KCK_MIC_DEFAULT_LEN 16u | |
129 | #define EAPOL_WPA_ENCR_KEY_DEFAULT_LEN 16u | |
130 | ||
131 | #ifndef EAPOL_KEY_HDR_VER_V2 | |
132 | #define EAPOL_WPA_KEY_MIC_LEN 16u /* deprecated */ | |
133 | #define EAPOL_WPA_KEY_LEN 95u /* deprecated */ | |
134 | #endif // endif | |
1cac41cb | 135 | |
5a068558 | 136 | #ifndef EAPOL_KEY_HDR_VER_V2 |
1cac41cb MB |
137 | /* WPA EAPOL-Key : deprecated */ |
138 | typedef BWL_PRE_PACKED_STRUCT struct { | |
139 | unsigned char type; /* Key Descriptor Type */ | |
140 | unsigned short key_info; /* Key Information (unaligned) */ | |
141 | unsigned short key_len; /* Key Length (unaligned) */ | |
142 | unsigned char replay[EAPOL_WPA_KEY_REPLAY_LEN]; /* Replay Counter */ | |
143 | unsigned char nonce[EAPOL_WPA_KEY_NONCE_LEN]; /* Nonce */ | |
144 | unsigned char iv[EAPOL_WPA_KEY_IV_LEN]; /* Key IV */ | |
145 | unsigned char rsc[EAPOL_WPA_KEY_RSC_LEN]; /* Key RSC */ | |
146 | unsigned char id[EAPOL_WPA_KEY_ID_LEN]; /* WPA:Key ID, 802.11i/WPA2: Reserved */ | |
147 | unsigned char mic[EAPOL_WPA_KEY_MIC_LEN]; /* Key MIC */ | |
148 | unsigned short data_len; /* Key Data Length */ | |
149 | unsigned char data[EAPOL_WPA_KEY_DATA_LEN]; /* Key data */ | |
150 | } BWL_POST_PACKED_STRUCT eapol_wpa_key_header_t; | |
5a068558 | 151 | #else |
1cac41cb MB |
152 | /* WPA EAPOL-Key : new structure to consider dynamic MIC length */ |
153 | typedef BWL_PRE_PACKED_STRUCT struct { | |
154 | unsigned char type; /* Key Descriptor Type */ | |
155 | unsigned short key_info; /* Key Information (unaligned) */ | |
156 | unsigned short key_len; /* Key Length (unaligned) */ | |
157 | unsigned char replay[EAPOL_WPA_KEY_REPLAY_LEN]; /* Replay Counter */ | |
158 | unsigned char nonce[EAPOL_WPA_KEY_NONCE_LEN]; /* Nonce */ | |
159 | unsigned char iv[EAPOL_WPA_KEY_IV_LEN]; /* Key IV */ | |
160 | unsigned char rsc[EAPOL_WPA_KEY_RSC_LEN]; /* Key RSC */ | |
161 | unsigned char id[EAPOL_WPA_KEY_ID_LEN]; /* WPA:Key ID, 802.11i/WPA2: Reserved */ | |
162 | } BWL_POST_PACKED_STRUCT eapol_wpa_key_header_v2_t; | |
163 | ||
5a068558 MB |
164 | typedef eapol_wpa_key_header_v2_t eapol_wpa_key_header_t; |
165 | #endif /* EAPOL_KEY_HDR_VER_V2 */ | |
166 | ||
167 | #define EAPOL_WPA_KEY_DATA_LEN_SIZE 2u | |
1cac41cb | 168 | |
5a068558 | 169 | #ifdef EAPOL_KEY_HDR_VER_V2 |
1cac41cb MB |
170 | #define EAPOL_WPA_KEY_HDR_SIZE(mic_len) (sizeof(eapol_wpa_key_header_v2_t) \ |
171 | + mic_len + EAPOL_WPA_KEY_DATA_LEN_SIZE) | |
172 | ||
173 | /* WPA EAPOL-Key header macros to reach out mic/data_len/data field */ | |
174 | #define EAPOL_WPA_KEY_HDR_MIC_PTR(pos) ((uint8 *)pos + sizeof(eapol_wpa_key_header_v2_t)) | |
175 | #define EAPOL_WPA_KEY_HDR_DATA_LEN_PTR(pos, mic_len) \ | |
176 | ((uint8 *)pos + sizeof(eapol_wpa_key_header_v2_t) + mic_len) | |
177 | #define EAPOL_WPA_KEY_HDR_DATA_PTR(pos, mic_len) \ | |
178 | ((uint8 *)pos + EAPOL_WPA_KEY_HDR_SIZE(mic_len)) | |
5a068558 MB |
179 | #else |
180 | #define EAPOL_WPA_KEY_HDR_SIZE(mic_len) EAPOL_WPA_KEY_LEN | |
181 | #define EAPOL_WPA_KEY_HDR_MIC_PTR(pos) ((uint8 *)&pos->mic) | |
182 | #define EAPOL_WPA_KEY_HDR_DATA_LEN_PTR(pos, mic_len) ((uint8 *)&pos->data_len) | |
183 | #define EAPOL_WPA_KEY_HDR_DATA_PTR(pos, mic_len) ((uint8 *)&pos->data) | |
184 | #endif /* EAPOL_KEY_HDR_VER_V2 */ | |
1cac41cb MB |
185 | |
186 | /* WPA/802.11i/WPA2 KEY KEY_INFO bits */ | |
187 | #define WPA_KEY_DESC_OSEN 0x0 | |
188 | #define WPA_KEY_DESC_V0 0x0 | |
189 | #define WPA_KEY_DESC_V1 0x01 | |
190 | #define WPA_KEY_DESC_V2 0x02 | |
191 | #define WPA_KEY_DESC_V3 0x03 | |
192 | #define WPA_KEY_PAIRWISE 0x08 | |
193 | #define WPA_KEY_INSTALL 0x40 | |
194 | #define WPA_KEY_ACK 0x80 | |
195 | #define WPA_KEY_MIC 0x100 | |
196 | #define WPA_KEY_SECURE 0x200 | |
197 | #define WPA_KEY_ERROR 0x400 | |
198 | #define WPA_KEY_REQ 0x800 | |
199 | #define WPA_KEY_DESC_VER(_ki) ((_ki) & 0x03u) | |
200 | ||
201 | #define WPA_KEY_DESC_V2_OR_V3 WPA_KEY_DESC_V2 | |
202 | ||
203 | /* WPA-only KEY KEY_INFO bits */ | |
204 | #define WPA_KEY_INDEX_0 0x00 | |
205 | #define WPA_KEY_INDEX_1 0x10 | |
206 | #define WPA_KEY_INDEX_2 0x20 | |
207 | #define WPA_KEY_INDEX_3 0x30 | |
208 | #define WPA_KEY_INDEX_MASK 0x30 | |
209 | #define WPA_KEY_INDEX_SHIFT 0x04 | |
210 | ||
211 | /* 802.11i/WPA2-only KEY KEY_INFO bits */ | |
212 | #define WPA_KEY_ENCRYPTED_DATA 0x1000 | |
213 | ||
214 | /* Key Data encapsulation */ | |
215 | typedef BWL_PRE_PACKED_STRUCT struct { | |
216 | uint8 type; | |
217 | uint8 length; | |
218 | uint8 oui[3]; | |
219 | uint8 subtype; | |
220 | uint8 data[1]; | |
221 | } BWL_POST_PACKED_STRUCT eapol_wpa2_encap_data_t; | |
222 | ||
223 | #define EAPOL_WPA2_ENCAP_DATA_HDR_LEN 6 | |
224 | ||
225 | #define WPA2_KEY_DATA_SUBTYPE_GTK 1 | |
226 | #define WPA2_KEY_DATA_SUBTYPE_STAKEY 2 | |
227 | #define WPA2_KEY_DATA_SUBTYPE_MAC 3 | |
228 | #define WPA2_KEY_DATA_SUBTYPE_PMKID 4 | |
229 | #define WPA2_KEY_DATA_SUBTYPE_IGTK 9 | |
230 | ||
231 | /* GTK encapsulation */ | |
232 | typedef BWL_PRE_PACKED_STRUCT struct { | |
233 | uint8 flags; | |
234 | uint8 reserved; | |
235 | uint8 gtk[EAPOL_WPA_MAX_KEY_SIZE]; | |
236 | } BWL_POST_PACKED_STRUCT eapol_wpa2_key_gtk_encap_t; | |
237 | ||
238 | #define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN 2 | |
239 | ||
240 | #define WPA2_GTK_INDEX_MASK 0x03 | |
241 | #define WPA2_GTK_INDEX_SHIFT 0x00 | |
242 | ||
243 | #define WPA2_GTK_TRANSMIT 0x04 | |
244 | ||
245 | /* IGTK encapsulation */ | |
246 | typedef BWL_PRE_PACKED_STRUCT struct { | |
247 | uint16 key_id; | |
248 | uint8 ipn[6]; | |
249 | uint8 key[EAPOL_WPA_MAX_KEY_SIZE]; | |
250 | } BWL_POST_PACKED_STRUCT eapol_wpa2_key_igtk_encap_t; | |
251 | ||
252 | #define EAPOL_WPA2_KEY_IGTK_ENCAP_HDR_LEN 8 | |
253 | ||
254 | /* STAKey encapsulation */ | |
255 | typedef BWL_PRE_PACKED_STRUCT struct { | |
256 | uint8 reserved[2]; | |
257 | uint8 mac[ETHER_ADDR_LEN]; | |
258 | uint8 stakey[EAPOL_WPA_MAX_KEY_SIZE]; | |
259 | } BWL_POST_PACKED_STRUCT eapol_wpa2_key_stakey_encap_t; | |
260 | ||
261 | #define WPA2_KEY_DATA_PAD 0xdd | |
262 | ||
263 | /* This marks the end of a packed structure section. */ | |
264 | #include <packed_section_end.h> | |
265 | ||
266 | #endif /* _eapol_h_ */ |