aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-11-26 18:47:24 (GMT)
committerJouni Malinen <j@w1.fi>2008-11-26 18:47:24 (GMT)
commitf855f923a735c38b0ec918f3302173bf3e8e7a7f (patch)
treeb43ddb34a95893a58abea6f24c7ab4033ec89b36
parent2f4eb314547bcbeea9a4b89c0d20cf6a2fb553cc (diff)
downloadhostap-f855f923a735c38b0ec918f3302173bf3e8e7a7f.zip
hostap-f855f923a735c38b0ec918f3302173bf3e8e7a7f.tar.gz
hostap-f855f923a735c38b0ec918f3302173bf3e8e7a7f.tar.bz2
WPS: Moved UUID configuration from phase1 into global config area
-rw-r--r--src/eap_peer/eap.c2
-rw-r--r--src/eap_peer/eap.h6
-rw-r--r--src/eap_peer/eap_i.h1
-rw-r--r--src/eap_peer/eap_wsc.c18
-rw-r--r--src/eapol_supp/eapol_supp_sm.c1
-rw-r--r--src/eapol_supp/eapol_supp_sm.h7
-rw-r--r--src/utils/uuid.c10
-rw-r--r--src/utils/uuid.h1
-rw-r--r--wpa_supplicant/config.h5
-rw-r--r--wpa_supplicant/config_file.c29
-rw-r--r--wpa_supplicant/config_winreg.c33
-rw-r--r--wpa_supplicant/scan.c16
-rw-r--r--wpa_supplicant/wpa_supplicant.conf10
-rw-r--r--wpa_supplicant/wpas_glue.c1
14 files changed, 110 insertions, 30 deletions
diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c
index 2627faa..7ec6d1a 100644
--- a/src/eap_peer/eap.c
+++ b/src/eap_peer/eap.c
@@ -1180,6 +1180,8 @@ struct eap_sm * eap_peer_sm_init(void *eapol_ctx,
sm->ClientTimeout = 60;
if (conf->mac_addr)
os_memcpy(sm->mac_addr, conf->mac_addr, ETH_ALEN);
+ if (conf->uuid)
+ os_memcpy(sm->uuid, conf->uuid, 16);
os_memset(&tlsconf, 0, sizeof(tlsconf));
tlsconf.opensc_engine_path = conf->opensc_engine_path;
diff --git a/src/eap_peer/eap.h b/src/eap_peer/eap.h
index cd08032..a23f88a 100644
--- a/src/eap_peer/eap.h
+++ b/src/eap_peer/eap.h
@@ -263,6 +263,12 @@ struct eap_config {
* This is only used by EAP-WSC and can be left %NULL if not available.
*/
const u8 *mac_addr;
+ /**
+ * uuid - Device UUID
+ *
+ * This is only used by EAP-WSC and can be left %NULL if not available.
+ */
+ const u8 *uuid;
};
struct eap_sm * eap_peer_sm_init(void *eapol_ctx,
diff --git a/src/eap_peer/eap_i.h b/src/eap_peer/eap_i.h
index 623701c..6f425d2 100644
--- a/src/eap_peer/eap_i.h
+++ b/src/eap_peer/eap_i.h
@@ -334,6 +334,7 @@ struct eap_sm {
int force_disabled;
u8 mac_addr[ETH_ALEN];
+ u8 uuid[16];
};
const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);
diff --git a/src/eap_peer/eap_wsc.c b/src/eap_peer/eap_wsc.c
index e80b7c6..669f336 100644
--- a/src/eap_peer/eap_wsc.c
+++ b/src/eap_peer/eap_wsc.c
@@ -107,7 +107,6 @@ static void * eap_wsc_init(struct eap_sm *sm)
size_t identity_len;
int registrar;
struct wps_config cfg;
- u8 uuid[UUID_LEN];
const char *pos;
const char *phase1;
struct wps_context *wps = NULL;
@@ -201,23 +200,10 @@ static void * eap_wsc_init(struct eap_sm *sm)
return NULL;
}
- pos = os_strstr(phase1, "uuid=");
- if (pos == NULL) {
- wpa_printf(MSG_INFO, "EAP-WSC: UUID not set in phase1 "
- "configuration data");
- os_free(data);
- return NULL;
- }
- if (uuid_str2bin(pos + 5, uuid)) {
- wpa_printf(MSG_INFO, "EAP-WSC: Invalid UUID in phase1 "
- "configuration data");
- os_free(data);
- return NULL;
- }
if (registrar && wps)
- os_memcpy(wps->uuid, uuid, UUID_LEN);
+ os_memcpy(wps->uuid, sm->uuid, UUID_LEN);
else
- cfg.uuid = uuid;
+ cfg.uuid = sm->uuid;
cfg.wps_cred_cb = sm->eapol_cb->wps_cred;
cfg.cb_ctx = sm->eapol_ctx;
data->wps = wps_init(&cfg);
diff --git a/src/eapol_supp/eapol_supp_sm.c b/src/eapol_supp/eapol_supp_sm.c
index 9af1d6d..3ae5e15 100644
--- a/src/eapol_supp/eapol_supp_sm.c
+++ b/src/eapol_supp/eapol_supp_sm.c
@@ -1820,6 +1820,7 @@ struct eapol_sm *eapol_sm_init(struct eapol_ctx *ctx)
conf.pkcs11_module_path = ctx->pkcs11_module_path;
#endif /* EAP_TLS_OPENSSL */
conf.mac_addr = ctx->mac_addr;
+ conf.uuid = ctx->uuid;
sm->eap = eap_peer_sm_init(sm, &eapol_cb, sm->ctx->msg_ctx, &conf);
if (sm->eap == NULL) {
diff --git a/src/eapol_supp/eapol_supp_sm.h b/src/eapol_supp/eapol_supp_sm.h
index f297d23..637a1a4 100644
--- a/src/eapol_supp/eapol_supp_sm.h
+++ b/src/eapol_supp/eapol_supp_sm.h
@@ -208,6 +208,13 @@ struct eapol_ctx {
const u8 *mac_addr;
/**
+ * uuid - Device UUID
+ *
+ * This is only used by EAP-WSC and can be left %NULL if not available.
+ */
+ const u8 *uuid;
+
+ /**
* wps_cred - Notify that new credential was received from WPS
* @ctx: Callback context (ctx)
* Returns: 0 on success (credential stored), -1 on failure
diff --git a/src/utils/uuid.c b/src/utils/uuid.c
index b1fd234..d8cc267 100644
--- a/src/utils/uuid.c
+++ b/src/utils/uuid.c
@@ -65,3 +65,13 @@ int uuid_bin2str(const u8 *bin, char *str, size_t max_len)
return -1;
return 0;
}
+
+
+int is_nil_uuid(const u8 *uuid)
+{
+ int i;
+ for (i = 0; i < UUID_LEN; i++)
+ if (uuid[i])
+ return 0;
+ return 1;
+}
diff --git a/src/utils/uuid.h b/src/utils/uuid.h
index bb56bbb..0759165 100644
--- a/src/utils/uuid.h
+++ b/src/utils/uuid.h
@@ -19,5 +19,6 @@
int uuid_str2bin(const char *str, u8 *bin);
int uuid_bin2str(const u8 *bin, char *str, size_t max_len);
+int is_nil_uuid(const u8 *uuid);
#endif /* UUID_H */
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 1eae050..b05576d 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -247,6 +247,11 @@ struct wpa_config {
* blobs - Configuration blobs
*/
struct wpa_config_blob *blobs;
+
+ /**
+ * uuid - Universally Unique IDentifier (UUID; see RFC 4122) for WPS
+ */
+ u8 uuid[16];
};
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 3153214..acc9ee5 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -21,6 +21,7 @@
#include "common.h"
#include "config.h"
#include "base64.h"
+#include "uuid.h"
#include "eap_peer/eap_methods.h"
@@ -427,6 +428,22 @@ static int wpa_config_process_load_dynamic_eap(int line, char *so)
}
+#ifdef CONFIG_WPS
+static int wpa_config_process_uuid(struct wpa_config *config, int line,
+ char *pos)
+{
+ char buf[40];
+ if (uuid_str2bin(pos, config->uuid)) {
+ wpa_printf(MSG_ERROR, "Line %d: invalid UUID", line);
+ return -1;
+ }
+ uuid_bin2str(config->uuid, buf, sizeof(buf));
+ wpa_printf(MSG_DEBUG, "uuid=%s", buf);
+ return 0;
+}
+#endif /* CONFIG_WPS */
+
+
static int wpa_config_process_global(struct wpa_config *config, char *pos,
int line)
{
@@ -481,6 +498,11 @@ static int wpa_config_process_global(struct wpa_config *config, char *pos,
if (os_strncmp(pos, "load_dynamic_eap=", 17) == 0)
return wpa_config_process_load_dynamic_eap(line, pos + 17);
+#ifdef CONFIG_WPS
+ if (os_strncmp(pos, "uuid=", 5) == 0)
+ return wpa_config_process_uuid(config, line, pos + 5);
+#endif /* CONFIG_WPS */
+
return -1;
}
@@ -845,6 +867,13 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
config->dot11RSNAConfigSATimeout);
if (config->update_config)
fprintf(f, "update_config=%d\n", config->update_config);
+#ifdef CONFIG_WPS
+ if (is_nil_uuid(config->uuid)) {
+ char buf[40];
+ uuid_bin2str(config->uuid, buf, sizeof(buf));
+ fprintf(f, "uuid=%s\n", buf);
+ }
+#endif /* CONFIG_WPS */
}
#endif /* CONFIG_NO_CONFIG_WRITE */
diff --git a/wpa_supplicant/config_winreg.c b/wpa_supplicant/config_winreg.c
index 48e5c80..466908b 100644
--- a/wpa_supplicant/config_winreg.c
+++ b/wpa_supplicant/config_winreg.c
@@ -32,6 +32,7 @@
#include "includes.h"
#include "common.h"
+#include "uuid.h"
#include "config.h"
#ifndef WPA_KEY_ROOT
@@ -161,6 +162,26 @@ static char * wpa_config_read_reg_string(HKEY hk, const TCHAR *name)
}
+#ifdef CONFIG_WPS
+static int wpa_config_read_global_uuid(struct wpa_config *config, HKEY hk)
+{
+ char *str;
+ int ret = 0;
+
+ str = wpa_config_read_reg_string(hk, TEXT("uuid"));
+ if (str == NULL)
+ return 0;
+
+ if (uuid_str2bin(str, config->uuid))
+ ret = -1;
+
+ os_free(str);
+
+ return ret;
+}
+#endif /* CONFIG_WPS */
+
+
static int wpa_config_read_global(struct wpa_config *config, HKEY hk)
{
int errors = 0;
@@ -191,6 +212,11 @@ static int wpa_config_read_global(struct wpa_config *config, HKEY hk)
config->ctrl_interface = wpa_config_read_reg_string(
hk, TEXT("ctrl_interface"));
+#ifdef CONFIG_WPS
+ if (wpa_config_read_global_uuid(config, hk))
+ errors++;
+#endif /* CONFIG_WPS */
+
return errors ? -1 : 0;
}
@@ -492,6 +518,13 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk)
wpa_config_write_reg_dword(hk, TEXT("update_config"),
config->update_config,
0);
+#ifdef CONFIG_WPS
+ if (is_nil_uuid(config->uuid)) {
+ char buf[40];
+ uuid_bin2str(config->uuid, buf, sizeof(buf));
+ wpa_config_write_reg_string(hk, "uuid", buf);
+ }
+#endif /* CONFIG_WPS */
return 0;
}
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 04b6d44..8002920 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -19,7 +19,6 @@
#include "config.h"
#include "wpa_supplicant_i.h"
#include "mlme.h"
-#include "uuid.h"
#include "wps/wps.h"
@@ -43,11 +42,10 @@ static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
#ifdef CONFIG_WPS
-static int wpas_wps_in_use(struct wpa_config *conf, u8 *uuid)
+static int wpas_wps_in_use(struct wpa_config *conf)
{
struct wpa_ssid *ssid;
int wps = 0;
- const char *pos;
for (ssid = conf->ssid; ssid; ssid = ssid->next) {
if (!(ssid->key_mgmt & WPA_KEY_MGMT_WPS))
@@ -57,10 +55,6 @@ static int wpas_wps_in_use(struct wpa_config *conf, u8 *uuid)
if (!ssid->eap.phase1)
continue;
- pos = os_strstr(ssid->eap.phase1, "uuid=");
- if (pos)
- uuid_str2bin(pos + 5, uuid);
-
if (os_strstr(ssid->eap.phase1, "pbc=1"))
return 2;
}
@@ -78,9 +72,6 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
const u8 *extra_ie = NULL;
size_t extra_ie_len = 0;
int wps = 0;
-#ifdef CONFIG_WPS
- u8 uuid[UUID_LEN];
-#endif /* CONFIG_WPS */
if (wpa_s->disconnected && !wpa_s->scan_req)
return;
@@ -168,7 +159,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
#ifdef CONFIG_WPS
- wps = wpas_wps_in_use(wpa_s->conf, uuid);
+ wps = wpas_wps_in_use(wpa_s->conf);
#endif /* CONFIG_WPS */
if (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
@@ -184,7 +175,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
#ifdef CONFIG_WPS
if (wps) {
- wps_ie = wps_enrollee_build_probe_req_ie(wps == 2, uuid);
+ wps_ie = wps_enrollee_build_probe_req_ie(wps == 2,
+ wpa_s->conf->uuid);
if (wps_ie) {
extra_ie = wpabuf_head(wps_ie);
extra_ie_len = wpabuf_len(wps_ie);
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index a4c1ca7..0765ad3 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -142,6 +142,12 @@ fast_reauth=1
# Timeout for security association negotiation in seconds; default 60
#dot11RSNAConfigSATimeout=60
+# Wi-Fi Protected Setup (WPS) parameters
+
+# Universally Unique IDentifier (UUID; see RFC 4122) of the device
+#uuid=12345678-9abc-def0-1234-56789abcdef0
+
+
# network block
#
# Each network (usually AP's sharing the same SSID) is configured as a separate
@@ -397,8 +403,8 @@ fast_reauth=1
# * 0 = do not use cryptobinding (default)
# * 1 = use cryptobinding if server supports it
# * 2 = require cryptobinding
-# EAP-WSC (WPS) uses following options: pin=<Device Password> and
-# uuid=<Device UUID>.
+# EAP-WSC (WPS) uses following options: pin=<Device Password> or
+# pbc=1.
# phase2: Phase2 (inner authentication with TLS tunnel) parameters
# (string with field-value pairs, e.g., "auth=MSCHAPV2" for EAP-PEAP or
# "autheap=MSCHAPV2 autheap=MD5" for EAP-TTLS)
diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c
index 41159bb..8ea9622 100644
--- a/wpa_supplicant/wpas_glue.c
+++ b/wpa_supplicant/wpas_glue.c
@@ -703,6 +703,7 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
#endif /* EAP_TLS_OPENSSL */
ctx->mac_addr = wpa_s->own_addr;
+ ctx->uuid = wpa_s->conf->uuid;
ctx->wps_cred = wpa_supplicant_wps_cred;
ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
ctx->cb = wpa_supplicant_eapol_cb;