1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/compiler.h>
7 #define WBIT(n) (1 << (n))
13 #define ETHER_HDR_SIZE 20
16 unsigned char h_dest
[ETH_ALEN
]; /* destination eth addr */
17 unsigned char h_source
[ETH_ALEN
]; /* source ether addr */
18 unsigned char h_dest_snap
;
19 unsigned char h_source_snap
;
20 unsigned char h_command
;
21 unsigned char h_vendor_id
[3];
22 __be16 h_proto
; /* packet type ID field */
23 #define ETHER_PROTOCOL_TYPE_EAP 0x888e
24 #define ETHER_PROTOCOL_TYPE_IP 0x0800
25 #define ETHER_PROTOCOL_TYPE_ARP 0x0806
26 /* followed by length octets of data */
29 struct ieee802_1x_hdr
{
30 unsigned char version
;
32 unsigned short length
;
33 /* followed by length octets of data */
36 #define EAPOL_VERSION 2
38 enum { IEEE802_1X_TYPE_EAP_PACKET
= 0,
39 IEEE802_1X_TYPE_EAPOL_START
= 1,
40 IEEE802_1X_TYPE_EAPOL_LOGOFF
= 2,
41 IEEE802_1X_TYPE_EAPOL_KEY
= 3,
42 IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT
= 4
45 enum { EAPOL_KEY_TYPE_RC4
= 1, EAPOL_KEY_TYPE_RSN
= 2,
46 EAPOL_KEY_TYPE_WPA
= 254
49 #define IEEE8021X_REPLAY_COUNTER_LEN 8
50 #define IEEE8021X_KEY_SIGN_LEN 16
51 #define IEEE8021X_KEY_IV_LEN 16
53 #define IEEE8021X_KEY_INDEX_FLAG 0x80
54 #define IEEE8021X_KEY_INDEX_MASK 0x03
56 struct ieee802_1x_eapol_key
{
58 unsigned short key_length
;
60 * does not repeat within the life of the keying material used to
61 * encrypt the Key field; 64-bit NTP timestamp MAY be used here
63 unsigned char replay_counter
[IEEE8021X_REPLAY_COUNTER_LEN
];
64 unsigned char key_iv
[IEEE8021X_KEY_IV_LEN
]; /* cryptographically random
67 unsigned char key_index
; /*
68 * key flag in the most significant bit:
69 * 0 = broadcast (default key),
70 * 1 = unicast (key mapping key);
71 * key index is in the 7 least
75 * HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
78 unsigned char key_signature
[IEEE8021X_KEY_SIGN_LEN
];
81 * followed by key: if packet body length = 44 + key length, then the
82 * key field (of key_length bytes) contains the key in encrypted form;
83 * if packet body length = 44, key field is absent and key_length
84 * represents the number of least significant octets from
85 * MS-MPPE-Send-Key attribute to be used as the keying material;
86 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key
90 #define WPA_NONCE_LEN 32
91 #define WPA_REPLAY_COUNTER_LEN 8
93 struct wpa_eapol_key
{
96 unsigned short key_length
;
97 unsigned char replay_counter
[WPA_REPLAY_COUNTER_LEN
];
98 unsigned char key_nonce
[WPA_NONCE_LEN
];
99 unsigned char key_iv
[16];
100 unsigned char key_rsc
[8];
101 unsigned char key_id
[8]; /* Reserved in IEEE 802.11i/RSN */
102 unsigned char key_mic
[16];
103 unsigned short key_data_length
;
104 /* followed by key_data_length bytes of key_data */
107 #define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2))
108 #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0)
109 #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1)
110 #define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */
111 /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
112 #define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5))
113 #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
114 #define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */
115 #define WPA_KEY_INFO_TXRX WBIT(6) /* group */
116 #define WPA_KEY_INFO_ACK WBIT(7)
117 #define WPA_KEY_INFO_MIC WBIT(8)
118 #define WPA_KEY_INFO_SECURE WBIT(9)
119 #define WPA_KEY_INFO_ERROR WBIT(10)
120 #define WPA_KEY_INFO_REQUEST WBIT(11)
121 #define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */
123 #define WPA_CAPABILITY_PREAUTH WBIT(0)
125 #define GENERIC_INFO_ELEM 0xdd
126 #define RSN_INFO_ELEM 0x30
129 REASON_UNSPECIFIED
= 1,
130 REASON_DEAUTH_LEAVING
= 3,
131 REASON_INVALID_IE
= 13,
132 REASON_MICHAEL_MIC_FAILURE
= 14,
133 REASON_4WAY_HANDSHAKE_TIMEOUT
= 15,
134 REASON_GROUP_KEY_UPDATE_TIMEOUT
= 16,
135 REASON_IE_IN_4WAY_DIFFERS
= 17,
136 REASON_GROUP_CIPHER_NOT_VALID
= 18,
137 REASON_PAIRWISE_CIPHER_NOT_VALID
= 19,
138 REASON_AKMP_NOT_VALID
= 20,
139 REASON_UNSUPPORTED_RSN_IE_VERSION
= 21,
140 REASON_INVALID_RSN_IE_CAPAB
= 22,
141 REASON_IEEE_802_1X_AUTH_FAILED
= 23,
142 REASON_CIPHER_SUITE_REJECTED
= 24
145 #endif /* EAP_PACKET_H */