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 <quic_jouni@quicinc.com>
This commit is contained in:
Vinay Gannevaram 2022-09-19 16:12:49 +05:30 committed by Jouni Malinen
parent 14b5ebce73
commit bc9fbe1b24
3 changed files with 23 additions and 48 deletions

View file

@ -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;

View file

@ -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 */
};

View file

@ -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