From 3f2c8ba6d39d5c5184a8fdd121998dd0d7629f1f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 27 Jun 2012 18:56:41 +0300 Subject: WPS: Add new mechanism for NFC config method using password token Instead of requiring low-level access to an NFC device and synchronous operations, the new WPS_NFC_TOKEN and WPS_NFC ctrl_iface commands can be used to build a NFC password token and initiate WPS protocol run using that token (or pre-configured values) as separate commands. The WPS_NFC_TOKEN output can be written to a NFC tag using an external program, i.e., wpa_supplicant does not need to have low-level code for NFC operations for this. Signed-hostap: Jouni Malinen --- src/wps/wps.h | 3 +++ src/wps/wps_common.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/wps/wps.h b/src/wps/wps.h index b49bb91..48ba76f 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -832,6 +832,9 @@ char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf, size_t buf_len); void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid); u16 wps_config_methods_str2bin(const char *str); +struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id, + const struct wpabuf *pubkey, + const struct wpabuf *dev_pw); /* ndef.c */ struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf); diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c index c7c0c29..63857e0 100644 --- a/src/wps/wps_common.c +++ b/src/wps/wps_common.c @@ -335,6 +335,30 @@ static struct wpabuf * wps_get_oob_cred(struct wps_context *wps) } +struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id, + const struct wpabuf *pubkey, + const struct wpabuf *dev_pw) +{ + struct wpabuf *data; + + data = wpabuf_alloc(200); + if (data == NULL) + return NULL; + + if (wps_build_version(data) || + wps_build_oob_dev_pw(data, dev_pw_id, pubkey, + wpabuf_head(dev_pw), wpabuf_len(dev_pw)) || + wps_build_wfa_ext(data, 0, NULL, 0)) { + wpa_printf(MSG_ERROR, "WPS: Failed to build NFC password " + "token"); + wpabuf_free(data); + return NULL; + } + + return data; +} + + static struct wpabuf * wps_get_oob_dev_pwd(struct wps_context *wps) { struct wpabuf *data; -- cgit v1.1