WPS: Remove deprecated UFD config method and OOB ctrl_iface
The UFD (USB flash drive) configuration method was deprecated in WSC 2.0. Since this is not known to be used, remove the UFD implementation from hostapd and wpa_supplicant to allow the WPS implementation to be cleaned up. This removes the now unused OOB operations and ctrl_iface commands that had already been deprecated by the new NFC operations. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
30c371e8a5
commit
207fb86411
20 changed files with 1 additions and 751 deletions
|
@ -369,12 +369,6 @@ NEED_AES_CBC=y
|
|||
NEED_MODEXP=y
|
||||
CONFIG_EAP=y
|
||||
|
||||
ifdef CONFIG_WPS_UFD
|
||||
L_CFLAGS += -DCONFIG_WPS_UFD
|
||||
OBJS += src/wps/wps_ufd.c
|
||||
NEED_WPS_OOB=y
|
||||
endif
|
||||
|
||||
ifdef CONFIG_WPS_NFC
|
||||
L_CFLAGS += -DCONFIG_WPS_NFC
|
||||
OBJS += src/wps/ndef.c
|
||||
|
|
|
@ -361,12 +361,6 @@ NEED_AES_CBC=y
|
|||
NEED_MODEXP=y
|
||||
CONFIG_EAP=y
|
||||
|
||||
ifdef CONFIG_WPS_UFD
|
||||
CFLAGS += -DCONFIG_WPS_UFD
|
||||
OBJS += ../src/wps/wps_ufd.o
|
||||
NEED_WPS_OOB=y
|
||||
endif
|
||||
|
||||
ifdef CONFIG_WPS_NFC
|
||||
CFLAGS += -DCONFIG_WPS_NFC
|
||||
OBJS += ../src/wps/ndef.o
|
||||
|
|
|
@ -250,26 +250,6 @@ static int hostapd_ctrl_iface_wps_check_pin(
|
|||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
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_OOB */
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
static int hostapd_ctrl_iface_wps_nfc_tag_read(struct hostapd_data *hapd,
|
||||
char *pos)
|
||||
|
@ -908,11 +888,6 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
|
|||
} else if (os_strcmp(buf, "WPS_CANCEL") == 0) {
|
||||
if (hostapd_wps_cancel(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 */
|
||||
} else if (os_strncmp(buf, "WPS_AP_PIN ", 11) == 0) {
|
||||
reply_len = hostapd_ctrl_iface_wps_ap_pin(hapd, buf + 11,
|
||||
reply, reply_size);
|
||||
|
|
|
@ -72,9 +72,6 @@ static const char *commands_help =
|
|||
" wps_check_pin <PIN> verify PIN checksum\n"
|
||||
" wps_pbc indicate button pushed to initiate PBC\n"
|
||||
" wps_cancel cancel the pending WPS operation\n"
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
" wps_oob <type> <path> <method> use WPS with out-of-band (UFD)\n"
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
" wps_nfc_tag_read <hexdump> report read NFC tag with WPS data\n"
|
||||
" wps_nfc_config_token <WPS/NDEF> build NFC configuration token\n"
|
||||
|
@ -405,34 +402,6 @@ static int hostapd_cli_cmd_wps_cancel(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[])
|
||||
{
|
||||
char cmd[256];
|
||||
int res;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Invalid WPS_OOB command: need three "
|
||||
"arguments:\n"
|
||||
"- DEV_TYPE: use 'ufd'\n"
|
||||
"- PATH: path of OOB device like '/mnt'\n"
|
||||
"- 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_OOB */
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
static int hostapd_cli_cmd_wps_nfc_tag_read(struct wpa_ctrl *ctrl, int argc,
|
||||
char *argv[])
|
||||
|
@ -798,9 +767,6 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
|
|||
{ "wps_check_pin", hostapd_cli_cmd_wps_check_pin },
|
||||
{ "wps_pbc", hostapd_cli_cmd_wps_pbc },
|
||||
{ "wps_cancel", hostapd_cli_cmd_wps_cancel },
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
{ "wps_oob", hostapd_cli_cmd_wps_oob },
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
{ "wps_nfc_tag_read", hostapd_cli_cmd_wps_nfc_tag_read },
|
||||
{ "wps_nfc_config_token", hostapd_cli_cmd_wps_nfc_config_token },
|
||||
|
|
|
@ -1036,8 +1036,6 @@ 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);
|
||||
hostapd_wps_nfc_clear(hapd->wps);
|
||||
os_free(hapd->wps);
|
||||
|
@ -1155,59 +1153,6 @@ int hostapd_wps_cancel(struct hostapd_data *hapd)
|
|||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
|
||||
char *path, char *method)
|
||||
{
|
||||
struct wps_context *wps = hapd->wps;
|
||||
struct oob_device_data *oob_dev;
|
||||
|
||||
oob_dev = wps_get_oob_device(device_type);
|
||||
if (oob_dev == NULL)
|
||||
return -1;
|
||||
oob_dev->device_path = path;
|
||||
wps->oob_conf.oob_method = wps_get_oob_method(method);
|
||||
|
||||
if (wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) {
|
||||
/*
|
||||
* Use pre-configured DH keys in order to be able to write the
|
||||
* key hash into the OOB file.
|
||||
*/
|
||||
wpabuf_free(wps->dh_pubkey);
|
||||
wpabuf_free(wps->dh_privkey);
|
||||
wps->dh_privkey = NULL;
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (wps_process_oob(wps, oob_dev, 1) < 0)
|
||||
goto error;
|
||||
|
||||
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, NULL, "any",
|
||||
wpabuf_head(wps->oob_conf.dev_password), 0) <
|
||||
0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
wpabuf_free(wps->dh_pubkey);
|
||||
wps->dh_pubkey = NULL;
|
||||
wpabuf_free(wps->dh_privkey);
|
||||
wps->dh_privkey = NULL;
|
||||
return -1;
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
|
||||
static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr, const u8 *da,
|
||||
const u8 *bssid,
|
||||
const u8 *ie, size_t ie_len,
|
||||
|
|
|
@ -21,8 +21,6 @@ int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr,
|
|||
int hostapd_wps_button_pushed(struct hostapd_data *hapd,
|
||||
const u8 *p2p_dev_addr);
|
||||
int hostapd_wps_cancel(struct hostapd_data *hapd);
|
||||
int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
|
||||
char *path, char *method);
|
||||
int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr,
|
||||
char *buf, size_t buflen);
|
||||
void hostapd_wps_ap_pin_disable(struct hostapd_data *hapd);
|
||||
|
|
|
@ -45,8 +45,7 @@ struct wps_data * wps_init(const struct wps_config *cfg)
|
|||
os_memcpy(data->uuid_e, cfg->wps->uuid, WPS_UUID_LEN);
|
||||
}
|
||||
if (cfg->pin) {
|
||||
data->dev_pw_id = data->wps->oob_dev_pw_id == 0 ?
|
||||
cfg->dev_pw_id : data->wps->oob_dev_pw_id;
|
||||
data->dev_pw_id = cfg->dev_pw_id;
|
||||
data->dev_password = os_malloc(cfg->pin_len);
|
||||
if (data->dev_password == NULL) {
|
||||
os_free(data);
|
||||
|
|
|
@ -103,17 +103,6 @@ struct wps_device_data {
|
|||
int p2p;
|
||||
};
|
||||
|
||||
struct oob_conf_data {
|
||||
enum {
|
||||
OOB_METHOD_UNKNOWN = 0,
|
||||
OOB_METHOD_DEV_PWD_E,
|
||||
OOB_METHOD_DEV_PWD_R,
|
||||
OOB_METHOD_CRED,
|
||||
} oob_method;
|
||||
struct wpabuf *dev_password;
|
||||
struct wpabuf *pubkey_hash;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wps_config - WPS configuration for a single registration protocol run
|
||||
*/
|
||||
|
@ -618,16 +607,6 @@ struct wps_context {
|
|||
*/
|
||||
struct wps_device_data dev;
|
||||
|
||||
/**
|
||||
* oob_conf - OOB Config data
|
||||
*/
|
||||
struct oob_conf_data oob_conf;
|
||||
|
||||
/**
|
||||
* oob_dev_pw_id - OOB Device password id
|
||||
*/
|
||||
u16 oob_dev_pw_id;
|
||||
|
||||
/**
|
||||
* dh_ctx - Context data for Diffie-Hellman operation
|
||||
*/
|
||||
|
@ -766,15 +745,6 @@ struct wps_context {
|
|||
struct wpabuf *ap_nfc_dev_pw;
|
||||
};
|
||||
|
||||
struct oob_device_data {
|
||||
char *device_path;
|
||||
void * (*init_func)(struct wps_context *, struct oob_device_data *,
|
||||
int);
|
||||
struct wpabuf * (*read_func)(void *);
|
||||
int (*write_func)(void *, struct wpabuf *);
|
||||
void (*deinit_func)(void *);
|
||||
};
|
||||
|
||||
struct wps_registrar *
|
||||
wps_registrar_init(struct wps_context *wps,
|
||||
const struct wps_registrar_config *cfg);
|
||||
|
@ -813,10 +783,6 @@ unsigned int wps_generate_pin(void);
|
|||
int wps_pin_str_valid(const char *pin);
|
||||
void wps_free_pending_msgs(struct upnp_pending_message *msgs);
|
||||
|
||||
struct oob_device_data * wps_get_oob_device(char *device_type);
|
||||
int wps_get_oob_method(char *method);
|
||||
int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
|
||||
int registrar);
|
||||
struct wpabuf * wps_get_oob_cred(struct wps_context *wps);
|
||||
int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr);
|
||||
int wps_attr_text(struct wpabuf *data, char *buf, char *end);
|
||||
|
|
|
@ -368,38 +368,6 @@ int wps_build_oob_dev_pw(struct wpabuf *msg, u16 dev_pw_id,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps)
|
||||
{
|
||||
u8 dev_password_bin[WPS_OOB_DEVICE_PASSWORD_LEN];
|
||||
|
||||
wpa_printf(MSG_DEBUG, "WPS: * OOB Device Password");
|
||||
|
||||
if (os_get_random((u8 *) &wps->oob_dev_pw_id, sizeof(u16)) < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: device password id "
|
||||
"generation error");
|
||||
return -1;
|
||||
}
|
||||
wps->oob_dev_pw_id |= 0x0010;
|
||||
|
||||
if (random_get_bytes(dev_password_bin, WPS_OOB_DEVICE_PASSWORD_LEN) <
|
||||
0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: OOB device password "
|
||||
"generation error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
wpa_snprintf_hex_uppercase(
|
||||
wpabuf_put(wps->oob_conf.dev_password,
|
||||
wpabuf_size(wps->oob_conf.dev_password)),
|
||||
wpabuf_size(wps->oob_conf.dev_password),
|
||||
dev_password_bin, WPS_OOB_DEVICE_PASSWORD_LEN);
|
||||
|
||||
return wps_build_oob_dev_pw(msg, wps->oob_dev_pw_id, wps->dh_pubkey,
|
||||
dev_password_bin,
|
||||
WPS_OOB_DEVICE_PASSWORD_LEN);
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
|
||||
|
|
|
@ -375,84 +375,6 @@ struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id,
|
|||
}
|
||||
|
||||
|
||||
static struct wpabuf * wps_get_oob_dev_pwd(struct wps_context *wps)
|
||||
{
|
||||
struct wpabuf *data;
|
||||
|
||||
data = wpabuf_alloc(200);
|
||||
if (data == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to allocate memory for OOB "
|
||||
"device password attribute");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wpabuf_free(wps->oob_conf.dev_password);
|
||||
wps->oob_conf.dev_password =
|
||||
wpabuf_alloc(WPS_OOB_DEVICE_PASSWORD_LEN * 2 + 1);
|
||||
if (wps->oob_conf.dev_password == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to allocate memory for OOB "
|
||||
"device password");
|
||||
wpabuf_free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (wps_build_version(data) ||
|
||||
wps_build_oob_dev_password(data, wps) ||
|
||||
wps_build_wfa_ext(data, 0, NULL, 0)) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Build OOB device password "
|
||||
"attribute error");
|
||||
wpabuf_free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static int wps_parse_oob_dev_pwd(struct wps_context *wps,
|
||||
struct wpabuf *data)
|
||||
{
|
||||
struct oob_conf_data *oob_conf = &wps->oob_conf;
|
||||
struct wps_parse_attr attr;
|
||||
const u8 *pos;
|
||||
size_t pw_len;
|
||||
|
||||
if (wps_parse_msg(data, &attr) < 0 ||
|
||||
attr.oob_dev_password == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: OOB device password not found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pos = attr.oob_dev_password;
|
||||
|
||||
wpabuf_free(oob_conf->pubkey_hash);
|
||||
oob_conf->pubkey_hash =
|
||||
wpabuf_alloc_copy(pos, WPS_OOB_PUBKEY_HASH_LEN);
|
||||
if (oob_conf->pubkey_hash == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to allocate memory for OOB "
|
||||
"public key hash");
|
||||
return -1;
|
||||
}
|
||||
pos += WPS_OOB_PUBKEY_HASH_LEN;
|
||||
|
||||
wps->oob_dev_pw_id = WPA_GET_BE16(pos);
|
||||
pos += sizeof(wps->oob_dev_pw_id);
|
||||
|
||||
pw_len = attr.oob_dev_password_len - WPS_OOB_PUBKEY_HASH_LEN - 2;
|
||||
oob_conf->dev_password = wpabuf_alloc(pw_len * 2 + 1);
|
||||
if (oob_conf->dev_password == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to allocate memory for OOB "
|
||||
"device password");
|
||||
return -1;
|
||||
}
|
||||
wpa_snprintf_hex_uppercase(wpabuf_put(oob_conf->dev_password,
|
||||
pw_len * 2 + 1),
|
||||
pw_len * 2 + 1, pos, pw_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr)
|
||||
{
|
||||
struct wpabuf msg;
|
||||
|
@ -477,88 +399,6 @@ int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr)
|
|||
}
|
||||
|
||||
|
||||
static int wps_parse_oob_cred(struct wps_context *wps, struct wpabuf *data)
|
||||
{
|
||||
struct wps_parse_attr attr;
|
||||
|
||||
if (wps_parse_msg(data, &attr) < 0 || attr.num_cred <= 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: OOB credential not found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return wps_oob_use_cred(wps, &attr);
|
||||
}
|
||||
|
||||
|
||||
int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
|
||||
int registrar)
|
||||
{
|
||||
struct wpabuf *data;
|
||||
int ret, write_f, oob_method = wps->oob_conf.oob_method;
|
||||
void *oob_priv;
|
||||
|
||||
write_f = oob_method == OOB_METHOD_DEV_PWD_E ? !registrar : registrar;
|
||||
|
||||
oob_priv = oob_dev->init_func(wps, oob_dev, registrar);
|
||||
if (oob_priv == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to initialize OOB device");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write_f) {
|
||||
if (oob_method == OOB_METHOD_CRED)
|
||||
data = wps_get_oob_cred(wps);
|
||||
else
|
||||
data = wps_get_oob_dev_pwd(wps);
|
||||
|
||||
ret = 0;
|
||||
if (data == NULL || oob_dev->write_func(oob_priv, data) < 0)
|
||||
ret = -1;
|
||||
} else {
|
||||
data = oob_dev->read_func(oob_priv);
|
||||
if (data == NULL)
|
||||
ret = -1;
|
||||
else {
|
||||
if (oob_method == OOB_METHOD_CRED)
|
||||
ret = wps_parse_oob_cred(wps, data);
|
||||
else
|
||||
ret = wps_parse_oob_dev_pwd(wps, data);
|
||||
}
|
||||
}
|
||||
wpabuf_free(data);
|
||||
oob_dev->deinit_func(oob_priv);
|
||||
|
||||
if (ret < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to process OOB data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct oob_device_data * wps_get_oob_device(char *device_type)
|
||||
{
|
||||
#ifdef CONFIG_WPS_UFD
|
||||
if (os_strstr(device_type, "ufd") != NULL)
|
||||
return &oob_ufd_device_data;
|
||||
#endif /* CONFIG_WPS_UFD */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int wps_get_oob_method(char *method)
|
||||
{
|
||||
if (os_strstr(method, "pin-e") != NULL)
|
||||
return OOB_METHOD_DEV_PWD_E;
|
||||
if (os_strstr(method, "pin-r") != NULL)
|
||||
return OOB_METHOD_DEV_PWD_R;
|
||||
if (os_strstr(method, "cred") != NULL)
|
||||
return OOB_METHOD_CRED;
|
||||
return OOB_METHOD_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
|
||||
|
@ -638,15 +478,10 @@ u16 wps_config_methods_str2bin(const char *str)
|
|||
#ifdef CONFIG_WPS2
|
||||
methods |= WPS_CONFIG_VIRT_DISPLAY;
|
||||
#endif /* CONFIG_WPS2 */
|
||||
#ifdef CONFIG_WPS_UFD
|
||||
methods |= WPS_CONFIG_USBA;
|
||||
#endif /* CONFIG_WPS_UFD */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
methods |= WPS_CONFIG_NFC_INTERFACE;
|
||||
#endif /* CONFIG_WPS_NFC */
|
||||
} else {
|
||||
if (os_strstr(str, "usba"))
|
||||
methods |= WPS_CONFIG_USBA;
|
||||
if (os_strstr(str, "ethernet"))
|
||||
methods |= WPS_CONFIG_ETHERNET;
|
||||
if (os_strstr(str, "label"))
|
||||
|
|
|
@ -523,23 +523,6 @@ 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];
|
||||
u8 hash[WPS_HASH_LEN];
|
||||
|
||||
addr[0] = pk;
|
||||
sha256_vector(1, addr, &pk_len, hash);
|
||||
if (os_memcmp(hash,
|
||||
wpabuf_head(wps->wps->oob_conf.pubkey_hash),
|
||||
WPS_OOB_PUBKEY_HASH_LEN) != 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Public Key hash error");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
wpabuf_free(wps->dh_pubkey_r);
|
||||
wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len);
|
||||
if (wps->dh_pubkey_r == NULL)
|
||||
|
|
|
@ -137,8 +137,6 @@ void wps_pwd_auth_fail_event(struct wps_context *wps, int enrollee, int part);
|
|||
void wps_pbc_overlap_event(struct wps_context *wps);
|
||||
void wps_pbc_timeout_event(struct wps_context *wps);
|
||||
|
||||
extern struct oob_device_data oob_ufd_device_data;
|
||||
|
||||
struct wpabuf * wps_build_wsc_ack(struct wps_data *wps);
|
||||
struct wpabuf * wps_build_wsc_nack(struct wps_data *wps);
|
||||
|
||||
|
@ -167,7 +165,6 @@ int wps_build_assoc_state(struct wps_data *wps, struct wpabuf *msg);
|
|||
int wps_build_oob_dev_pw(struct wpabuf *msg, u16 dev_pw_id,
|
||||
const struct wpabuf *pubkey, const u8 *dev_pw,
|
||||
size_t dev_pw_len);
|
||||
int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps);
|
||||
struct wpabuf * wps_ie_encapsulate(struct wpabuf *data);
|
||||
|
||||
/* wps_attr_process.c */
|
||||
|
|
|
@ -2233,22 +2233,6 @@ 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];
|
||||
|
||||
addr[0] = pk;
|
||||
sha256_vector(1, addr, &pk_len, hash);
|
||||
if (os_memcmp(hash,
|
||||
wpabuf_head(wps->wps->oob_conf.pubkey_hash),
|
||||
WPS_OOB_PUBKEY_HASH_LEN) != 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Public Key hash error");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
wpabuf_free(wps->dh_pubkey_e);
|
||||
wps->dh_pubkey_e = wpabuf_alloc_copy(pk, pk_len);
|
||||
if (wps->dh_pubkey_e == NULL)
|
||||
|
@ -2544,16 +2528,6 @@ static enum wps_process_res wps_process_m1(struct wps_data *wps,
|
|||
}
|
||||
#endif /* CONFIG_WPS_NFC */
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
if (wps->dev_pw_id >= 0x10 && wps->nfc_pw_token == NULL &&
|
||||
wps->dev_pw_id != wps->wps->oob_dev_pw_id) {
|
||||
wpa_printf(MSG_DEBUG, "WPS: OOB Device Password ID "
|
||||
"%d mismatch", wps->dev_pw_id);
|
||||
wps->state = SEND_M2D;
|
||||
return WPS_CONTINUE;
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
if (wps->dev_pw_id == DEV_PW_PUSHBUTTON) {
|
||||
if ((wps->wps->registrar->force_pbc_overlap ||
|
||||
wps_registrar_pbc_overlap(wps->wps->registrar,
|
||||
|
|
|
@ -1,229 +0,0 @@
|
|||
/*
|
||||
* UFD routines for Wi-Fi Protected Setup
|
||||
* Copyright (c) 2009-2012, Masashi Honma <masashi.honma@gmail.com>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "common.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "wps/wps.h"
|
||||
#include "wps/wps_i.h"
|
||||
|
||||
#ifdef CONFIG_NATIVE_WINDOWS
|
||||
#define UFD_DIR1 "%s\\SMRTNTKY"
|
||||
#define UFD_DIR2 UFD_DIR1 "\\WFAWSC"
|
||||
#define UFD_FILE UFD_DIR2 "\\%s"
|
||||
#else /* CONFIG_NATIVE_WINDOWS */
|
||||
#define UFD_DIR1 "%s/SMRTNTKY"
|
||||
#define UFD_DIR2 UFD_DIR1 "/WFAWSC"
|
||||
#define UFD_FILE UFD_DIR2 "/%s"
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
|
||||
|
||||
struct wps_ufd_data {
|
||||
int ufd_fd;
|
||||
};
|
||||
|
||||
|
||||
static int dev_pwd_e_file_filter(const struct dirent *entry)
|
||||
{
|
||||
unsigned int prefix;
|
||||
char ext[5];
|
||||
|
||||
if (sscanf(entry->d_name, "%8x.%4s", &prefix, ext) != 2)
|
||||
return 0;
|
||||
if (prefix == 0)
|
||||
return 0;
|
||||
if (os_strcasecmp(ext, "WFA") != 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int wps_get_dev_pwd_e_file_name(char *path, char *file_name)
|
||||
{
|
||||
struct dirent **namelist;
|
||||
int i, file_num;
|
||||
|
||||
file_num = scandir(path, &namelist, &dev_pwd_e_file_filter,
|
||||
alphasort);
|
||||
if (file_num < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: OOB file not found: %d (%s)",
|
||||
errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (file_num == 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS: OOB file not found");
|
||||
os_free(namelist);
|
||||
return -1;
|
||||
}
|
||||
os_strlcpy(file_name, namelist[0]->d_name, 13);
|
||||
for (i = 0; i < file_num; i++)
|
||||
os_free(namelist[i]);
|
||||
os_free(namelist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int get_file_name(struct wps_context *wps, int registrar,
|
||||
const char *path, char *file_name)
|
||||
{
|
||||
switch (wps->oob_conf.oob_method) {
|
||||
case OOB_METHOD_CRED:
|
||||
os_snprintf(file_name, 13, "00000000.WSC");
|
||||
break;
|
||||
case OOB_METHOD_DEV_PWD_E:
|
||||
if (registrar) {
|
||||
char temp[128];
|
||||
os_snprintf(temp, sizeof(temp), UFD_DIR2, path);
|
||||
if (wps_get_dev_pwd_e_file_name(temp, file_name) < 0)
|
||||
return -1;
|
||||
} else {
|
||||
u8 *mac_addr = wps->dev.mac_addr;
|
||||
|
||||
os_snprintf(file_name, 13, "%02X%02X%02X%02X.WFA",
|
||||
mac_addr[2], mac_addr[3], mac_addr[4],
|
||||
mac_addr[5]);
|
||||
}
|
||||
break;
|
||||
case OOB_METHOD_DEV_PWD_R:
|
||||
os_snprintf(file_name, 13, "00000000.WFA");
|
||||
break;
|
||||
default:
|
||||
wpa_printf(MSG_ERROR, "WPS: Invalid USBA OOB method");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ufd_mkdir(const char *path)
|
||||
{
|
||||
if (mkdir(path, S_IRWXU) < 0 && errno != EEXIST) {
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to create directory "
|
||||
"'%s': %d (%s)", path, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void * init_ufd(struct wps_context *wps,
|
||||
struct oob_device_data *oob_dev, int registrar)
|
||||
{
|
||||
int write_f;
|
||||
char temp[128];
|
||||
char *path = oob_dev->device_path;
|
||||
char filename[13];
|
||||
struct wps_ufd_data *data;
|
||||
int ufd_fd;
|
||||
|
||||
if (path == NULL)
|
||||
return NULL;
|
||||
|
||||
write_f = wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ?
|
||||
!registrar : registrar;
|
||||
|
||||
if (get_file_name(wps, registrar, path, filename) < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to get file name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (write_f) {
|
||||
os_snprintf(temp, sizeof(temp), UFD_DIR1, path);
|
||||
if (ufd_mkdir(temp))
|
||||
return NULL;
|
||||
os_snprintf(temp, sizeof(temp), UFD_DIR2, path);
|
||||
if (ufd_mkdir(temp))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
os_snprintf(temp, sizeof(temp), UFD_FILE, path, filename);
|
||||
if (write_f)
|
||||
ufd_fd = open(temp, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR);
|
||||
else
|
||||
ufd_fd = open(temp, O_RDONLY);
|
||||
if (ufd_fd < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to open %s: %s",
|
||||
temp, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = os_zalloc(sizeof(*data));
|
||||
if (data == NULL) {
|
||||
close(ufd_fd);
|
||||
return NULL;
|
||||
}
|
||||
data->ufd_fd = ufd_fd;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static struct wpabuf * read_ufd(void *priv)
|
||||
{
|
||||
struct wps_ufd_data *data = priv;
|
||||
struct wpabuf *buf;
|
||||
struct stat s;
|
||||
size_t file_size;
|
||||
|
||||
if (fstat(data->ufd_fd, &s) < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to get file size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
file_size = s.st_size;
|
||||
buf = wpabuf_alloc(file_size);
|
||||
if (buf == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to alloc read "
|
||||
"buffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (read(data->ufd_fd, wpabuf_mhead(buf), file_size) !=
|
||||
(int) file_size) {
|
||||
wpabuf_free(buf);
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to read");
|
||||
return NULL;
|
||||
}
|
||||
wpabuf_put(buf, file_size);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
static int write_ufd(void *priv, struct wpabuf *buf)
|
||||
{
|
||||
struct wps_ufd_data *data = priv;
|
||||
|
||||
if (write(data->ufd_fd, wpabuf_mhead(buf), wpabuf_len(buf)) !=
|
||||
(int) wpabuf_len(buf)) {
|
||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to write");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void deinit_ufd(void *priv)
|
||||
{
|
||||
struct wps_ufd_data *data = priv;
|
||||
close(data->ufd_fd);
|
||||
os_free(data);
|
||||
}
|
||||
|
||||
|
||||
struct oob_device_data oob_ufd_device_data = {
|
||||
.device_path = NULL,
|
||||
.init_func = init_ufd,
|
||||
.read_func = read_ufd,
|
||||
.write_func = write_ufd,
|
||||
.deinit_func = deinit_ufd,
|
||||
};
|
|
@ -584,12 +584,6 @@ NEED_80211_COMMON=y
|
|||
NEED_AES_CBC=y
|
||||
NEED_MODEXP=y
|
||||
|
||||
ifdef CONFIG_WPS_UFD
|
||||
L_CFLAGS += -DCONFIG_WPS_UFD
|
||||
OBJS += src/wps/wps_ufd.c
|
||||
NEED_WPS_OOB=y
|
||||
endif
|
||||
|
||||
ifdef CONFIG_WPS_NFC
|
||||
L_CFLAGS += -DCONFIG_WPS_NFC
|
||||
OBJS += src/wps/ndef.c
|
||||
|
|
|
@ -592,12 +592,6 @@ NEED_80211_COMMON=y
|
|||
NEED_AES_CBC=y
|
||||
NEED_MODEXP=y
|
||||
|
||||
ifdef CONFIG_WPS_UFD
|
||||
CFLAGS += -DCONFIG_WPS_UFD
|
||||
OBJS += ../src/wps/wps_ufd.o
|
||||
NEED_WPS_OOB=y
|
||||
endif
|
||||
|
||||
ifdef CONFIG_WPS_NFC
|
||||
CFLAGS += -DCONFIG_WPS_NFC
|
||||
OBJS += ../src/wps/ndef.o
|
||||
|
|
|
@ -750,27 +750,6 @@ static int wpa_supplicant_ctrl_iface_wps_check_pin(
|
|||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
static int wpa_supplicant_ctrl_iface_wps_oob(struct wpa_supplicant *wpa_s,
|
||||
char *cmd)
|
||||
{
|
||||
char *path, *method;
|
||||
|
||||
path = os_strchr(cmd, ' ');
|
||||
if (path == NULL)
|
||||
return -1;
|
||||
*path++ = '\0';
|
||||
|
||||
method = os_strchr(path, ' ');
|
||||
if (method == NULL)
|
||||
return -1;
|
||||
*method++ = '\0';
|
||||
|
||||
return wpas_wps_start_oob(wpa_s, cmd, path, method);
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
|
||||
static int wpa_supplicant_ctrl_iface_wps_nfc(struct wpa_supplicant *wpa_s,
|
||||
|
@ -4787,11 +4766,6 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
|
|||
} else if (os_strcmp(buf, "WPS_CANCEL") == 0) {
|
||||
if (wpas_wps_cancel(wpa_s))
|
||||
reply_len = -1;
|
||||
#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 */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
} else if (os_strcmp(buf, "WPS_NFC") == 0) {
|
||||
if (wpa_supplicant_ctrl_iface_wps_nfc(wpa_s, NULL))
|
||||
|
|
|
@ -736,24 +736,6 @@ static int wpa_cli_cmd_wps_cancel(struct wpa_ctrl *ctrl, int argc,
|
|||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
static int wpa_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf("Invalid WPS_OOB command: need three "
|
||||
"arguments:\n"
|
||||
"- DEV_TYPE: use 'ufd'\n"
|
||||
"- PATH: path of OOB device like '/mnt'\n"
|
||||
"- METHOD: OOB method 'pin-e' or 'pin-r', "
|
||||
"'cred'\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return wpa_cli_cmd(ctrl, "WPS_OOB", 3, argc, argv);
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
|
||||
static int wpa_cli_cmd_wps_nfc(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
||||
|
@ -2485,11 +2467,6 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
|
|||
"<PIN> = verify PIN checksum" },
|
||||
{ "wps_cancel", wpa_cli_cmd_wps_cancel, NULL, cli_cmd_flag_none,
|
||||
"Cancels the pending WPS operation" },
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
{ "wps_oob", wpa_cli_cmd_wps_oob, NULL,
|
||||
cli_cmd_flag_sensitive,
|
||||
"<DEV_TYPE> <PATH> <METHOD> = start WPS OOB" },
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
{ "wps_nfc", wpa_cli_cmd_wps_nfc, wpa_cli_complete_bss,
|
||||
cli_cmd_flag_none,
|
||||
|
|
|
@ -1003,56 +1003,6 @@ int wpas_wps_cancel(struct wpa_supplicant *wpa_s)
|
|||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
|
||||
char *path, char *method)
|
||||
{
|
||||
struct wps_context *wps = wpa_s->wps;
|
||||
struct oob_device_data *oob_dev;
|
||||
|
||||
oob_dev = wps_get_oob_device(device_type);
|
||||
if (oob_dev == NULL)
|
||||
return -1;
|
||||
oob_dev->device_path = path;
|
||||
wps->oob_conf.oob_method = wps_get_oob_method(method);
|
||||
|
||||
if (wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E) {
|
||||
/*
|
||||
* Use pre-configured DH keys in order to be able to write the
|
||||
* key hash into the OOB file.
|
||||
*/
|
||||
wpabuf_free(wps->dh_pubkey);
|
||||
wpabuf_free(wps->dh_privkey);
|
||||
wps->dh_privkey = NULL;
|
||||
wps->dh_pubkey = NULL;
|
||||
dh5_free(wps->dh_ctx);
|
||||
wps->dh_ctx = dh5_init(&wps->dh_privkey, &wps->dh_pubkey);
|
||||
wps->dh_pubkey = wpabuf_zeropad(wps->dh_pubkey, 192);
|
||||
if (wps->dh_ctx == NULL || wps->dh_pubkey == NULL) {
|
||||
wpa_printf(MSG_ERROR, "WPS: Failed to initialize "
|
||||
"Diffie-Hellman handshake");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (wps->oob_conf.oob_method == OOB_METHOD_CRED)
|
||||
wpas_clear_wps(wpa_s);
|
||||
|
||||
if (wps_process_oob(wps, oob_dev, 0) < 0)
|
||||
return -1;
|
||||
|
||||
if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
|
||||
wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) &&
|
||||
wpas_wps_start_pin(wpa_s, NULL,
|
||||
wpabuf_head(wps->oob_conf.dev_password), 0,
|
||||
DEV_PW_DEFAULT) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
||||
|
||||
int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
||||
const char *pin, struct wps_new_ap_settings *settings)
|
||||
{
|
||||
|
@ -1316,8 +1266,6 @@ void wpas_wps_deinit(struct wpa_supplicant *wpa_s)
|
|||
wps_registrar_deinit(wpa_s->wps->registrar);
|
||||
wpabuf_free(wpa_s->wps->dh_pubkey);
|
||||
wpabuf_free(wpa_s->wps->dh_privkey);
|
||||
wpabuf_free(wpa_s->wps->oob_conf.pubkey_hash);
|
||||
wpabuf_free(wpa_s->wps->oob_conf.dev_password);
|
||||
wpabuf_free(wpa_s->wps->dev.vendor_ext_m1);
|
||||
os_free(wpa_s->wps->network_key);
|
||||
os_free(wpa_s->wps);
|
||||
|
|
|
@ -35,8 +35,6 @@ int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|||
int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
||||
const char *pin, int p2p_group, u16 dev_pw_id);
|
||||
int wpas_wps_cancel(struct wpa_supplicant *wpa_s);
|
||||
int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
|
||||
char *path, char *method);
|
||||
int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
||||
const char *pin, struct wps_new_ap_settings *settings);
|
||||
int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
|
||||
|
|
Loading…
Reference in a new issue