Home | History | Annotate | Download | only in common
      1 /*
      2  * EAPOL definitions shared between hostapd and wpa_supplicant
      3  * Copyright (c) 2002-2007, Jouni Malinen <j (at) 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 
     18 struct ieee802_1x_hdr {
     19 	u8 version;
     20 	u8 type;
     21 	be16 length;
     22 	/* followed by length octets of data */
     23 } STRUCT_PACKED;
     24 
     25 #ifdef _MSC_VER
     26 #pragma pack(pop)
     27 #endif /* _MSC_VER */
     28 
     29 #define EAPOL_VERSION 2
     30 
     31 enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
     32        IEEE802_1X_TYPE_EAPOL_START = 1,
     33        IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
     34        IEEE802_1X_TYPE_EAPOL_KEY = 3,
     35        IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
     36 };
     37 
     38 enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
     39        EAPOL_KEY_TYPE_WPA = 254 };
     40 
     41 
     42 #define IEEE8021X_REPLAY_COUNTER_LEN 8
     43 #define IEEE8021X_KEY_SIGN_LEN 16
     44 #define IEEE8021X_KEY_IV_LEN 16
     45 
     46 #define IEEE8021X_KEY_INDEX_FLAG 0x80
     47 #define IEEE8021X_KEY_INDEX_MASK 0x03
     48 
     49 #ifdef _MSC_VER
     50 #pragma pack(push, 1)
     51 #endif /* _MSC_VER */
     52 
     53 struct ieee802_1x_eapol_key {
     54 	u8 type;
     55 	/* Note: key_length is unaligned */
     56 	u8 key_length[2];
     57 	/* does not repeat within the life of the keying material used to
     58 	 * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
     59 	u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
     60 	u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
     61 	u8 key_index; /* key flag in the most significant bit:
     62 		       * 0 = broadcast (default key),
     63 		       * 1 = unicast (key mapping key); key index is in the
     64 		       * 7 least significant bits */
     65 	/* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
     66 	 * the key */
     67 	u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
     68 
     69 	/* followed by key: if packet body length = 44 + key length, then the
     70 	 * key field (of key_length bytes) contains the key in encrypted form;
     71 	 * if packet body length = 44, key field is absent and key_length
     72 	 * represents the number of least significant octets from
     73 	 * MS-MPPE-Send-Key attribute to be used as the keying material;
     74 	 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
     75 } STRUCT_PACKED;
     76 
     77 #ifdef _MSC_VER
     78 #pragma pack(pop)
     79 #endif /* _MSC_VER */
     80 
     81 #endif /* EAPOL_COMMON_H */
     82