From 2bdc47a9455e4630bb4c1b6806ccd9d515810f58 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 23 Nov 2017 23:47:52 +0200 Subject: [PATCH] DPP: Allow PKEX own/peer MAC addresses to be overridden This is for testing purposes to allow a test vector with specific values to be generated. Signed-off-by: Jouni Malinen --- src/common/dpp.c | 31 +++++++++++++++++++++++++++++++ src/common/dpp.h | 2 ++ wpa_supplicant/ctrl_iface.c | 8 ++++++++ 3 files changed, 41 insertions(+) diff --git a/src/common/dpp.c b/src/common/dpp.c index 54a5a6c7d..9ce9ffa41 100644 --- a/src/common/dpp.c +++ b/src/common/dpp.c @@ -30,6 +30,8 @@ #ifdef CONFIG_TESTING_OPTIONS enum dpp_test_behavior dpp_test = DPP_TEST_DISABLED; +u8 dpp_pkex_own_mac_override[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; +u8 dpp_pkex_peer_mac_override[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; static int dpp_test_gen_invalid_key(struct wpabuf *msg, const struct dpp_curve_params *curve); @@ -6166,6 +6168,14 @@ struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi, { struct dpp_pkex *pkex; +#ifdef CONFIG_TESTING_OPTIONS + if (!is_zero_ether_addr(dpp_pkex_own_mac_override)) { + wpa_printf(MSG_INFO, "DPP: TESTING - own_mac override " MACSTR, + MAC2STR(dpp_pkex_own_mac_override)); + own_mac = dpp_pkex_own_mac_override; + } +#endif /* CONFIG_TESTING_OPTIONS */ + pkex = os_zalloc(sizeof(*pkex)); if (!pkex) return NULL; @@ -6370,6 +6380,19 @@ struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx, return NULL; } +#ifdef CONFIG_TESTING_OPTIONS + if (!is_zero_ether_addr(dpp_pkex_peer_mac_override)) { + wpa_printf(MSG_INFO, "DPP: TESTING - peer_mac override " MACSTR, + MAC2STR(dpp_pkex_peer_mac_override)); + peer_mac = dpp_pkex_peer_mac_override; + } + if (!is_zero_ether_addr(dpp_pkex_own_mac_override)) { + wpa_printf(MSG_INFO, "DPP: TESTING - own_mac override " MACSTR, + MAC2STR(dpp_pkex_own_mac_override)); + own_mac = dpp_pkex_own_mac_override; + } +#endif /* CONFIG_TESTING_OPTIONS */ + attr_id = dpp_get_attr(buf, len, DPP_ATTR_CODE_IDENTIFIER, &attr_id_len); if (!attr_id && identifier) { @@ -6694,6 +6717,14 @@ struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, if (pkex->failed || pkex->t >= PKEX_COUNTER_T_LIMIT || !pkex->initiator) return NULL; +#ifdef CONFIG_TESTING_OPTIONS + if (!is_zero_ether_addr(dpp_pkex_peer_mac_override)) { + wpa_printf(MSG_INFO, "DPP: TESTING - peer_mac override " MACSTR, + MAC2STR(dpp_pkex_peer_mac_override)); + peer_mac = dpp_pkex_peer_mac_override; + } +#endif /* CONFIG_TESTING_OPTIONS */ + os_memcpy(pkex->peer_mac, peer_mac, ETH_ALEN); attr_status = dpp_get_attr(buf, buflen, DPP_ATTR_STATUS, diff --git a/src/common/dpp.h b/src/common/dpp.h index 0a998c436..85a18ebe4 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -324,6 +324,8 @@ enum dpp_test_behavior { }; extern enum dpp_test_behavior dpp_test; +extern u8 dpp_pkex_own_mac_override[ETH_ALEN]; +extern u8 dpp_pkex_peer_mac_override[ETH_ALEN]; #endif /* CONFIG_TESTING_OPTIONS */ void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info); diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index f756bcae6..ec52dd747 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -615,6 +615,12 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, wpa_s->dpp_resp_max_tries = atoi(value); } else if (os_strcasecmp(cmd, "dpp_resp_retry_time") == 0) { wpa_s->dpp_resp_retry_time = atoi(value); + } else if (os_strcasecmp(cmd, "dpp_pkex_own_mac_override") == 0) { + if (hwaddr_aton(value, dpp_pkex_own_mac_override)) + ret = -1; + } else if (os_strcasecmp(cmd, "dpp_pkex_peer_mac_override") == 0) { + if (hwaddr_aton(value, dpp_pkex_peer_mac_override)) + ret = -1; #endif /* CONFIG_DPP */ #ifdef CONFIG_TESTING_OPTIONS } else if (os_strcasecmp(cmd, "ext_mgmt_frame_handling") == 0) { @@ -7761,6 +7767,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s) wpa_s->dpp_resp_wait_time = 0; wpa_s->dpp_resp_max_tries = 0; wpa_s->dpp_resp_retry_time = 0; + os_memset(dpp_pkex_own_mac_override, 0, ETH_ALEN); + os_memset(dpp_pkex_peer_mac_override, 0, ETH_ALEN); #endif /* CONFIG_DPP */ #ifdef CONFIG_TDLS