aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorMasashi Honma <honma@ictec.co.jp>2009-02-26 19:57:38 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-26 19:57:38 (GMT)
commit46bdb83acdb9c2f1a031971e665b75fce6bcbe47 (patch)
treebf3fdd443275779adc6329be9201b111407bf07d /hostapd
parentb414900a90829d3d3a58a45f29be708a6757b258 (diff)
downloadhostap-46bdb83acdb9c2f1a031971e665b75fce6bcbe47.zip
hostap-46bdb83acdb9c2f1a031971e665b75fce6bcbe47.tar.gz
hostap-46bdb83acdb9c2f1a031971e665b75fce6bcbe47.tar.bz2
WPS: Add UFD support (USBA out-of-band mechanism)
This patch is only for the following use case: - Enrollee = wpa_supplicant - Registrar = hostapd internal Registrar Following UFD methods can be used: - Enrollee PIN with UFD - Registrar PIN with UFD - unencrypted credential with UFD Encrypted credentials are not supported. Enrollee side operation: wpa_cli -i ath0 wps_oob <device type> <mount point> <oob method> oob method = pin-e/pin-r/cred wpa_cli -i ath0 wps_oob ufd /mnt/ pin-r Registrar side operation: ./hostapd_cli -i ath0 wps_oob <device type> <mount point> <oob method> oob method = pin-e/pin-r/cred hostapd_cli -i ath0 wps_oob ufd /mnt/ cred
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/Makefile1
-rw-r--r--hostapd/ctrl_iface.c21
-rw-r--r--hostapd/hostapd_cli.c27
-rw-r--r--hostapd/wps_hostapd.c37
-rw-r--r--hostapd/wps_hostapd.h2
5 files changed, 88 insertions, 0 deletions
diff --git a/hostapd/Makefile b/hostapd/Makefile
index c8f9dfb..c5f12f7 100644
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
@@ -313,6 +313,7 @@ OBJS += ../src/wps/wps_attr_process.o
OBJS += ../src/wps/wps_dev_attr.o
OBJS += ../src/wps/wps_enrollee.o
OBJS += ../src/wps/wps_registrar.o
+OBJS += ../src/wps/wps_ufd.o
NEED_DH_GROUPS=y
NEED_SHA256=y
NEED_CRYPTO=y
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 4e31fb3..9e6505a 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -252,6 +252,24 @@ static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
*pin++ = '\0';
return hostapd_wps_add_pin(hapd, txt, pin);
}
+
+
+static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt)
+{
+ char *path, *method;
+
+ path = os_strchr(txt, ' ');
+ if (path == NULL)
+ return -1;
+ *path++ = '\0';
+
+ method = os_strchr(path, ' ');
+ if (method == NULL)
+ return -1;
+ *method++ = '\0';
+
+ return hostapd_wps_start_oob(hapd, txt, path, method);
+}
#endif /* CONFIG_WPS */
@@ -350,6 +368,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
} else if (os_strcmp(buf, "WPS_PBC") == 0) {
if (hostapd_wps_button_pushed(hapd))
reply_len = -1;
+ } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) {
+ if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8))
+ reply_len = -1;
#endif /* CONFIG_WPS */
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 2614113..d4d7a3f 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -89,6 +89,7 @@ static const char *commands_help =
#ifdef CONFIG_WPS
" wps_pin <uuid> <pin> add WPS Enrollee PIN (Device Password)\n"
" wps_pbc indicate button pushed to initiate PBC\n"
+" wps_oob <type> <path> <method> use WPS with out-of-band (UFD)\n"
#endif /* CONFIG_WPS */
" help show this usage help\n"
" interface [ifname] show interfaces/select interface\n"
@@ -275,6 +276,31 @@ static int hostapd_cli_cmd_wps_pbc(struct wpa_ctrl *ctrl, int argc,
{
return wpa_ctrl_command(ctrl, "WPS_PBC");
}
+
+
+static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ char cmd[256];
+ int res;
+
+ if (argc != 3) {
+ printf("Invalid WPS_OOB command: need three arguments:\n"
+ "- OOB_DEV_TYPE: use 'ufd'\n"
+ "- OOB_PATH: path of OOB device like '/mnt'\n"
+ "- OOB_METHOD: OOB method 'pin-e' or 'pin-r', "
+ "'cred'\n");
+ return -1;
+ }
+
+ res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s",
+ argv[0], argv[1], argv[2]);
+ if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
+ printf("Too long WPS_OOB command.\n");
+ return -1;
+ }
+ return wpa_ctrl_command(ctrl, cmd);
+}
#endif /* CONFIG_WPS */
@@ -432,6 +458,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
#ifdef CONFIG_WPS
{ "wps_pin", hostapd_cli_cmd_wps_pin },
{ "wps_pbc", hostapd_cli_cmd_wps_pbc },
+ { "wps_oob", hostapd_cli_cmd_wps_oob },
#endif /* CONFIG_WPS */
{ "help", hostapd_cli_cmd_help },
{ "interface", hostapd_cli_cmd_interface },
diff --git a/hostapd/wps_hostapd.c b/hostapd/wps_hostapd.c
index e0e7c0d..c470a36 100644
--- a/hostapd/wps_hostapd.c
+++ b/hostapd/wps_hostapd.c
@@ -26,6 +26,7 @@
#include "wps/wps_defs.h"
#include "wps/wps_dev_attr.h"
#include "wps_hostapd.h"
+#include "dh_groups.h"
#ifdef CONFIG_WPS_UPNP
@@ -648,6 +649,16 @@ int hostapd_init_wps(struct hostapd_data *hapd,
}
#endif /* CONFIG_WPS_UPNP */
+ wps->dh_pubkey = dh_init(dh_groups_get(WPS_DH_GROUP),
+ &wps->dh_privkey);
+ wps->dh_pubkey = wpabuf_zeropad(wps->dh_pubkey, 192);
+ if (wps->dh_pubkey == NULL) {
+ wpa_printf(MSG_ERROR, "WPS: Failed to initialize "
+ "Diffie-Hellman handshake");
+ os_free(wps);
+ return -1;
+ }
+
hapd->wps = wps;
return 0;
@@ -664,6 +675,8 @@ void hostapd_deinit_wps(struct hostapd_data *hapd)
wps_registrar_deinit(hapd->wps->registrar);
os_free(hapd->wps->network_key);
wps_device_data_free(&hapd->wps->dev);
+ wpabuf_free(hapd->wps->dh_pubkey);
+ wpabuf_free(hapd->wps->dh_privkey);
wps_free_pending_msgs(hapd->wps->upnp_msgs);
os_free(hapd->wps);
hapd->wps = NULL;
@@ -696,6 +709,30 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd)
}
+int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
+ char *path, char *method)
+{
+ struct wps_context *wps = hapd->wps;
+
+ wps->oob_dev = wps_get_oob_device(device_type);
+ if (wps->oob_dev == NULL)
+ return -1;
+ wps->oob_dev->device_path = path;
+ wps->oob_conf.oob_method = wps_get_oob_method(method);
+
+ if (wps_process_oob(wps, 1) < 0)
+ return -1;
+
+ if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
+ wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) &&
+ hostapd_wps_add_pin(hapd, "any",
+ wpabuf_head(wps->oob_conf.dev_password)) < 0)
+ return -1;
+
+ return 0;
+}
+
+
void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr,
const u8 *ie, size_t ie_len)
{
diff --git a/hostapd/wps_hostapd.h b/hostapd/wps_hostapd.h
index 6615c62..0d39797 100644
--- a/hostapd/wps_hostapd.h
+++ b/hostapd/wps_hostapd.h
@@ -23,6 +23,8 @@ void hostapd_deinit_wps(struct hostapd_data *hapd);
int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
const char *pin);
int hostapd_wps_button_pushed(struct hostapd_data *hapd);
+int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
+ char *path, char *method);
void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr,
const u8 *ie, size_t ie_len);