]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OWE: Allow DH Parameters element to be overridden for testing purposes
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 10 Oct 2017 15:26:29 +0000 (18:26 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 10 Oct 2017 15:26:29 +0000 (18:26 +0300)
This allows CONFIG_TESTING_OPTIONS=y builds of wpa_supplicant to
override the OWE DH Parameters element in (Re)Association Request frames
with arbitrary data specified with the "VENDOR_ELEM_ADD 13 <IE>"
command. This is only for testing purposes.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h
wpa_supplicant/sme.c

index 4da10d206ab2e552c0389a00617ef75122624bce..120d4e883b17ca6de1ac940b29593a5ee4e494b3 100644 (file)
@@ -1433,6 +1433,40 @@ const u8 * get_ie(const u8 *ies, size_t len, u8 eid)
 }
 
 
+/**
+ * get_ie_ext - Fetch a specified extended information element from IEs buffer
+ * @ies: Information elements buffer
+ * @len: Information elements buffer length
+ * @ext: Information element extension identifier (WLAN_EID_EXT_*)
+ * Returns: Pointer to the information element (id field) or %NULL if not found
+ *
+ * This function returns the first matching information element in the IEs
+ * buffer or %NULL in case the element is not found.
+ */
+const u8 * get_ie_ext(const u8 *ies, size_t len, u8 ext)
+{
+       const u8 *end;
+
+       if (!ies)
+               return NULL;
+
+       end = ies + len;
+
+       while (end - ies > 1) {
+               if (2 + ies[1] > end - ies)
+                       break;
+
+               if (ies[0] == WLAN_EID_EXTENSION && ies[1] >= 1 &&
+                   ies[2] == ext)
+                       return ies;
+
+               ies += 2 + ies[1];
+       }
+
+       return NULL;
+}
+
+
 size_t mbo_add_ie(u8 *buf, size_t len, const u8 *attr, size_t attr_len)
 {
        /*
index ff2f8e761bb1a8538c83a7a93d89fdba91eaf998..92761585151d042dc93204d577f6004e08e888fe 100644 (file)
@@ -176,6 +176,7 @@ extern const struct oper_class_map global_op_class[];
 extern size_t global_op_class_size;
 
 const u8 * get_ie(const u8 *ies, size_t len, u8 eid);
+const u8 * get_ie_ext(const u8 *ies, size_t len, u8 ext);
 
 size_t mbo_add_ie(u8 *buf, size_t len, const u8 *attr, size_t attr_len);
 
index 4023026bc236cae44134de37d2ad3d6cd1bd8c9f..c14433a3f187156feab8b26c546fe31f7a02cf0e 100644 (file)
@@ -1192,6 +1192,12 @@ void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode,
 #endif /* CONFIG_FILS */
 
 #ifdef CONFIG_OWE
+#ifdef CONFIG_TESTING_OPTIONS
+       if (get_ie_ext(wpa_s->sme.assoc_req_ie, wpa_s->sme.assoc_req_ie_len,
+                      WLAN_EID_EXT_OWE_DH_PARAM)) {
+               wpa_printf(MSG_INFO, "TESTING: Override OWE DH element");
+       } else
+#endif /* CONFIG_TESTING_OPTIONS */
        if (auth_type == WLAN_AUTH_OPEN &&
            wpa_s->key_mgmt == WPA_KEY_MGMT_OWE) {
                struct wpabuf *owe_ie;