1 /*
2  * WPA definitions shared between hostapd and wpa_supplicant
3  * Copyright (c) 2002-2018, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef WPA_COMMON_H
10 #define WPA_COMMON_H
11 
12 
13 /* IEEE 802.11i */
14 #define PMKID_LEN 16
15 #define PMK_LEN 32
16 #define PMK_LEN_SUITE_B_192 48
17 #define PMK_LEN_MAX 64
18 #define WPA_REPLAY_COUNTER_LEN 8
19 #define WPA_NONCE_LEN 32
20 #define WPA_KEY_RSC_LEN 8
21 #define WPA_GMK_LEN 32
22 #define WPA_GTK_MAX_LEN 32
23 
24 #define OWE_DH_GROUP 19
25 
26 #define WPA_ALLOWED_PAIRWISE_CIPHERS \
27 (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | WPA_CIPHER_TKIP | WPA_CIPHER_NONE | \
28 WPA_CIPHER_GCMP_256 | WPA_CIPHER_CCMP_256)
29 #define WPA_ALLOWED_GROUP_CIPHERS \
30 (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | WPA_CIPHER_TKIP | \
31 WPA_CIPHER_GCMP_256 | WPA_CIPHER_CCMP_256 | \
32 WPA_CIPHER_GTK_NOT_USED)
33 #define WPA_ALLOWED_GROUP_MGMT_CIPHERS \
34 (WPA_CIPHER_AES_128_CMAC | WPA_CIPHER_BIP_GMAC_128 | WPA_CIPHER_BIP_GMAC_256 | \
35 WPA_CIPHER_BIP_CMAC_256)
36 
37 #define WPA_SELECTOR_LEN 4
38 #define WPA_VERSION 1
39 #define RSN_SELECTOR_LEN 4
40 #define RSN_VERSION 1
41 
42 #define RSN_SELECTOR(a, b, c, d) \
43 	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
44 	 (u32) (d))
45 
46 #define WPA_AUTH_KEY_MGMT_NONE RSN_SELECTOR(0x00, 0x50, 0xf2, 0)
47 #define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
48 #define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X RSN_SELECTOR(0x00, 0x50, 0xf2, 2)
49 #define WPA_AUTH_KEY_MGMT_CCKM RSN_SELECTOR(0x00, 0x40, 0x96, 0)
50 #define WPA_CIPHER_SUITE_NONE RSN_SELECTOR(0x00, 0x50, 0xf2, 0)
51 #define WPA_CIPHER_SUITE_TKIP RSN_SELECTOR(0x00, 0x50, 0xf2, 2)
52 #define WPA_CIPHER_SUITE_CCMP RSN_SELECTOR(0x00, 0x50, 0xf2, 4)
53 
54 
55 #define RSN_AUTH_KEY_MGMT_UNSPEC_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
56 #define RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
57 #define RSN_AUTH_KEY_MGMT_FT_802_1X RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
58 #define RSN_AUTH_KEY_MGMT_FT_PSK RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
59 #define RSN_AUTH_KEY_MGMT_802_1X_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
60 #define RSN_AUTH_KEY_MGMT_PSK_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
61 #define RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
62 #define RSN_AUTH_KEY_MGMT_SAE RSN_SELECTOR(0x00, 0x0f, 0xac, 8)
63 #define RSN_AUTH_KEY_MGMT_FT_SAE RSN_SELECTOR(0x00, 0x0f, 0xac, 9)
64 #define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B RSN_SELECTOR(0x00, 0x0f, 0xac, 11)
65 #define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192 RSN_SELECTOR(0x00, 0x0f, 0xac, 12)
66 #define RSN_AUTH_KEY_MGMT_FT_802_1X_SHA384 RSN_SELECTOR(0x00, 0x0f, 0xac, 13)
67 #define RSN_AUTH_KEY_MGMT_FILS_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 14)
68 #define RSN_AUTH_KEY_MGMT_FILS_SHA384 RSN_SELECTOR(0x00, 0x0f, 0xac, 15)
69 #define RSN_AUTH_KEY_MGMT_FT_FILS_SHA256 RSN_SELECTOR(0x00, 0x0f, 0xac, 16)
70 #define RSN_AUTH_KEY_MGMT_FT_FILS_SHA384 RSN_SELECTOR(0x00, 0x0f, 0xac, 17)
71 #define RSN_AUTH_KEY_MGMT_OWE RSN_SELECTOR(0x00, 0x0f, 0xac, 18)
72 #define RSN_AUTH_KEY_MGMT_CCKM RSN_SELECTOR(0x00, 0x40, 0x96, 0x00)
73 #define RSN_AUTH_KEY_MGMT_OSEN RSN_SELECTOR(0x50, 0x6f, 0x9a, 0x01)
74 #define RSN_AUTH_KEY_MGMT_DPP RSN_SELECTOR(0x50, 0x6f, 0x9a, 0x02)
75 
76 #define RSN_CIPHER_SUITE_NONE RSN_SELECTOR(0x00, 0x0f, 0xac, 0)
77 #define RSN_CIPHER_SUITE_WEP40 RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
78 #define RSN_CIPHER_SUITE_TKIP RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
79 #if 0
80 #define RSN_CIPHER_SUITE_WRAP RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
81 #endif
82 #define RSN_CIPHER_SUITE_CCMP RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
83 #define RSN_CIPHER_SUITE_WEP104 RSN_SELECTOR(0x00, 0x0f, 0xac, 5)
84 #define RSN_CIPHER_SUITE_AES_128_CMAC RSN_SELECTOR(0x00, 0x0f, 0xac, 6)
85 #define RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED RSN_SELECTOR(0x00, 0x0f, 0xac, 7)
86 #define RSN_CIPHER_SUITE_GCMP RSN_SELECTOR(0x00, 0x0f, 0xac, 8)
87 #define RSN_CIPHER_SUITE_GCMP_256 RSN_SELECTOR(0x00, 0x0f, 0xac, 9)
88 #define RSN_CIPHER_SUITE_CCMP_256 RSN_SELECTOR(0x00, 0x0f, 0xac, 10)
89 #define RSN_CIPHER_SUITE_BIP_GMAC_128 RSN_SELECTOR(0x00, 0x0f, 0xac, 11)
90 #define RSN_CIPHER_SUITE_BIP_GMAC_256 RSN_SELECTOR(0x00, 0x0f, 0xac, 12)
91 #define RSN_CIPHER_SUITE_BIP_CMAC_256 RSN_SELECTOR(0x00, 0x0f, 0xac, 13)
92 #define RSN_CIPHER_SUITE_SMS4 RSN_SELECTOR(0x00, 0x14, 0x72, 1)
93 #define RSN_CIPHER_SUITE_CKIP RSN_SELECTOR(0x00, 0x40, 0x96, 0)
94 #define RSN_CIPHER_SUITE_CKIP_CMIC RSN_SELECTOR(0x00, 0x40, 0x96, 1)
95 #define RSN_CIPHER_SUITE_CMIC RSN_SELECTOR(0x00, 0x40, 0x96, 2)
96 /* KRK is defined for nl80211 use only */
97 #define RSN_CIPHER_SUITE_KRK RSN_SELECTOR(0x00, 0x40, 0x96, 255)
98 
99 /* EAPOL-Key Key Data Encapsulation
100  * GroupKey and PeerKey require encryption, otherwise, encryption is optional.
101  */
102 #define RSN_KEY_DATA_GROUPKEY RSN_SELECTOR(0x00, 0x0f, 0xac, 1)
103 #if 0
104 #define RSN_KEY_DATA_STAKEY RSN_SELECTOR(0x00, 0x0f, 0xac, 2)
105 #endif
106 #define RSN_KEY_DATA_MAC_ADDR RSN_SELECTOR(0x00, 0x0f, 0xac, 3)
107 #define RSN_KEY_DATA_PMKID RSN_SELECTOR(0x00, 0x0f, 0xac, 4)
108 #ifdef CONFIG_IEEE80211W
109 #define RSN_KEY_DATA_IGTK RSN_SELECTOR(0x00, 0x0f, 0xac, 9)
110 #endif /* CONFIG_IEEE80211W */
111 #define RSN_KEY_DATA_KEYID RSN_SELECTOR(0x00, 0x0f, 0xac, 10)
112 #define RSN_KEY_DATA_MULTIBAND_GTK RSN_SELECTOR(0x00, 0x0f, 0xac, 11)
113 #define RSN_KEY_DATA_MULTIBAND_KEYID RSN_SELECTOR(0x00, 0x0f, 0xac, 12)
114 #define RSN_KEY_DATA_OCI RSN_SELECTOR(0x00, 0x0f, 0xac, 13)
115 
116 #define WFA_KEY_DATA_IP_ADDR_REQ RSN_SELECTOR(0x50, 0x6f, 0x9a, 4)
117 #define WFA_KEY_DATA_IP_ADDR_ALLOC RSN_SELECTOR(0x50, 0x6f, 0x9a, 5)
118 
119 #ifndef WPA_OUI_TYPE
120 #define WPA_OUI_TYPE RSN_SELECTOR(0x00, 0x50, 0xf2, 1)
121 #endif
122 
123 #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *) (a), (val))
124 #define RSN_SELECTOR_GET(a) WPA_GET_BE32((const u8 *) (a))
125 
126 #define RSN_NUM_REPLAY_COUNTERS_1 0
127 #define RSN_NUM_REPLAY_COUNTERS_2 1
128 #define RSN_NUM_REPLAY_COUNTERS_4 2
129 #define RSN_NUM_REPLAY_COUNTERS_16 3
130 
131 
132 #ifdef _MSC_VER
133 #pragma pack(push, 1)
134 #endif /* _MSC_VER */
135 
136 #ifdef CONFIG_IEEE80211W
137 #define WPA_IGTK_LEN 16
138 #define WPA_IGTK_MAX_LEN 32
139 #endif /* CONFIG_IEEE80211W */
140 
141 
142 /* IEEE 802.11, 7.3.2.25.3 RSN Capabilities */
143 #define WPA_CAPABILITY_PREAUTH BIT(0)
144 #define WPA_CAPABILITY_NO_PAIRWISE BIT(1)
145 /* B2-B3: PTKSA Replay Counter */
146 /* B4-B5: GTKSA Replay Counter */
147 #define WPA_CAPABILITY_MFPR BIT(6)
148 #define WPA_CAPABILITY_MFPC BIT(7)
149 /* B8: Reserved */
150 #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
151 #define WPA_CAPABILITY_SPP_A_MSDU_CAPABLE BIT(10)
152 #define WPA_CAPABILITY_SPP_A_MSDU_REQUIRED BIT(11)
153 #define WPA_CAPABILITY_PBAC BIT(12)
154 #define WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST BIT(13)
155 #define WPA_CAPABILITY_OCVC BIT(14)
156 /* B15: Reserved */
157 
158 
159 /* IEEE 802.11r */
160 #define MOBILITY_DOMAIN_ID_LEN 2
161 #define FT_R0KH_ID_MAX_LEN 48
162 #define FT_R1KH_ID_LEN 6
163 #define WPA_PMK_NAME_LEN 16
164 
165 
166 /* IEEE 802.11, 8.5.2 EAPOL-Key frames */
167 #define WPA_KEY_INFO_TYPE_MASK ((u16) (BIT(0) | BIT(1) | BIT(2)))
168 #define WPA_KEY_INFO_TYPE_AKM_DEFINED 0
169 #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0)
170 #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES BIT(1)
171 #define WPA_KEY_INFO_TYPE_AES_128_CMAC 3
172 #define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */
173 /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
174 #define WPA_KEY_INFO_KEY_INDEX_MASK (BIT(4) | BIT(5))
175 #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
176 #define WPA_KEY_INFO_INSTALL BIT(6) /* pairwise */
177 #define WPA_KEY_INFO_TXRX BIT(6) /* group */
178 #define WPA_KEY_INFO_ACK BIT(7)
179 #define WPA_KEY_INFO_MIC BIT(8)
180 #define WPA_KEY_INFO_SECURE BIT(9)
181 #define WPA_KEY_INFO_ERROR BIT(10)
182 #define WPA_KEY_INFO_REQUEST BIT(11)
183 #define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12) /* IEEE 802.11i/RSN only */
184 #define WPA_KEY_INFO_SMK_MESSAGE BIT(13)
185 
186 
187 struct wpa_eapol_key {
188 	u8 type;
189 	/* Note: key_info, key_length, and key_data_length are unaligned */
190 	u8 key_info[2]; /* big endian */
191 	u8 key_length[2]; /* big endian */
192 	u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
193 	u8 key_nonce[WPA_NONCE_LEN];
194 	u8 key_iv[16];
195 	u8 key_rsc[WPA_KEY_RSC_LEN];
196 	u8 key_id[8]; /* Reserved in IEEE 802.11i/RSN */
197 	/* variable length Key MIC field */
198 	/* big endian 2-octet Key Data Length field */
199 	/* followed by Key Data Length bytes of Key Data */
200 } STRUCT_PACKED;
201 
202 #define WPA_EAPOL_KEY_MIC_MAX_LEN 32
203 #define WPA_KCK_MAX_LEN 32
204 #define WPA_KEK_MAX_LEN 64
205 #define WPA_TK_MAX_LEN 32
206 #define FILS_ICK_MAX_LEN 48
207 #define FILS_FT_MAX_LEN 48
208 
209 /**
210  * struct wpa_ptk - WPA Pairwise Transient Key
211  * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
212  */
213 struct wpa_ptk {
214 	u8 kck[WPA_KCK_MAX_LEN]; /* EAPOL-Key Key Confirmation Key (KCK) */
215 	u8 kek[WPA_KEK_MAX_LEN]; /* EAPOL-Key Key Encryption Key (KEK) */
216 	u8 tk[WPA_TK_MAX_LEN]; /* Temporal Key (TK) */
217 	u8 kck2[WPA_KCK_MAX_LEN]; /* FT reasoc Key Confirmation Key (KCK2) */
218 	u8 kek2[WPA_KEK_MAX_LEN]; /* FT reassoc Key Encryption Key (KEK2) */
219 	size_t kck_len;
220 	size_t kek_len;
221 	size_t tk_len;
222 	size_t kck2_len;
223 	size_t kek2_len;
224 	int installed; /* 1 if key has already been installed to driver */
225 };
226 
227 struct wpa_gtk {
228 	u8 gtk[WPA_GTK_MAX_LEN];
229 	size_t gtk_len;
230 };
231 
232 #ifdef CONFIG_IEEE80211W
233 struct wpa_igtk {
234 	u8 igtk[WPA_IGTK_MAX_LEN];
235 	size_t igtk_len;
236 };
237 #endif /* CONFIG_IEEE80211W */
238 
239 /* WPA IE version 1
240  * 00-50-f2:1 (OUI:OUI type)
241  * 0x01 0x00 (version; little endian)
242  * (all following fields are optional:)
243  * Group Suite Selector (4 octets) (default: TKIP)
244  * Pairwise Suite Count (2 octets, little endian) (default: 1)
245  * Pairwise Suite List (4 * n octets) (default: TKIP)
246  * Authenticated Key Management Suite Count (2 octets, little endian)
247  *    (default: 1)
248  * Authenticated Key Management Suite List (4 * n octets)
249  *    (default: unspec 802.1X)
250  * WPA Capabilities (2 octets, little endian) (default: 0)
251  */
252 
253 struct wpa_ie_hdr {
254 	u8 elem_id;
255 	u8 len;
256 	u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
257 	u8 version[2]; /* little endian */
258 } STRUCT_PACKED;
259 
260 
261 /* 1/4: PMKID
262  * 2/4: RSN IE
263  * 3/4: one or two RSN IEs + GTK IE (encrypted)
264  * 4/4: empty
265  * 1/2: GTK IE (encrypted)
266  * 2/2: empty
267  */
268 
269 /* RSN IE version 1
270  * 0x01 0x00 (version; little endian)
271  * (all following fields are optional:)
272  * Group Suite Selector (4 octets) (default: CCMP)
273  * Pairwise Suite Count (2 octets, little endian) (default: 1)
274  * Pairwise Suite List (4 * n octets) (default: CCMP)
275  * Authenticated Key Management Suite Count (2 octets, little endian)
276  *    (default: 1)
277  * Authenticated Key Management Suite List (4 * n octets)
278  *    (default: unspec 802.1X)
279  * RSN Capabilities (2 octets, little endian) (default: 0)
280  * PMKID Count (2 octets) (default: 0)
281  * PMKID List (16 * n octets)
282  * Management Group Cipher Suite (4 octets) (default: AES-128-CMAC)
283  */
284 
285 struct rsn_ie_hdr {
286 	u8 elem_id; /* WLAN_EID_RSN */
287 	u8 len;
288 	u8 version[2]; /* little endian */
289 } STRUCT_PACKED;
290 
291 
292 struct rsn_error_kde {
293 	be16 mui;
294 	be16 error_type;
295 } STRUCT_PACKED;
296 
297 #ifdef CONFIG_IEEE80211W
298 #define WPA_IGTK_KDE_PREFIX_LEN (2 + 6)
299 struct wpa_igtk_kde {
300 	u8 keyid[2];
301 	u8 pn[6];
302 	u8 igtk[WPA_IGTK_MAX_LEN];
303 } STRUCT_PACKED;
304 #endif /* CONFIG_IEEE80211W */
305 
306 struct rsn_mdie {
307 	u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
308 	u8 ft_capab;
309 } STRUCT_PACKED;
310 
311 #define RSN_FT_CAPAB_FT_OVER_DS BIT(0)
312 #define RSN_FT_CAPAB_FT_RESOURCE_REQ_SUPP BIT(1)
313 
314 struct rsn_ftie {
315 	u8 mic_control[2];
316 	u8 mic[16];
317 	u8 anonce[WPA_NONCE_LEN];
318 	u8 snonce[WPA_NONCE_LEN];
319 	/* followed by optional parameters */
320 } STRUCT_PACKED;
321 
322 struct rsn_ftie_sha384 {
323 	u8 mic_control[2];
324 	u8 mic[24];
325 	u8 anonce[WPA_NONCE_LEN];
326 	u8 snonce[WPA_NONCE_LEN];
327 	/* followed by optional parameters */
328 } STRUCT_PACKED;
329 
330 #define FTIE_SUBELEM_R1KH_ID 1
331 #define FTIE_SUBELEM_GTK 2
332 #define FTIE_SUBELEM_R0KH_ID 3
333 #define FTIE_SUBELEM_IGTK 4
334 #define FTIE_SUBELEM_OCI 5
335 
336 struct rsn_rdie {
337 	u8 id;
338 	u8 descr_count;
339 	le16 status_code;
340 } STRUCT_PACKED;
341 
342 
343 #ifdef _MSC_VER
344 #pragma pack(pop)
345 #endif /* _MSC_VER */
346 
347 
348 int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver,
349 		      const u8 *buf, size_t len, u8 *mic);
350 int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label,
351 		   const u8 *addr1, const u8 *addr2,
352 		   const u8 *nonce1, const u8 *nonce2,
353 		   struct wpa_ptk *ptk, int akmp, int cipher,
354 		   const u8 *z, size_t z_len);
355 int fils_rmsk_to_pmk(int akmp, const u8 *rmsk, size_t rmsk_len,
356 		     const u8 *snonce, const u8 *anonce, const u8 *dh_ss,
357 		     size_t dh_ss_len, u8 *pmk, size_t *pmk_len);
358 int fils_pmkid_erp(int akmp, const u8 *reauth, size_t reauth_len,
359 		   u8 *pmkid);
360 int fils_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa,
361 		    const u8 *snonce, const u8 *anonce, const u8 *dhss,
362 		    size_t dhss_len, struct wpa_ptk *ptk,
363 		    u8 *ick, size_t *ick_len, int akmp, int cipher,
364 		    u8 *fils_ft, size_t *fils_ft_len);
365 int fils_key_auth_sk(const u8 *ick, size_t ick_len, const u8 *snonce,
366 		     const u8 *anonce, const u8 *sta_addr, const u8 *bssid,
367 		     const u8 *g_sta, size_t g_sta_len,
368 		     const u8 *g_ap, size_t g_ap_len,
369 		     int akmp, u8 *key_auth_sta, u8 *key_auth_ap,
370 		     size_t *key_auth_len);
371 
372 #ifdef CONFIG_IEEE80211R
373 int wpa_ft_mic(const u8 *kck, size_t kck_len, const u8 *sta_addr,
374 	       const u8 *ap_addr, u8 transaction_seqnum,
375 	       const u8 *mdie, size_t mdie_len,
376 	       const u8 *ftie, size_t ftie_len,
377 	       const u8 *rsnie, size_t rsnie_len,
378 	       const u8 *ric, size_t ric_len, u8 *mic);
379 int wpa_derive_pmk_r0(const u8 *xxkey, size_t xxkey_len,
380 		      const u8 *ssid, size_t ssid_len,
381 		      const u8 *mdid, const u8 *r0kh_id, size_t r0kh_id_len,
382 		      const u8 *s0kh_id, u8 *pmk_r0, u8 *pmk_r0_name,
383 		      int use_sha384);
384 int wpa_derive_pmk_r1_name(const u8 *pmk_r0_name, const u8 *r1kh_id,
385 			   const u8 *s1kh_id, u8 *pmk_r1_name, int use_sha384);
386 int wpa_derive_pmk_r1(const u8 *pmk_r0, size_t pmk_r0_len,
387 		      const u8 *pmk_r0_name,
388 		      const u8 *r1kh_id, const u8 *s1kh_id,
389 		      u8 *pmk_r1, u8 *pmk_r1_name);
390 int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, size_t pmk_r1_len, const u8 *snonce,
391 		      const u8 *anonce, const u8 *sta_addr, const u8 *bssid,
392 		      const u8 *pmk_r1_name,
393 		      struct wpa_ptk *ptk, u8 *ptk_name, int akmp, int cipher);
394 #endif /* CONFIG_IEEE80211R */
395 
396 struct wpa_ie_data {
397 	int proto;
398 	int pairwise_cipher;
399 	int has_pairwise;
400 	int group_cipher;
401 	int has_group;
402 	int key_mgmt;
403 	int capabilities;
404 	size_t num_pmkid;
405 	const u8 *pmkid;
406 	int mgmt_group_cipher;
407 };
408 
409 
410 int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
411 			 struct wpa_ie_data *data);
412 int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
413 			 struct wpa_ie_data *data);
414 int wpa_default_rsn_cipher(int freq);
415 
416 void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
417 	       u8 *pmkid, int akmp);
418 #ifdef CONFIG_SUITEB
419 int rsn_pmkid_suite_b(const u8 *kck, size_t kck_len, const u8 *aa,
420 		       const u8 *spa, u8 *pmkid);
421 #else /* CONFIG_SUITEB */
rsn_pmkid_suite_b(const u8 * kck,size_t kck_len,const u8 * aa,const u8 * spa,u8 * pmkid)422 static inline int rsn_pmkid_suite_b(const u8 *kck, size_t kck_len, const u8 *aa,
423 				    const u8 *spa, u8 *pmkid)
424 {
425 	return -1;
426 }
427 #endif /* CONFIG_SUITEB */
428 #ifdef CONFIG_SUITEB192
429 int rsn_pmkid_suite_b_192(const u8 *kck, size_t kck_len, const u8 *aa,
430 			  const u8 *spa, u8 *pmkid);
431 #else /* CONFIG_SUITEB192 */
rsn_pmkid_suite_b_192(const u8 * kck,size_t kck_len,const u8 * aa,const u8 * spa,u8 * pmkid)432 static inline int rsn_pmkid_suite_b_192(const u8 *kck, size_t kck_len,
433 					const u8 *aa, const u8 *spa, u8 *pmkid)
434 {
435 	return -1;
436 }
437 #endif /* CONFIG_SUITEB192 */
438 
439 const char * wpa_cipher_txt(int cipher);
440 const char * wpa_key_mgmt_txt(int key_mgmt, int proto);
441 u32 wpa_akm_to_suite(int akm);
442 int wpa_compare_rsn_ie(int ft_initial_assoc,
443 		       const u8 *ie1, size_t ie1len,
444 		       const u8 *ie2, size_t ie2len);
445 int wpa_insert_pmkid(u8 *ies, size_t *ies_len, const u8 *pmkid);
446 
447 struct wpa_ft_ies {
448 	const u8 *mdie;
449 	size_t mdie_len;
450 	const u8 *ftie;
451 	size_t ftie_len;
452 	const u8 *r1kh_id;
453 	const u8 *gtk;
454 	size_t gtk_len;
455 	const u8 *r0kh_id;
456 	size_t r0kh_id_len;
457 	const u8 *rsn;
458 	size_t rsn_len;
459 	const u8 *rsn_pmkid;
460 	const u8 *tie;
461 	size_t tie_len;
462 	const u8 *igtk;
463 	size_t igtk_len;
464 #ifdef CONFIG_OCV
465 	const u8 *oci;
466 	size_t oci_len;
467 #endif /* CONFIG_OCV */
468 	const u8 *ric;
469 	size_t ric_len;
470 	int key_mgmt;
471 	int pairwise_cipher;
472 };
473 
474 int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse,
475 		     int use_sha384);
476 
477 int wpa_cipher_key_len(int cipher);
478 int wpa_cipher_rsc_len(int cipher);
479 enum wpa_alg wpa_cipher_to_alg(int cipher);
480 int wpa_cipher_valid_group(int cipher);
481 int wpa_cipher_valid_pairwise(int cipher);
482 int wpa_cipher_valid_mgmt_group(int cipher);
483 u32 wpa_cipher_to_suite(int proto, int cipher);
484 int rsn_cipher_put_suites(u8 *pos, int ciphers);
485 int wpa_cipher_put_suites(u8 *pos, int ciphers);
486 int wpa_pick_pairwise_cipher(int ciphers, int none_allowed);
487 int wpa_pick_group_cipher(int ciphers);
488 int wpa_parse_cipher(const char *value);
489 int wpa_write_ciphers(char *start, char *end, int ciphers, const char *delim);
490 int wpa_select_ap_group_cipher(int wpa, int wpa_pairwise, int rsn_pairwise);
491 unsigned int wpa_mic_len(int akmp, size_t pmk_len);
492 int wpa_use_akm_defined(int akmp);
493 int wpa_use_cmac(int akmp);
494 int wpa_use_aes_key_wrap(int akmp);
495 int fils_domain_name_hash(const char *domain, u8 *hash);
496 
497 #endif /* WPA_COMMON_H */
498