1/* 2 * Copyright (C) 1999-2013, Broadcom Corporation 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * 16 * $Id: eapol.h 382882 2013-02-04 23:24:31Z $ 17 */ 18 19#ifndef _eapol_h_ 20#define _eapol_h_ 21 22#ifndef _TYPEDEFS_H_ 23#include <typedefs.h> 24#endif 25 26/* This marks the start of a packed structure section. */ 27#include <packed_section_start.h> 28 29#include <bcmcrypto/aeskeywrap.h> 30 31/* EAPOL for 802.3/Ethernet */ 32typedef BWL_PRE_PACKED_STRUCT struct { 33 struct ether_header eth; /* 802.3/Ethernet header */ 34 unsigned char version; /* EAPOL protocol version */ 35 unsigned char type; /* EAPOL type */ 36 unsigned short length; /* Length of body */ 37 unsigned char body[1]; /* Body (optional) */ 38} BWL_POST_PACKED_STRUCT eapol_header_t; 39 40#define EAPOL_HEADER_LEN 18 41 42typedef struct { 43 unsigned char version; /* EAPOL protocol version */ 44 unsigned char type; /* EAPOL type */ 45 unsigned short length; /* Length of body */ 46} eapol_hdr_t; 47 48#define EAPOL_HDR_LEN 4 49 50/* EAPOL version */ 51#define WPA2_EAPOL_VERSION 2 52#define WPA_EAPOL_VERSION 1 53#define LEAP_EAPOL_VERSION 1 54#define SES_EAPOL_VERSION 1 55 56/* EAPOL types */ 57#define EAP_PACKET 0 58#define EAPOL_START 1 59#define EAPOL_LOGOFF 2 60#define EAPOL_KEY 3 61#define EAPOL_ASF 4 62 63/* EAPOL-Key types */ 64#define EAPOL_RC4_KEY 1 65#define EAPOL_WPA2_KEY 2 /* 802.11i/WPA2 */ 66#define EAPOL_WPA_KEY 254 /* WPA */ 67 68/* RC4 EAPOL-Key header field sizes */ 69#define EAPOL_KEY_REPLAY_LEN 8 70#define EAPOL_KEY_IV_LEN 16 71#define EAPOL_KEY_SIG_LEN 16 72 73/* RC4 EAPOL-Key */ 74typedef BWL_PRE_PACKED_STRUCT struct { 75 unsigned char type; /* Key Descriptor Type */ 76 unsigned short length; /* Key Length (unaligned) */ 77 unsigned char replay[EAPOL_KEY_REPLAY_LEN]; /* Replay Counter */ 78 unsigned char iv[EAPOL_KEY_IV_LEN]; /* Key IV */ 79 unsigned char index; /* Key Flags & Index */ 80 unsigned char signature[EAPOL_KEY_SIG_LEN]; /* Key Signature */ 81 unsigned char key[1]; /* Key (optional) */ 82} BWL_POST_PACKED_STRUCT eapol_key_header_t; 83 84#define EAPOL_KEY_HEADER_LEN 44 85 86/* RC4 EAPOL-Key flags */ 87#define EAPOL_KEY_FLAGS_MASK 0x80 88#define EAPOL_KEY_BROADCAST 0 89#define EAPOL_KEY_UNICAST 0x80 90 91/* RC4 EAPOL-Key index */ 92#define EAPOL_KEY_INDEX_MASK 0x7f 93 94/* WPA/802.11i/WPA2 EAPOL-Key header field sizes */ 95#define EAPOL_WPA_KEY_REPLAY_LEN 8 96#define EAPOL_WPA_KEY_NONCE_LEN 32 97#define EAPOL_WPA_KEY_IV_LEN 16 98#define EAPOL_WPA_KEY_RSC_LEN 8 99#define EAPOL_WPA_KEY_ID_LEN 8 100#define EAPOL_WPA_KEY_MIC_LEN 16 101#define EAPOL_WPA_KEY_DATA_LEN (EAPOL_WPA_MAX_KEY_SIZE + AKW_BLOCK_LEN) 102#define EAPOL_WPA_MAX_KEY_SIZE 32 103 104/* WPA EAPOL-Key */ 105typedef BWL_PRE_PACKED_STRUCT struct { 106 unsigned char type; /* Key Descriptor Type */ 107 unsigned short key_info; /* Key Information (unaligned) */ 108 unsigned short key_len; /* Key Length (unaligned) */ 109 unsigned char replay[EAPOL_WPA_KEY_REPLAY_LEN]; /* Replay Counter */ 110 unsigned char nonce[EAPOL_WPA_KEY_NONCE_LEN]; /* Nonce */ 111 unsigned char iv[EAPOL_WPA_KEY_IV_LEN]; /* Key IV */ 112 unsigned char rsc[EAPOL_WPA_KEY_RSC_LEN]; /* Key RSC */ 113 unsigned char id[EAPOL_WPA_KEY_ID_LEN]; /* WPA:Key ID, 802.11i/WPA2: Reserved */ 114 unsigned char mic[EAPOL_WPA_KEY_MIC_LEN]; /* Key MIC */ 115 unsigned short data_len; /* Key Data Length */ 116 unsigned char data[EAPOL_WPA_KEY_DATA_LEN]; /* Key data */ 117} BWL_POST_PACKED_STRUCT eapol_wpa_key_header_t; 118 119#define EAPOL_WPA_KEY_LEN 95 120 121/* WPA/802.11i/WPA2 KEY KEY_INFO bits */ 122#define WPA_KEY_DESC_V1 0x01 123#define WPA_KEY_DESC_V2 0x02 124#define WPA_KEY_DESC_V3 0x03 125#define WPA_KEY_PAIRWISE 0x08 126#define WPA_KEY_INSTALL 0x40 127#define WPA_KEY_ACK 0x80 128#define WPA_KEY_MIC 0x100 129#define WPA_KEY_SECURE 0x200 130#define WPA_KEY_ERROR 0x400 131#define WPA_KEY_REQ 0x800 132 133#define WPA_KEY_DESC_V2_OR_V3 WPA_KEY_DESC_V2 134 135/* WPA-only KEY KEY_INFO bits */ 136#define WPA_KEY_INDEX_0 0x00 137#define WPA_KEY_INDEX_1 0x10 138#define WPA_KEY_INDEX_2 0x20 139#define WPA_KEY_INDEX_3 0x30 140#define WPA_KEY_INDEX_MASK 0x30 141#define WPA_KEY_INDEX_SHIFT 0x04 142 143/* 802.11i/WPA2-only KEY KEY_INFO bits */ 144#define WPA_KEY_ENCRYPTED_DATA 0x1000 145 146/* Key Data encapsulation */ 147typedef BWL_PRE_PACKED_STRUCT struct { 148 uint8 type; 149 uint8 length; 150 uint8 oui[3]; 151 uint8 subtype; 152 uint8 data[1]; 153} BWL_POST_PACKED_STRUCT eapol_wpa2_encap_data_t; 154 155#define EAPOL_WPA2_ENCAP_DATA_HDR_LEN 6 156 157#define WPA2_KEY_DATA_SUBTYPE_GTK 1 158#define WPA2_KEY_DATA_SUBTYPE_STAKEY 2 159#define WPA2_KEY_DATA_SUBTYPE_MAC 3 160#define WPA2_KEY_DATA_SUBTYPE_PMKID 4 161#define WPA2_KEY_DATA_SUBTYPE_IGTK 9 162 163/* GTK encapsulation */ 164typedef BWL_PRE_PACKED_STRUCT struct { 165 uint8 flags; 166 uint8 reserved; 167 uint8 gtk[EAPOL_WPA_MAX_KEY_SIZE]; 168} BWL_POST_PACKED_STRUCT eapol_wpa2_key_gtk_encap_t; 169 170#define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN 2 171 172#define WPA2_GTK_INDEX_MASK 0x03 173#define WPA2_GTK_INDEX_SHIFT 0x00 174 175#define WPA2_GTK_TRANSMIT 0x04 176 177/* IGTK encapsulation */ 178typedef BWL_PRE_PACKED_STRUCT struct { 179 uint16 key_id; 180 uint8 ipn[6]; 181 uint8 key[EAPOL_WPA_MAX_KEY_SIZE]; 182} BWL_POST_PACKED_STRUCT eapol_wpa2_key_igtk_encap_t; 183 184#define EAPOL_WPA2_KEY_IGTK_ENCAP_HDR_LEN 8 185 186/* STAKey encapsulation */ 187typedef BWL_PRE_PACKED_STRUCT struct { 188 uint8 reserved[2]; 189 uint8 mac[ETHER_ADDR_LEN]; 190 uint8 stakey[EAPOL_WPA_MAX_KEY_SIZE]; 191} BWL_POST_PACKED_STRUCT eapol_wpa2_key_stakey_encap_t; 192 193#define WPA2_KEY_DATA_PAD 0xdd 194 195 196/* This marks the end of a packed structure section. */ 197#include <packed_section_end.h> 198 199#endif /* _eapol_h_ */ 200