139beb93cSSam Leffler /*
2e28a4053SRui Paulo * Internal WPA/RSN supplicant state machine definitions
385732ac8SCy Schubert * Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi>
439beb93cSSam Leffler *
5f05cddf9SRui Paulo * This software may be distributed under the terms of the BSD license.
6f05cddf9SRui Paulo * See README for more details.
739beb93cSSam Leffler */
839beb93cSSam Leffler
939beb93cSSam Leffler #ifndef WPA_I_H
1039beb93cSSam Leffler #define WPA_I_H
1139beb93cSSam Leffler
12e28a4053SRui Paulo #include "utils/list.h"
13e28a4053SRui Paulo
14f05cddf9SRui Paulo struct wpa_tdls_peer;
1539beb93cSSam Leffler struct wpa_eapol_key;
1639beb93cSSam Leffler
17c1d255d3SCy Schubert struct pasn_ft_r1kh {
18c1d255d3SCy Schubert u8 bssid[ETH_ALEN];
19c1d255d3SCy Schubert u8 r1kh_id[FT_R1KH_ID_LEN];
20c1d255d3SCy Schubert };
21c1d255d3SCy Schubert
2239beb93cSSam Leffler /**
2339beb93cSSam Leffler * struct wpa_sm - Internal WPA state machine data
2439beb93cSSam Leffler */
2539beb93cSSam Leffler struct wpa_sm {
26780fb4a2SCy Schubert u8 pmk[PMK_LEN_MAX];
2739beb93cSSam Leffler size_t pmk_len;
2839beb93cSSam Leffler struct wpa_ptk ptk, tptk;
2939beb93cSSam Leffler int ptk_set, tptk_set;
30*a90b9d01SCy Schubert bool tk_set; /* Whether any TK is configured to the driver */
315b9c547cSRui Paulo unsigned int msg_3_of_4_ok:1;
3239beb93cSSam Leffler u8 snonce[WPA_NONCE_LEN];
3339beb93cSSam Leffler u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
3439beb93cSSam Leffler int renew_snonce;
3539beb93cSSam Leffler u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
3639beb93cSSam Leffler int rx_replay_counter_set;
3739beb93cSSam Leffler u8 request_counter[WPA_REPLAY_COUNTER_LEN];
38a2063804SGordon Tetlow struct wpa_gtk gtk;
39a2063804SGordon Tetlow struct wpa_gtk gtk_wnm_sleep;
40a2063804SGordon Tetlow struct wpa_igtk igtk;
41a2063804SGordon Tetlow struct wpa_igtk igtk_wnm_sleep;
42c1d255d3SCy Schubert struct wpa_bigtk bigtk;
43c1d255d3SCy Schubert struct wpa_bigtk bigtk_wnm_sleep;
4439beb93cSSam Leffler
4539beb93cSSam Leffler struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
4639beb93cSSam Leffler
4739beb93cSSam Leffler struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
4839beb93cSSam Leffler struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */
49e28a4053SRui Paulo struct dl_list pmksa_candidates;
5039beb93cSSam Leffler
5139beb93cSSam Leffler struct l2_packet_data *l2_preauth;
5239beb93cSSam Leffler struct l2_packet_data *l2_preauth_br;
53f05cddf9SRui Paulo struct l2_packet_data *l2_tdls;
5439beb93cSSam Leffler u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
5539beb93cSSam Leffler * 00:00:00:00:00:00 if no pre-auth is
5639beb93cSSam Leffler * in progress */
5739beb93cSSam Leffler struct eapol_sm *preauth_eapol;
5839beb93cSSam Leffler
5939beb93cSSam Leffler struct wpa_sm_ctx *ctx;
6039beb93cSSam Leffler
6139beb93cSSam Leffler void *scard_ctx; /* context for smartcard callbacks */
6239beb93cSSam Leffler int fast_reauth; /* whether EAP fast re-authentication is enabled */
6339beb93cSSam Leffler
6439beb93cSSam Leffler void *network_ctx;
6539beb93cSSam Leffler int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
6639beb93cSSam Leffler int proactive_key_caching;
6739beb93cSSam Leffler int eap_workaround;
6839beb93cSSam Leffler void *eap_conf_ctx;
6939beb93cSSam Leffler u8 ssid[32];
7039beb93cSSam Leffler size_t ssid_len;
7139beb93cSSam Leffler int wpa_ptk_rekey;
72c1d255d3SCy Schubert int wpa_deny_ptk0_rekey:1;
735b9c547cSRui Paulo int p2p;
74780fb4a2SCy Schubert int wpa_rsc_relaxation;
75c1d255d3SCy Schubert int owe_ptk_workaround;
76c1d255d3SCy Schubert int beacon_prot;
77c1d255d3SCy Schubert int ext_key_id; /* whether Extended Key ID is enabled */
78c1d255d3SCy Schubert int use_ext_key_id; /* whether Extended Key ID has been detected
79c1d255d3SCy Schubert * to be used */
80c1d255d3SCy Schubert int keyidx_active; /* Key ID for the active TK */
81c1d255d3SCy Schubert
82c1d255d3SCy Schubert /*
83c1d255d3SCy Schubert * If set Key Derivation Key should be derived as part of PMK to
84c1d255d3SCy Schubert * PTK derivation regardless of advertised capabilities.
85c1d255d3SCy Schubert */
86c1d255d3SCy Schubert bool force_kdk_derivation;
8739beb93cSSam Leffler
8839beb93cSSam Leffler u8 own_addr[ETH_ALEN];
8939beb93cSSam Leffler const char *ifname;
9039beb93cSSam Leffler const char *bridge_ifname;
9139beb93cSSam Leffler u8 bssid[ETH_ALEN];
9239beb93cSSam Leffler
9339beb93cSSam Leffler unsigned int dot11RSNAConfigPMKLifetime;
9439beb93cSSam Leffler unsigned int dot11RSNAConfigPMKReauthThreshold;
9539beb93cSSam Leffler unsigned int dot11RSNAConfigSATimeout;
9639beb93cSSam Leffler
9739beb93cSSam Leffler unsigned int dot11RSNA4WayHandshakeFailures;
9839beb93cSSam Leffler
9939beb93cSSam Leffler /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
10039beb93cSSam Leffler unsigned int proto;
10139beb93cSSam Leffler unsigned int pairwise_cipher;
10239beb93cSSam Leffler unsigned int group_cipher;
10339beb93cSSam Leffler unsigned int key_mgmt;
10439beb93cSSam Leffler unsigned int mgmt_group_cipher;
10539beb93cSSam Leffler
10639beb93cSSam Leffler int rsn_enabled; /* Whether RSN is enabled in configuration */
107e28a4053SRui Paulo int mfp; /* 0 = disabled, 1 = optional, 2 = mandatory */
1084bc52338SCy Schubert int ocv; /* Operating Channel Validation */
109*a90b9d01SCy Schubert enum sae_pwe sae_pwe; /* SAE PWE generation options */
110c1d255d3SCy Schubert
111c1d255d3SCy Schubert unsigned int sae_pk:1; /* whether SAE-PK is used */
112c1d255d3SCy Schubert unsigned int secure_ltf:1;
113c1d255d3SCy Schubert unsigned int secure_rtt:1;
114c1d255d3SCy Schubert unsigned int prot_range_neg:1;
115*a90b9d01SCy Schubert unsigned int ssid_protection:1;
11639beb93cSSam Leffler
11739beb93cSSam Leffler u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
11839beb93cSSam Leffler size_t assoc_wpa_ie_len;
119c1d255d3SCy Schubert u8 *assoc_rsnxe; /* Own RSNXE from (Re)AssocReq */
120c1d255d3SCy Schubert size_t assoc_rsnxe_len;
121c1d255d3SCy Schubert u8 *ap_wpa_ie, *ap_rsn_ie, *ap_rsnxe;
122c1d255d3SCy Schubert size_t ap_wpa_ie_len, ap_rsn_ie_len, ap_rsnxe_len;
12339beb93cSSam Leffler
124f05cddf9SRui Paulo #ifdef CONFIG_TDLS
125f05cddf9SRui Paulo struct wpa_tdls_peer *tdls;
126f05cddf9SRui Paulo int tdls_prohibited;
1275b9c547cSRui Paulo int tdls_chan_switch_prohibited;
128f05cddf9SRui Paulo int tdls_disabled;
129f05cddf9SRui Paulo
130f05cddf9SRui Paulo /* The driver supports TDLS */
131f05cddf9SRui Paulo int tdls_supported;
132f05cddf9SRui Paulo
133f05cddf9SRui Paulo /*
134f05cddf9SRui Paulo * The driver requires explicit discovery/setup/teardown frames sent
135f05cddf9SRui Paulo * to it via tdls_mgmt.
136f05cddf9SRui Paulo */
137f05cddf9SRui Paulo int tdls_external_setup;
1385b9c547cSRui Paulo
1395b9c547cSRui Paulo /* The driver supports TDLS channel switching */
1405b9c547cSRui Paulo int tdls_chan_switch;
141f05cddf9SRui Paulo #endif /* CONFIG_TDLS */
14239beb93cSSam Leffler
14339beb93cSSam Leffler #ifdef CONFIG_IEEE80211R
14485732ac8SCy Schubert u8 xxkey[PMK_LEN_MAX]; /* PSK or the second 256 bits of MSK, or the
14585732ac8SCy Schubert * first 384 bits of MSK */
14639beb93cSSam Leffler size_t xxkey_len;
14785732ac8SCy Schubert u8 pmk_r0[PMK_LEN_MAX];
14885732ac8SCy Schubert size_t pmk_r0_len;
14939beb93cSSam Leffler u8 pmk_r0_name[WPA_PMK_NAME_LEN];
15085732ac8SCy Schubert u8 pmk_r1[PMK_LEN_MAX];
15185732ac8SCy Schubert size_t pmk_r1_len;
15239beb93cSSam Leffler u8 pmk_r1_name[WPA_PMK_NAME_LEN];
15339beb93cSSam Leffler u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
154*a90b9d01SCy Schubert u8 key_mobility_domain[MOBILITY_DOMAIN_ID_LEN];
15539beb93cSSam Leffler u8 r0kh_id[FT_R0KH_ID_MAX_LEN];
15639beb93cSSam Leffler size_t r0kh_id_len;
15739beb93cSSam Leffler u8 r1kh_id[FT_R1KH_ID_LEN];
1584bc52338SCy Schubert unsigned int ft_completed:1;
1594bc52338SCy Schubert unsigned int ft_reassoc_completed:1;
1604bc52338SCy Schubert unsigned int ft_protocol:1;
16139beb93cSSam Leffler int over_the_ds_in_progress;
16239beb93cSSam Leffler u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
163e28a4053SRui Paulo int set_ptk_after_assoc;
164e28a4053SRui Paulo u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */
165e28a4053SRui Paulo u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */
166e28a4053SRui Paulo size_t assoc_resp_ies_len;
167c1d255d3SCy Schubert #ifdef CONFIG_PASN
168c1d255d3SCy Schubert /*
169c1d255d3SCy Schubert * Currently, the WPA state machine stores the PMK-R1, PMK-R1-Name and
170c1d255d3SCy Schubert * R1KH-ID only for the current association. As PMK-R1 is required to
171c1d255d3SCy Schubert * perform PASN authentication with FT, store the R1KH-ID for previous
172c1d255d3SCy Schubert * associations, which would later be used to derive the PMK-R1 as part
173c1d255d3SCy Schubert * of the PASN authentication flow.
174c1d255d3SCy Schubert */
175c1d255d3SCy Schubert struct pasn_ft_r1kh *pasn_r1kh;
176c1d255d3SCy Schubert unsigned int n_pasn_r1kh;
177c1d255d3SCy Schubert #endif /* CONFIG_PASN */
17839beb93cSSam Leffler #endif /* CONFIG_IEEE80211R */
1795b9c547cSRui Paulo
1805b9c547cSRui Paulo #ifdef CONFIG_P2P
1815b9c547cSRui Paulo u8 p2p_ip_addr[3 * 4];
1825b9c547cSRui Paulo #endif /* CONFIG_P2P */
183780fb4a2SCy Schubert
184780fb4a2SCy Schubert #ifdef CONFIG_TESTING_OPTIONS
185780fb4a2SCy Schubert struct wpabuf *test_assoc_ie;
186*a90b9d01SCy Schubert struct wpabuf *test_eapol_m2_elems;
187*a90b9d01SCy Schubert struct wpabuf *test_eapol_m4_elems;
188c1d255d3SCy Schubert int ft_rsnxe_used;
189c1d255d3SCy Schubert unsigned int oci_freq_override_eapol;
190c1d255d3SCy Schubert unsigned int oci_freq_override_eapol_g2;
191c1d255d3SCy Schubert unsigned int oci_freq_override_ft_assoc;
192c1d255d3SCy Schubert unsigned int oci_freq_override_fils_assoc;
193*a90b9d01SCy Schubert unsigned int disable_eapol_g2_tx;
194*a90b9d01SCy Schubert bool encrypt_eapol_m2;
195*a90b9d01SCy Schubert bool encrypt_eapol_m4;
196780fb4a2SCy Schubert #endif /* CONFIG_TESTING_OPTIONS */
19785732ac8SCy Schubert
19885732ac8SCy Schubert #ifdef CONFIG_FILS
19985732ac8SCy Schubert u8 fils_nonce[FILS_NONCE_LEN];
20085732ac8SCy Schubert u8 fils_session[FILS_SESSION_LEN];
20185732ac8SCy Schubert u8 fils_anonce[FILS_NONCE_LEN];
20285732ac8SCy Schubert u8 fils_key_auth_ap[FILS_MAX_KEY_AUTH_LEN];
20385732ac8SCy Schubert u8 fils_key_auth_sta[FILS_MAX_KEY_AUTH_LEN];
20485732ac8SCy Schubert size_t fils_key_auth_len;
20585732ac8SCy Schubert unsigned int fils_completed:1;
20685732ac8SCy Schubert unsigned int fils_erp_pmkid_set:1;
20785732ac8SCy Schubert unsigned int fils_cache_id_set:1;
20885732ac8SCy Schubert u8 fils_erp_pmkid[PMKID_LEN];
20985732ac8SCy Schubert u8 fils_cache_id[FILS_CACHE_ID_LEN];
21085732ac8SCy Schubert struct crypto_ecdh *fils_ecdh;
21185732ac8SCy Schubert int fils_dh_group;
21285732ac8SCy Schubert size_t fils_dh_elem_len;
21385732ac8SCy Schubert struct wpabuf *fils_ft_ies;
21485732ac8SCy Schubert u8 fils_ft[FILS_FT_MAX_LEN];
21585732ac8SCy Schubert size_t fils_ft_len;
21685732ac8SCy Schubert #endif /* CONFIG_FILS */
21785732ac8SCy Schubert
21885732ac8SCy Schubert #ifdef CONFIG_OWE
21985732ac8SCy Schubert struct crypto_ecdh *owe_ecdh;
22085732ac8SCy Schubert u16 owe_group;
22185732ac8SCy Schubert #endif /* CONFIG_OWE */
2224bc52338SCy Schubert
2234bc52338SCy Schubert #ifdef CONFIG_DPP2
2244bc52338SCy Schubert struct wpabuf *dpp_z;
225c1d255d3SCy Schubert int dpp_pfs;
2264bc52338SCy Schubert #endif /* CONFIG_DPP2 */
227*a90b9d01SCy Schubert struct wpa_sm_mlo mlo;
228*a90b9d01SCy Schubert
229*a90b9d01SCy Schubert bool wmm_enabled;
230*a90b9d01SCy Schubert bool driver_bss_selection;
231*a90b9d01SCy Schubert bool ft_prepend_pmkid;
23239beb93cSSam Leffler };
23339beb93cSSam Leffler
23439beb93cSSam Leffler
wpa_sm_set_state(struct wpa_sm * sm,enum wpa_states state)235e28a4053SRui Paulo static inline void wpa_sm_set_state(struct wpa_sm *sm, enum wpa_states state)
23639beb93cSSam Leffler {
23739beb93cSSam Leffler WPA_ASSERT(sm->ctx->set_state);
23839beb93cSSam Leffler sm->ctx->set_state(sm->ctx->ctx, state);
23939beb93cSSam Leffler }
24039beb93cSSam Leffler
wpa_sm_get_state(struct wpa_sm * sm)241e28a4053SRui Paulo static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm)
24239beb93cSSam Leffler {
24339beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_state);
24439beb93cSSam Leffler return sm->ctx->get_state(sm->ctx->ctx);
24539beb93cSSam Leffler }
24639beb93cSSam Leffler
wpa_sm_deauthenticate(struct wpa_sm * sm,u16 reason_code)247206b73d0SCy Schubert static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, u16 reason_code)
24839beb93cSSam Leffler {
24939beb93cSSam Leffler WPA_ASSERT(sm->ctx->deauthenticate);
25039beb93cSSam Leffler sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
25139beb93cSSam Leffler }
25239beb93cSSam Leffler
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)253*a90b9d01SCy Schubert static inline int wpa_sm_set_key(struct wpa_sm *sm, int link_id,
254*a90b9d01SCy Schubert enum wpa_alg alg, const u8 *addr, int key_idx,
255*a90b9d01SCy Schubert int set_tx, const u8 *seq, size_t seq_len,
256c1d255d3SCy Schubert const u8 *key, size_t key_len,
257c1d255d3SCy Schubert enum key_flag key_flag)
25839beb93cSSam Leffler {
25939beb93cSSam Leffler WPA_ASSERT(sm->ctx->set_key);
260*a90b9d01SCy Schubert return sm->ctx->set_key(sm->ctx->ctx, link_id, alg, addr, key_idx,
261*a90b9d01SCy Schubert set_tx, seq, seq_len, key, key_len, key_flag);
262c1d255d3SCy Schubert }
263c1d255d3SCy Schubert
wpa_sm_reconnect(struct wpa_sm * sm)264c1d255d3SCy Schubert static inline void wpa_sm_reconnect(struct wpa_sm *sm)
265c1d255d3SCy Schubert {
266c1d255d3SCy Schubert WPA_ASSERT(sm->ctx->reconnect);
267c1d255d3SCy Schubert sm->ctx->reconnect(sm->ctx->ctx);
26839beb93cSSam Leffler }
26939beb93cSSam Leffler
wpa_sm_get_network_ctx(struct wpa_sm * sm)27039beb93cSSam Leffler static inline void * wpa_sm_get_network_ctx(struct wpa_sm *sm)
27139beb93cSSam Leffler {
27239beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_network_ctx);
27339beb93cSSam Leffler return sm->ctx->get_network_ctx(sm->ctx->ctx);
27439beb93cSSam Leffler }
27539beb93cSSam Leffler
wpa_sm_get_bssid(struct wpa_sm * sm,u8 * bssid)27639beb93cSSam Leffler static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
27739beb93cSSam Leffler {
27839beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_bssid);
27939beb93cSSam Leffler return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
28039beb93cSSam Leffler }
28139beb93cSSam Leffler
wpa_sm_ether_send(struct wpa_sm * sm,const u8 * dest,u16 proto,const u8 * buf,size_t len)28239beb93cSSam Leffler static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
28339beb93cSSam Leffler u16 proto, const u8 *buf, size_t len)
28439beb93cSSam Leffler {
28539beb93cSSam Leffler WPA_ASSERT(sm->ctx->ether_send);
28639beb93cSSam Leffler return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
28739beb93cSSam Leffler }
28839beb93cSSam Leffler
wpa_sm_get_beacon_ie(struct wpa_sm * sm)28939beb93cSSam Leffler static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
29039beb93cSSam Leffler {
29139beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_beacon_ie);
29239beb93cSSam Leffler return sm->ctx->get_beacon_ie(sm->ctx->ctx);
29339beb93cSSam Leffler }
29439beb93cSSam Leffler
wpa_sm_cancel_auth_timeout(struct wpa_sm * sm)29539beb93cSSam Leffler static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
29639beb93cSSam Leffler {
29739beb93cSSam Leffler WPA_ASSERT(sm->ctx->cancel_auth_timeout);
29839beb93cSSam Leffler sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
29939beb93cSSam Leffler }
30039beb93cSSam Leffler
wpa_sm_alloc_eapol(struct wpa_sm * sm,u8 type,const void * data,u16 data_len,size_t * msg_len,void ** data_pos)30139beb93cSSam Leffler static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
30239beb93cSSam Leffler const void *data, u16 data_len,
30339beb93cSSam Leffler size_t *msg_len, void **data_pos)
30439beb93cSSam Leffler {
30539beb93cSSam Leffler WPA_ASSERT(sm->ctx->alloc_eapol);
30639beb93cSSam Leffler return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
30739beb93cSSam Leffler msg_len, data_pos);
30839beb93cSSam Leffler }
30939beb93cSSam Leffler
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)31085732ac8SCy Schubert static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, void *network_ctx,
31185732ac8SCy Schubert const u8 *bssid, const u8 *pmkid,
31285732ac8SCy Schubert const u8 *cache_id, const u8 *pmk,
313c1d255d3SCy Schubert size_t pmk_len, u32 pmk_lifetime,
314c1d255d3SCy Schubert u8 pmk_reauth_threshold, int akmp)
31539beb93cSSam Leffler {
31639beb93cSSam Leffler WPA_ASSERT(sm->ctx->add_pmkid);
31785732ac8SCy Schubert return sm->ctx->add_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid,
318c1d255d3SCy Schubert cache_id, pmk, pmk_len, pmk_lifetime,
319c1d255d3SCy Schubert pmk_reauth_threshold, akmp);
32039beb93cSSam Leffler }
32139beb93cSSam Leffler
wpa_sm_remove_pmkid(struct wpa_sm * sm,void * network_ctx,const u8 * bssid,const u8 * pmkid,const u8 * cache_id)32285732ac8SCy Schubert static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, void *network_ctx,
32385732ac8SCy Schubert const u8 *bssid, const u8 *pmkid,
32485732ac8SCy Schubert const u8 *cache_id)
32539beb93cSSam Leffler {
32639beb93cSSam Leffler WPA_ASSERT(sm->ctx->remove_pmkid);
32785732ac8SCy Schubert return sm->ctx->remove_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid,
32885732ac8SCy Schubert cache_id);
32939beb93cSSam Leffler }
33039beb93cSSam Leffler
wpa_sm_mlme_setprotection(struct wpa_sm * sm,const u8 * addr,int protect_type,int key_type)33139beb93cSSam Leffler static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
33239beb93cSSam Leffler int protect_type, int key_type)
33339beb93cSSam Leffler {
33439beb93cSSam Leffler WPA_ASSERT(sm->ctx->mlme_setprotection);
33539beb93cSSam Leffler return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
33639beb93cSSam Leffler key_type);
33739beb93cSSam Leffler }
33839beb93cSSam Leffler
wpa_sm_update_ft_ies(struct wpa_sm * sm,const u8 * md,const u8 * ies,size_t ies_len)33939beb93cSSam Leffler static inline int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md,
34039beb93cSSam Leffler const u8 *ies, size_t ies_len)
34139beb93cSSam Leffler {
34239beb93cSSam Leffler if (sm->ctx->update_ft_ies)
34339beb93cSSam Leffler return sm->ctx->update_ft_ies(sm->ctx->ctx, md, ies, ies_len);
34439beb93cSSam Leffler return -1;
34539beb93cSSam Leffler }
34639beb93cSSam Leffler
wpa_sm_send_ft_action(struct wpa_sm * sm,u8 action,const u8 * target_ap,const u8 * ies,size_t ies_len)34739beb93cSSam Leffler static inline int wpa_sm_send_ft_action(struct wpa_sm *sm, u8 action,
34839beb93cSSam Leffler const u8 *target_ap,
34939beb93cSSam Leffler const u8 *ies, size_t ies_len)
35039beb93cSSam Leffler {
35139beb93cSSam Leffler if (sm->ctx->send_ft_action)
35239beb93cSSam Leffler return sm->ctx->send_ft_action(sm->ctx->ctx, action, target_ap,
35339beb93cSSam Leffler ies, ies_len);
35439beb93cSSam Leffler return -1;
35539beb93cSSam Leffler }
35639beb93cSSam Leffler
wpa_sm_mark_authenticated(struct wpa_sm * sm,const u8 * target_ap)357e28a4053SRui Paulo static inline int wpa_sm_mark_authenticated(struct wpa_sm *sm,
358e28a4053SRui Paulo const u8 *target_ap)
359e28a4053SRui Paulo {
360e28a4053SRui Paulo if (sm->ctx->mark_authenticated)
361e28a4053SRui Paulo return sm->ctx->mark_authenticated(sm->ctx->ctx, target_ap);
362e28a4053SRui Paulo return -1;
363e28a4053SRui Paulo }
364e28a4053SRui Paulo
wpa_sm_set_rekey_offload(struct wpa_sm * sm)365f05cddf9SRui Paulo static inline void wpa_sm_set_rekey_offload(struct wpa_sm *sm)
366f05cddf9SRui Paulo {
367f05cddf9SRui Paulo if (!sm->ctx->set_rekey_offload)
368f05cddf9SRui Paulo return;
3695b9c547cSRui Paulo sm->ctx->set_rekey_offload(sm->ctx->ctx, sm->ptk.kek, sm->ptk.kek_len,
3705b9c547cSRui Paulo sm->ptk.kck, sm->ptk.kck_len,
3715b9c547cSRui Paulo sm->rx_replay_counter);
372f05cddf9SRui Paulo }
373f05cddf9SRui Paulo
374f05cddf9SRui Paulo #ifdef CONFIG_TDLS
wpa_sm_tdls_get_capa(struct wpa_sm * sm,int * tdls_supported,int * tdls_ext_setup,int * tdls_chan_switch)375f05cddf9SRui Paulo static inline int wpa_sm_tdls_get_capa(struct wpa_sm *sm,
376f05cddf9SRui Paulo int *tdls_supported,
3775b9c547cSRui Paulo int *tdls_ext_setup,
3785b9c547cSRui Paulo int *tdls_chan_switch)
379f05cddf9SRui Paulo {
380f05cddf9SRui Paulo if (sm->ctx->tdls_get_capa)
381f05cddf9SRui Paulo return sm->ctx->tdls_get_capa(sm->ctx->ctx, tdls_supported,
3825b9c547cSRui Paulo tdls_ext_setup, tdls_chan_switch);
383f05cddf9SRui Paulo return -1;
384f05cddf9SRui Paulo }
385f05cddf9SRui Paulo
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)386f05cddf9SRui Paulo static inline int wpa_sm_send_tdls_mgmt(struct wpa_sm *sm, const u8 *dst,
387f05cddf9SRui Paulo u8 action_code, u8 dialog_token,
3885b9c547cSRui Paulo u16 status_code, u32 peer_capab,
3895b9c547cSRui Paulo int initiator, const u8 *buf,
390*a90b9d01SCy Schubert size_t len, int link_id)
391f05cddf9SRui Paulo {
392f05cddf9SRui Paulo if (sm->ctx->send_tdls_mgmt)
393f05cddf9SRui Paulo return sm->ctx->send_tdls_mgmt(sm->ctx->ctx, dst, action_code,
394f05cddf9SRui Paulo dialog_token, status_code,
3955b9c547cSRui Paulo peer_capab, initiator, buf,
396*a90b9d01SCy Schubert len, link_id);
397f05cddf9SRui Paulo return -1;
398f05cddf9SRui Paulo }
399f05cddf9SRui Paulo
wpa_sm_tdls_oper(struct wpa_sm * sm,int oper,const u8 * peer)400f05cddf9SRui Paulo static inline int wpa_sm_tdls_oper(struct wpa_sm *sm, int oper,
401f05cddf9SRui Paulo const u8 *peer)
402f05cddf9SRui Paulo {
403f05cddf9SRui Paulo if (sm->ctx->tdls_oper)
404f05cddf9SRui Paulo return sm->ctx->tdls_oper(sm->ctx->ctx, oper, peer);
405f05cddf9SRui Paulo return -1;
406f05cddf9SRui Paulo }
407f05cddf9SRui Paulo
408f05cddf9SRui Paulo 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)409f05cddf9SRui Paulo wpa_sm_tdls_peer_addset(struct wpa_sm *sm, const u8 *addr, int add,
4105b9c547cSRui Paulo u16 aid, u16 capability, const u8 *supp_rates,
4115b9c547cSRui Paulo size_t supp_rates_len,
4125b9c547cSRui Paulo const struct ieee80211_ht_capabilities *ht_capab,
4135b9c547cSRui Paulo const struct ieee80211_vht_capabilities *vht_capab,
414c1d255d3SCy Schubert const struct ieee80211_he_capabilities *he_capab,
415c1d255d3SCy Schubert size_t he_capab_len,
4164b72b91aSCy Schubert const struct ieee80211_he_6ghz_band_cap *he_6ghz_capab,
4175b9c547cSRui Paulo u8 qosinfo, int wmm, const u8 *ext_capab,
4185b9c547cSRui Paulo size_t ext_capab_len, const u8 *supp_channels,
4195b9c547cSRui Paulo size_t supp_channels_len, const u8 *supp_oper_classes,
420*a90b9d01SCy Schubert size_t supp_oper_classes_len,
421*a90b9d01SCy Schubert const struct ieee80211_eht_capabilities *eht_capab,
422*a90b9d01SCy Schubert size_t eht_capab_len, int mld_link_id)
423f05cddf9SRui Paulo {
424f05cddf9SRui Paulo if (sm->ctx->tdls_peer_addset)
425f05cddf9SRui Paulo return sm->ctx->tdls_peer_addset(sm->ctx->ctx, addr, add,
4265b9c547cSRui Paulo aid, capability, supp_rates,
4275b9c547cSRui Paulo supp_rates_len, ht_capab,
428c1d255d3SCy Schubert vht_capab,
429c1d255d3SCy Schubert he_capab, he_capab_len,
4304b72b91aSCy Schubert he_6ghz_capab, qosinfo, wmm,
4315b9c547cSRui Paulo ext_capab, ext_capab_len,
4325b9c547cSRui Paulo supp_channels,
4335b9c547cSRui Paulo supp_channels_len,
4345b9c547cSRui Paulo supp_oper_classes,
435*a90b9d01SCy Schubert supp_oper_classes_len,
436*a90b9d01SCy Schubert eht_capab, eht_capab_len,
437*a90b9d01SCy Schubert mld_link_id);
4385b9c547cSRui Paulo return -1;
4395b9c547cSRui Paulo }
4405b9c547cSRui Paulo
4415b9c547cSRui Paulo 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)4425b9c547cSRui Paulo wpa_sm_tdls_enable_channel_switch(struct wpa_sm *sm, const u8 *addr,
4435b9c547cSRui Paulo u8 oper_class,
4445b9c547cSRui Paulo const struct hostapd_freq_params *freq_params)
4455b9c547cSRui Paulo {
4465b9c547cSRui Paulo if (sm->ctx->tdls_enable_channel_switch)
4475b9c547cSRui Paulo return sm->ctx->tdls_enable_channel_switch(sm->ctx->ctx, addr,
4485b9c547cSRui Paulo oper_class,
4495b9c547cSRui Paulo freq_params);
4505b9c547cSRui Paulo return -1;
4515b9c547cSRui Paulo }
4525b9c547cSRui Paulo
4535b9c547cSRui Paulo static inline int
wpa_sm_tdls_disable_channel_switch(struct wpa_sm * sm,const u8 * addr)4545b9c547cSRui Paulo wpa_sm_tdls_disable_channel_switch(struct wpa_sm *sm, const u8 *addr)
4555b9c547cSRui Paulo {
4565b9c547cSRui Paulo if (sm->ctx->tdls_disable_channel_switch)
4575b9c547cSRui Paulo return sm->ctx->tdls_disable_channel_switch(sm->ctx->ctx, addr);
458f05cddf9SRui Paulo return -1;
459f05cddf9SRui Paulo }
460f05cddf9SRui Paulo #endif /* CONFIG_TDLS */
46139beb93cSSam Leffler
wpa_sm_key_mgmt_set_pmk(struct wpa_sm * sm,const u8 * pmk,size_t pmk_len)4625b9c547cSRui Paulo static inline int wpa_sm_key_mgmt_set_pmk(struct wpa_sm *sm,
4635b9c547cSRui Paulo const u8 *pmk, size_t pmk_len)
4645b9c547cSRui Paulo {
4655b9c547cSRui Paulo if (!sm->ctx->key_mgmt_set_pmk)
4665b9c547cSRui Paulo return -1;
4675b9c547cSRui Paulo return sm->ctx->key_mgmt_set_pmk(sm->ctx->ctx, pmk, pmk_len);
4685b9c547cSRui Paulo }
4695b9c547cSRui Paulo
wpa_sm_fils_hlp_rx(struct wpa_sm * sm,const u8 * dst,const u8 * src,const u8 * pkt,size_t pkt_len)47085732ac8SCy Schubert static inline void wpa_sm_fils_hlp_rx(struct wpa_sm *sm,
47185732ac8SCy Schubert const u8 *dst, const u8 *src,
47285732ac8SCy Schubert const u8 *pkt, size_t pkt_len)
47385732ac8SCy Schubert {
47485732ac8SCy Schubert if (sm->ctx->fils_hlp_rx)
47585732ac8SCy Schubert sm->ctx->fils_hlp_rx(sm->ctx->ctx, dst, src, pkt, pkt_len);
47685732ac8SCy Schubert }
47785732ac8SCy Schubert
wpa_sm_channel_info(struct wpa_sm * sm,struct wpa_channel_info * ci)4784bc52338SCy Schubert static inline int wpa_sm_channel_info(struct wpa_sm *sm,
4794bc52338SCy Schubert struct wpa_channel_info *ci)
4804bc52338SCy Schubert {
4814bc52338SCy Schubert if (!sm->ctx->channel_info)
4824bc52338SCy Schubert return -1;
4834bc52338SCy Schubert return sm->ctx->channel_info(sm->ctx->ctx, ci);
4844bc52338SCy Schubert }
4854bc52338SCy Schubert
wpa_sm_transition_disable(struct wpa_sm * sm,u8 bitmap)486c1d255d3SCy Schubert static inline void wpa_sm_transition_disable(struct wpa_sm *sm, u8 bitmap)
487c1d255d3SCy Schubert {
488c1d255d3SCy Schubert if (sm->ctx->transition_disable)
489c1d255d3SCy Schubert sm->ctx->transition_disable(sm->ctx->ctx, bitmap);
490c1d255d3SCy Schubert }
491c1d255d3SCy Schubert
wpa_sm_store_ptk(struct wpa_sm * sm,const u8 * addr,int cipher,u32 life_time,struct wpa_ptk * ptk)492c1d255d3SCy Schubert static inline void wpa_sm_store_ptk(struct wpa_sm *sm,
493*a90b9d01SCy Schubert const u8 *addr, int cipher,
494c1d255d3SCy Schubert u32 life_time, struct wpa_ptk *ptk)
495c1d255d3SCy Schubert {
496c1d255d3SCy Schubert if (sm->ctx->store_ptk)
497c1d255d3SCy Schubert sm->ctx->store_ptk(sm->ctx->ctx, addr, cipher, life_time,
498c1d255d3SCy Schubert ptk);
499c1d255d3SCy Schubert }
50085732ac8SCy Schubert
501*a90b9d01SCy Schubert #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)502*a90b9d01SCy Schubert static inline int wpa_sm_set_ltf_keyseed(struct wpa_sm *sm, const u8 *own_addr,
503*a90b9d01SCy Schubert const u8 *peer_addr,
504*a90b9d01SCy Schubert size_t ltf_keyseed_len,
505*a90b9d01SCy Schubert const u8 *ltf_keyseed)
506*a90b9d01SCy Schubert {
507*a90b9d01SCy Schubert WPA_ASSERT(sm->ctx->set_ltf_keyseed);
508*a90b9d01SCy Schubert return sm->ctx->set_ltf_keyseed(sm->ctx->ctx, own_addr, peer_addr,
509*a90b9d01SCy Schubert ltf_keyseed_len, ltf_keyseed);
510*a90b9d01SCy Schubert }
511*a90b9d01SCy Schubert #endif /* CONFIG_PASN */
512*a90b9d01SCy Schubert
513*a90b9d01SCy Schubert static inline void
wpa_sm_notify_pmksa_cache_entry(struct wpa_sm * sm,struct rsn_pmksa_cache_entry * entry)514*a90b9d01SCy Schubert wpa_sm_notify_pmksa_cache_entry(struct wpa_sm *sm,
515*a90b9d01SCy Schubert struct rsn_pmksa_cache_entry *entry)
516*a90b9d01SCy Schubert {
517*a90b9d01SCy Schubert if (sm->ctx->notify_pmksa_cache_entry)
518*a90b9d01SCy Schubert sm->ctx->notify_pmksa_cache_entry(sm->ctx->ctx, entry);
519*a90b9d01SCy Schubert }
520*a90b9d01SCy Schubert
wpa_sm_ssid_verified(struct wpa_sm * sm)521*a90b9d01SCy Schubert static inline void wpa_sm_ssid_verified(struct wpa_sm *sm)
522*a90b9d01SCy Schubert {
523*a90b9d01SCy Schubert if (sm->ctx->ssid_verified)
524*a90b9d01SCy Schubert sm->ctx->ssid_verified(sm->ctx->ctx);
525*a90b9d01SCy Schubert }
526*a90b9d01SCy Schubert
52785732ac8SCy Schubert int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk,
52839beb93cSSam Leffler int ver, const u8 *dest, u16 proto,
52939beb93cSSam Leffler u8 *msg, size_t msg_len, u8 *key_mic);
53039beb93cSSam Leffler int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst,
53139beb93cSSam Leffler const struct wpa_eapol_key *key,
53239beb93cSSam Leffler int ver, const u8 *nonce,
53339beb93cSSam Leffler const u8 *wpa_ie, size_t wpa_ie_len,
53439beb93cSSam Leffler struct wpa_ptk *ptk);
53539beb93cSSam Leffler int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst,
53639beb93cSSam Leffler const struct wpa_eapol_key *key,
53739beb93cSSam Leffler u16 ver, u16 key_info,
53839beb93cSSam Leffler struct wpa_ptk *ptk);
53939beb93cSSam Leffler
54039beb93cSSam Leffler int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
5415b9c547cSRui Paulo const struct wpa_eapol_key *key, struct wpa_ptk *ptk);
54239beb93cSSam Leffler
543f05cddf9SRui Paulo void wpa_tdls_assoc(struct wpa_sm *sm);
544f05cddf9SRui Paulo void wpa_tdls_disassoc(struct wpa_sm *sm);
545f05cddf9SRui Paulo
54639beb93cSSam Leffler #endif /* WPA_I_H */
547