PASN: Allow extra elements to be added into PASN Authentication frames

Wi-Fi Aware defines protocol specific elements in PASN Authentication
frames for pairing setup. Add an option to add this type of custom
elements into PASN frames. This is mainly for the libpasn.so use cases.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Vinay Gannevaram 2022-11-03 12:59:16 +05:30 committed by Jouni Malinen
parent 08abcdf4e7
commit b1ed44b6a6
5 changed files with 35 additions and 0 deletions

View file

@ -4102,4 +4102,27 @@ void wpa_pasn_add_rsnxe(struct wpabuf *buf, u16 capab)
wpabuf_put_u8(buf, capab);
}
/*
* wpa_pasn_add_extra_ies - Add protocol specific IEs in Authentication
* frame for PASN.
*
* @buf: Buffer in which the elements will be added
* @extra_ies: Protocol specific elements to add
* @len: Length of the elements
* Returns: 0 on success, -1 on failure
*/
int wpa_pasn_add_extra_ies(struct wpabuf *buf, const u8 *extra_ies, size_t len)
{
if (!len || !extra_ies || !buf)
return 0;
if (wpabuf_tailroom(buf) < sizeof(len))
return -1;
wpabuf_put_data(buf, extra_ies, len);
return 0;
}
#endif /* CONFIG_PASN */

View file

@ -749,5 +749,6 @@ int wpa_pasn_parse_parameter_ie(const u8 *data, u8 len, bool from_ap,
struct wpa_pasn_params_data *pasn_params);
void wpa_pasn_add_rsnxe(struct wpabuf *buf, u16 capab);
int wpa_pasn_add_extra_ies(struct wpabuf *buf, const u8 *extra_ies, size_t len);
#endif /* WPA_COMMON_H */

View file

@ -115,6 +115,13 @@ struct wpas_pasn {
bool custom_pmkid_valid;
u8 custom_pmkid[PMKID_LEN];
/**
* Extra elements to add into Authentication frames. These can be used,
* e.g., for Wi-Fi Aware use cases.
*/
const u8 *extra_ies;
size_t extra_ies_len;
/**
* send_mgmt - Function handler to transmit a Management frame
* @ctx: Callback context from cb_ctx

View file

@ -579,6 +579,8 @@ static struct wpabuf * wpas_pasn_build_auth_1(struct wpas_pasn *pasn,
wpa_pasn_add_rsnxe(buf, pasn->rsnxe_capab);
wpa_pasn_add_extra_ies(buf, pasn->extra_ies, pasn->extra_ies_len);
ret = pasn_auth_frame_hash(pasn->akmp, pasn->cipher,
wpabuf_head_u8(buf) + IEEE80211_HDRLEN,
wpabuf_len(buf) - IEEE80211_HDRLEN,

View file

@ -491,6 +491,8 @@ int handle_auth_pasn_resp(struct wpas_pasn *pasn, const u8 *own_addr,
if (rsnxe_ie)
wpabuf_put_data(buf, rsnxe_ie, 2 + rsnxe_ie[1]);
wpa_pasn_add_extra_ies(buf, pasn->extra_ies, pasn->extra_ies_len);
/* Add the mic */
mic_len = pasn_mic_len(pasn->akmp, pasn->cipher);
wpabuf_put_u8(buf, WLAN_EID_MIC);