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