• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Fundamental types and constants relating to WPA
3  *
4  * Copyright (C) 1999-2013, Broadcom Corporation
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  * $Id: wpa.h 384536 2013-02-12 04:13:09Z $
19  */
20 
21 #ifndef _proto_wpa_h_
22 #define _proto_wpa_h_
23 
24 #include <typedefs.h>
25 #include <proto/ethernet.h>
26 
27 
28 /* This marks the start of a packed structure section. */
29 #include <packed_section_start.h>
30 
31 /* Reason Codes */
32 
33 /* 13 through 23 taken from IEEE Std 802.11i-2004 */
34 #define DOT11_RC_INVALID_WPA_IE		13	/* Invalid info. element */
35 #define DOT11_RC_MIC_FAILURE		14	/* Michael failure */
36 #define DOT11_RC_4WH_TIMEOUT		15	/* 4-way handshake timeout */
37 #define DOT11_RC_GTK_UPDATE_TIMEOUT	16	/* Group key update timeout */
38 #define DOT11_RC_WPA_IE_MISMATCH	17	/* WPA IE in 4-way handshake differs from
39 						 * (re-)assoc. request/probe response
40 						 */
41 #define DOT11_RC_INVALID_MC_CIPHER	18	/* Invalid multicast cipher */
42 #define DOT11_RC_INVALID_UC_CIPHER	19	/* Invalid unicast cipher */
43 #define DOT11_RC_INVALID_AKMP		20	/* Invalid authenticated key management protocol */
44 #define DOT11_RC_BAD_WPA_VERSION	21	/* Unsupported WPA version */
45 #define DOT11_RC_INVALID_WPA_CAP	22	/* Invalid WPA IE capabilities */
46 #define DOT11_RC_8021X_AUTH_FAIL	23	/* 802.1X authentication failure */
47 
48 #define WPA2_PMKID_LEN	16
49 
50 /* WPA IE fixed portion */
51 typedef BWL_PRE_PACKED_STRUCT struct
52 {
53 	uint8 tag;	/* TAG */
54 	uint8 length;	/* TAG length */
55 	uint8 oui[3];	/* IE OUI */
56 	uint8 oui_type;	/* OUI type */
57 	BWL_PRE_PACKED_STRUCT struct {
58 		uint8 low;
59 		uint8 high;
60 	} BWL_POST_PACKED_STRUCT version;	/* IE version */
61 } BWL_POST_PACKED_STRUCT wpa_ie_fixed_t;
62 #define WPA_IE_OUITYPE_LEN	4
63 #define WPA_IE_FIXED_LEN	8
64 #define WPA_IE_TAG_FIXED_LEN	6
65 
66 typedef BWL_PRE_PACKED_STRUCT struct {
67 	uint8 tag;	/* TAG */
68 	uint8 length;	/* TAG length */
69 	BWL_PRE_PACKED_STRUCT struct {
70 		uint8 low;
71 		uint8 high;
72 	} BWL_POST_PACKED_STRUCT version;	/* IE version */
73 } BWL_POST_PACKED_STRUCT wpa_rsn_ie_fixed_t;
74 #define WPA_RSN_IE_FIXED_LEN	4
75 #define WPA_RSN_IE_TAG_FIXED_LEN	2
76 typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
77 
78 /* WPA suite/multicast suite */
79 typedef BWL_PRE_PACKED_STRUCT struct
80 {
81 	uint8 oui[3];
82 	uint8 type;
83 } BWL_POST_PACKED_STRUCT wpa_suite_t, wpa_suite_mcast_t;
84 #define WPA_SUITE_LEN	4
85 
86 /* WPA unicast suite list/key management suite list */
87 typedef BWL_PRE_PACKED_STRUCT struct
88 {
89 	BWL_PRE_PACKED_STRUCT struct {
90 		uint8 low;
91 		uint8 high;
92 	} BWL_POST_PACKED_STRUCT count;
93 	wpa_suite_t list[1];
94 } BWL_POST_PACKED_STRUCT wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
95 #define WPA_IE_SUITE_COUNT_LEN	2
96 typedef BWL_PRE_PACKED_STRUCT struct
97 {
98 	BWL_PRE_PACKED_STRUCT struct {
99 		uint8 low;
100 		uint8 high;
101 	} BWL_POST_PACKED_STRUCT count;
102 	wpa_pmkid_t list[1];
103 } BWL_POST_PACKED_STRUCT wpa_pmkid_list_t;
104 
105 /* WPA cipher suites */
106 #define WPA_CIPHER_NONE		0	/* None */
107 #define WPA_CIPHER_WEP_40	1	/* WEP (40-bit) */
108 #define WPA_CIPHER_TKIP		2	/* TKIP: default for WPA */
109 #define WPA_CIPHER_AES_OCB	3	/* AES (OCB) */
110 #define WPA_CIPHER_AES_CCM	4	/* AES (CCM) */
111 #define WPA_CIPHER_WEP_104	5	/* WEP (104-bit) */
112 #define WPA_CIPHER_BIP		6	/* WEP (104-bit) */
113 #define WPA_CIPHER_TPK		7	/* Group addressed traffic not allowed */
114 
115 
116 #define IS_WPA_CIPHER(cipher)	((cipher) == WPA_CIPHER_NONE || \
117 				 (cipher) == WPA_CIPHER_WEP_40 || \
118 				 (cipher) == WPA_CIPHER_WEP_104 || \
119 				 (cipher) == WPA_CIPHER_TKIP || \
120 				 (cipher) == WPA_CIPHER_AES_OCB || \
121 				 (cipher) == WPA_CIPHER_AES_CCM || \
122 				 (cipher) == WPA_CIPHER_TPK)
123 
124 
125 /* WPA TKIP countermeasures parameters */
126 #define WPA_TKIP_CM_DETECT	60	/* multiple MIC failure window (seconds) */
127 #define WPA_TKIP_CM_BLOCK	60	/* countermeasures active window (seconds) */
128 
129 /* RSN IE defines */
130 #define RSN_CAP_LEN		2	/* Length of RSN capabilities field (2 octets) */
131 
132 /* RSN Capabilities defined in 802.11i */
133 #define RSN_CAP_PREAUTH			0x0001
134 #define RSN_CAP_NOPAIRWISE		0x0002
135 #define RSN_CAP_PTK_REPLAY_CNTR_MASK	0x000C
136 #define RSN_CAP_PTK_REPLAY_CNTR_SHIFT	2
137 #define RSN_CAP_GTK_REPLAY_CNTR_MASK	0x0030
138 #define RSN_CAP_GTK_REPLAY_CNTR_SHIFT	4
139 #define RSN_CAP_1_REPLAY_CNTR		0
140 #define RSN_CAP_2_REPLAY_CNTRS		1
141 #define RSN_CAP_4_REPLAY_CNTRS		2
142 #define RSN_CAP_16_REPLAY_CNTRS		3
143 #define RSN_CAP_MFPR			0x0040
144 #define RSN_CAP_MFPC			0x0080
145 #define RSN_CAP_SPPC			0x0400
146 #define RSN_CAP_SPPR			0x0800
147 
148 /* WPA capabilities defined in 802.11i */
149 #define WPA_CAP_4_REPLAY_CNTRS		RSN_CAP_4_REPLAY_CNTRS
150 #define WPA_CAP_16_REPLAY_CNTRS		RSN_CAP_16_REPLAY_CNTRS
151 #define WPA_CAP_REPLAY_CNTR_SHIFT	RSN_CAP_PTK_REPLAY_CNTR_SHIFT
152 #define WPA_CAP_REPLAY_CNTR_MASK	RSN_CAP_PTK_REPLAY_CNTR_MASK
153 
154 /* WPA capabilities defined in 802.11zD9.0 */
155 #define WPA_CAP_PEER_KEY_ENABLE		(0x1 << 1)	/* bit 9 */
156 
157 /* WPA Specific defines */
158 #define WPA_CAP_LEN	RSN_CAP_LEN	/* Length of RSN capabilities in RSN IE (2 octets) */
159 #define WPA_PMKID_CNT_LEN	2 	/* Length of RSN PMKID count (2 octests) */
160 
161 #define	WPA_CAP_WPA2_PREAUTH		RSN_CAP_PREAUTH
162 
163 #define WPA2_PMKID_COUNT_LEN	2
164 
165 
166 /* This marks the end of a packed structure section. */
167 #include <packed_section_end.h>
168 
169 #endif /* _proto_wpa_h_ */
170