xref: /freebsd/contrib/wpa/src/rsn_supp/wpa_i.h (revision 71e72c9e91c4b8007a4292e09669e8b549c29e97)
1 /*
2  * Internal WPA/RSN supplicant state machine definitions
3  * Copyright (c) 2004-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_I_H
10 #define WPA_I_H
11 
12 #include "utils/list.h"
13 
14 struct wpa_tdls_peer;
15 struct wpa_eapol_key;
16 
17 struct pasn_ft_r1kh {
18 	u8 bssid[ETH_ALEN];
19 	u8 r1kh_id[FT_R1KH_ID_LEN];
20 };
21 
22 /**
23  * struct wpa_sm - Internal WPA state machine data
24  */
25 struct wpa_sm {
26 	u8 pmk[PMK_LEN_MAX];
27 	size_t pmk_len;
28 	struct wpa_ptk ptk, tptk;
29 	enum rsn_hash_alg hash_alg;
30 	int ptk_set, tptk_set;
31 	bool tk_set; /* Whether any TK is configured to the driver */
32 	unsigned int msg_3_of_4_ok:1;
33 	u8 snonce[WPA_NONCE_LEN];
34 	u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
35 	int renew_snonce;
36 	u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
37 	int rx_replay_counter_set;
38 	u8 request_counter[WPA_REPLAY_COUNTER_LEN];
39 	struct wpa_gtk gtk;
40 	struct wpa_gtk gtk_wnm_sleep;
41 	struct wpa_igtk igtk;
42 	struct wpa_igtk igtk_wnm_sleep;
43 	struct wpa_bigtk bigtk;
44 	struct wpa_bigtk bigtk_wnm_sleep;
45 
46 	struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
47 
48 	struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
49 	struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */
50 	struct dl_list pmksa_candidates;
51 
52 	struct l2_packet_data *l2_preauth;
53 	struct l2_packet_data *l2_preauth_br;
54 	struct l2_packet_data *l2_tdls;
55 	u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
56 				     * 00:00:00:00:00:00 if no pre-auth is
57 				     * in progress */
58 	struct eapol_sm *preauth_eapol;
59 
60 	struct wpa_sm_ctx *ctx;
61 
62 	void *scard_ctx; /* context for smartcard callbacks */
63 	int fast_reauth; /* whether EAP fast re-authentication is enabled */
64 
65 	void *network_ctx;
66 	int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
67 	int proactive_key_caching;
68 	int eap_workaround;
69 	void *eap_conf_ctx;
70 	u8 ssid[32];
71 	size_t ssid_len;
72 	int wpa_ptk_rekey;
73 	unsigned int wpa_deny_ptk0_rekey:1;
74 	int p2p;
75 	int wpa_rsc_relaxation;
76 	int owe_ptk_workaround;
77 	int beacon_prot;
78 	int ext_key_id; /* whether Extended Key ID is enabled */
79 	int use_ext_key_id; /* whether Extended Key ID has been detected
80 			     * to be used */
81 	int keyidx_active; /* Key ID for the active TK */
82 
83 	/*
84 	 * If set Key Derivation Key should be derived as part of PMK to
85 	 * PTK derivation regardless of advertised capabilities.
86 	 */
87 	bool force_kdk_derivation;
88 
89 	u8 own_addr[ETH_ALEN];
90 	const char *ifname;
91 	const char *bridge_ifname;
92 	u8 bssid[ETH_ALEN];
93 
94 	unsigned int dot11RSNAConfigPMKLifetime;
95 	unsigned int dot11RSNAConfigPMKReauthThreshold;
96 	unsigned int dot11RSNAConfigSATimeout;
97 
98 	unsigned int dot11RSNA4WayHandshakeFailures;
99 
100 	/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
101 	unsigned int proto;
102 	unsigned int pairwise_cipher;
103 	unsigned int group_cipher;
104 	unsigned int key_mgmt;
105 	unsigned int mgmt_group_cipher;
106 
107 	int rsn_enabled; /* Whether RSN is enabled in configuration */
108 	int mfp; /* 0 = disabled, 1 = optional, 2 = mandatory */
109 	int ocv; /* Operating Channel Validation */
110 	enum sae_pwe sae_pwe; /* SAE PWE generation options */
111 
112 	unsigned int sae_pk:1; /* whether SAE-PK is used */
113 	unsigned int secure_ltf:1;
114 	unsigned int secure_rtt:1;
115 	unsigned int prot_range_neg:1;
116 	unsigned int prot_range_neg_x20:1;
117 	unsigned int ssid_protection:1;
118 	unsigned int spp_amsdu:1;
119 	unsigned int sae_pw_id_change:1;
120 	unsigned int assoc_encryption:1;
121 	unsigned int pmksa_privacy:1;
122 	unsigned int eap_over_auth_frame:1;
123 
124 	u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
125 	size_t assoc_wpa_ie_len;
126 	u8 *assoc_rsnxe; /* Own RSNXE from (Re)AssocReq */
127 	size_t assoc_rsnxe_len;
128 	u8 *ap_wpa_ie, *ap_rsn_ie, *ap_rsnxe;
129 	size_t ap_wpa_ie_len, ap_rsn_ie_len, ap_rsnxe_len;
130 	u8 *ap_rsne_override, *ap_rsne_override_2, *ap_rsnxe_override;
131 	size_t ap_rsne_override_len, ap_rsne_override_2_len,
132 		ap_rsnxe_override_len;
133 
134 #ifdef CONFIG_TDLS
135 	struct wpa_tdls_peer *tdls;
136 	int tdls_prohibited;
137 	int tdls_chan_switch_prohibited;
138 	int tdls_disabled;
139 
140 	/* The driver supports TDLS */
141 	int tdls_supported;
142 
143 	/*
144 	 * The driver requires explicit discovery/setup/teardown frames sent
145 	 * to it via tdls_mgmt.
146 	 */
147 	int tdls_external_setup;
148 
149 	/* The driver supports TDLS channel switching */
150 	int tdls_chan_switch;
151 #endif /* CONFIG_TDLS */
152 
153 #ifdef CONFIG_IEEE80211R
154 	u8 xxkey[PMK_LEN_MAX]; /* PSK or the second 256 bits of MSK, or the
155 				* first 384 bits of MSK */
156 	size_t xxkey_len;
157 	u8 pmk_r0[PMK_LEN_MAX];
158 	size_t pmk_r0_len;
159 	u8 pmk_r0_name[WPA_PMK_NAME_LEN];
160 	u8 pmk_r1[PMK_LEN_MAX];
161 	size_t pmk_r1_len;
162 	u8 pmk_r1_name[WPA_PMK_NAME_LEN];
163 	u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
164 	u8 key_mobility_domain[MOBILITY_DOMAIN_ID_LEN];
165 	u8 r0kh_id[FT_R0KH_ID_MAX_LEN];
166 	size_t r0kh_id_len;
167 	u8 r1kh_id[FT_R1KH_ID_LEN];
168 	unsigned int ft_completed:1;
169 	unsigned int ft_reassoc_completed:1;
170 	unsigned int ft_protocol:1;
171 	int over_the_ds_in_progress;
172 	u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
173 	int set_ptk_after_assoc;
174 	u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */
175 	u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */
176 	size_t assoc_resp_ies_len;
177 #ifdef CONFIG_PASN
178 	/*
179 	 * Currently, the WPA state machine stores the PMK-R1, PMK-R1-Name and
180 	 * R1KH-ID only for the current association. As PMK-R1 is required to
181 	 * perform PASN authentication with FT, store the R1KH-ID for previous
182 	 * associations, which would later be used to derive the PMK-R1 as part
183 	 * of the PASN authentication flow.
184 	 */
185 	struct pasn_ft_r1kh *pasn_r1kh;
186 	unsigned int n_pasn_r1kh;
187 #endif /* CONFIG_PASN */
188 #endif /* CONFIG_IEEE80211R */
189 
190 #ifdef CONFIG_P2P
191 	u8 p2p_ip_addr[3 * 4];
192 #endif /* CONFIG_P2P */
193 
194 #ifdef CONFIG_TESTING_OPTIONS
195 	struct wpabuf *test_assoc_ie;
196 	struct wpabuf *test_eapol_m2_elems;
197 	struct wpabuf *test_eapol_m4_elems;
198 	struct wpabuf *test_rsnxe_data;
199 	struct wpabuf *test_rsnxe_mask;
200 	int ft_rsnxe_used;
201 	unsigned int oci_freq_override_eapol;
202 	unsigned int oci_freq_override_eapol_g2;
203 	unsigned int oci_freq_override_ft_assoc;
204 	unsigned int oci_freq_override_fils_assoc;
205 	unsigned int disable_eapol_g2_tx;
206 	unsigned int eapol_2_key_info_set_mask;
207 	bool encrypt_eapol_m2;
208 	bool encrypt_eapol_m4;
209 #endif /* CONFIG_TESTING_OPTIONS */
210 
211 #ifdef CONFIG_FILS
212 	u8 fils_nonce[NONCE_LEN];
213 	u8 fils_session[FILS_SESSION_LEN];
214 	u8 fils_anonce[NONCE_LEN];
215 	u8 fils_key_auth_ap[FILS_MAX_KEY_AUTH_LEN];
216 	u8 fils_key_auth_sta[FILS_MAX_KEY_AUTH_LEN];
217 	size_t fils_key_auth_len;
218 	unsigned int fils_completed:1;
219 	unsigned int fils_erp_pmkid_set:1;
220 	unsigned int fils_cache_id_set:1;
221 	u8 fils_erp_pmkid[PMKID_LEN];
222 	u8 fils_cache_id[FILS_CACHE_ID_LEN];
223 	struct crypto_ecdh *fils_ecdh;
224 	int fils_dh_group;
225 	size_t fils_dh_elem_len;
226 	struct wpabuf *fils_ft_ies;
227 	u8 fils_ft[FILS_FT_MAX_LEN];
228 	size_t fils_ft_len;
229 #endif /* CONFIG_FILS */
230 #ifdef CONFIG_ENC_ASSOC
231 	unsigned int eppke_completed:1;
232 	unsigned int eap_over_auth_frame_completed:1;
233 #endif /* CONFIG_ENC_ASSOC */
234 
235 #ifdef CONFIG_OWE
236 	struct crypto_ecdh *owe_ecdh;
237 	u16 owe_group;
238 #endif /* CONFIG_OWE */
239 
240 #ifdef CONFIG_DPP2
241 	struct wpabuf *dpp_z;
242 	int dpp_pfs;
243 #endif /* CONFIG_DPP2 */
244 	struct wpa_sm_mlo mlo;
245 
246 	bool wmm_enabled;
247 	bool driver_bss_selection;
248 	bool ft_prepend_pmkid;
249 
250 	bool rsn_override_support;
251 	enum wpa_rsn_override rsn_override;
252 
253 	u8 last_kck[WPA_KCK_MAX_LEN];
254 	size_t last_kck_len;
255 	size_t last_kck_pmk_len;
256 	unsigned int last_kck_key_mgmt;
257 	int last_kck_eapol_key_ver;
258 	u8 last_kck_aa[ETH_ALEN];
259 	int last_eapol_key_ver;
260 };
261 
262 
wpa_sm_set_state(struct wpa_sm * sm,enum wpa_states state)263 static inline void wpa_sm_set_state(struct wpa_sm *sm, enum wpa_states state)
264 {
265 	WPA_ASSERT(sm->ctx->set_state);
266 	sm->ctx->set_state(sm->ctx->ctx, state);
267 }
268 
wpa_sm_get_state(struct wpa_sm * sm)269 static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm)
270 {
271 	WPA_ASSERT(sm->ctx->get_state);
272 	return sm->ctx->get_state(sm->ctx->ctx);
273 }
274 
wpa_sm_deauthenticate(struct wpa_sm * sm,u16 reason_code)275 static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, u16 reason_code)
276 {
277 	WPA_ASSERT(sm->ctx->deauthenticate);
278 	sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
279 }
280 
wpa_sm_set_key(struct wpa_sm * sm,int link_id,enum wpa_alg alg,const u8 * addr,int key_idx,int set_tx,const u8 * seq,size_t seq_len,const u8 * key,size_t key_len,enum key_flag key_flag)281 static inline int wpa_sm_set_key(struct wpa_sm *sm, int link_id,
282 				 enum wpa_alg alg, const u8 *addr, int key_idx,
283 				 int set_tx, const u8 *seq, size_t seq_len,
284 				 const u8 *key, size_t key_len,
285 				 enum key_flag key_flag)
286 {
287 	WPA_ASSERT(sm->ctx->set_key);
288 	return sm->ctx->set_key(sm->ctx->ctx, link_id, alg, addr, key_idx,
289 				set_tx, seq, seq_len, key, key_len, key_flag);
290 }
291 
wpa_sm_reconnect(struct wpa_sm * sm)292 static inline void wpa_sm_reconnect(struct wpa_sm *sm)
293 {
294 	WPA_ASSERT(sm->ctx->reconnect);
295 	sm->ctx->reconnect(sm->ctx->ctx);
296 }
297 
wpa_sm_get_network_ctx(struct wpa_sm * sm)298 static inline void * wpa_sm_get_network_ctx(struct wpa_sm *sm)
299 {
300 	WPA_ASSERT(sm->ctx->get_network_ctx);
301 	return sm->ctx->get_network_ctx(sm->ctx->ctx);
302 }
303 
wpa_sm_get_bssid(struct wpa_sm * sm,u8 * bssid)304 static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
305 {
306 	WPA_ASSERT(sm->ctx->get_bssid);
307 	return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
308 }
309 
wpa_sm_ether_send(struct wpa_sm * sm,const u8 * dest,u16 proto,const u8 * buf,size_t len)310 static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
311 				    u16 proto, const u8 *buf, size_t len)
312 {
313 	WPA_ASSERT(sm->ctx->ether_send);
314 	return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
315 }
316 
wpa_sm_get_beacon_ie(struct wpa_sm * sm)317 static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
318 {
319 	WPA_ASSERT(sm->ctx->get_beacon_ie);
320 	return sm->ctx->get_beacon_ie(sm->ctx->ctx);
321 }
322 
wpa_sm_cancel_auth_timeout(struct wpa_sm * sm)323 static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
324 {
325 	WPA_ASSERT(sm->ctx->cancel_auth_timeout);
326 	sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
327 }
328 
wpa_sm_alloc_eapol(struct wpa_sm * sm,u8 type,const void * data,u16 data_len,size_t * msg_len,void ** data_pos)329 static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
330 				      const void *data, u16 data_len,
331 				      size_t *msg_len, void **data_pos)
332 {
333 	WPA_ASSERT(sm->ctx->alloc_eapol);
334 	return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
335 				    msg_len, data_pos);
336 }
337 
wpa_sm_add_pmkid(struct wpa_sm * sm,void * network_ctx,const u8 * bssid,const u8 * pmkid,const u8 * cache_id,const u8 * pmk,size_t pmk_len,u32 pmk_lifetime,u8 pmk_reauth_threshold,int akmp)338 static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, void *network_ctx,
339 				   const u8 *bssid, const u8 *pmkid,
340 				   const u8 *cache_id, const u8 *pmk,
341 				   size_t pmk_len, u32 pmk_lifetime,
342 				   u8 pmk_reauth_threshold, int akmp)
343 {
344 	WPA_ASSERT(sm->ctx->add_pmkid);
345 	return sm->ctx->add_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid,
346 				  cache_id, pmk, pmk_len, pmk_lifetime,
347 				  pmk_reauth_threshold, akmp);
348 }
349 
wpa_sm_remove_pmkid(struct wpa_sm * sm,void * network_ctx,const u8 * bssid,const u8 * pmkid,const u8 * cache_id)350 static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, void *network_ctx,
351 				      const u8 *bssid, const u8 *pmkid,
352 				      const u8 *cache_id)
353 {
354 	WPA_ASSERT(sm->ctx->remove_pmkid);
355 	return sm->ctx->remove_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid,
356 				     cache_id);
357 }
358 
wpa_sm_mlme_setprotection(struct wpa_sm * sm,const u8 * addr,int protect_type,int key_type)359 static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
360 					    int protect_type, int key_type)
361 {
362 	WPA_ASSERT(sm->ctx->mlme_setprotection);
363 	return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
364 					   key_type);
365 }
366 
wpa_sm_update_ft_ies(struct wpa_sm * sm,const u8 * md,const u8 * ies,size_t ies_len)367 static inline int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md,
368 				       const u8 *ies, size_t ies_len)
369 {
370 	if (sm->ctx->update_ft_ies)
371 		return sm->ctx->update_ft_ies(sm->ctx->ctx, md, ies, ies_len);
372 	return -1;
373 }
374 
wpa_sm_send_ft_action(struct wpa_sm * sm,u8 action,const u8 * target_ap,const u8 * ies,size_t ies_len)375 static inline int wpa_sm_send_ft_action(struct wpa_sm *sm, u8 action,
376 					const u8 *target_ap,
377 					const u8 *ies, size_t ies_len)
378 {
379 	if (sm->ctx->send_ft_action)
380 		return sm->ctx->send_ft_action(sm->ctx->ctx, action, target_ap,
381 					       ies, ies_len);
382 	return -1;
383 }
384 
wpa_sm_mark_authenticated(struct wpa_sm * sm,const u8 * target_ap)385 static inline int wpa_sm_mark_authenticated(struct wpa_sm *sm,
386 					    const u8 *target_ap)
387 {
388 	if (sm->ctx->mark_authenticated)
389 		return sm->ctx->mark_authenticated(sm->ctx->ctx, target_ap);
390 	return -1;
391 }
392 
wpa_sm_set_rekey_offload(struct wpa_sm * sm)393 static inline void wpa_sm_set_rekey_offload(struct wpa_sm *sm)
394 {
395 	if (!sm->ctx->set_rekey_offload)
396 		return;
397 	sm->ctx->set_rekey_offload(sm->ctx->ctx, sm->ptk.kek, sm->ptk.kek_len,
398 				   sm->ptk.kck, sm->ptk.kck_len,
399 				   sm->rx_replay_counter);
400 }
401 
402 #ifdef CONFIG_TDLS
wpa_sm_tdls_get_capa(struct wpa_sm * sm,int * tdls_supported,int * tdls_ext_setup,int * tdls_chan_switch)403 static inline int wpa_sm_tdls_get_capa(struct wpa_sm *sm,
404 				       int *tdls_supported,
405 				       int *tdls_ext_setup,
406 				       int *tdls_chan_switch)
407 {
408 	if (sm->ctx->tdls_get_capa)
409 		return sm->ctx->tdls_get_capa(sm->ctx->ctx, tdls_supported,
410 					      tdls_ext_setup, tdls_chan_switch);
411 	return -1;
412 }
413 
wpa_sm_send_tdls_mgmt(struct wpa_sm * sm,const u8 * dst,u8 action_code,u8 dialog_token,u16 status_code,u32 peer_capab,int initiator,const u8 * buf,size_t len,int link_id)414 static inline int wpa_sm_send_tdls_mgmt(struct wpa_sm *sm, const u8 *dst,
415 					u8 action_code, u8 dialog_token,
416 					u16 status_code, u32 peer_capab,
417 					int initiator, const u8 *buf,
418 					size_t len, int link_id)
419 {
420 	if (sm->ctx->send_tdls_mgmt)
421 		return sm->ctx->send_tdls_mgmt(sm->ctx->ctx, dst, action_code,
422 					       dialog_token, status_code,
423 					       peer_capab, initiator, buf,
424 					       len, link_id);
425 	return -1;
426 }
427 
wpa_sm_tdls_oper(struct wpa_sm * sm,int oper,const u8 * peer)428 static inline int wpa_sm_tdls_oper(struct wpa_sm *sm, int oper,
429 				   const u8 *peer)
430 {
431 	if (sm->ctx->tdls_oper)
432 		return sm->ctx->tdls_oper(sm->ctx->ctx, oper, peer);
433 	return -1;
434 }
435 
436 static inline int
wpa_sm_tdls_peer_addset(struct wpa_sm * sm,const u8 * addr,int add,u16 aid,u16 capability,const u8 * supp_rates,size_t supp_rates_len,const struct ieee80211_ht_capabilities * ht_capab,const struct ieee80211_vht_capabilities * vht_capab,const struct ieee80211_he_capabilities * he_capab,size_t he_capab_len,const struct ieee80211_he_6ghz_band_cap * he_6ghz_capab,u8 qosinfo,int wmm,const u8 * ext_capab,size_t ext_capab_len,const u8 * supp_channels,size_t supp_channels_len,const u8 * supp_oper_classes,size_t supp_oper_classes_len,const struct ieee80211_eht_capabilities * eht_capab,size_t eht_capab_len,int mld_link_id)437 wpa_sm_tdls_peer_addset(struct wpa_sm *sm, const u8 *addr, int add,
438 			u16 aid, u16 capability, const u8 *supp_rates,
439 			size_t supp_rates_len,
440 			const struct ieee80211_ht_capabilities *ht_capab,
441 			const struct ieee80211_vht_capabilities *vht_capab,
442 			const struct ieee80211_he_capabilities *he_capab,
443 			size_t he_capab_len,
444 			const struct ieee80211_he_6ghz_band_cap *he_6ghz_capab,
445 			u8 qosinfo, int wmm, const u8 *ext_capab,
446 			size_t ext_capab_len, const u8 *supp_channels,
447 			size_t supp_channels_len, const u8 *supp_oper_classes,
448 			size_t supp_oper_classes_len,
449 			const struct ieee80211_eht_capabilities *eht_capab,
450 			size_t eht_capab_len, int mld_link_id)
451 {
452 	if (sm->ctx->tdls_peer_addset)
453 		return sm->ctx->tdls_peer_addset(sm->ctx->ctx, addr, add,
454 						 aid, capability, supp_rates,
455 						 supp_rates_len, ht_capab,
456 						 vht_capab,
457 						 he_capab, he_capab_len,
458 						 he_6ghz_capab, qosinfo, wmm,
459 						 ext_capab, ext_capab_len,
460 						 supp_channels,
461 						 supp_channels_len,
462 						 supp_oper_classes,
463 						 supp_oper_classes_len,
464 						 eht_capab, eht_capab_len,
465 						 mld_link_id);
466 	return -1;
467 }
468 
469 static inline int
wpa_sm_tdls_enable_channel_switch(struct wpa_sm * sm,const u8 * addr,u8 oper_class,const struct hostapd_freq_params * freq_params)470 wpa_sm_tdls_enable_channel_switch(struct wpa_sm *sm, const u8 *addr,
471 				  u8 oper_class,
472 				  const struct hostapd_freq_params *freq_params)
473 {
474 	if (sm->ctx->tdls_enable_channel_switch)
475 		return sm->ctx->tdls_enable_channel_switch(sm->ctx->ctx, addr,
476 							   oper_class,
477 							   freq_params);
478 	return -1;
479 }
480 
481 static inline int
wpa_sm_tdls_disable_channel_switch(struct wpa_sm * sm,const u8 * addr)482 wpa_sm_tdls_disable_channel_switch(struct wpa_sm *sm, const u8 *addr)
483 {
484 	if (sm->ctx->tdls_disable_channel_switch)
485 		return sm->ctx->tdls_disable_channel_switch(sm->ctx->ctx, addr);
486 	return -1;
487 }
488 #endif /* CONFIG_TDLS */
489 
wpa_sm_key_mgmt_set_pmk(struct wpa_sm * sm,const u8 * pmk,size_t pmk_len)490 static inline int wpa_sm_key_mgmt_set_pmk(struct wpa_sm *sm,
491 					  const u8 *pmk, size_t pmk_len)
492 {
493 	if (!sm->ctx->key_mgmt_set_pmk)
494 		return -1;
495 	return sm->ctx->key_mgmt_set_pmk(sm->ctx->ctx, pmk, pmk_len);
496 }
497 
wpa_sm_fils_hlp_rx(struct wpa_sm * sm,const u8 * dst,const u8 * src,const u8 * pkt,size_t pkt_len)498 static inline void wpa_sm_fils_hlp_rx(struct wpa_sm *sm,
499 				      const u8 *dst, const u8 *src,
500 				      const u8 *pkt, size_t pkt_len)
501 {
502 	if (sm->ctx->fils_hlp_rx)
503 		sm->ctx->fils_hlp_rx(sm->ctx->ctx, dst, src, pkt, pkt_len);
504 }
505 
wpa_sm_channel_info(struct wpa_sm * sm,struct wpa_channel_info * ci)506 static inline int wpa_sm_channel_info(struct wpa_sm *sm,
507 				      struct wpa_channel_info *ci)
508 {
509 	if (!sm->ctx->channel_info)
510 		return -1;
511 	return sm->ctx->channel_info(sm->ctx->ctx, ci);
512 }
513 
wpa_sm_transition_disable(struct wpa_sm * sm,u8 bitmap)514 static inline void wpa_sm_transition_disable(struct wpa_sm *sm, u8 bitmap)
515 {
516 	if (sm->ctx->transition_disable)
517 		sm->ctx->transition_disable(sm->ctx->ctx, bitmap);
518 }
519 
wpa_sm_store_ptk(struct wpa_sm * sm,const u8 * addr,int cipher,u32 life_time,struct wpa_ptk * ptk)520 static inline void wpa_sm_store_ptk(struct wpa_sm *sm,
521 				    const u8 *addr, int cipher,
522 				    u32 life_time, struct wpa_ptk *ptk)
523 {
524 	if (sm->ctx->store_ptk)
525 		sm->ctx->store_ptk(sm->ctx->ctx, addr, cipher, life_time,
526 				   ptk);
527 }
528 
529 #ifdef CONFIG_PASN
wpa_sm_set_ltf_keyseed(struct wpa_sm * sm,const u8 * own_addr,const u8 * peer_addr,size_t ltf_keyseed_len,const u8 * ltf_keyseed)530 static inline int wpa_sm_set_ltf_keyseed(struct wpa_sm *sm, const u8 *own_addr,
531 					 const u8 *peer_addr,
532 					 size_t ltf_keyseed_len,
533 					 const u8 *ltf_keyseed)
534 {
535 	WPA_ASSERT(sm->ctx->set_ltf_keyseed);
536 	return sm->ctx->set_ltf_keyseed(sm->ctx->ctx, own_addr, peer_addr,
537 					ltf_keyseed_len, ltf_keyseed);
538 }
539 #endif /* CONFIG_PASN */
540 
541 static inline void
wpa_sm_notify_pmksa_cache_entry(struct wpa_sm * sm,struct rsn_pmksa_cache_entry * entry)542 wpa_sm_notify_pmksa_cache_entry(struct wpa_sm *sm,
543 				struct rsn_pmksa_cache_entry *entry)
544 {
545 	if (sm->ctx->notify_pmksa_cache_entry)
546 		sm->ctx->notify_pmksa_cache_entry(sm->ctx->ctx, entry);
547 }
548 
wpa_sm_ssid_verified(struct wpa_sm * sm)549 static inline void wpa_sm_ssid_verified(struct wpa_sm *sm)
550 {
551 	if (sm->ctx->ssid_verified)
552 		sm->ctx->ssid_verified(sm->ctx->ctx);
553 }
554 
555 int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk,
556 		       int ver, const u8 *dest, u16 proto,
557 		       u8 *msg, size_t msg_len, u8 *key_mic);
558 int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst,
559 			       const struct wpa_eapol_key *key,
560 			       int ver, const u8 *nonce,
561 			       const u8 *wpa_ie, size_t wpa_ie_len,
562 			       struct wpa_ptk *ptk);
563 int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst,
564 			       const struct wpa_eapol_key *key,
565 			       u16 ver, u16 key_info,
566 			       struct wpa_ptk *ptk);
567 
568 int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
569 		      const struct wpa_eapol_key *key, struct wpa_ptk *ptk);
570 
571 void wpa_tdls_assoc(struct wpa_sm *sm);
572 void wpa_tdls_disassoc(struct wpa_sm *sm);
573 bool wpa_sm_rsn_overriding_supported(struct wpa_sm *sm);
574 
575 #endif /* WPA_I_H */
576