Browse Source

WPS: Provide the unparsed Credential attribute to cred_cb()

This makes it easier to pass the credential data to external programs
(e.g., Network Manager) for processing. The actual use of this data is
not yet included in hostapd/wpa_supplicant.
Jouni Malinen 16 years ago
parent
commit
eca6e0a9a5
4 changed files with 24 additions and 4 deletions
  1. 3 0
      hostapd/wps_hostapd.c
  2. 5 0
      src/wps/wps.h
  3. 13 4
      src/wps/wps_enrollee.c
  4. 3 0
      wpa_supplicant/wps_supplicant.c

+ 3 - 0
hostapd/wps_hostapd.c

@@ -181,6 +181,9 @@ static int hostapd_wps_cred_cb(void *ctx, const struct wps_credential *cred)
 	int multi_bss;
 	int wpa;
 
+	wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
+			cred->cred_attr, cred->cred_attr_len);
+
 	wpa_printf(MSG_DEBUG, "WPS: Received new AP Settings");
 	wpa_hexdump_ascii(MSG_DEBUG, "WPS: SSID", cred->ssid, cred->ssid_len);
 	wpa_printf(MSG_DEBUG, "WPS: Authentication Type 0x%x",

+ 5 - 0
src/wps/wps.h

@@ -41,6 +41,9 @@ struct wps_registrar;
  * @key: Key
  * @key_len: Key length in octets
  * @mac_addr: MAC address of the peer
+ * @cred_attr: Unparsed Credential attribute data (used only in cred_cb());
+ *	this may be %NULL, if not used
+ * @cred_attr_len: Length of cred_attr in octets
  */
 struct wps_credential {
 	u8 ssid[32];
@@ -51,6 +54,8 @@ struct wps_credential {
 	u8 key[64];
 	size_t key_len;
 	u8 mac_addr[ETH_ALEN];
+	const u8 *cred_attr;
+	size_t cred_attr_len;
 };
 
 /**

+ 13 - 4
src/wps/wps_enrollee.c

@@ -630,8 +630,13 @@ static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
 	    wps_process_cred(&attr, &wps->cred))
 		return -1;
 
-	if (wps->wps->cred_cb)
+	if (wps->wps->cred_cb) {
+		wps->cred.cred_attr = cred - 4;
+		wps->cred.cred_attr_len = cred_len + 4;
 		wps->wps->cred_cb(wps->wps->cb_ctx, &wps->cred);
+		wps->cred.cred_attr = NULL;
+		wps->cred.cred_attr_len = 0;
+	}
 
 	return 0;
 }
@@ -661,7 +666,8 @@ static int wps_process_creds(struct wps_data *wps, const u8 *cred[],
 
 
 static int wps_process_ap_settings_e(struct wps_data *wps,
-				     struct wps_parse_attr *attr)
+				     struct wps_parse_attr *attr,
+				     struct wpabuf *attrs)
 {
 	struct wps_credential cred;
 
@@ -674,8 +680,11 @@ static int wps_process_ap_settings_e(struct wps_data *wps,
 	wpa_printf(MSG_INFO, "WPS: Received new AP configuration from "
 		   "Registrar");
 
-	if (wps->wps->cred_cb)
+	if (wps->wps->cred_cb) {
+		cred.cred_attr = wpabuf_head(attrs);
+		cred.cred_attr_len = wpabuf_len(attrs);
 		wps->wps->cred_cb(wps->wps->cb_ctx, &cred);
+	}
 
 	return 0;
 }
@@ -904,7 +913,7 @@ static enum wps_process_res wps_process_m8(struct wps_data *wps,
 	    wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
 	    wps_process_creds(wps, eattr.cred, eattr.cred_len,
 			      eattr.num_cred) ||
-	    wps_process_ap_settings_e(wps, &eattr)) {
+	    wps_process_ap_settings_e(wps, &eattr, decrypted)) {
 		wpabuf_free(decrypted);
 		wps->state = SEND_WSC_NACK;
 		return WPS_CONTINUE;

+ 3 - 0
wpa_supplicant/wps_supplicant.c

@@ -58,6 +58,9 @@ static int wpa_supplicant_wps_cred(void *ctx,
 
 	wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
 
+	wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
+			cred->cred_attr, cred->cred_attr_len);
+
 	if (cred->auth_type != WPS_AUTH_OPEN &&
 	    cred->auth_type != WPS_AUTH_SHARED &&
 	    cred->auth_type != WPS_AUTH_WPAPSK &&