aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2010-06-18 01:35:18 (GMT)
committerJouni Malinen <j@w1.fi>2010-09-09 13:07:48 (GMT)
commit53587ec1836cc9532d33c872875e1bad422ab5ad (patch)
treeee1e95f22a01684951959ce045a373c11058c99f /src
parentc15a854aec10a053cdbb955abc7f05d11fa51d1f (diff)
downloadhostap-53587ec1836cc9532d33c872875e1bad422ab5ad.zip
hostap-53587ec1836cc9532d33c872875e1bad422ab5ad.tar.gz
hostap-53587ec1836cc9532d33c872875e1bad422ab5ad.tar.bz2
WPS 2.0: Make WSC 2.0 support to be build option (CONFIG_WPS2)
For now, the default build will only include WSC 1.0 support. CONFIG_WPS2=y can be used to add support for WSC 2.0.
Diffstat (limited to 'src')
-rw-r--r--src/wps/wps.c11
-rw-r--r--src/wps/wps_attr_build.c4
-rw-r--r--src/wps/wps_attr_parse.c4
-rw-r--r--src/wps/wps_common.c4
-rw-r--r--src/wps/wps_defs.h8
-rw-r--r--src/wps/wps_enrollee.c6
-rw-r--r--src/wps/wps_er.c2
-rw-r--r--src/wps/wps_registrar.c50
8 files changed, 74 insertions, 15 deletions
diff --git a/src/wps/wps.c b/src/wps/wps.c
index 48cc2d8..1361b73 100644
--- a/src/wps/wps.c
+++ b/src/wps/wps.c
@@ -437,12 +437,14 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
if (pbc) {
methods = WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
/*
* TODO: At least in theory, should figure out whether this
* Probe Request was triggered with physical or virtual
* pushbutton.
*/
methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
+#endif /* CONFIG_WPS2 */
} else {
/*
* TODO: At least in theory, should figure out whether this
@@ -450,7 +452,9 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
* display.
*/
methods = WPS_CONFIG_LABEL | WPS_CONFIG_DISPLAY |
+#ifdef CONFIG_WPS2
WPS_CONFIG_VIRT_DISPLAY |
+#endif /* CONFIG_WPS2 */
WPS_CONFIG_KEYPAD;
#ifdef CONFIG_WPS_UFD
methods |= WPS_CONFIG_USBA;
@@ -470,13 +474,18 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
wps_build_config_error(ie, WPS_CFG_NO_ERROR) ||
wps_build_dev_password_id(ie, pbc ? DEV_PW_PUSHBUTTON :
DEV_PW_DEFAULT) ||
+#ifdef CONFIG_WPS2
wps_build_version2(ie) ||
wps_build_manufacturer(dev, ie) ||
wps_build_model_name(dev, ie) ||
wps_build_model_number(dev, ie) ||
wps_build_dev_name(dev, ie) ||
(req_type == WPS_REQ_ENROLLEE &&
- wps_build_req_to_enroll(ie))) {
+ wps_build_req_to_enroll(ie))
+#else /* CONFIG_WPS2 */
+ 0
+#endif /* CONFIG_WPS2 */
+ ) {
wpabuf_free(ie);
return NULL;
}
diff --git a/src/wps/wps_attr_build.c b/src/wps/wps_attr_build.c
index 3ec8204..2880141 100644
--- a/src/wps/wps_attr_build.c
+++ b/src/wps/wps_attr_build.c
@@ -174,6 +174,7 @@ int wps_build_version(struct wpabuf *msg)
int wps_build_version2(struct wpabuf *msg)
{
+#ifdef CONFIG_WPS2
wpa_printf(MSG_DEBUG, "WPS: * Version2 (0x%x)", WPS_VERSION);
wpabuf_put_be16(msg, ATTR_VERSION2);
wpabuf_put_be16(msg, 1);
@@ -185,6 +186,7 @@ int wps_build_version2(struct wpabuf *msg)
wpabuf_put_be16(msg, 1);
wpabuf_put_u8(msg, 42);
#endif /* CONFIG_WPS_EXTENSIBILITY_TESTING */
+#endif /* CONFIG_WPS2 */
return 0;
}
@@ -349,10 +351,12 @@ int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps)
int wps_build_req_to_enroll(struct wpabuf *msg)
{
+#ifdef CONFIG_WPS2
wpa_printf(MSG_DEBUG, "WPS: * Request to Enroll (1)");
wpabuf_put_be16(msg, ATTR_REQUEST_TO_ENROLL);
wpabuf_put_be16(msg, 1);
wpabuf_put_u8(msg, 1);
+#endif /* CONFIG_WPS2 */
return 0;
}
diff --git a/src/wps/wps_attr_parse.c b/src/wps/wps_attr_parse.c
index ffce495..70e3c60 100644
--- a/src/wps/wps_attr_parse.c
+++ b/src/wps/wps_attr_parse.c
@@ -34,6 +34,7 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
}
attr->version = pos;
break;
+#ifdef CONFIG_WPS2
case ATTR_VERSION2:
if (len != 1) {
wpa_printf(MSG_DEBUG, "WPS: Invalid Version2 length "
@@ -42,6 +43,7 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
}
attr->version2 = pos;
break;
+#endif /* CONFIG_WPS2 */
case ATTR_MSG_TYPE:
if (len != 1) {
wpa_printf(MSG_DEBUG, "WPS: Invalid Message Type "
@@ -409,6 +411,7 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
}
attr->ap_setup_locked = pos;
break;
+#ifdef CONFIG_WPS2
case ATTR_SETTINGS_DELAY_TIME:
if (len != 1) {
wpa_printf(MSG_DEBUG, "WPS: Invalid Settings Delay "
@@ -452,6 +455,7 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
attr->req_dev_type[attr->num_req_dev_type] = pos;
attr->num_req_dev_type++;
break;
+#endif /* CONFIG_WPS2 */
default:
wpa_printf(MSG_DEBUG, "WPS: Unsupported attribute type 0x%x "
"len=%u", type, len);
diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c
index a6a9594..001f7f2 100644
--- a/src/wps/wps_common.c
+++ b/src/wps/wps_common.c
@@ -609,7 +609,9 @@ u16 wps_config_methods_str2bin(const char *str)
if (str == NULL) {
/* Default to enabling methods based on build configuration */
methods |= WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
+#ifdef CONFIG_WPS2
methods |= WPS_CONFIG_VIRT_DISPLAY;
+#endif /* CONFIG_WPS2 */
#ifdef CONFIG_WPS_UFD
methods |= WPS_CONFIG_USBA;
#endif /* CONFIG_WPS_UFD */
@@ -635,6 +637,7 @@ u16 wps_config_methods_str2bin(const char *str)
methods |= WPS_CONFIG_PUSHBUTTON;
if (os_strstr(str, "keypad"))
methods |= WPS_CONFIG_KEYPAD;
+#ifdef CONFIG_WPS2
if (os_strstr(str, "virtual_display"))
methods |= WPS_CONFIG_VIRT_DISPLAY;
if (os_strstr(str, "physical_display"))
@@ -643,6 +646,7 @@ u16 wps_config_methods_str2bin(const char *str)
methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
if (os_strstr(str, "physical_push_button"))
methods |= WPS_CONFIG_PHY_PUSHBUTTON;
+#endif /* CONFIG_WPS2 */
}
return methods;
diff --git a/src/wps/wps_defs.h b/src/wps/wps_defs.h
index 13716de..1343a43 100644
--- a/src/wps/wps_defs.h
+++ b/src/wps/wps_defs.h
@@ -15,11 +15,15 @@
#ifndef WPS_DEFS_H
#define WPS_DEFS_H
+#ifdef CONFIG_WPS2
#ifdef CONFIG_WPS_EXTENSIBILITY_TESTING
#define WPS_VERSION 0x57
#else /* CONFIG_WPS_EXTENSIBILITY_TESTING */
#define WPS_VERSION 0x20
#endif /* CONFIG_WPS_EXTENSIBILITY_TESTING */
+#else /* CONFIG_WPS2 */
+#define WPS_VERSION 0x10
+#endif /* CONFIG_WPS2 */
/* Diffie-Hellman 1536-bit MODP Group; RFC 3526, Group 5 */
#define WPS_DH_GROUP 5
@@ -129,12 +133,14 @@ enum wps_attribute {
ATTR_802_1X_ENABLED = 0x1062,
ATTR_APPSESSIONKEY = 0x1063,
ATTR_WEPTRANSMITKEY = 0x1064,
+#ifdef CONFIG_WPS2
ATTR_SETTINGS_DELAY_TIME = 0x1065,
ATTR_NETWORK_KEY_SHAREABLE = 0x1066,
ATTR_VERSION2 = 0x1067,
ATTR_REQUEST_TO_ENROLL = 0x1068,
ATTR_AUTHORIZED_MACS = 0x1069,
ATTR_REQUESTED_DEV_TYPE = 0x106a,
+#endif /* CONFIG_WPS2 */
ATTR_EXTENSIBILITY_TEST = 0x10fa /* _NOT_ defined in the spec */
};
@@ -222,10 +228,12 @@ enum wps_config_error {
#define WPS_CONFIG_NFC_INTERFACE 0x0040
#define WPS_CONFIG_PUSHBUTTON 0x0080
#define WPS_CONFIG_KEYPAD 0x0100
+#ifdef CONFIG_WPS2
#define WPS_CONFIG_VIRT_PUSHBUTTON 0x0280
#define WPS_CONFIG_PHY_PUSHBUTTON 0x0480
#define WPS_CONFIG_VIRT_DISPLAY 0x2008
#define WPS_CONFIG_PHY_DISPLAY 0x4008
+#endif /* CONFIG_WPS2 */
/* Connection Type Flags */
#define WPS_CONN_ESS 0x01
diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c
index 8f915b2..6e2b511 100644
--- a/src/wps/wps_enrollee.c
+++ b/src/wps/wps_enrollee.c
@@ -698,6 +698,7 @@ static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
#endif /* CONFIG_WPS_STRICT */
}
+#ifdef CONFIG_WPS2
if (!(wps->cred.encr_type &
(WPS_ENCR_NONE | WPS_ENCR_TKIP | WPS_ENCR_AES))) {
if (wps->cred.encr_type & WPS_ENCR_WEP) {
@@ -710,6 +711,7 @@ static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
"invalid encr_type 0x%x", wps->cred.encr_type);
return -1;
}
+#endif /* CONFIG_WPS2 */
if (wps->wps->cred_cb) {
wps->cred.cred_attr = cred - 4;
@@ -796,6 +798,7 @@ static int wps_process_ap_settings_e(struct wps_data *wps,
#endif /* CONFIG_WPS_STRICT */
}
+#ifdef CONFIG_WPS2
if (!(cred.encr_type & (WPS_ENCR_NONE | WPS_ENCR_TKIP | WPS_ENCR_AES)))
{
if (cred.encr_type & WPS_ENCR_WEP) {
@@ -808,6 +811,7 @@ static int wps_process_ap_settings_e(struct wps_data *wps,
"invalid encr_type 0x%x", cred.encr_type);
return -1;
}
+#endif /* CONFIG_WPS2 */
#ifdef CONFIG_WPS_STRICT
if (wps2) {
@@ -822,6 +826,7 @@ static int wps_process_ap_settings_e(struct wps_data *wps,
}
#endif /* CONFIG_WPS_STRICT */
+#ifdef CONFIG_WPS2
if ((cred.encr_type & (WPS_ENCR_TKIP | WPS_ENCR_AES)) == WPS_ENCR_TKIP)
{
wpa_printf(MSG_DEBUG, "WPS: Upgrade encr_type TKIP -> "
@@ -835,6 +840,7 @@ static int wps_process_ap_settings_e(struct wps_data *wps,
"WPAPSK+WPA2PSK");
cred.auth_type |= WPS_AUTH_WPA2PSK;
}
+#endif /* CONFIG_WPS2 */
if (wps->wps->cred_cb) {
cred.cred_attr = wpabuf_head(attrs);
diff --git a/src/wps/wps_er.c b/src/wps/wps_er.c
index 9f5074a..51306cb 100644
--- a/src/wps/wps_er.c
+++ b/src/wps/wps_er.c
@@ -1351,9 +1351,11 @@ static int wps_er_build_sel_reg_config_methods(struct wpabuf *msg,
static int wps_er_build_uuid_r(struct wpabuf *msg, const u8 *uuid_r)
{
+#ifdef CONFIG_WPS2
wpabuf_put_be16(msg, ATTR_UUID_R);
wpabuf_put_be16(msg, WPS_UUID_LEN);
wpabuf_put_data(msg, uuid_r, WPS_UUID_LEN);
+#endif /* CONFIG_WPS2 */
return 0;
}
diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
index 3fc541f..96d0bfc 100644
--- a/src/wps/wps_registrar.c
+++ b/src/wps/wps_registrar.c
@@ -422,15 +422,20 @@ static int wps_build_sel_reg_config_methods(struct wps_registrar *reg,
u16 methods;
if (!reg->sel_reg_union)
return 0;
- methods = reg->wps->config_methods &
- ~(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_VIRT_PUSHBUTTON |
- WPS_CONFIG_PHY_PUSHBUTTON);
+ methods = reg->wps->config_methods;
+ methods &= ~WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
+ methods &= ~(WPS_CONFIG_VIRT_PUSHBUTTON |
+ WPS_CONFIG_PHY_PUSHBUTTON);
+#endif /* CONFIG_WPS2 */
if (reg->pbc) {
methods |= WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
if (reg->wps->config_methods & WPS_CONFIG_VIRT_PUSHBUTTON)
methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
if (reg->wps->config_methods & WPS_CONFIG_PHY_PUSHBUTTON)
methods |= WPS_CONFIG_PHY_PUSHBUTTON;
+#endif /* CONFIG_WPS2 */
}
if (reg->sel_reg_config_methods_override >= 0)
methods = reg->sel_reg_config_methods_override;
@@ -451,9 +456,11 @@ static int wps_build_probe_config_methods(struct wps_registrar *reg,
* These are the methods that the AP supports as an Enrollee for adding
* external Registrars.
*/
- methods = reg->wps->config_methods &
- ~(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_VIRT_PUSHBUTTON |
- WPS_CONFIG_PHY_PUSHBUTTON);
+ methods = reg->wps->config_methods & ~WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
+ methods &= ~(WPS_CONFIG_VIRT_PUSHBUTTON |
+ WPS_CONFIG_PHY_PUSHBUTTON);
+#endif /* CONFIG_WPS2 */
wpa_printf(MSG_DEBUG, "WPS: * Config Methods (%x)", methods);
wpabuf_put_be16(msg, ATTR_CONFIG_METHODS);
wpabuf_put_be16(msg, 2);
@@ -466,15 +473,19 @@ static int wps_build_config_methods_r(struct wps_registrar *reg,
struct wpabuf *msg)
{
u16 methods;
- methods = reg->wps->config_methods &
- ~(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_VIRT_PUSHBUTTON |
- WPS_CONFIG_PHY_PUSHBUTTON);
+ methods = reg->wps->config_methods & ~WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
+ methods &= ~(WPS_CONFIG_VIRT_PUSHBUTTON |
+ WPS_CONFIG_PHY_PUSHBUTTON);
+#endif /* CONFIG_WPS2 */
if (reg->pbc) {
methods |= WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
if (reg->wps->config_methods & WPS_CONFIG_VIRT_PUSHBUTTON)
methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
if (reg->wps->config_methods & WPS_CONFIG_PHY_PUSHBUTTON)
methods |= WPS_CONFIG_PHY_PUSHBUTTON;
+#endif /* CONFIG_WPS2 */
}
return wps_build_config_methods(msg, methods);
}
@@ -482,6 +493,7 @@ static int wps_build_config_methods_r(struct wps_registrar *reg,
int wps_build_authorized_macs(struct wps_registrar *reg, struct wpabuf *msg)
{
+#ifdef CONFIG_WPS2
int count = 0;
while (count < WPS_MAX_AUTHORIZED_MACS) {
@@ -497,6 +509,7 @@ int wps_build_authorized_macs(struct wps_registrar *reg, struct wpabuf *msg)
wpabuf_put_be16(msg, ATTR_AUTHORIZED_MACS);
wpabuf_put_be16(msg, count * ETH_ALEN);
wpabuf_put_data(msg, reg->authorized_macs_union, count * ETH_ALEN);
+#endif /* CONFIG_WPS2 */
return 0;
}
@@ -938,17 +951,21 @@ static void wps_cb_set_sel_reg(struct wps_registrar *reg)
return;
if (reg->selected_registrar) {
- methods = reg->wps->config_methods &
- ~(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_VIRT_PUSHBUTTON |
- WPS_CONFIG_PHY_PUSHBUTTON);
+ methods = reg->wps->config_methods & ~WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
+ methods &= ~(WPS_CONFIG_VIRT_PUSHBUTTON |
+ WPS_CONFIG_PHY_PUSHBUTTON);
+#endif /* CONFIG_WPS2 */
if (reg->pbc) {
methods |= WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
if (reg->wps->config_methods &
WPS_CONFIG_VIRT_PUSHBUTTON)
methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
if (reg->wps->config_methods &
WPS_CONFIG_PHY_PUSHBUTTON)
methods |= WPS_CONFIG_PHY_PUSHBUTTON;
+#endif /* CONFIG_WPS2 */
}
}
@@ -2963,14 +2980,18 @@ void wps_registrar_selected_registrar_changed(struct wps_registrar *reg)
WPS_MAX_AUTHORIZED_MACS * ETH_ALEN);
if (reg->selected_registrar) {
reg->sel_reg_config_methods_override =
- reg->wps->config_methods &
- ~(WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_VIRT_PUSHBUTTON |
+ reg->wps->config_methods & ~WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
+ reg->sel_reg_config_methods_override &=
+ ~(WPS_CONFIG_VIRT_PUSHBUTTON |
WPS_CONFIG_PHY_PUSHBUTTON);
+#endif /* CONFIG_WPS2 */
if (reg->pbc) {
reg->sel_reg_dev_password_id_override =
DEV_PW_PUSHBUTTON;
reg->sel_reg_config_methods_override |=
WPS_CONFIG_PUSHBUTTON;
+#ifdef CONFIG_WPS2
if (reg->wps->config_methods &
WPS_CONFIG_VIRT_PUSHBUTTON)
reg->sel_reg_config_methods_override |=
@@ -2979,6 +3000,7 @@ void wps_registrar_selected_registrar_changed(struct wps_registrar *reg)
WPS_CONFIG_PHY_PUSHBUTTON)
reg->sel_reg_config_methods_override |=
WPS_CONFIG_PHY_PUSHBUTTON;
+#endif /* CONFIG_WPS2 */
}
wpa_printf(MSG_DEBUG, "WPS: Internal Registrar selected "
"(pbc=%d)", reg->pbc);