From fe904963d0b029a398abd62aeacf5ad5b54ca821 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 4 Apr 2013 17:49:53 +0300 Subject: [PATCH] WPS: Fix AP auto configuration on config token generation Signed-hostap: Jouni Malinen --- src/wps/wps_common.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c index 0897b7ba3..4e4da5ec4 100644 --- a/src/wps/wps_common.c +++ b/src/wps/wps_common.c @@ -343,10 +343,36 @@ struct wpabuf * wps_get_oob_cred(struct wps_context *wps) if (wps_build_version(plain) || wps_build_cred(&data, plain) || wps_build_wfa_ext(plain, 0, NULL, 0)) { + os_free(data.new_psk); wpabuf_free(plain); return NULL; } + if (wps->wps_state == WPS_STATE_NOT_CONFIGURED && data.new_psk && + wps->ap) { + struct wps_credential cred; + + wpa_printf(MSG_DEBUG, "WPS: Moving to Configured state based " + "on credential token generation"); + + os_memset(&cred, 0, sizeof(cred)); + os_memcpy(cred.ssid, wps->ssid, wps->ssid_len); + cred.ssid_len = wps->ssid_len; + cred.auth_type = WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK; + cred.encr_type = WPS_ENCR_TKIP | WPS_ENCR_AES; + os_memcpy(cred.key, data.new_psk, data.new_psk_len); + cred.key_len = data.new_psk_len; + + wps->wps_state = WPS_STATE_CONFIGURED; + wpa_hexdump_ascii_key(MSG_DEBUG, + "WPS: Generated random passphrase", + data.new_psk, data.new_psk_len); + if (wps->cred_cb) + wps->cred_cb(wps->cb_ctx, &cred); + } + + os_free(data.new_psk); + return plain; }