4 #include <linux/compiler.h>
6 #define WBIT(n) (1 << (n))
13 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
14 unsigned char h_source[ETH_ALEN]; /* source ether addr */
15 unsigned char h_dest_snap;
16 unsigned char h_source_snap;
17 unsigned char h_command;
18 unsigned char h_vendor_id[3];
19 unsigned short h_proto; /* packet type ID field */
20 #define ETHER_PROTOCOL_TYPE_EAP 0x888e
21 #define ETHER_PROTOCOL_TYPE_IP 0x0800
22 #define ETHER_PROTOCOL_TYPE_ARP 0x0806
23 /* followed by length octets of data */
26 struct ieee802_1x_hdr {
27 unsigned char version;
29 unsigned short length;
30 /* followed by length octets of data */
33 #define EAPOL_VERSION 2
35 enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
36 IEEE802_1X_TYPE_EAPOL_START = 1,
37 IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
38 IEEE802_1X_TYPE_EAPOL_KEY = 3,
39 IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
42 enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
43 EAPOL_KEY_TYPE_WPA = 254
46 #define IEEE8021X_REPLAY_COUNTER_LEN 8
47 #define IEEE8021X_KEY_SIGN_LEN 16
48 #define IEEE8021X_KEY_IV_LEN 16
50 #define IEEE8021X_KEY_INDEX_FLAG 0x80
51 #define IEEE8021X_KEY_INDEX_MASK 0x03
53 struct ieee802_1x_eapol_key {
55 unsigned short key_length;
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
60 unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
61 unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
62 unsigned char key_index; /*
63 * key flag in the most significant bit:
64 * 0 = broadcast (default key),
65 * 1 = unicast (key mapping key); key index is in the
66 * 7 least significant bits
69 * HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
72 unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN];
75 * followed by key: if packet body length = 44 + key length, then the
76 * key field (of key_length bytes) contains the key in encrypted form;
77 * if packet body length = 44, key field is absent and key_length
78 * represents the number of least significant octets from
79 * MS-MPPE-Send-Key attribute to be used as the keying material;
80 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key
84 #define WPA_NONCE_LEN 32
85 #define WPA_REPLAY_COUNTER_LEN 8
87 struct wpa_eapol_key {
89 unsigned short key_info;
90 unsigned short key_length;
91 unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN];
92 unsigned char key_nonce[WPA_NONCE_LEN];
93 unsigned char key_iv[16];
94 unsigned char key_rsc[8];
95 unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */
96 unsigned char key_mic[16];
97 unsigned short key_data_length;
98 /* followed by key_data_length bytes of key_data */
101 #define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2))
102 #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0)
103 #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1)
104 #define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */
105 /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
106 #define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5))
107 #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
108 #define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */
109 #define WPA_KEY_INFO_TXRX WBIT(6) /* group */
110 #define WPA_KEY_INFO_ACK WBIT(7)
111 #define WPA_KEY_INFO_MIC WBIT(8)
112 #define WPA_KEY_INFO_SECURE WBIT(9)
113 #define WPA_KEY_INFO_ERROR WBIT(10)
114 #define WPA_KEY_INFO_REQUEST WBIT(11)
115 #define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */
117 #define WPA_CAPABILITY_PREAUTH WBIT(0)
119 #define GENERIC_INFO_ELEM 0xdd
120 #define RSN_INFO_ELEM 0x30
123 REASON_UNSPECIFIED = 1,
124 REASON_DEAUTH_LEAVING = 3,
125 REASON_INVALID_IE = 13,
126 REASON_MICHAEL_MIC_FAILURE = 14,
127 REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
128 REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
129 REASON_IE_IN_4WAY_DIFFERS = 17,
130 REASON_GROUP_CIPHER_NOT_VALID = 18,
131 REASON_PAIRWISE_CIPHER_NOT_VALID = 19,
132 REASON_AKMP_NOT_VALID = 20,
133 REASON_UNSUPPORTED_RSN_IE_VERSION = 21,
134 REASON_INVALID_RSN_IE_CAPAB = 22,
135 REASON_IEEE_802_1X_AUTH_FAILED = 23,
136 REASON_CIPHER_SUITE_REJECTED = 24
139 #endif /* EAP_PACKET_H */