From: Shivani Baranwal Date: Sun, 4 Aug 2024 22:12:08 +0000 (+0530) Subject: P2P2: Indicate SAE password and PMK from pairing with GO negotiation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=240e1297d4aa98c02eb107cec7c8d1e7127dfdff;p=thirdparty%2Fhostap.git P2P2: Indicate SAE password and PMK from pairing with GO negotiation Signed-off-by: Shivani Baranwal --- diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 13e30231e..f4ba0eaa7 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -255,6 +255,7 @@ void p2p_go_neg_failed(struct p2p_data *p2p, int status) os_memset(&res, 0, sizeof(res)); res.status = status; + res.p2p2 = peer->p2p2; os_memcpy(res.peer_device_addr, peer->info.p2p_device_addr, ETH_ALEN); os_memcpy(res.peer_interface_addr, peer->intended_addr, ETH_ALEN); p2p->cfg->go_neg_completed(p2p->cfg->cb_ctx, &res); @@ -1925,8 +1926,44 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer) peer->go_neg_conf = NULL; #ifdef CONFIG_PASN - if (peer->p2p2 && peer->pasn) + if (peer->p2p2 && peer->pasn) { + res.p2p2 = peer->p2p2; + res.akmp = peer->pasn->akmp; + + if (res.akmp == WPA_KEY_MGMT_PASN) { + if (go) { + os_strlcpy(res.sae_password, + p2p->dev_sae_password, + sizeof(res.sae_password)); + } else { + if (!os_strlen(p2p->peer_sae_password)) { + p2p_dbg(p2p, "No password from peer GO for P2P2 group formation"); + return; + } + os_strlcpy(res.sae_password, + p2p->peer_sae_password, + sizeof(res.sae_password)); + } + } else if (res.akmp == WPA_KEY_MGMT_SAE) { + if (peer->role == P2P_ROLE_PAIRING_INITIATOR) { + pasn_initiator_pmksa_cache_get( + peer->pasn->pmksa, + peer->pasn->peer_addr, + res.pmkid, res.pmk, &res.pmk_len); + } else { + pasn_responder_pmksa_cache_get( + peer->pasn->pmksa, + peer->pasn->peer_addr, + res.pmkid, res.pmk, &res.pmk_len); + } + } + + os_memset(p2p->dev_sae_password, 0, + sizeof(p2p->dev_sae_password)); + os_memset(p2p->peer_sae_password, 0, + sizeof(p2p->peer_sae_password)); wpa_pasn_reset(peer->pasn); + } #endif /* CONFIG_PASN */ p2p_set_state(p2p, P2P_PROVISIONING); diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index ece779893..610f7db55 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -11,6 +11,7 @@ #include "common/ieee802_11_defs.h" #include "wps/wps.h" +#include "common/wpa_common.h" #define DEVICE_IDENTITY_KEY_MAX_LEN 64 #define DEVICE_IDENTITY_KEY_LEN 16 @@ -181,6 +182,36 @@ struct p2p_go_neg_results { * peer_config_timeout - Peer configuration timeout (in 10 msec units) */ unsigned int peer_config_timeout; + + /** + * p2p2 - Whether this group uses P2P2 + */ + bool p2p2; + + /** + * akmp - The negotiated PASN AKMP for P2P2 + */ + int akmp; + + /** + * pmkid - PMKID for P2P2 when PMK is derived as part of pairing + */ + u8 pmkid[PMKID_LEN]; + + /** + * pmk - PMK for P2P2 when PMK is derived as part of pairing + */ + u8 pmk[PMK_LEN_MAX]; + + /** + * pmk_len - Length of @pmk in octets + */ + size_t pmk_len; + + /** + * sae_password - SAE password for the group (P2P2) + */ + char sae_password[100]; }; struct p2ps_provision {