aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-18 22:31:57 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-22 19:35:20 (GMT)
commit456fe11d1b92bced01df39d04aa5ba005c65dad5 (patch)
tree30ec79e52d2925956561d39f624fbbe5a1ff910e
parent35db79ce3ae84eb83d797dfebbb15f928bfe0393 (diff)
downloadhostap-06-456fe11d1b92bced01df39d04aa5ba005c65dad5.zip
hostap-06-456fe11d1b92bced01df39d04aa5ba005c65dad5.tar.gz
hostap-06-456fe11d1b92bced01df39d04aa5ba005c65dad5.tar.bz2
WPS: Fix MAC Address inside Credential be that of Enrollee's
The WPS 1.0h specification is quite unclear on what exactly should be used as the MAC Address value in the Credential and AP Settings. It looks like this should after all be the MAC Address of the Enrollee, so change Registrar implementation to use that address instead of the AP BSSID. In addition, add validation code to the Enrollee implementation to check the MAC Address value inside Credential (and also inside AP Settings) to make sure it matches with the Enrollee's own address. However, since there are deployed implementations that do not follow this interpretation of the spec, only show the mismatch in debug information to avoid breaking interoperability with existing devices. (cherry picked from commit 4bdd556886fea5790aa4d56e2f416cc82ebf15b5)
-rw-r--r--src/wps/wps.h2
-rw-r--r--src/wps/wps_enrollee.c30
-rw-r--r--src/wps/wps_registrar.c6
3 files changed, 35 insertions, 3 deletions
diff --git a/src/wps/wps.h b/src/wps/wps.h
index f14384c..99a3c26 100644
--- a/src/wps/wps.h
+++ b/src/wps/wps.h
@@ -42,7 +42,7 @@ struct upnp_wps_device_sm;
* @key_idx: Key index
* @key: Key
* @key_len: Key length in octets
- * @mac_addr: MAC address of the peer
+ * @mac_addr: MAC address of the Credential receiver
* @cred_attr: Unparsed Credential attribute data (used only in cred_cb());
* this may be %NULL, if not used
* @cred_attr_len: Length of cred_attr in octets
diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c
index fcb3103..5cb3e1e 100644
--- a/src/wps/wps_enrollee.c
+++ b/src/wps/wps_enrollee.c
@@ -646,6 +646,21 @@ static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
wps_process_cred(&attr, &wps->cred))
return -1;
+ if (os_memcmp(wps->cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN) !=
+ 0) {
+ wpa_printf(MSG_DEBUG, "WPS: MAC Address in the Credential ("
+ MACSTR ") does not match with own address (" MACSTR
+ ")", MAC2STR(wps->cred.mac_addr),
+ MAC2STR(wps->wps->dev.mac_addr));
+ /*
+ * In theory, this could be consider fatal error, but there are
+ * number of deployed implementations using other address here
+ * due to unclarity in the specification. For interoperability
+ * reasons, allow this to be processed since we do not really
+ * use the MAC Address information for anything.
+ */
+ }
+
if (wps->wps->cred_cb) {
wps->cred.cred_attr = cred - 4;
wps->cred.cred_attr_len = cred_len + 4;
@@ -696,6 +711,21 @@ static int wps_process_ap_settings_e(struct wps_data *wps,
wpa_printf(MSG_INFO, "WPS: Received new AP configuration from "
"Registrar");
+ if (os_memcmp(cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN) !=
+ 0) {
+ wpa_printf(MSG_DEBUG, "WPS: MAC Address in the AP Settings ("
+ MACSTR ") does not match with own address (" MACSTR
+ ")", MAC2STR(cred.mac_addr),
+ MAC2STR(wps->wps->dev.mac_addr));
+ /*
+ * In theory, this could be consider fatal error, but there are
+ * number of deployed implementations using other address here
+ * due to unclarity in the specification. For interoperability
+ * reasons, allow this to be processed since we do not really
+ * use the MAC Address information for anything.
+ */
+ }
+
if (wps->wps->cred_cb) {
cred.cred_attr = wpabuf_head(attrs);
cred.cred_attr_len = wpabuf_len(attrs);
diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
index eafa1a9..472b232 100644
--- a/src/wps/wps_registrar.c
+++ b/src/wps/wps_registrar.c
@@ -1070,8 +1070,10 @@ static int wps_build_cred(struct wps_data *wps, struct wpabuf *msg)
}
}
wps->cred.encr_type = wps->encr_type;
- /* Set MAC address in the Credential to be the AP's address (BSSID) */
- os_memcpy(wps->cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN);
+ /*
+ * Set MAC address in the Credential to be the Enrollee's MAC address
+ */
+ os_memcpy(wps->cred.mac_addr, wps->mac_addr_e, ETH_ALEN);
if (wps->wps->wps_state == WPS_STATE_NOT_CONFIGURED && wps->wps->ap &&
!wps->wps->registrar->disable_auto_conf) {