1/* 2 * EAPOL definitions shared between hostapd and wpa_supplicant 3 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9#ifndef EAPOL_COMMON_H 10#define EAPOL_COMMON_H 11 12/* IEEE Std 802.1X-2004 */ 13 14#ifdef _MSC_VER 15#pragma pack(push, 1) 16#endif /* _MSC_VER */ 17 18struct ieee802_1x_hdr { 19 u8 version; 20 u8 type; 21 be16 length; 22 /* followed by length octets of data */ 23} STRUCT_PACKED; 24 25struct ieee8023_hdr { 26 u8 dest[ETH_ALEN]; 27 u8 src[ETH_ALEN]; 28 u16 ethertype; 29} STRUCT_PACKED; 30 31#ifdef _MSC_VER 32#pragma pack(pop) 33#endif /* _MSC_VER */ 34 35#ifdef CONFIG_MACSEC 36#define EAPOL_VERSION 3 37#else /* CONFIG_MACSEC */ 38#define EAPOL_VERSION 2 39#endif /* CONFIG_MACSEC */ 40 41enum { IEEE802_1X_TYPE_EAP_PACKET = 0, 42 IEEE802_1X_TYPE_EAPOL_START = 1, 43 IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, 44 IEEE802_1X_TYPE_EAPOL_KEY = 3, 45 IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4, 46 IEEE802_1X_TYPE_EAPOL_MKA = 5, 47}; 48 49enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2, 50 EAPOL_KEY_TYPE_WPA = 254 }; 51 52 53#define IEEE8021X_REPLAY_COUNTER_LEN 8 54#define IEEE8021X_KEY_SIGN_LEN 16 55#define IEEE8021X_KEY_IV_LEN 16 56 57#define IEEE8021X_KEY_INDEX_FLAG 0x80 58#define IEEE8021X_KEY_INDEX_MASK 0x03 59 60#ifdef _MSC_VER 61#pragma pack(push, 1) 62#endif /* _MSC_VER */ 63 64struct ieee802_1x_eapol_key { 65 u8 type; 66 /* Note: key_length is unaligned */ 67 u8 key_length[2]; 68 /* does not repeat within the life of the keying material used to 69 * encrypt the Key field; 64-bit NTP timestamp MAY be used here */ 70 u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN]; 71 u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */ 72 u8 key_index; /* key flag in the most significant bit: 73 * 0 = broadcast (default key), 74 * 1 = unicast (key mapping key); key index is in the 75 * 7 least significant bits */ 76 /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as 77 * the key */ 78 u8 key_signature[IEEE8021X_KEY_SIGN_LEN]; 79 80 /* followed by key: if packet body length = 44 + key length, then the 81 * key field (of key_length bytes) contains the key in encrypted form; 82 * if packet body length = 44, key field is absent and key_length 83 * represents the number of least significant octets from 84 * MS-MPPE-Send-Key attribute to be used as the keying material; 85 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */ 86} STRUCT_PACKED; 87 88#ifdef _MSC_VER 89#pragma pack(pop) 90#endif /* _MSC_VER */ 91 92#endif /* EAPOL_COMMON_H */ 93