aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-06-27 18:25:16 +0300
committerJouni Malinen <j@w1.fi>2012-06-27 21:22:12 +0300
commit78e625f79a43f59f8101e3d122812a2fd47627f9 (patch)
tree6da1813c71c74e34fae7ed88449317ed3c5c49fb /src
parent8a13732f832d4300cdb2a2a16d0139248dfbeac4 (diff)
downloadexternal_wpa_supplicant_8_ti-78e625f79a43f59f8101e3d122812a2fd47627f9.zip
external_wpa_supplicant_8_ti-78e625f79a43f59f8101e3d122812a2fd47627f9.tar.gz
external_wpa_supplicant_8_ti-78e625f79a43f59f8101e3d122812a2fd47627f9.tar.bz2
WPS: Split wps_build_oob_dev_password() into parts
This allows sharing of a function to build the attribute without changing the OOB parameters. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src')
-rw-r--r--src/wps/wps_attr_build.c35
-rw-r--r--src/wps/wps_i.h3
2 files changed, 26 insertions, 12 deletions
diff --git a/src/wps/wps_attr_build.c b/src/wps/wps_attr_build.c
index 753083d..77f90ef 100644
--- a/src/wps/wps_attr_build.c
+++ b/src/wps/wps_attr_build.c
@@ -340,19 +340,34 @@ 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_pw(struct wpabuf *msg, u16 dev_pw_id,
+ const struct wpabuf *pubkey, const u8 *dev_pw,
+ size_t dev_pw_len)
{
size_t hash_len;
const u8 *addr[1];
u8 pubkey_hash[WPS_HASH_LEN];
+
+ addr[0] = wpabuf_head(pubkey);
+ hash_len = wpabuf_len(pubkey);
+ sha256_vector(1, addr, &hash_len, pubkey_hash);
+
+ wpabuf_put_be16(msg, ATTR_OOB_DEVICE_PASSWORD);
+ wpabuf_put_be16(msg, WPS_OOB_PUBKEY_HASH_LEN + 2 + dev_pw_len);
+ wpabuf_put_data(msg, pubkey_hash, WPS_OOB_PUBKEY_HASH_LEN);
+ wpabuf_put_be16(msg, dev_pw_id);
+ wpabuf_put_data(msg, dev_pw, dev_pw_len);
+
+ 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");
- addr[0] = wpabuf_head(wps->dh_pubkey);
- hash_len = wpabuf_len(wps->dh_pubkey);
- sha256_vector(1, addr, &hash_len, pubkey_hash);
-
if (os_get_random((u8 *) &wps->oob_dev_pw_id, sizeof(u16)) < 0) {
wpa_printf(MSG_ERROR, "WPS: device password id "
"generation error");
@@ -367,19 +382,15 @@ int wps_build_oob_dev_password(struct wpabuf *msg, struct wps_context *wps)
return -1;
}
- wpabuf_put_be16(msg, ATTR_OOB_DEVICE_PASSWORD);
- wpabuf_put_be16(msg, WPS_OOB_DEVICE_PASSWORD_ATTR_LEN);
- wpabuf_put_data(msg, pubkey_hash, WPS_OOB_PUBKEY_HASH_LEN);
- wpabuf_put_be16(msg, wps->oob_dev_pw_id);
- wpabuf_put_data(msg, dev_password_bin, WPS_OOB_DEVICE_PASSWORD_LEN);
-
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 0;
+ 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 */
diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h
index aeadfc1..6b6f215 100644
--- a/src/wps/wps_i.h
+++ b/src/wps/wps_i.h
@@ -255,6 +255,9 @@ int wps_build_auth_type_flags(struct wps_data *wps, struct wpabuf *msg);
int wps_build_encr_type_flags(struct wps_data *wps, struct wpabuf *msg);
int wps_build_conn_type_flags(struct wps_data *wps, struct wpabuf *msg);
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);