diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index b60f77001..c1861cb8b 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -19,6 +19,7 @@ #include "ap_config.h" #include "p2p_hostapd.h" #include "hs20.h" +#include "wpa_auth.h" #include "ap_drv_ops.h" @@ -348,12 +349,35 @@ int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr, u16 seq, u16 status, const u8 *ie, size_t len) { struct wpa_driver_sta_auth_params params; +#ifdef CONFIG_FILS + struct sta_info *sta; +#endif /* CONFIG_FILS */ if (hapd->driver == NULL || hapd->driver->sta_auth == NULL) return 0; os_memset(¶ms, 0, sizeof(params)); +#ifdef CONFIG_FILS + sta = ap_get_sta(hapd, addr); + if (!sta) { + wpa_printf(MSG_DEBUG, "Station " MACSTR + " not found for sta_auth processing", + MAC2STR(addr)); + return 0; + } + + if (sta->auth_alg == WLAN_AUTH_FILS_SK || + sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || + sta->auth_alg == WLAN_AUTH_FILS_PK) { + params.fils_auth = 1; + wpa_auth_get_fils_aead_params(sta->wpa_sm, params.fils_anonce, + params.fils_snonce, + params.fils_kek, + ¶ms.fils_kek_len); + } +#endif /* CONFIG_FILS */ + params.own_addr = hapd->own_addr; params.addr = addr; params.seq = seq; diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index d7e3d2238..24b1241e1 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -4284,4 +4284,15 @@ int wpa_auth_write_fte(struct wpa_authenticator *wpa_auth, u8 *buf, size_t len) } #endif /* CONFIG_IEEE80211R_AP */ + +void wpa_auth_get_fils_aead_params(struct wpa_state_machine *sm, + u8 *fils_anonce, u8 *fils_snonce, + u8 *fils_kek, size_t *fils_kek_len) +{ + os_memcpy(fils_anonce, sm->ANonce, WPA_NONCE_LEN); + os_memcpy(fils_snonce, sm->SNonce, WPA_NONCE_LEN); + os_memcpy(fils_kek, sm->PTK.kek, WPA_KEK_MAX_LEN); + *fils_kek_len = sm->PTK.kek_len; +} + #endif /* CONFIG_FILS */ diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h index 6793fecc0..9a1d9d70f 100644 --- a/src/ap/wpa_auth.h +++ b/src/ap/wpa_auth.h @@ -376,5 +376,8 @@ int fils_encrypt_assoc(struct wpa_state_machine *sm, u8 *buf, int fils_set_tk(struct wpa_state_machine *sm); int wpa_auth_write_fte(struct wpa_authenticator *wpa_auth, u8 *buf, size_t len); +void wpa_auth_get_fils_aead_params(struct wpa_state_machine *sm, + u8 *fils_anonce, u8 *fils_snonce, + u8 *fils_kek, size_t *fils_kek_len); #endif /* WPA_AUTH_H */