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-2017, Broadcom Corporation 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 * 31 * $Id: eapol.h 700076 2017-05-17 14:42:22Z $ 32 */ 33 34 #ifndef _eapol_h_ 35 #define _eapol_h_ 36 37 #ifndef _TYPEDEFS_H_ 38 #include <typedefs.h> 39 #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 65 #define EAPOL_HDR_LEN 4 66 67 /* EAPOL version */ 68 #define WPA2_EAPOL_VERSION 2 69 #define WPA_EAPOL_VERSION 1 70 #define LEAP_EAPOL_VERSION 1 71 #define SES_EAPOL_VERSION 1 72 73 /* EAPOL types */ 74 #define EAP_PACKET 0 75 #define EAPOL_START 1 76 #define EAPOL_LOGOFF 2 77 #define EAPOL_KEY 3 78 #define EAPOL_ASF 4 79 80 /* EAPOL-Key types */ 81 #define EAPOL_RC4_KEY 1 82 #define EAPOL_WPA2_KEY 2 /* 802.11i/WPA2 */ 83 #define EAPOL_WPA_KEY 254 /* WPA */ 84 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 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 101 #define EAPOL_KEY_HEADER_LEN 44 102 103 /* RC4 EAPOL-Key flags */ 104 #define EAPOL_KEY_FLAGS_MASK 0x80 105 #define EAPOL_KEY_BROADCAST 0 106 #define EAPOL_KEY_UNICAST 0x80 107 108 /* RC4 EAPOL-Key index */ 109 #define EAPOL_KEY_INDEX_MASK 0x7f 110 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 119 #define EAPOL_WPA_KEY_DATA_LEN (EAPOL_WPA_MAX_KEY_SIZE + EAPOL_AKW_BLOCK_LEN) 120 #define EAPOL_WPA_MAX_KEY_SIZE 32 121 122 /* WPA EAPOL-Key */ 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; 136 137 #define EAPOL_WPA_KEY_LEN 95 138 139 /* WPA/802.11i/WPA2 KEY KEY_INFO bits */ 140 #define WPA_KEY_DESC_OSEN 0x0 141 #define WPA_KEY_DESC_V1 0x01 142 #define WPA_KEY_DESC_V2 0x02 143 #define WPA_KEY_DESC_V3 0x03 144 #define WPA_KEY_PAIRWISE 0x08 145 #define WPA_KEY_INSTALL 0x40 146 #define WPA_KEY_ACK 0x80 147 #define WPA_KEY_MIC 0x100 148 #define WPA_KEY_SECURE 0x200 149 #define WPA_KEY_ERROR 0x400 150 #define WPA_KEY_REQ 0x800 151 152 #define WPA_KEY_DESC_V2_OR_V3 WPA_KEY_DESC_V2 153 154 /* WPA-only KEY KEY_INFO bits */ 155 #define WPA_KEY_INDEX_0 0x00 156 #define WPA_KEY_INDEX_1 0x10 157 #define WPA_KEY_INDEX_2 0x20 158 #define WPA_KEY_INDEX_3 0x30 159 #define WPA_KEY_INDEX_MASK 0x30 160 #define WPA_KEY_INDEX_SHIFT 0x04 161 162 /* 802.11i/WPA2-only KEY KEY_INFO bits */ 163 #define WPA_KEY_ENCRYPTED_DATA 0x1000 164 165 /* Key Data encapsulation */ 166 typedef BWL_PRE_PACKED_STRUCT struct { 167 uint8 type; 168 uint8 length; 169 uint8 oui[3]; 170 uint8 subtype; 171 uint8 data[1]; 172 } BWL_POST_PACKED_STRUCT eapol_wpa2_encap_data_t; 173 174 #define EAPOL_WPA2_ENCAP_DATA_HDR_LEN 6 175 176 #define WPA2_KEY_DATA_SUBTYPE_GTK 1 177 #define WPA2_KEY_DATA_SUBTYPE_STAKEY 2 178 #define WPA2_KEY_DATA_SUBTYPE_MAC 3 179 #define WPA2_KEY_DATA_SUBTYPE_PMKID 4 180 #define WPA2_KEY_DATA_SUBTYPE_IGTK 9 181 182 /* GTK encapsulation */ 183 typedef BWL_PRE_PACKED_STRUCT struct { 184 uint8 flags; 185 uint8 reserved; 186 uint8 gtk[EAPOL_WPA_MAX_KEY_SIZE]; 187 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_gtk_encap_t; 188 189 #define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN 2 190 191 #define WPA2_GTK_INDEX_MASK 0x03 192 #define WPA2_GTK_INDEX_SHIFT 0x00 193 194 #define WPA2_GTK_TRANSMIT 0x04 195 196 /* IGTK encapsulation */ 197 typedef BWL_PRE_PACKED_STRUCT struct { 198 uint16 key_id; 199 uint8 ipn[6]; 200 uint8 key[EAPOL_WPA_MAX_KEY_SIZE]; 201 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_igtk_encap_t; 202 203 #define EAPOL_WPA2_KEY_IGTK_ENCAP_HDR_LEN 8 204 205 /* STAKey encapsulation */ 206 typedef BWL_PRE_PACKED_STRUCT struct { 207 uint8 reserved[2]; 208 uint8 mac[ETHER_ADDR_LEN]; 209 uint8 stakey[EAPOL_WPA_MAX_KEY_SIZE]; 210 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_stakey_encap_t; 211 212 #define WPA2_KEY_DATA_PAD 0xdd 213 214 215 /* This marks the end of a packed structure section. */ 216 #include <packed_section_end.h> 217 218 #endif /* _eapol_h_ */ 219