]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PASN: Allow extra elements to be added into PASN Authentication frames
authorVinay Gannevaram <quic_vganneva@quicinc.com>
Thu, 3 Nov 2022 07:29:16 +0000 (12:59 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 4 Nov 2022 10:33:38 +0000 (12:33 +0200)
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>
src/common/wpa_common.c
src/common/wpa_common.h
src/pasn/pasn_common.h
src/pasn/pasn_initiator.c
src/pasn/pasn_responder.c

index 38bca41a0b629103f8b956c771e4ca539813f1e5..bedc1423395cca16380af6391b6d7d3a9e9f199e 100644 (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 */
index 7374d8b7b3fd85cbfb8e066e76f44a9b9f380b98..2c6fe05ac4917d0571408f254196bf6d9ca20b70 100644 (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 */
index d34bde302ed35fb23438c6564a7e52de41670bc9..e091b8eb4c64aca3a6d489be86e66d1d346e7ce7 100644 (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
index f123afb1b66d1371caec832eb32c2896a7b1e33c..4afe7859a85eeb76182133156a7940f64dd7050d 100644 (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,
index 30fc51204fdab217b8fe99b0811c85a8d31827ab..02a1088bf5d3a433d35a7f65f3cf5ed79795ba93 100644 (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);