WPS UFD: Build OOB functionality only if UFD is enabled

This commit is contained in:
Jouni Malinen 2009-02-26 22:10:21 +02:00
parent d5e2b2d274
commit 116f7bb0a3
12 changed files with 46 additions and 0 deletions

View file

@ -321,6 +321,11 @@ NEED_BASE64=y
ifdef CONFIG_WPS_UFD ifdef CONFIG_WPS_UFD
CFLAGS += -DCONFIG_WPS_UFD CFLAGS += -DCONFIG_WPS_UFD
OBJS += ../src/wps/wps_ufd.o OBJS += ../src/wps/wps_ufd.o
NEED_WPS_OOB=y
endif
ifdef NEED_WPS_OOB
CFLAGS += -DCONFIG_WPS_OOB
endif endif
ifdef CONFIG_WPS_UPNP ifdef CONFIG_WPS_UPNP

View file

@ -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) static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt)
{ {
char *path, *method; 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); return hostapd_wps_start_oob(hapd, txt, path, method);
} }
#endif /* CONFIG_WPS_OOB */
#endif /* CONFIG_WPS */ #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) { } else if (os_strcmp(buf, "WPS_PBC") == 0) {
if (hostapd_wps_button_pushed(hapd)) if (hostapd_wps_button_pushed(hapd))
reply_len = -1; reply_len = -1;
#ifdef CONFIG_WPS_OOB
} else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) { } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) {
if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8)) if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8))
reply_len = -1; reply_len = -1;
#endif /* CONFIG_WPS_OOB */
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
} else { } else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16); os_memcpy(reply, "UNKNOWN COMMAND\n", 16);

View file

@ -89,7 +89,9 @@ static const char *commands_help =
#ifdef CONFIG_WPS #ifdef CONFIG_WPS
" wps_pin <uuid> <pin> add WPS Enrollee PIN (Device Password)\n" " wps_pin <uuid> <pin> add WPS Enrollee PIN (Device Password)\n"
" wps_pbc indicate button pushed to initiate PBC\n" " wps_pbc indicate button pushed to initiate PBC\n"
#ifdef CONFIG_WPS_OOB
" wps_oob <type> <path> <method> use WPS with out-of-band (UFD)\n" " wps_oob <type> <path> <method> use WPS with out-of-band (UFD)\n"
#endif /* CONFIG_WPS_OOB */
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
" help show this usage help\n" " help show this usage help\n"
" interface [ifname] show interfaces/select interface\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, static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc,
char *argv[]) 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); return wpa_ctrl_command(ctrl, cmd);
} }
#endif /* CONFIG_WPS_OOB */
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
@ -458,7 +462,9 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
#ifdef CONFIG_WPS #ifdef CONFIG_WPS
{ "wps_pin", hostapd_cli_cmd_wps_pin }, { "wps_pin", hostapd_cli_cmd_wps_pin },
{ "wps_pbc", hostapd_cli_cmd_wps_pbc }, { "wps_pbc", hostapd_cli_cmd_wps_pbc },
#ifdef CONFIG_WPS_OOB
{ "wps_oob", hostapd_cli_cmd_wps_oob }, { "wps_oob", hostapd_cli_cmd_wps_oob },
#endif /* CONFIG_WPS_OOB */
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
{ "help", hostapd_cli_cmd_help }, { "help", hostapd_cli_cmd_help },
{ "interface", hostapd_cli_cmd_interface }, { "interface", hostapd_cli_cmd_interface },

View file

@ -667,6 +667,8 @@ void hostapd_deinit_wps(struct hostapd_data *hapd)
wps_device_data_free(&hapd->wps->dev); wps_device_data_free(&hapd->wps->dev);
wpabuf_free(hapd->wps->dh_pubkey); wpabuf_free(hapd->wps->dh_pubkey);
wpabuf_free(hapd->wps->dh_privkey); 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); wps_free_pending_msgs(hapd->wps->upnp_msgs);
os_free(hapd->wps); os_free(hapd->wps);
hapd->wps = NULL; 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, int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
char *path, char *method) char *path, char *method)
{ {
@ -747,6 +750,7 @@ error:
wps->dh_privkey = NULL; wps->dh_privkey = NULL;
return -1; return -1;
} }
#endif /* CONFIG_WPS_OOB */
void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr, void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr,

View file

@ -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) int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps)
{ {
size_t hash_len; size_t hash_len;
@ -306,3 +307,4 @@ int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps)
return 0; return 0;
} }
#endif /* CONFIG_WPS_OOB */

View file

@ -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) static struct wpabuf * wps_get_oob_cred(struct wps_context *wps)
{ {
struct wps_data data; struct wps_data data;
@ -538,3 +540,5 @@ int wps_get_oob_method(char *method)
return OOB_METHOD_CRED; return OOB_METHOD_CRED;
return OOB_METHOD_UNKNOWN; return OOB_METHOD_UNKNOWN;
} }
#endif /* CONFIG_WPS_OOB */

View file

@ -517,6 +517,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
return -1; return -1;
} }
#ifdef CONFIG_WPS_OOB
if (wps->dev_pw_id != DEV_PW_DEFAULT && if (wps->dev_pw_id != DEV_PW_DEFAULT &&
wps->wps->oob_conf.pubkey_hash) { wps->wps->oob_conf.pubkey_hash) {
const u8 *addr[1]; const u8 *addr[1];
@ -531,6 +532,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
return -1; return -1;
} }
} }
#endif /* CONFIG_WPS_OOB */
wpabuf_free(wps->dh_pubkey_r); wpabuf_free(wps->dh_pubkey_r);
wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len); wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len);

View file

@ -1627,6 +1627,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
return -1; return -1;
} }
#ifdef CONFIG_WPS_OOB
if (wps->wps->oob_conf.pubkey_hash != NULL) { if (wps->wps->oob_conf.pubkey_hash != NULL) {
const u8 *addr[1]; const u8 *addr[1];
u8 hash[WPS_HASH_LEN]; u8 hash[WPS_HASH_LEN];
@ -1640,6 +1641,7 @@ static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
return -1; return -1;
} }
} }
#endif /* CONFIG_WPS_OOB */
wpabuf_free(wps->dh_pubkey_e); wpabuf_free(wps->dh_pubkey_e);
wps->dh_pubkey_e = wpabuf_alloc_copy(pk, pk_len); 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; return WPS_CONTINUE;
} }
#ifdef CONFIG_WPS_OOB
if (wps->dev_pw_id >= 0x10 && if (wps->dev_pw_id >= 0x10 &&
wps->dev_pw_id != wps->wps->oob_dev_pw_id) { wps->dev_pw_id != wps->wps->oob_dev_pw_id) {
wpa_printf(MSG_DEBUG, "WPS: OOB Device Password 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; wps->state = SEND_M2D;
return WPS_CONTINUE; return WPS_CONTINUE;
} }
#endif /* CONFIG_WPS_OOB */
if (wps->dev_pw_id == DEV_PW_PUSHBUTTON) { if (wps->dev_pw_id == DEV_PW_PUSHBUTTON) {
if (wps_registrar_pbc_overlap(wps->wps->registrar, if (wps_registrar_pbc_overlap(wps->wps->registrar,

View file

@ -530,6 +530,11 @@ NEED_BASE64=y
ifdef CONFIG_WPS_UFD ifdef CONFIG_WPS_UFD
CFLAGS += -DCONFIG_WPS_UFD CFLAGS += -DCONFIG_WPS_UFD
OBJS += ../src/wps/wps_ufd.o OBJS += ../src/wps/wps_ufd.o
NEED_WPS_OOB=y
endif
ifdef NEED_WPS_OOB
CFLAGS += -DCONFIG_WPS_OOB
endif endif
ifdef CONFIG_WPS_UPNP ifdef CONFIG_WPS_UPNP

View file

@ -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, static int wpa_supplicant_ctrl_iface_wps_oob(struct wpa_supplicant *wpa_s,
char *cmd) 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); 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, 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_len = wpa_supplicant_ctrl_iface_wps_pin(wpa_s, buf + 8,
reply, reply,
reply_size); reply_size);
#ifdef CONFIG_WPS_OOB
} else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) { } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) {
if (wpa_supplicant_ctrl_iface_wps_oob(wpa_s, buf + 8)) if (wpa_supplicant_ctrl_iface_wps_oob(wpa_s, buf + 8))
reply_len = -1; reply_len = -1;
#endif /* CONFIG_WPS_OOB */
} else if (os_strncmp(buf, "WPS_REG ", 8) == 0) { } else if (os_strncmp(buf, "WPS_REG ", 8) == 0) {
if (wpa_supplicant_ctrl_iface_wps_reg(wpa_s, buf + 8)) if (wpa_supplicant_ctrl_iface_wps_reg(wpa_s, buf + 8))
reply_len = -1; reply_len = -1;

View file

@ -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[]) static int wpa_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, char *argv[])
{ {
char cmd[256]; 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); 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[]) 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, cli_cmd_flag_sensitive,
"<BSSID> [PIN] = start WPS PIN method (returns PIN, if not " "<BSSID> [PIN] = start WPS PIN method (returns PIN, if not "
"hardcoded)" }, "hardcoded)" },
#ifdef CONFIG_WPS_OOB
{ "wps_oob", wpa_cli_cmd_wps_oob, { "wps_oob", wpa_cli_cmd_wps_oob,
cli_cmd_flag_sensitive, cli_cmd_flag_sensitive,
"<OOB_DEV_TYPE> <OOB_PATH> <OOB_METHOD> = start WPS OOB" }, "<OOB_DEV_TYPE> <OOB_PATH> <OOB_METHOD> = start WPS OOB" },
#endif /* CONFIG_WPS_OOB */
{ "wps_reg", wpa_cli_cmd_wps_reg, { "wps_reg", wpa_cli_cmd_wps_reg,
cli_cmd_flag_sensitive, cli_cmd_flag_sensitive,
"<BSSID> <AP PIN> = start WPS Registrar to configure an AP" }, "<BSSID> <AP PIN> = start WPS Registrar to configure an AP" },

View file

@ -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, int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
char *path, char *method) char *path, char *method)
{ {
@ -506,6 +507,7 @@ int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
return 0; return 0;
} }
#endif /* CONFIG_WPS_OOB */
int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid, int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,