P2P: Set Device Password ID in WPS M1/M2 per new rules

If the P2P client (WPS Enrollee) uses a PIN from the GO (Registrar),
Device Password ID in M1 & M2 is set to Registrar-specified.
This commit is contained in:
Jouni Malinen 2010-06-26 22:49:41 -07:00 committed by Jouni Malinen
parent ef922c4a34
commit 3c5126a41f
10 changed files with 40 additions and 14 deletions

View file

@ -203,6 +203,10 @@ static void * eap_wsc_init(struct eap_sm *sm)
return NULL;
}
pos = os_strstr(phase1, "dev_pw_id=");
if (pos && cfg.pin)
cfg.dev_pw_id = atoi(pos + 10);
res = eap_wsc_new_ap_settings(&new_ap_settings, phase1);
if (res < 0) {
os_free(data);

View file

@ -46,7 +46,7 @@ struct wps_data * wps_init(const struct wps_config *cfg)
}
if (cfg->pin) {
data->dev_pw_id = data->wps->oob_dev_pw_id == 0 ?
DEV_PW_DEFAULT : data->wps->oob_dev_pw_id;
cfg->dev_pw_id : data->wps->oob_dev_pw_id;
data->dev_password = os_malloc(cfg->pin_len);
if (data->dev_password == NULL) {
os_free(data);

View file

@ -159,6 +159,11 @@ struct wps_config {
* struct wpa_context::psk.
*/
int use_psk_key;
/**
* dev_pw_id - Device Password ID for Enrollee when PIN is used
*/
u16 dev_pw_id;
};
struct wps_data * wps_init(const struct wps_config *cfg);

View file

@ -216,7 +216,8 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_AP */
if (pin) {
ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0);
ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0,
DEV_PW_DEFAULT);
if (ret < 0)
return -1;
ret = os_snprintf(buf, buflen, "%s", pin);
@ -225,7 +226,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s,
return ret;
}
ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0);
ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0, DEV_PW_DEFAULT);
if (ret < 0)
return -1;

View file

@ -231,7 +231,8 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
ret = wpas_wps_start_reg(wpa_s, params.bssid, params.pin,
NULL);
else if (params.type == 1) {
ret = wpas_wps_start_pin(wpa_s, params.bssid, params.pin, 0);
ret = wpas_wps_start_pin(wpa_s, params.bssid, params.pin, 0,
DEV_PW_DEFAULT);
if (ret > 0)
os_snprintf(npin, sizeof(npin), "%08d", ret);
} else

View file

@ -94,9 +94,11 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
}
if (os_strlen(pin) > 0)
ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0);
ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0,
DEV_PW_DEFAULT);
else
ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0);
ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0,
DEV_PW_DEFAULT);
if (ret < 0) {
return dbus_message_new_error(message,

View file

@ -683,9 +683,13 @@ static void wpas_start_wps_enrollee(struct wpa_supplicant *wpa_s,
if (res->wps_method == WPS_PBC)
wpas_wps_start_pbc(wpa_s, NULL /* res->peer_interface_addr */,
1);
else
else {
u16 dev_pw_id = DEV_PW_DEFAULT;
if (wpa_s->p2p_wps_method == WPS_PIN_KEYPAD)
dev_pw_id = DEV_PW_REGISTRAR_SPECIFIED;
wpas_wps_start_pin(wpa_s, res->peer_interface_addr,
wpa_s->p2p_pin, 1);
wpa_s->p2p_pin, 1, dev_pw_id);
}
}
@ -928,9 +932,11 @@ void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
wpas_p2p_remove_pending_group_interface(wpa_s);
return;
}
if (group_wpa_s != wpa_s)
if (group_wpa_s != wpa_s) {
os_memcpy(group_wpa_s->p2p_pin, wpa_s->p2p_pin,
sizeof(group_wpa_s->p2p_pin));
group_wpa_s->p2p_wps_method = wpa_s->p2p_wps_method;
}
os_memset(wpa_s->pending_interface_addr, 0, ETH_ALEN);
wpa_s->pending_interface_name[0] = '\0';
group_wpa_s->p2p_in_provisioning = 1;
@ -2384,9 +2390,11 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s)
group = wpas_p2p_get_group_iface(wpa_s, 0, 0);
if (group == NULL)
return -1;
if (group != wpa_s)
if (group != wpa_s) {
os_memcpy(group->p2p_pin, wpa_s->p2p_pin,
sizeof(group->p2p_pin));
group->p2p_wps_method = wpa_s->p2p_wps_method;
}
group->p2p_in_provisioning = 1;
@ -2430,6 +2438,8 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
if (!auth)
wpa_s->p2p_long_listen = 0;
wpa_s->p2p_wps_method = wps_method;
if (pin)
os_strlcpy(wpa_s->p2p_pin, pin, sizeof(wpa_s->p2p_pin));
else if (wps_method == WPS_PIN_DISPLAY) {

View file

@ -473,6 +473,7 @@ struct wpa_supplicant {
struct p2p_group *p2p_group;
int p2p_long_listen;
char p2p_pin[10];
int p2p_wps_method;
int p2p_sd_over_ctrl_iface;
int p2p_in_provisioning;
int pending_invite_ssid_id;

View file

@ -702,7 +702,7 @@ 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)
const char *pin, int p2p_group, u16 dev_pw_id)
{
struct wpa_ssid *ssid;
char val[128];
@ -715,10 +715,12 @@ int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
ssid->temporary = 1;
ssid->p2p_group = p2p_group;
if (pin)
os_snprintf(val, sizeof(val), "\"pin=%s\"", pin);
os_snprintf(val, sizeof(val), "\"pin=%s dev_pw_id=%u\"",
pin, dev_pw_id);
else {
rpin = wps_generate_pin();
os_snprintf(val, sizeof(val), "\"pin=%08d\"", rpin);
os_snprintf(val, sizeof(val), "\"pin=%08d dev_pw_id=%u\"",
rpin, dev_pw_id);
}
wpa_config_set(ssid, "phase1", val, 0);
if (wpa_s->wps_fragment_size)

View file

@ -38,7 +38,7 @@ enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid);
int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
int p2p_group);
int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
const char *pin, int p2p_group);
const char *pin, int p2p_group, u16 dev_pw_id);
int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
char *path, char *method, char *name);
int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,