From 265bda34441da14249cb22ce8a459cebe8015a55 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 10 Oct 2017 18:26:29 +0300 Subject: [PATCH] OWE: Allow DH Parameters element to be overridden for testing purposes 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 " command. This is only for testing purposes. Signed-off-by: Jouni Malinen --- src/common/ieee802_11_common.c | 34 ++++++++++++++++++++++++++++++++++ src/common/ieee802_11_common.h | 1 + wpa_supplicant/sme.c | 6 ++++++ 3 files changed, 41 insertions(+) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 4da10d206..120d4e883 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -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) { /* diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index ff2f8e761..927615851 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -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); diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 4023026bc..c14433a3f 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -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; -- 2.39.2