aboutsummaryrefslogtreecommitdiffstats
path: root/src/wps
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-06-27 18:28:13 +0300
committerJouni Malinen <j@w1.fi>2012-06-27 21:22:12 +0300
commit4e0131d3512acc67eff02ffa07fd1c0fea2fd3f4 (patch)
treee432f27be0156ff119e8fe34f1edbe3b1d0223f8 /src/wps
parent582143e5440c59ca3c0f97e4e2fe73a0af8750ee (diff)
downloadexternal_wpa_supplicant_8_ti-4e0131d3512acc67eff02ffa07fd1c0fea2fd3f4.zip
external_wpa_supplicant_8_ti-4e0131d3512acc67eff02ffa07fd1c0fea2fd3f4.tar.gz
external_wpa_supplicant_8_ti-4e0131d3512acc67eff02ffa07fd1c0fea2fd3f4.tar.bz2
WPS: Add support for OOB dev password lengths 16..31
Previously, only the maximum length 32 octets for OOB device password was accepted. Since the specification allows a shorter password to be used with limited OOB mechanism (e.g., small NFC tag), we should accept lengths 16..32. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/wps')
-rw-r--r--src/wps/wps_attr_parse.c6
-rw-r--r--src/wps/wps_common.c10
-rw-r--r--src/wps/wps_defs.h2
-rw-r--r--src/wps/wps_i.h4
4 files changed, 13 insertions, 9 deletions
diff --git a/src/wps/wps_attr_parse.c b/src/wps/wps_attr_parse.c
index f5ad403..d0d1efb 100644
--- a/src/wps/wps_attr_parse.c
+++ b/src/wps/wps_attr_parse.c
@@ -262,12 +262,16 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
attr->dev_password_id = pos;
break;
case ATTR_OOB_DEVICE_PASSWORD:
- if (len != WPS_OOB_DEVICE_PASSWORD_ATTR_LEN) {
+ if (len < WPS_OOB_PUBKEY_HASH_LEN + 2 +
+ WPS_OOB_DEVICE_PASSWORD_MIN_LEN ||
+ len > WPS_OOB_PUBKEY_HASH_LEN + 2 +
+ WPS_OOB_DEVICE_PASSWORD_LEN) {
wpa_printf(MSG_DEBUG, "WPS: Invalid OOB Device "
"Password length %u", len);
return -1;
}
attr->oob_dev_password = pos;
+ attr->oob_dev_password_len = len;
break;
case ATTR_OS_VERSION:
if (len != 4) {
diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c
index 510d99d..c7c0c29 100644
--- a/src/wps/wps_common.c
+++ b/src/wps/wps_common.c
@@ -375,6 +375,7 @@ static int wps_parse_oob_dev_pwd(struct wps_context *wps,
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) {
@@ -397,17 +398,16 @@ static int wps_parse_oob_dev_pwd(struct wps_context *wps,
wps->oob_dev_pw_id = WPA_GET_BE16(pos);
pos += sizeof(wps->oob_dev_pw_id);
- oob_conf->dev_password =
- wpabuf_alloc(WPS_OOB_DEVICE_PASSWORD_LEN * 2 + 1);
+ 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,
- wpabuf_size(oob_conf->dev_password)),
- wpabuf_size(oob_conf->dev_password), pos,
- WPS_OOB_DEVICE_PASSWORD_LEN);
+ pw_len * 2 + 1),
+ pw_len * 2 + 1, pos, pw_len);
return 0;
}
diff --git a/src/wps/wps_defs.h b/src/wps/wps_defs.h
index e128a19..2f42603 100644
--- a/src/wps/wps_defs.h
+++ b/src/wps/wps_defs.h
@@ -41,7 +41,7 @@ extern int wps_testing_dummy_cred;
#define WPS_MGMTAUTHKEY_LEN 32
#define WPS_MGMTENCKEY_LEN 16
#define WPS_MGMT_KEY_ID_LEN 16
-#define WPS_OOB_DEVICE_PASSWORD_ATTR_LEN 54
+#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN 16
#define WPS_OOB_DEVICE_PASSWORD_LEN 32
#define WPS_OOB_PUBKEY_HASH_LEN 20
diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h
index 1297f65..a873f33 100644
--- a/src/wps/wps_i.h
+++ b/src/wps/wps_i.h
@@ -136,8 +136,6 @@ struct wps_parse_attr {
const u8 *assoc_state; /* 2 octets */
const u8 *config_error; /* 2 octets */
const u8 *dev_password_id; /* 2 octets */
- const u8 *oob_dev_password; /* WPS_OOB_DEVICE_PASSWORD_ATTR_LEN (54)
- * octets */
const u8 *os_version; /* 4 octets */
const u8 *wps_state; /* 1 octet */
const u8 *authenticator; /* WPS_AUTHENTICATOR_LEN (8) octets */
@@ -192,6 +190,8 @@ struct wps_parse_attr {
size_t authorized_macs_len;
const u8 *sec_dev_type_list; /* <= 128 octets */
size_t sec_dev_type_list_len;
+ const u8 *oob_dev_password; /* 38..54 octets */
+ size_t oob_dev_password_len;
/* attributes that can occur multiple times */
#define MAX_CRED_COUNT 10