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 17*c1d255d3SCy Schubert struct pasn_ft_r1kh { 18*c1d255d3SCy Schubert u8 bssid[ETH_ALEN]; 19*c1d255d3SCy Schubert u8 r1kh_id[FT_R1KH_ID_LEN]; 20*c1d255d3SCy Schubert }; 21*c1d255d3SCy 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; 305b9c547cSRui Paulo unsigned int msg_3_of_4_ok:1; 3139beb93cSSam Leffler u8 snonce[WPA_NONCE_LEN]; 3239beb93cSSam Leffler u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */ 3339beb93cSSam Leffler int renew_snonce; 3439beb93cSSam Leffler u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN]; 3539beb93cSSam Leffler int rx_replay_counter_set; 3639beb93cSSam Leffler u8 request_counter[WPA_REPLAY_COUNTER_LEN]; 37a2063804SGordon Tetlow struct wpa_gtk gtk; 38a2063804SGordon Tetlow struct wpa_gtk gtk_wnm_sleep; 39a2063804SGordon Tetlow struct wpa_igtk igtk; 40a2063804SGordon Tetlow struct wpa_igtk igtk_wnm_sleep; 41*c1d255d3SCy Schubert struct wpa_bigtk bigtk; 42*c1d255d3SCy Schubert struct wpa_bigtk bigtk_wnm_sleep; 4339beb93cSSam Leffler 4439beb93cSSam Leffler struct eapol_sm *eapol; /* EAPOL state machine from upper level code */ 4539beb93cSSam Leffler 4639beb93cSSam Leffler struct rsn_pmksa_cache *pmksa; /* PMKSA cache */ 4739beb93cSSam Leffler struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */ 48e28a4053SRui Paulo struct dl_list pmksa_candidates; 4939beb93cSSam Leffler 5039beb93cSSam Leffler struct l2_packet_data *l2_preauth; 5139beb93cSSam Leffler struct l2_packet_data *l2_preauth_br; 52f05cddf9SRui Paulo struct l2_packet_data *l2_tdls; 5339beb93cSSam Leffler u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or 5439beb93cSSam Leffler * 00:00:00:00:00:00 if no pre-auth is 5539beb93cSSam Leffler * in progress */ 5639beb93cSSam Leffler struct eapol_sm *preauth_eapol; 5739beb93cSSam Leffler 5839beb93cSSam Leffler struct wpa_sm_ctx *ctx; 5939beb93cSSam Leffler 6039beb93cSSam Leffler void *scard_ctx; /* context for smartcard callbacks */ 6139beb93cSSam Leffler int fast_reauth; /* whether EAP fast re-authentication is enabled */ 6239beb93cSSam Leffler 6339beb93cSSam Leffler void *network_ctx; 6439beb93cSSam Leffler int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */ 6539beb93cSSam Leffler int proactive_key_caching; 6639beb93cSSam Leffler int eap_workaround; 6739beb93cSSam Leffler void *eap_conf_ctx; 6839beb93cSSam Leffler u8 ssid[32]; 6939beb93cSSam Leffler size_t ssid_len; 7039beb93cSSam Leffler int wpa_ptk_rekey; 71*c1d255d3SCy Schubert int wpa_deny_ptk0_rekey:1; 725b9c547cSRui Paulo int p2p; 73780fb4a2SCy Schubert int wpa_rsc_relaxation; 74*c1d255d3SCy Schubert int owe_ptk_workaround; 75*c1d255d3SCy Schubert int beacon_prot; 76*c1d255d3SCy Schubert int ext_key_id; /* whether Extended Key ID is enabled */ 77*c1d255d3SCy Schubert int use_ext_key_id; /* whether Extended Key ID has been detected 78*c1d255d3SCy Schubert * to be used */ 79*c1d255d3SCy Schubert int keyidx_active; /* Key ID for the active TK */ 80*c1d255d3SCy Schubert 81*c1d255d3SCy Schubert /* 82*c1d255d3SCy Schubert * If set Key Derivation Key should be derived as part of PMK to 83*c1d255d3SCy Schubert * PTK derivation regardless of advertised capabilities. 84*c1d255d3SCy Schubert */ 85*c1d255d3SCy Schubert bool force_kdk_derivation; 8639beb93cSSam Leffler 8739beb93cSSam Leffler u8 own_addr[ETH_ALEN]; 8839beb93cSSam Leffler const char *ifname; 8939beb93cSSam Leffler const char *bridge_ifname; 9039beb93cSSam Leffler u8 bssid[ETH_ALEN]; 9139beb93cSSam Leffler 9239beb93cSSam Leffler unsigned int dot11RSNAConfigPMKLifetime; 9339beb93cSSam Leffler unsigned int dot11RSNAConfigPMKReauthThreshold; 9439beb93cSSam Leffler unsigned int dot11RSNAConfigSATimeout; 9539beb93cSSam Leffler 9639beb93cSSam Leffler unsigned int dot11RSNA4WayHandshakeFailures; 9739beb93cSSam Leffler 9839beb93cSSam Leffler /* Selected configuration (based on Beacon/ProbeResp WPA IE) */ 9939beb93cSSam Leffler unsigned int proto; 10039beb93cSSam Leffler unsigned int pairwise_cipher; 10139beb93cSSam Leffler unsigned int group_cipher; 10239beb93cSSam Leffler unsigned int key_mgmt; 10339beb93cSSam Leffler unsigned int mgmt_group_cipher; 10439beb93cSSam Leffler 10539beb93cSSam Leffler int rsn_enabled; /* Whether RSN is enabled in configuration */ 106e28a4053SRui Paulo int mfp; /* 0 = disabled, 1 = optional, 2 = mandatory */ 1074bc52338SCy Schubert int ocv; /* Operating Channel Validation */ 108*c1d255d3SCy Schubert int sae_pwe; /* SAE PWE generation options */ 109*c1d255d3SCy Schubert 110*c1d255d3SCy Schubert unsigned int sae_pk:1; /* whether SAE-PK is used */ 111*c1d255d3SCy Schubert unsigned int secure_ltf:1; 112*c1d255d3SCy Schubert unsigned int secure_rtt:1; 113*c1d255d3SCy Schubert unsigned int prot_range_neg:1; 11439beb93cSSam Leffler 11539beb93cSSam Leffler u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */ 11639beb93cSSam Leffler size_t assoc_wpa_ie_len; 117*c1d255d3SCy Schubert u8 *assoc_rsnxe; /* Own RSNXE from (Re)AssocReq */ 118*c1d255d3SCy Schubert size_t assoc_rsnxe_len; 119*c1d255d3SCy Schubert u8 *ap_wpa_ie, *ap_rsn_ie, *ap_rsnxe; 120*c1d255d3SCy Schubert size_t ap_wpa_ie_len, ap_rsn_ie_len, ap_rsnxe_len; 12139beb93cSSam Leffler 122f05cddf9SRui Paulo #ifdef CONFIG_TDLS 123f05cddf9SRui Paulo struct wpa_tdls_peer *tdls; 124f05cddf9SRui Paulo int tdls_prohibited; 1255b9c547cSRui Paulo int tdls_chan_switch_prohibited; 126f05cddf9SRui Paulo int tdls_disabled; 127f05cddf9SRui Paulo 128f05cddf9SRui Paulo /* The driver supports TDLS */ 129f05cddf9SRui Paulo int tdls_supported; 130f05cddf9SRui Paulo 131f05cddf9SRui Paulo /* 132f05cddf9SRui Paulo * The driver requires explicit discovery/setup/teardown frames sent 133f05cddf9SRui Paulo * to it via tdls_mgmt. 134f05cddf9SRui Paulo */ 135f05cddf9SRui Paulo int tdls_external_setup; 1365b9c547cSRui Paulo 1375b9c547cSRui Paulo /* The driver supports TDLS channel switching */ 1385b9c547cSRui Paulo int tdls_chan_switch; 139f05cddf9SRui Paulo #endif /* CONFIG_TDLS */ 14039beb93cSSam Leffler 14139beb93cSSam Leffler #ifdef CONFIG_IEEE80211R 14285732ac8SCy Schubert u8 xxkey[PMK_LEN_MAX]; /* PSK or the second 256 bits of MSK, or the 14385732ac8SCy Schubert * first 384 bits of MSK */ 14439beb93cSSam Leffler size_t xxkey_len; 14585732ac8SCy Schubert u8 pmk_r0[PMK_LEN_MAX]; 14685732ac8SCy Schubert size_t pmk_r0_len; 14739beb93cSSam Leffler u8 pmk_r0_name[WPA_PMK_NAME_LEN]; 14885732ac8SCy Schubert u8 pmk_r1[PMK_LEN_MAX]; 14985732ac8SCy Schubert size_t pmk_r1_len; 15039beb93cSSam Leffler u8 pmk_r1_name[WPA_PMK_NAME_LEN]; 15139beb93cSSam Leffler u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN]; 15239beb93cSSam Leffler u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; 15339beb93cSSam Leffler size_t r0kh_id_len; 15439beb93cSSam Leffler u8 r1kh_id[FT_R1KH_ID_LEN]; 1554bc52338SCy Schubert unsigned int ft_completed:1; 1564bc52338SCy Schubert unsigned int ft_reassoc_completed:1; 1574bc52338SCy Schubert unsigned int ft_protocol:1; 15839beb93cSSam Leffler int over_the_ds_in_progress; 15939beb93cSSam Leffler u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */ 160e28a4053SRui Paulo int set_ptk_after_assoc; 161e28a4053SRui Paulo u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */ 162e28a4053SRui Paulo u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */ 163e28a4053SRui Paulo size_t assoc_resp_ies_len; 164*c1d255d3SCy Schubert #ifdef CONFIG_PASN 165*c1d255d3SCy Schubert /* 166*c1d255d3SCy Schubert * Currently, the WPA state machine stores the PMK-R1, PMK-R1-Name and 167*c1d255d3SCy Schubert * R1KH-ID only for the current association. As PMK-R1 is required to 168*c1d255d3SCy Schubert * perform PASN authentication with FT, store the R1KH-ID for previous 169*c1d255d3SCy Schubert * associations, which would later be used to derive the PMK-R1 as part 170*c1d255d3SCy Schubert * of the PASN authentication flow. 171*c1d255d3SCy Schubert */ 172*c1d255d3SCy Schubert struct pasn_ft_r1kh *pasn_r1kh; 173*c1d255d3SCy Schubert unsigned int n_pasn_r1kh; 174*c1d255d3SCy Schubert #endif /* CONFIG_PASN */ 17539beb93cSSam Leffler #endif /* CONFIG_IEEE80211R */ 1765b9c547cSRui Paulo 1775b9c547cSRui Paulo #ifdef CONFIG_P2P 1785b9c547cSRui Paulo u8 p2p_ip_addr[3 * 4]; 1795b9c547cSRui Paulo #endif /* CONFIG_P2P */ 180780fb4a2SCy Schubert 181780fb4a2SCy Schubert #ifdef CONFIG_TESTING_OPTIONS 182780fb4a2SCy Schubert struct wpabuf *test_assoc_ie; 183*c1d255d3SCy Schubert int ft_rsnxe_used; 184*c1d255d3SCy Schubert unsigned int oci_freq_override_eapol; 185*c1d255d3SCy Schubert unsigned int oci_freq_override_eapol_g2; 186*c1d255d3SCy Schubert unsigned int oci_freq_override_ft_assoc; 187*c1d255d3SCy Schubert unsigned int oci_freq_override_fils_assoc; 188780fb4a2SCy Schubert #endif /* CONFIG_TESTING_OPTIONS */ 18985732ac8SCy Schubert 19085732ac8SCy Schubert #ifdef CONFIG_FILS 19185732ac8SCy Schubert u8 fils_nonce[FILS_NONCE_LEN]; 19285732ac8SCy Schubert u8 fils_session[FILS_SESSION_LEN]; 19385732ac8SCy Schubert u8 fils_anonce[FILS_NONCE_LEN]; 19485732ac8SCy Schubert u8 fils_key_auth_ap[FILS_MAX_KEY_AUTH_LEN]; 19585732ac8SCy Schubert u8 fils_key_auth_sta[FILS_MAX_KEY_AUTH_LEN]; 19685732ac8SCy Schubert size_t fils_key_auth_len; 19785732ac8SCy Schubert unsigned int fils_completed:1; 19885732ac8SCy Schubert unsigned int fils_erp_pmkid_set:1; 19985732ac8SCy Schubert unsigned int fils_cache_id_set:1; 20085732ac8SCy Schubert u8 fils_erp_pmkid[PMKID_LEN]; 20185732ac8SCy Schubert u8 fils_cache_id[FILS_CACHE_ID_LEN]; 20285732ac8SCy Schubert struct crypto_ecdh *fils_ecdh; 20385732ac8SCy Schubert int fils_dh_group; 20485732ac8SCy Schubert size_t fils_dh_elem_len; 20585732ac8SCy Schubert struct wpabuf *fils_ft_ies; 20685732ac8SCy Schubert u8 fils_ft[FILS_FT_MAX_LEN]; 20785732ac8SCy Schubert size_t fils_ft_len; 20885732ac8SCy Schubert #endif /* CONFIG_FILS */ 20985732ac8SCy Schubert 21085732ac8SCy Schubert #ifdef CONFIG_OWE 21185732ac8SCy Schubert struct crypto_ecdh *owe_ecdh; 21285732ac8SCy Schubert u16 owe_group; 21385732ac8SCy Schubert #endif /* CONFIG_OWE */ 2144bc52338SCy Schubert 2154bc52338SCy Schubert #ifdef CONFIG_DPP2 2164bc52338SCy Schubert struct wpabuf *dpp_z; 217*c1d255d3SCy Schubert int dpp_pfs; 2184bc52338SCy Schubert #endif /* CONFIG_DPP2 */ 21939beb93cSSam Leffler }; 22039beb93cSSam Leffler 22139beb93cSSam Leffler 222e28a4053SRui Paulo static inline void wpa_sm_set_state(struct wpa_sm *sm, enum wpa_states state) 22339beb93cSSam Leffler { 22439beb93cSSam Leffler WPA_ASSERT(sm->ctx->set_state); 22539beb93cSSam Leffler sm->ctx->set_state(sm->ctx->ctx, state); 22639beb93cSSam Leffler } 22739beb93cSSam Leffler 228e28a4053SRui Paulo static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm) 22939beb93cSSam Leffler { 23039beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_state); 23139beb93cSSam Leffler return sm->ctx->get_state(sm->ctx->ctx); 23239beb93cSSam Leffler } 23339beb93cSSam Leffler 234206b73d0SCy Schubert static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, u16 reason_code) 23539beb93cSSam Leffler { 23639beb93cSSam Leffler WPA_ASSERT(sm->ctx->deauthenticate); 23739beb93cSSam Leffler sm->ctx->deauthenticate(sm->ctx->ctx, reason_code); 23839beb93cSSam Leffler } 23939beb93cSSam Leffler 240e28a4053SRui Paulo static inline int wpa_sm_set_key(struct wpa_sm *sm, enum wpa_alg alg, 24139beb93cSSam Leffler const u8 *addr, int key_idx, int set_tx, 24239beb93cSSam Leffler const u8 *seq, size_t seq_len, 243*c1d255d3SCy Schubert const u8 *key, size_t key_len, 244*c1d255d3SCy Schubert enum key_flag key_flag) 24539beb93cSSam Leffler { 24639beb93cSSam Leffler WPA_ASSERT(sm->ctx->set_key); 24739beb93cSSam Leffler return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx, 248*c1d255d3SCy Schubert seq, seq_len, key, key_len, key_flag); 249*c1d255d3SCy Schubert } 250*c1d255d3SCy Schubert 251*c1d255d3SCy Schubert static inline void wpa_sm_reconnect(struct wpa_sm *sm) 252*c1d255d3SCy Schubert { 253*c1d255d3SCy Schubert WPA_ASSERT(sm->ctx->reconnect); 254*c1d255d3SCy Schubert sm->ctx->reconnect(sm->ctx->ctx); 25539beb93cSSam Leffler } 25639beb93cSSam Leffler 25739beb93cSSam Leffler static inline void * wpa_sm_get_network_ctx(struct wpa_sm *sm) 25839beb93cSSam Leffler { 25939beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_network_ctx); 26039beb93cSSam Leffler return sm->ctx->get_network_ctx(sm->ctx->ctx); 26139beb93cSSam Leffler } 26239beb93cSSam Leffler 26339beb93cSSam Leffler static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid) 26439beb93cSSam Leffler { 26539beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_bssid); 26639beb93cSSam Leffler return sm->ctx->get_bssid(sm->ctx->ctx, bssid); 26739beb93cSSam Leffler } 26839beb93cSSam Leffler 26939beb93cSSam Leffler static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest, 27039beb93cSSam Leffler u16 proto, const u8 *buf, size_t len) 27139beb93cSSam Leffler { 27239beb93cSSam Leffler WPA_ASSERT(sm->ctx->ether_send); 27339beb93cSSam Leffler return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len); 27439beb93cSSam Leffler } 27539beb93cSSam Leffler 27639beb93cSSam Leffler static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm) 27739beb93cSSam Leffler { 27839beb93cSSam Leffler WPA_ASSERT(sm->ctx->get_beacon_ie); 27939beb93cSSam Leffler return sm->ctx->get_beacon_ie(sm->ctx->ctx); 28039beb93cSSam Leffler } 28139beb93cSSam Leffler 28239beb93cSSam Leffler static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm) 28339beb93cSSam Leffler { 28439beb93cSSam Leffler WPA_ASSERT(sm->ctx->cancel_auth_timeout); 28539beb93cSSam Leffler sm->ctx->cancel_auth_timeout(sm->ctx->ctx); 28639beb93cSSam Leffler } 28739beb93cSSam Leffler 28839beb93cSSam Leffler static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type, 28939beb93cSSam Leffler const void *data, u16 data_len, 29039beb93cSSam Leffler size_t *msg_len, void **data_pos) 29139beb93cSSam Leffler { 29239beb93cSSam Leffler WPA_ASSERT(sm->ctx->alloc_eapol); 29339beb93cSSam Leffler return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len, 29439beb93cSSam Leffler msg_len, data_pos); 29539beb93cSSam Leffler } 29639beb93cSSam Leffler 29785732ac8SCy Schubert static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, void *network_ctx, 29885732ac8SCy Schubert const u8 *bssid, const u8 *pmkid, 29985732ac8SCy Schubert const u8 *cache_id, const u8 *pmk, 300*c1d255d3SCy Schubert size_t pmk_len, u32 pmk_lifetime, 301*c1d255d3SCy Schubert u8 pmk_reauth_threshold, int akmp) 30239beb93cSSam Leffler { 30339beb93cSSam Leffler WPA_ASSERT(sm->ctx->add_pmkid); 30485732ac8SCy Schubert return sm->ctx->add_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid, 305*c1d255d3SCy Schubert cache_id, pmk, pmk_len, pmk_lifetime, 306*c1d255d3SCy Schubert pmk_reauth_threshold, akmp); 30739beb93cSSam Leffler } 30839beb93cSSam Leffler 30985732ac8SCy Schubert static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, void *network_ctx, 31085732ac8SCy Schubert const u8 *bssid, const u8 *pmkid, 31185732ac8SCy Schubert const u8 *cache_id) 31239beb93cSSam Leffler { 31339beb93cSSam Leffler WPA_ASSERT(sm->ctx->remove_pmkid); 31485732ac8SCy Schubert return sm->ctx->remove_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid, 31585732ac8SCy Schubert cache_id); 31639beb93cSSam Leffler } 31739beb93cSSam Leffler 31839beb93cSSam Leffler static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr, 31939beb93cSSam Leffler int protect_type, int key_type) 32039beb93cSSam Leffler { 32139beb93cSSam Leffler WPA_ASSERT(sm->ctx->mlme_setprotection); 32239beb93cSSam Leffler return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type, 32339beb93cSSam Leffler key_type); 32439beb93cSSam Leffler } 32539beb93cSSam Leffler 32639beb93cSSam Leffler static inline int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md, 32739beb93cSSam Leffler const u8 *ies, size_t ies_len) 32839beb93cSSam Leffler { 32939beb93cSSam Leffler if (sm->ctx->update_ft_ies) 33039beb93cSSam Leffler return sm->ctx->update_ft_ies(sm->ctx->ctx, md, ies, ies_len); 33139beb93cSSam Leffler return -1; 33239beb93cSSam Leffler } 33339beb93cSSam Leffler 33439beb93cSSam Leffler static inline int wpa_sm_send_ft_action(struct wpa_sm *sm, u8 action, 33539beb93cSSam Leffler const u8 *target_ap, 33639beb93cSSam Leffler const u8 *ies, size_t ies_len) 33739beb93cSSam Leffler { 33839beb93cSSam Leffler if (sm->ctx->send_ft_action) 33939beb93cSSam Leffler return sm->ctx->send_ft_action(sm->ctx->ctx, action, target_ap, 34039beb93cSSam Leffler ies, ies_len); 34139beb93cSSam Leffler return -1; 34239beb93cSSam Leffler } 34339beb93cSSam Leffler 344e28a4053SRui Paulo static inline int wpa_sm_mark_authenticated(struct wpa_sm *sm, 345e28a4053SRui Paulo const u8 *target_ap) 346e28a4053SRui Paulo { 347e28a4053SRui Paulo if (sm->ctx->mark_authenticated) 348e28a4053SRui Paulo return sm->ctx->mark_authenticated(sm->ctx->ctx, target_ap); 349e28a4053SRui Paulo return -1; 350e28a4053SRui Paulo } 351e28a4053SRui Paulo 352f05cddf9SRui Paulo static inline void wpa_sm_set_rekey_offload(struct wpa_sm *sm) 353f05cddf9SRui Paulo { 354f05cddf9SRui Paulo if (!sm->ctx->set_rekey_offload) 355f05cddf9SRui Paulo return; 3565b9c547cSRui Paulo sm->ctx->set_rekey_offload(sm->ctx->ctx, sm->ptk.kek, sm->ptk.kek_len, 3575b9c547cSRui Paulo sm->ptk.kck, sm->ptk.kck_len, 3585b9c547cSRui Paulo sm->rx_replay_counter); 359f05cddf9SRui Paulo } 360f05cddf9SRui Paulo 361f05cddf9SRui Paulo #ifdef CONFIG_TDLS 362f05cddf9SRui Paulo static inline int wpa_sm_tdls_get_capa(struct wpa_sm *sm, 363f05cddf9SRui Paulo int *tdls_supported, 3645b9c547cSRui Paulo int *tdls_ext_setup, 3655b9c547cSRui Paulo int *tdls_chan_switch) 366f05cddf9SRui Paulo { 367f05cddf9SRui Paulo if (sm->ctx->tdls_get_capa) 368f05cddf9SRui Paulo return sm->ctx->tdls_get_capa(sm->ctx->ctx, tdls_supported, 3695b9c547cSRui Paulo tdls_ext_setup, tdls_chan_switch); 370f05cddf9SRui Paulo return -1; 371f05cddf9SRui Paulo } 372f05cddf9SRui Paulo 373f05cddf9SRui Paulo static inline int wpa_sm_send_tdls_mgmt(struct wpa_sm *sm, const u8 *dst, 374f05cddf9SRui Paulo u8 action_code, u8 dialog_token, 3755b9c547cSRui Paulo u16 status_code, u32 peer_capab, 3765b9c547cSRui Paulo int initiator, const u8 *buf, 377f05cddf9SRui Paulo size_t len) 378f05cddf9SRui Paulo { 379f05cddf9SRui Paulo if (sm->ctx->send_tdls_mgmt) 380f05cddf9SRui Paulo return sm->ctx->send_tdls_mgmt(sm->ctx->ctx, dst, action_code, 381f05cddf9SRui Paulo dialog_token, status_code, 3825b9c547cSRui Paulo peer_capab, initiator, buf, 3835b9c547cSRui Paulo len); 384f05cddf9SRui Paulo return -1; 385f05cddf9SRui Paulo } 386f05cddf9SRui Paulo 387f05cddf9SRui Paulo static inline int wpa_sm_tdls_oper(struct wpa_sm *sm, int oper, 388f05cddf9SRui Paulo const u8 *peer) 389f05cddf9SRui Paulo { 390f05cddf9SRui Paulo if (sm->ctx->tdls_oper) 391f05cddf9SRui Paulo return sm->ctx->tdls_oper(sm->ctx->ctx, oper, peer); 392f05cddf9SRui Paulo return -1; 393f05cddf9SRui Paulo } 394f05cddf9SRui Paulo 395f05cddf9SRui Paulo static inline int 396f05cddf9SRui Paulo wpa_sm_tdls_peer_addset(struct wpa_sm *sm, const u8 *addr, int add, 3975b9c547cSRui Paulo u16 aid, u16 capability, const u8 *supp_rates, 3985b9c547cSRui Paulo size_t supp_rates_len, 3995b9c547cSRui Paulo const struct ieee80211_ht_capabilities *ht_capab, 4005b9c547cSRui Paulo const struct ieee80211_vht_capabilities *vht_capab, 401*c1d255d3SCy Schubert const struct ieee80211_he_capabilities *he_capab, 402*c1d255d3SCy Schubert size_t he_capab_len, 4035b9c547cSRui Paulo u8 qosinfo, int wmm, const u8 *ext_capab, 4045b9c547cSRui Paulo size_t ext_capab_len, const u8 *supp_channels, 4055b9c547cSRui Paulo size_t supp_channels_len, const u8 *supp_oper_classes, 4065b9c547cSRui Paulo size_t supp_oper_classes_len) 407f05cddf9SRui Paulo { 408f05cddf9SRui Paulo if (sm->ctx->tdls_peer_addset) 409f05cddf9SRui Paulo return sm->ctx->tdls_peer_addset(sm->ctx->ctx, addr, add, 4105b9c547cSRui Paulo aid, capability, supp_rates, 4115b9c547cSRui Paulo supp_rates_len, ht_capab, 412*c1d255d3SCy Schubert vht_capab, 413*c1d255d3SCy Schubert he_capab, he_capab_len, 414*c1d255d3SCy Schubert qosinfo, wmm, 4155b9c547cSRui Paulo ext_capab, ext_capab_len, 4165b9c547cSRui Paulo supp_channels, 4175b9c547cSRui Paulo supp_channels_len, 4185b9c547cSRui Paulo supp_oper_classes, 4195b9c547cSRui Paulo supp_oper_classes_len); 4205b9c547cSRui Paulo return -1; 4215b9c547cSRui Paulo } 4225b9c547cSRui Paulo 4235b9c547cSRui Paulo static inline int 4245b9c547cSRui Paulo wpa_sm_tdls_enable_channel_switch(struct wpa_sm *sm, const u8 *addr, 4255b9c547cSRui Paulo u8 oper_class, 4265b9c547cSRui Paulo const struct hostapd_freq_params *freq_params) 4275b9c547cSRui Paulo { 4285b9c547cSRui Paulo if (sm->ctx->tdls_enable_channel_switch) 4295b9c547cSRui Paulo return sm->ctx->tdls_enable_channel_switch(sm->ctx->ctx, addr, 4305b9c547cSRui Paulo oper_class, 4315b9c547cSRui Paulo freq_params); 4325b9c547cSRui Paulo return -1; 4335b9c547cSRui Paulo } 4345b9c547cSRui Paulo 4355b9c547cSRui Paulo static inline int 4365b9c547cSRui Paulo wpa_sm_tdls_disable_channel_switch(struct wpa_sm *sm, const u8 *addr) 4375b9c547cSRui Paulo { 4385b9c547cSRui Paulo if (sm->ctx->tdls_disable_channel_switch) 4395b9c547cSRui Paulo return sm->ctx->tdls_disable_channel_switch(sm->ctx->ctx, addr); 440f05cddf9SRui Paulo return -1; 441f05cddf9SRui Paulo } 442f05cddf9SRui Paulo #endif /* CONFIG_TDLS */ 44339beb93cSSam Leffler 4445b9c547cSRui Paulo static inline int wpa_sm_key_mgmt_set_pmk(struct wpa_sm *sm, 4455b9c547cSRui Paulo const u8 *pmk, size_t pmk_len) 4465b9c547cSRui Paulo { 4475b9c547cSRui Paulo if (!sm->ctx->key_mgmt_set_pmk) 4485b9c547cSRui Paulo return -1; 4495b9c547cSRui Paulo return sm->ctx->key_mgmt_set_pmk(sm->ctx->ctx, pmk, pmk_len); 4505b9c547cSRui Paulo } 4515b9c547cSRui Paulo 45285732ac8SCy Schubert static inline void wpa_sm_fils_hlp_rx(struct wpa_sm *sm, 45385732ac8SCy Schubert const u8 *dst, const u8 *src, 45485732ac8SCy Schubert const u8 *pkt, size_t pkt_len) 45585732ac8SCy Schubert { 45685732ac8SCy Schubert if (sm->ctx->fils_hlp_rx) 45785732ac8SCy Schubert sm->ctx->fils_hlp_rx(sm->ctx->ctx, dst, src, pkt, pkt_len); 45885732ac8SCy Schubert } 45985732ac8SCy Schubert 4604bc52338SCy Schubert static inline int wpa_sm_channel_info(struct wpa_sm *sm, 4614bc52338SCy Schubert struct wpa_channel_info *ci) 4624bc52338SCy Schubert { 4634bc52338SCy Schubert if (!sm->ctx->channel_info) 4644bc52338SCy Schubert return -1; 4654bc52338SCy Schubert return sm->ctx->channel_info(sm->ctx->ctx, ci); 4664bc52338SCy Schubert } 4674bc52338SCy Schubert 468*c1d255d3SCy Schubert static inline void wpa_sm_transition_disable(struct wpa_sm *sm, u8 bitmap) 469*c1d255d3SCy Schubert { 470*c1d255d3SCy Schubert if (sm->ctx->transition_disable) 471*c1d255d3SCy Schubert sm->ctx->transition_disable(sm->ctx->ctx, bitmap); 472*c1d255d3SCy Schubert } 473*c1d255d3SCy Schubert 474*c1d255d3SCy Schubert static inline void wpa_sm_store_ptk(struct wpa_sm *sm, 475*c1d255d3SCy Schubert u8 *addr, int cipher, 476*c1d255d3SCy Schubert u32 life_time, struct wpa_ptk *ptk) 477*c1d255d3SCy Schubert { 478*c1d255d3SCy Schubert if (sm->ctx->store_ptk) 479*c1d255d3SCy Schubert sm->ctx->store_ptk(sm->ctx->ctx, addr, cipher, life_time, 480*c1d255d3SCy Schubert ptk); 481*c1d255d3SCy Schubert } 48285732ac8SCy Schubert 48385732ac8SCy Schubert int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk, 48439beb93cSSam Leffler int ver, const u8 *dest, u16 proto, 48539beb93cSSam Leffler u8 *msg, size_t msg_len, u8 *key_mic); 48639beb93cSSam Leffler int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, 48739beb93cSSam Leffler const struct wpa_eapol_key *key, 48839beb93cSSam Leffler int ver, const u8 *nonce, 48939beb93cSSam Leffler const u8 *wpa_ie, size_t wpa_ie_len, 49039beb93cSSam Leffler struct wpa_ptk *ptk); 49139beb93cSSam Leffler int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst, 49239beb93cSSam Leffler const struct wpa_eapol_key *key, 49339beb93cSSam Leffler u16 ver, u16 key_info, 49439beb93cSSam Leffler struct wpa_ptk *ptk); 49539beb93cSSam Leffler 49639beb93cSSam Leffler int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr, 4975b9c547cSRui Paulo const struct wpa_eapol_key *key, struct wpa_ptk *ptk); 49839beb93cSSam Leffler 499f05cddf9SRui Paulo void wpa_tdls_assoc(struct wpa_sm *sm); 500f05cddf9SRui Paulo void wpa_tdls_disassoc(struct wpa_sm *sm); 501f05cddf9SRui Paulo 50239beb93cSSam Leffler #endif /* WPA_I_H */ 503