From bc9fbe1b24cd925fa80239edcd24a20187e4afcb Mon Sep 17 00:00:00 2001 From: Vinay Gannevaram Date: Mon, 19 Sep 2022 16:12:49 +0530 Subject: [PATCH] PASN: Common wpas_pasn structure for initiator and responder Make struct wpas_pasn common for both the initiator and the responder by adding required parameters for responder to the existing struct wpas_pasn. This makes both hostapd and wpa_supplicant share the same structure definitions in preparation for allowing PASN functionality to be built into a separate library. Signed-off-by: Jouni Malinen --- src/ap/ieee802_11.c | 19 ++++++++++--------- src/ap/sta_info.h | 41 ++--------------------------------------- src/pasn/pasn_common.h | 11 +++++++++++ 3 files changed, 23 insertions(+), 48 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 761abd7ce..f392daef8 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -55,6 +55,7 @@ #include "fils_hlp.h" #include "dpp_hostapd.h" #include "gas_query_ap.h" +#include "pasn/pasn_common.h" #ifdef CONFIG_FILS @@ -2394,7 +2395,7 @@ static int pasn_wd_handle_sae_commit(struct hostapd_data *hapd, struct sta_info *sta, struct wpabuf *wd) { - struct pasn_data *pasn = sta->pasn; + struct wpas_pasn *pasn = sta->pasn; const char *password; const u8 *data; size_t buf_len; @@ -2474,7 +2475,7 @@ static int pasn_wd_handle_sae_confirm(struct hostapd_data *hapd, struct sta_info *sta, struct wpabuf *wd) { - struct pasn_data *pasn = sta->pasn; + struct wpas_pasn *pasn = sta->pasn; const u8 *data; size_t buf_len; u16 res, alg, seq, status; @@ -2526,7 +2527,7 @@ static int pasn_wd_handle_sae_confirm(struct hostapd_data *hapd, static struct wpabuf * pasn_get_sae_wd(struct hostapd_data *hapd, struct sta_info *sta) { - struct pasn_data *pasn = sta->pasn; + struct wpas_pasn *pasn = sta->pasn; struct wpabuf *buf = NULL; u8 *len_ptr; size_t len; @@ -2571,8 +2572,8 @@ static struct wpabuf * pasn_get_sae_wd(struct hostapd_data *hapd, static struct wpabuf * pasn_get_fils_wd(struct hostapd_data *hapd, struct sta_info *sta) { - struct pasn_data *pasn = sta->pasn; - struct pasn_fils_data *fils = &pasn->fils; + struct wpas_pasn *pasn = sta->pasn; + struct pasn_fils *fils = &pasn->fils; struct wpabuf *buf = NULL; if (!fils->erp_resp) { @@ -2623,8 +2624,8 @@ static void pasn_fils_auth_resp(struct hostapd_data *hapd, struct wpabuf *erp_resp, const u8 *msk, size_t msk_len) { - struct pasn_data *pasn = sta->pasn; - struct pasn_fils_data *fils = &pasn->fils; + struct wpas_pasn *pasn = sta->pasn; + struct pasn_fils *fils = &pasn->fils; u8 pmk[PMK_LEN_MAX]; size_t pmk_len; int ret; @@ -2702,8 +2703,8 @@ static int pasn_wd_handle_fils(struct hostapd_data *hapd, struct sta_info *sta, wpa_printf(MSG_DEBUG, "PASN: FILS: RADIUS is not configured. Fail"); return -1; #else /* CONFIG_NO_RADIUS */ - struct pasn_data *pasn = sta->pasn; - struct pasn_fils_data *fils = &pasn->fils; + struct wpas_pasn *pasn = sta->pasn; + struct pasn_fils *fils = &pasn->fils; struct ieee802_11_elems elems; struct wpa_ie_data rsne_data; struct wpabuf *fils_wd; diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h index d2a8344ad..eef40b501 100644 --- a/src/ap/sta_info.h +++ b/src/ap/sta_info.h @@ -16,6 +16,7 @@ #include "common/ieee802_11_defs.h" #include "common/sae.h" #include "crypto/sha384.h" +#include "pasn/pasn_common.h" /* STA flags */ #define WLAN_STA_AUTH BIT(0) @@ -68,44 +69,6 @@ struct pending_eapol_rx { enum frame_encryption encrypted; }; -enum pasn_fils_state { - PASN_FILS_STATE_NONE = 0, - PASN_FILS_STATE_PENDING_AS, - PASN_FILS_STATE_COMPLETE -}; - -struct pasn_fils_data { - u8 state; - u8 nonce[FILS_NONCE_LEN]; - u8 anonce[FILS_NONCE_LEN]; - u8 session[FILS_SESSION_LEN]; - u8 erp_pmkid[PMKID_LEN]; - - struct wpabuf *erp_resp; -}; - -struct pasn_data { - int akmp; - int cipher; - u16 group; - bool secure_ltf; - u8 trans_seq; - u8 wrapped_data_format; - size_t kdk_len; - - u8 hash[SHA384_MAC_LEN]; - struct wpa_ptk ptk; - struct crypto_ecdh *ecdh; - - struct wpabuf *secret; -#ifdef CONFIG_SAE - struct sae_data sae; -#endif /* CONFIG_SAE */ -#ifdef CONFIG_FILS - struct pasn_fils_data fils; -#endif /* CONFIG_FILS */ -}; - struct sta_info { struct sta_info *next; /* next entry in sta list */ struct sta_info *hnext; /* next entry in hash table list */ @@ -333,7 +296,7 @@ struct sta_info { #endif /* CONFIG_AIRTIME_POLICY */ #ifdef CONFIG_PASN - struct pasn_data *pasn; + struct wpas_pasn *pasn; #endif /* CONFIG_PASN */ }; diff --git a/src/pasn/pasn_common.h b/src/pasn/pasn_common.h index cefe784d5..f9839359f 100644 --- a/src/pasn/pasn_common.h +++ b/src/pasn/pasn_common.h @@ -18,12 +18,20 @@ extern "C" { #ifdef CONFIG_PASN +enum pasn_fils_state { + PASN_FILS_STATE_NONE = 0, + PASN_FILS_STATE_PENDING_AS, + PASN_FILS_STATE_COMPLETE +}; + struct pasn_fils { + u8 state; u8 nonce[FILS_NONCE_LEN]; u8 anonce[FILS_NONCE_LEN]; u8 session[FILS_SESSION_LEN]; u8 erp_pmkid[PMKID_LEN]; bool completed; + struct wpabuf *erp_resp; }; struct wpas_pasn { @@ -82,6 +90,9 @@ struct wpas_pasn { u16 rsnxe_capab; int network_id; + u8 wrapped_data_format; + struct wpabuf *secret; + /** * send_mgmt - Function handler to transmit a Management frame * @ctx: Callback context from cb_ctx