diff --git a/hostapd/Makefile b/hostapd/Makefile index 9c44edb1e..0dbece698 100644 --- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -321,6 +321,11 @@ NEED_BASE64=y ifdef CONFIG_WPS_UFD CFLAGS += -DCONFIG_WPS_UFD OBJS += ../src/wps/wps_ufd.o +NEED_WPS_OOB=y +endif + +ifdef NEED_WPS_OOB +CFLAGS += -DCONFIG_WPS_OOB endif ifdef CONFIG_WPS_UPNP diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 9e6505a77..5d85558fa 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -254,6 +254,7 @@ static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt) } +#ifdef CONFIG_WPS_OOB static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt) { char *path, *method; @@ -270,6 +271,7 @@ static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt) return hostapd_wps_start_oob(hapd, txt, path, method); } +#endif /* CONFIG_WPS_OOB */ #endif /* CONFIG_WPS */ @@ -368,9 +370,11 @@ 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; +#ifdef CONFIG_WPS_OOB } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) { if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8)) reply_len = -1; +#endif /* CONFIG_WPS_OOB */ #endif /* CONFIG_WPS */ } else { os_memcpy(reply, "UNKNOWN COMMAND\n", 16); diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index d4d7a3fa9..c32d9d3de 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -89,7 +89,9 @@ static const char *commands_help = #ifdef CONFIG_WPS " wps_pin add WPS Enrollee PIN (Device Password)\n" " wps_pbc indicate button pushed to initiate PBC\n" +#ifdef CONFIG_WPS_OOB " wps_oob use WPS with out-of-band (UFD)\n" +#endif /* CONFIG_WPS_OOB */ #endif /* CONFIG_WPS */ " help show this usage help\n" " interface [ifname] show interfaces/select interface\n" @@ -278,6 +280,7 @@ static int hostapd_cli_cmd_wps_pbc(struct wpa_ctrl *ctrl, int argc, } +#ifdef CONFIG_WPS_OOB static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -301,6 +304,7 @@ static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, } return wpa_ctrl_command(ctrl, cmd); } +#endif /* CONFIG_WPS_OOB */ #endif /* CONFIG_WPS */ @@ -458,7 +462,9 @@ 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 }, +#ifdef CONFIG_WPS_OOB { "wps_oob", hostapd_cli_cmd_wps_oob }, +#endif /* CONFIG_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 896c85649..0905391b7 100644 --- a/hostapd/wps_hostapd.c +++ b/hostapd/wps_hostapd.c @@ -667,6 +667,8 @@ void hostapd_deinit_wps(struct hostapd_data *hapd) wps_device_data_free(&hapd->wps->dev); wpabuf_free(hapd->wps->dh_pubkey); wpabuf_free(hapd->wps->dh_privkey); + wpabuf_free(hapd->wps->oob_conf.pubkey_hash); + wpabuf_free(hapd->wps->oob_conf.dev_password); wps_free_pending_msgs(hapd->wps->upnp_msgs); os_free(hapd->wps); hapd->wps = NULL; @@ -699,6 +701,7 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd) } +#ifdef CONFIG_WPS_OOB int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type, char *path, char *method) { @@ -747,6 +750,7 @@ error: wps->dh_privkey = NULL; return -1; } +#endif /* CONFIG_WPS_OOB */ void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr, diff --git a/src/wps/wps_attr_build.c b/src/wps/wps_attr_build.c index 919755da9..f35881af4 100644 --- a/src/wps/wps_attr_build.c +++ b/src/wps/wps_attr_build.c @@ -266,6 +266,7 @@ int wps_build_encr_settings(struct wps_data *wps, struct wpabuf *msg, } +#ifdef CONFIG_WPS_OOB int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps) { size_t hash_len; @@ -306,3 +307,4 @@ int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps) return 0; } +#endif /* CONFIG_WPS_OOB */ diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c index b5bb485c7..f679ff6fe 100644 --- a/src/wps/wps_common.c +++ b/src/wps/wps_common.c @@ -337,6 +337,8 @@ void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part) } +#ifdef CONFIG_WPS_OOB + static struct wpabuf * wps_get_oob_cred(struct wps_context *wps) { struct wps_data data; @@ -538,3 +540,5 @@ int wps_get_oob_method(char *method) return OOB_METHOD_CRED; return OOB_METHOD_UNKNOWN; } + +#endif /* CONFIG_WPS_OOB */ diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c index 4c2dd223a..6de9a0440 100644 --- a/src/wps/wps_enrollee.c +++ b/src/wps/wps_enrollee.c @@ -517,6 +517,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk, return -1; } +#ifdef CONFIG_WPS_OOB if (wps->dev_pw_id != DEV_PW_DEFAULT && wps->wps->oob_conf.pubkey_hash) { const u8 *addr[1]; @@ -531,6 +532,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk, return -1; } } +#endif /* CONFIG_WPS_OOB */ wpabuf_free(wps->dh_pubkey_r); wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len); diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index fb5579b82..dff635db5 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -1627,6 +1627,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk, return -1; } +#ifdef CONFIG_WPS_OOB if (wps->wps->oob_conf.pubkey_hash != NULL) { const u8 *addr[1]; u8 hash[WPS_HASH_LEN]; @@ -1640,6 +1641,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk, return -1; } } +#endif /* CONFIG_WPS_OOB */ wpabuf_free(wps->dh_pubkey_e); wps->dh_pubkey_e = wpabuf_alloc_copy(pk, pk_len); @@ -1821,6 +1823,7 @@ static enum wps_process_res wps_process_m1(struct wps_data *wps, return WPS_CONTINUE; } +#ifdef CONFIG_WPS_OOB if (wps->dev_pw_id >= 0x10 && wps->dev_pw_id != wps->wps->oob_dev_pw_id) { wpa_printf(MSG_DEBUG, "WPS: OOB Device Password ID " @@ -1828,6 +1831,7 @@ static enum wps_process_res wps_process_m1(struct wps_data *wps, wps->state = SEND_M2D; return WPS_CONTINUE; } +#endif /* CONFIG_WPS_OOB */ if (wps->dev_pw_id == DEV_PW_PUSHBUTTON) { if (wps_registrar_pbc_overlap(wps->wps->registrar, diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index 83252223c..4dab19b09 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -530,6 +530,11 @@ NEED_BASE64=y ifdef CONFIG_WPS_UFD CFLAGS += -DCONFIG_WPS_UFD OBJS += ../src/wps/wps_ufd.o +NEED_WPS_OOB=y +endif + +ifdef NEED_WPS_OOB +CFLAGS += -DCONFIG_WPS_OOB endif ifdef CONFIG_WPS_UPNP diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index ae01173b6..494672c9e 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -204,6 +204,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s, } +#ifdef CONFIG_WPS_OOB static int wpa_supplicant_ctrl_iface_wps_oob(struct wpa_supplicant *wpa_s, char *cmd) { @@ -221,6 +222,7 @@ static int wpa_supplicant_ctrl_iface_wps_oob(struct wpa_supplicant *wpa_s, return wpas_wps_start_oob(wpa_s, cmd, path, method); } +#endif /* CONFIG_WPS_OOB */ static int wpa_supplicant_ctrl_iface_wps_reg(struct wpa_supplicant *wpa_s, @@ -1602,9 +1604,11 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, reply_len = wpa_supplicant_ctrl_iface_wps_pin(wpa_s, buf + 8, reply, reply_size); +#ifdef CONFIG_WPS_OOB } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) { if (wpa_supplicant_ctrl_iface_wps_oob(wpa_s, buf + 8)) reply_len = -1; +#endif /* CONFIG_WPS_OOB */ } else if (os_strncmp(buf, "WPS_REG ", 8) == 0) { if (wpa_supplicant_ctrl_iface_wps_reg(wpa_s, buf + 8)) reply_len = -1; diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index bae0d6f40..d6055e90b 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -446,6 +446,7 @@ static int wpa_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc, char *argv[]) } +#ifdef CONFIG_WPS_OOB static int wpa_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, char *argv[]) { char cmd[256]; @@ -468,6 +469,7 @@ static int wpa_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, char *argv[]) } return wpa_ctrl_command(ctrl, cmd); } +#endif /* CONFIG_WPS_OOB */ static int wpa_cli_cmd_wps_reg(struct wpa_ctrl *ctrl, int argc, char *argv[]) @@ -1282,9 +1284,11 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { cli_cmd_flag_sensitive, " [PIN] = start WPS PIN method (returns PIN, if not " "hardcoded)" }, +#ifdef CONFIG_WPS_OOB { "wps_oob", wpa_cli_cmd_wps_oob, cli_cmd_flag_sensitive, " = start WPS OOB" }, +#endif /* CONFIG_WPS_OOB */ { "wps_reg", wpa_cli_cmd_wps_reg, cli_cmd_flag_sensitive, " = start WPS Registrar to configure an AP" }, diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 3e1d650a4..67ae1ac0b 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -462,6 +462,7 @@ int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid, } +#ifdef CONFIG_WPS_OOB int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type, char *path, char *method) { @@ -506,6 +507,7 @@ int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type, return 0; } +#endif /* CONFIG_WPS_OOB */ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,