2 * 802.1x EAPOL definitions
6 * IEEE 802.1X RADIUS Usage Guidelines
8 * Copyright (C) 1999-2019, Broadcom.
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:
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.
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.
29 * <<Broadcom-WL-IPTag/Open:>>
31 * $Id: eapol.h 758863 2018-04-21 00:29:12Z $
41 /* This marks the start of a packed structure section. */
42 #include <packed_section_start.h>
44 #if !defined(BCMCRYPTO_COMPONENT)
45 #include <bcmcrypto/aeskeywrap.h>
46 #endif /* !BCMCRYPTO_COMPONENT */
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
;
57 #define EAPOL_HEADER_LEN 18
60 unsigned char version
; /* EAPOL protocol version */
61 unsigned char type
; /* EAPOL type */
62 unsigned short length
; /* Length of body */
65 #define EAPOL_HDR_LEN 4
68 #define WPA2_EAPOL_VERSION 2
69 #define WPA_EAPOL_VERSION 1
70 #define LEAP_EAPOL_VERSION 1
71 #define SES_EAPOL_VERSION 1
76 #define EAPOL_LOGOFF 2
81 #define EAPOL_RC4_KEY 1
82 #define EAPOL_WPA2_KEY 2 /* 802.11i/WPA2 */
83 #define EAPOL_WPA_KEY 254 /* WPA */
85 /* RC4 EAPOL-Key header field sizes */
86 #define EAPOL_KEY_REPLAY_LEN 8
87 #define EAPOL_KEY_IV_LEN 16
88 #define EAPOL_KEY_SIG_LEN 16
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
;
101 #define EAPOL_KEY_HEADER_LEN 44
103 /* RC4 EAPOL-Key flags */
104 #define EAPOL_KEY_FLAGS_MASK 0x80
105 #define EAPOL_KEY_BROADCAST 0
106 #define EAPOL_KEY_UNICAST 0x80
108 /* RC4 EAPOL-Key index */
109 #define EAPOL_KEY_INDEX_MASK 0x7f
111 /* WPA/802.11i/WPA2 EAPOL-Key header field sizes */
112 #define EAPOL_AKW_BLOCK_LEN 8
113 #define EAPOL_WPA_KEY_REPLAY_LEN 8
114 #define EAPOL_WPA_KEY_NONCE_LEN 32
115 #define EAPOL_WPA_KEY_IV_LEN 16
116 #define EAPOL_WPA_KEY_RSC_LEN 8
117 #define EAPOL_WPA_KEY_ID_LEN 8
118 #define EAPOL_WPA_KEY_MIC_LEN 16 /* deprecated */
119 #define EAPOL_WPA_KEY_DATA_LEN (EAPOL_WPA_MAX_KEY_SIZE + EAPOL_AKW_BLOCK_LEN)
120 #define EAPOL_WPA_MAX_KEY_SIZE 32
122 /* WPA EAPOL-Key : deprecated */
123 typedef BWL_PRE_PACKED_STRUCT
struct {
124 unsigned char type
; /* Key Descriptor Type */
125 unsigned short key_info
; /* Key Information (unaligned) */
126 unsigned short key_len
; /* Key Length (unaligned) */
127 unsigned char replay
[EAPOL_WPA_KEY_REPLAY_LEN
]; /* Replay Counter */
128 unsigned char nonce
[EAPOL_WPA_KEY_NONCE_LEN
]; /* Nonce */
129 unsigned char iv
[EAPOL_WPA_KEY_IV_LEN
]; /* Key IV */
130 unsigned char rsc
[EAPOL_WPA_KEY_RSC_LEN
]; /* Key RSC */
131 unsigned char id
[EAPOL_WPA_KEY_ID_LEN
]; /* WPA:Key ID, 802.11i/WPA2: Reserved */
132 unsigned char mic
[EAPOL_WPA_KEY_MIC_LEN
]; /* Key MIC */
133 unsigned short data_len
; /* Key Data Length */
134 unsigned char data
[EAPOL_WPA_KEY_DATA_LEN
]; /* Key data */
135 } BWL_POST_PACKED_STRUCT eapol_wpa_key_header_t
;
137 /* WPA EAPOL-Key : new structure to consider dynamic MIC length */
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 } BWL_POST_PACKED_STRUCT eapol_wpa_key_header_v2_t
;
149 #define EAPOL_WPA_KEY_LEN 95 /* deprecated */
150 #define EAPOL_WPA_KEY_DATA_LEN_SIZE 2
152 #define EAPOL_WPA_KEY_HDR_SIZE(mic_len) (sizeof(eapol_wpa_key_header_v2_t) \
153 + mic_len + EAPOL_WPA_KEY_DATA_LEN_SIZE)
155 /* WPA EAPOL-Key header macros to reach out mic/data_len/data field */
156 #define EAPOL_WPA_KEY_HDR_MIC_PTR(pos) ((uint8 *)pos + sizeof(eapol_wpa_key_header_v2_t))
157 #define EAPOL_WPA_KEY_HDR_DATA_LEN_PTR(pos, mic_len) \
158 ((uint8 *)pos + sizeof(eapol_wpa_key_header_v2_t) + mic_len)
159 #define EAPOL_WPA_KEY_HDR_DATA_PTR(pos, mic_len) \
160 ((uint8 *)pos + EAPOL_WPA_KEY_HDR_SIZE(mic_len))
162 /* WPA/802.11i/WPA2 KEY KEY_INFO bits */
163 #define WPA_KEY_DESC_OSEN 0x0
164 #define WPA_KEY_DESC_V0 0x0
165 #define WPA_KEY_DESC_V1 0x01
166 #define WPA_KEY_DESC_V2 0x02
167 #define WPA_KEY_DESC_V3 0x03
168 #define WPA_KEY_PAIRWISE 0x08
169 #define WPA_KEY_INSTALL 0x40
170 #define WPA_KEY_ACK 0x80
171 #define WPA_KEY_MIC 0x100
172 #define WPA_KEY_SECURE 0x200
173 #define WPA_KEY_ERROR 0x400
174 #define WPA_KEY_REQ 0x800
175 #define WPA_KEY_DESC_VER(_ki) ((_ki) & 0x03u)
177 #define WPA_KEY_DESC_V2_OR_V3 WPA_KEY_DESC_V2
179 /* WPA-only KEY KEY_INFO bits */
180 #define WPA_KEY_INDEX_0 0x00
181 #define WPA_KEY_INDEX_1 0x10
182 #define WPA_KEY_INDEX_2 0x20
183 #define WPA_KEY_INDEX_3 0x30
184 #define WPA_KEY_INDEX_MASK 0x30
185 #define WPA_KEY_INDEX_SHIFT 0x04
187 /* 802.11i/WPA2-only KEY KEY_INFO bits */
188 #define WPA_KEY_ENCRYPTED_DATA 0x1000
190 /* Key Data encapsulation */
191 typedef BWL_PRE_PACKED_STRUCT
struct {
197 } BWL_POST_PACKED_STRUCT eapol_wpa2_encap_data_t
;
199 #define EAPOL_WPA2_ENCAP_DATA_HDR_LEN 6
201 #define WPA2_KEY_DATA_SUBTYPE_GTK 1
202 #define WPA2_KEY_DATA_SUBTYPE_STAKEY 2
203 #define WPA2_KEY_DATA_SUBTYPE_MAC 3
204 #define WPA2_KEY_DATA_SUBTYPE_PMKID 4
205 #define WPA2_KEY_DATA_SUBTYPE_IGTK 9
207 /* GTK encapsulation */
208 typedef BWL_PRE_PACKED_STRUCT
struct {
211 uint8 gtk
[EAPOL_WPA_MAX_KEY_SIZE
];
212 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_gtk_encap_t
;
214 #define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN 2
216 #define WPA2_GTK_INDEX_MASK 0x03
217 #define WPA2_GTK_INDEX_SHIFT 0x00
219 #define WPA2_GTK_TRANSMIT 0x04
221 /* IGTK encapsulation */
222 typedef BWL_PRE_PACKED_STRUCT
struct {
225 uint8 key
[EAPOL_WPA_MAX_KEY_SIZE
];
226 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_igtk_encap_t
;
228 #define EAPOL_WPA2_KEY_IGTK_ENCAP_HDR_LEN 8
230 /* STAKey encapsulation */
231 typedef BWL_PRE_PACKED_STRUCT
struct {
233 uint8 mac
[ETHER_ADDR_LEN
];
234 uint8 stakey
[EAPOL_WPA_MAX_KEY_SIZE
];
235 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_stakey_encap_t
;
237 #define WPA2_KEY_DATA_PAD 0xdd
239 /* This marks the end of a packed structure section. */
240 #include <packed_section_end.h>
242 #endif /* _eapol_h_ */