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 * $Id: eapol.h 241182 2011-02-17 21:50:03Z $ 11 */ 12 13#ifndef _eapol_h_ 14#define _eapol_h_ 15 16#ifndef _TYPEDEFS_H_ 17#include <typedefs.h> 18#endif 19 20/* This marks the start of a packed structure section. */ 21#include <packed_section_start.h> 22 23#include <bcmcrypto/aeskeywrap.h> 24 25/* EAPOL for 802.3/Ethernet */ 26typedef BWL_PRE_PACKED_STRUCT struct { 27 struct ether_header eth; /* 802.3/Ethernet header */ 28 unsigned char version; /* EAPOL protocol version */ 29 unsigned char type; /* EAPOL type */ 30 unsigned short length; /* Length of body */ 31 unsigned char body[1]; /* Body (optional) */ 32} BWL_POST_PACKED_STRUCT eapol_header_t; 33 34#define EAPOL_HEADER_LEN 18 35 36typedef struct { 37 unsigned char version; /* EAPOL protocol version */ 38 unsigned char type; /* EAPOL type */ 39 unsigned short length; /* Length of body */ 40} eapol_hdr_t; 41 42#define EAPOL_HDR_LEN 4 43 44/* EAPOL version */ 45#define WPA2_EAPOL_VERSION 2 46#define WPA_EAPOL_VERSION 1 47#define LEAP_EAPOL_VERSION 1 48#define SES_EAPOL_VERSION 1 49 50/* EAPOL types */ 51#define EAP_PACKET 0 52#define EAPOL_START 1 53#define EAPOL_LOGOFF 2 54#define EAPOL_KEY 3 55#define EAPOL_ASF 4 56 57/* EAPOL-Key types */ 58#define EAPOL_RC4_KEY 1 59#define EAPOL_WPA2_KEY 2 /* 802.11i/WPA2 */ 60#define EAPOL_WPA_KEY 254 /* WPA */ 61 62/* RC4 EAPOL-Key header field sizes */ 63#define EAPOL_KEY_REPLAY_LEN 8 64#define EAPOL_KEY_IV_LEN 16 65#define EAPOL_KEY_SIG_LEN 16 66 67/* RC4 EAPOL-Key */ 68typedef BWL_PRE_PACKED_STRUCT struct { 69 unsigned char type; /* Key Descriptor Type */ 70 unsigned short length; /* Key Length (unaligned) */ 71 unsigned char replay[EAPOL_KEY_REPLAY_LEN]; /* Replay Counter */ 72 unsigned char iv[EAPOL_KEY_IV_LEN]; /* Key IV */ 73 unsigned char index; /* Key Flags & Index */ 74 unsigned char signature[EAPOL_KEY_SIG_LEN]; /* Key Signature */ 75 unsigned char key[1]; /* Key (optional) */ 76} BWL_POST_PACKED_STRUCT eapol_key_header_t; 77 78#define EAPOL_KEY_HEADER_LEN 44 79 80/* RC4 EAPOL-Key flags */ 81#define EAPOL_KEY_FLAGS_MASK 0x80 82#define EAPOL_KEY_BROADCAST 0 83#define EAPOL_KEY_UNICAST 0x80 84 85/* RC4 EAPOL-Key index */ 86#define EAPOL_KEY_INDEX_MASK 0x7f 87 88/* WPA/802.11i/WPA2 EAPOL-Key header field sizes */ 89#define EAPOL_WPA_KEY_REPLAY_LEN 8 90#define EAPOL_WPA_KEY_NONCE_LEN 32 91#define EAPOL_WPA_KEY_IV_LEN 16 92#define EAPOL_WPA_KEY_RSC_LEN 8 93#define EAPOL_WPA_KEY_ID_LEN 8 94#define EAPOL_WPA_KEY_MIC_LEN 16 95#define EAPOL_WPA_KEY_DATA_LEN (EAPOL_WPA_MAX_KEY_SIZE + AKW_BLOCK_LEN) 96#define EAPOL_WPA_MAX_KEY_SIZE 32 97 98/* WPA EAPOL-Key */ 99typedef BWL_PRE_PACKED_STRUCT struct { 100 unsigned char type; /* Key Descriptor Type */ 101 unsigned short key_info; /* Key Information (unaligned) */ 102 unsigned short key_len; /* Key Length (unaligned) */ 103 unsigned char replay[EAPOL_WPA_KEY_REPLAY_LEN]; /* Replay Counter */ 104 unsigned char nonce[EAPOL_WPA_KEY_NONCE_LEN]; /* Nonce */ 105 unsigned char iv[EAPOL_WPA_KEY_IV_LEN]; /* Key IV */ 106 unsigned char rsc[EAPOL_WPA_KEY_RSC_LEN]; /* Key RSC */ 107 unsigned char id[EAPOL_WPA_KEY_ID_LEN]; /* WPA:Key ID, 802.11i/WPA2: Reserved */ 108 unsigned char mic[EAPOL_WPA_KEY_MIC_LEN]; /* Key MIC */ 109 unsigned short data_len; /* Key Data Length */ 110 unsigned char data[EAPOL_WPA_KEY_DATA_LEN]; /* Key data */ 111} BWL_POST_PACKED_STRUCT eapol_wpa_key_header_t; 112 113#define EAPOL_WPA_KEY_LEN 95 114 115/* WPA/802.11i/WPA2 KEY KEY_INFO bits */ 116#define WPA_KEY_DESC_V1 0x01 117#define WPA_KEY_DESC_V2 0x02 118#define WPA_KEY_DESC_V3 0x03 119#define WPA_KEY_PAIRWISE 0x08 120#define WPA_KEY_INSTALL 0x40 121#define WPA_KEY_ACK 0x80 122#define WPA_KEY_MIC 0x100 123#define WPA_KEY_SECURE 0x200 124#define WPA_KEY_ERROR 0x400 125#define WPA_KEY_REQ 0x800 126 127#define WPA_KEY_DESC_V2_OR_V3 WPA_KEY_DESC_V2 128 129/* WPA-only KEY KEY_INFO bits */ 130#define WPA_KEY_INDEX_0 0x00 131#define WPA_KEY_INDEX_1 0x10 132#define WPA_KEY_INDEX_2 0x20 133#define WPA_KEY_INDEX_3 0x30 134#define WPA_KEY_INDEX_MASK 0x30 135#define WPA_KEY_INDEX_SHIFT 0x04 136 137/* 802.11i/WPA2-only KEY KEY_INFO bits */ 138#define WPA_KEY_ENCRYPTED_DATA 0x1000 139 140/* Key Data encapsulation */ 141typedef BWL_PRE_PACKED_STRUCT struct { 142 uint8 type; 143 uint8 length; 144 uint8 oui[3]; 145 uint8 subtype; 146 uint8 data[1]; 147} BWL_POST_PACKED_STRUCT eapol_wpa2_encap_data_t; 148 149#define EAPOL_WPA2_ENCAP_DATA_HDR_LEN 6 150 151#define WPA2_KEY_DATA_SUBTYPE_GTK 1 152#define WPA2_KEY_DATA_SUBTYPE_STAKEY 2 153#define WPA2_KEY_DATA_SUBTYPE_MAC 3 154#define WPA2_KEY_DATA_SUBTYPE_PMKID 4 155#define WPA2_KEY_DATA_SUBTYPE_IGTK 9 156 157/* GTK encapsulation */ 158typedef BWL_PRE_PACKED_STRUCT struct { 159 uint8 flags; 160 uint8 reserved; 161 uint8 gtk[EAPOL_WPA_MAX_KEY_SIZE]; 162} BWL_POST_PACKED_STRUCT eapol_wpa2_key_gtk_encap_t; 163 164#define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN 2 165 166#define WPA2_GTK_INDEX_MASK 0x03 167#define WPA2_GTK_INDEX_SHIFT 0x00 168 169#define WPA2_GTK_TRANSMIT 0x04 170 171/* IGTK encapsulation */ 172typedef BWL_PRE_PACKED_STRUCT struct { 173 uint16 key_id; 174 uint8 ipn[6]; 175 uint8 key[EAPOL_WPA_MAX_KEY_SIZE]; 176} BWL_POST_PACKED_STRUCT eapol_wpa2_key_igtk_encap_t; 177 178#define EAPOL_WPA2_KEY_IGTK_ENCAP_HDR_LEN 8 179 180/* STAKey encapsulation */ 181typedef BWL_PRE_PACKED_STRUCT struct { 182 uint8 reserved[2]; 183 uint8 mac[ETHER_ADDR_LEN]; 184 uint8 stakey[EAPOL_WPA_MAX_KEY_SIZE]; 185} BWL_POST_PACKED_STRUCT eapol_wpa2_key_stakey_encap_t; 186 187#define WPA2_KEY_DATA_PAD 0xdd 188 189 190/* This marks the end of a packed structure section. */ 191#include <packed_section_end.h> 192 193#endif /* _eapol_h_ */ 194