]> git.ipfire.org Git - thirdparty/linux.git/blame - drivers/staging/ks7010/eap_packet.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/linux.git] / drivers / staging / ks7010 / eap_packet.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
13a9930d
WS
2#ifndef EAP_PACKET_H
3#define EAP_PACKET_H
4
2460563f
MK
5#include <linux/compiler.h>
6
13a9930d
WS
7#define WBIT(n) (1 << (n))
8
9#ifndef ETH_ALEN
10#define ETH_ALEN 6
11#endif
12
08484ef4
TH
13#define ETHER_HDR_SIZE 20
14
13a9930d 15struct ether_hdr {
5d7696bc
WS
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];
c27fbc92 22 __be16 h_proto; /* packet type ID field */
13a9930d
WS
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 */
2460563f 27} __packed;
13a9930d
WS
28
29struct ieee802_1x_hdr {
30 unsigned char version;
31 unsigned char type;
32 unsigned short length;
33 /* followed by length octets of data */
2460563f 34} __packed;
13a9930d
WS
35
36#define EAPOL_VERSION 2
37
38enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
5d7696bc
WS
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
13a9930d
WS
43};
44
45enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
5d7696bc
WS
46 EAPOL_KEY_TYPE_WPA = 254
47};
13a9930d
WS
48
49#define IEEE8021X_REPLAY_COUNTER_LEN 8
50#define IEEE8021X_KEY_SIGN_LEN 16
51#define IEEE8021X_KEY_IV_LEN 16
52
53#define IEEE8021X_KEY_INDEX_FLAG 0x80
54#define IEEE8021X_KEY_INDEX_MASK 0x03
55
56struct ieee802_1x_eapol_key {
57 unsigned char type;
58 unsigned short key_length;
6315bbdb
MM
59 /*
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
62 */
13a9930d 63 unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
3ad90047
TD
64 unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random
65 * number
66 */
6315bbdb
MM
67 unsigned char key_index; /*
68 * key flag in the most significant bit:
5d7696bc 69 * 0 = broadcast (default key),
3ad90047
TD
70 * 1 = unicast (key mapping key);
71 * key index is in the 7 least
72 * significant bits
6315bbdb
MM
73 */
74 /*
75 * HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
76 * the key
77 */
13a9930d
WS
78 unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN];
79
6315bbdb
MM
80 /*
81 * followed by key: if packet body length = 44 + key length, then the
13a9930d
WS
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;
6315bbdb
MM
86 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key
87 */
2460563f 88} __packed;
13a9930d 89
13a9930d
WS
90#define WPA_NONCE_LEN 32
91#define WPA_REPLAY_COUNTER_LEN 8
92
93struct wpa_eapol_key {
94 unsigned char type;
c27fbc92 95 __be16 key_info;
13a9930d
WS
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];
5d7696bc 101 unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */
13a9930d
WS
102 unsigned char key_mic[16];
103 unsigned short key_data_length;
104 /* followed by key_data_length bytes of key_data */
2460563f 105} __packed;
13a9930d
WS
106
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)
5d7696bc 110#define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */
13a9930d
WS
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
5d7696bc
WS
114#define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */
115#define WPA_KEY_INFO_TXRX WBIT(6) /* group */
13a9930d
WS
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)
5d7696bc 121#define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */
13a9930d
WS
122
123#define WPA_CAPABILITY_PREAUTH WBIT(0)
124
125#define GENERIC_INFO_ELEM 0xdd
126#define RSN_INFO_ELEM 0x30
127
128enum {
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
143};
144
145#endif /* EAP_PACKET_H */