Home | History | Annotate | Download | only in wps

Lines Matching refs:wps

19 static int wps_build_mac_addr(struct wps_data *wps, struct wpabuf *msg)
21 wpa_printf(MSG_DEBUG, "WPS: * MAC Address");
24 wpabuf_put_data(msg, wps->mac_addr_e, ETH_ALEN);
29 static int wps_build_wps_state(struct wps_data *wps, struct wpabuf *msg)
32 if (wps->wps->ap)
33 state = wps->wps->wps_state;
36 wpa_printf(MSG_DEBUG, "WPS: * Wi-Fi Protected Setup State (%d)",
45 static int wps_build_e_hash(struct wps_data *wps, struct wpabuf *msg)
51 if (random_get_bytes(wps->snonce, 2 * WPS_SECRET_NONCE_LEN) < 0)
53 wpa_hexdump(MSG_DEBUG, "WPS: E-S1", wps->snonce, WPS_SECRET_NONCE_LEN);
54 wpa_hexdump(MSG_DEBUG, "WPS: E-S2",
55 wps->snonce + WPS_SECRET_NONCE_LEN, WPS_SECRET_NONCE_LEN);
57 if (wps->dh_pubkey_e == NULL || wps->dh_pubkey_r == NULL) {
58 wpa_printf(MSG_DEBUG, "WPS: DH public keys not available for "
63 wpa_printf(MSG_DEBUG, "WPS: * E-Hash1");
68 addr[0] = wps->snonce;
70 addr[1] = wps->psk1;
72 addr[2] = wpabuf_head(wps->dh_pubkey_e);
73 len[2] = wpabuf_len(wps->dh_pubkey_e);
74 addr[3] = wpabuf_head(wps->dh_pubkey_r);
75 len[3] = wpabuf_len(wps->dh_pubkey_r);
76 hmac_sha256_vector(wps->authkey, WPS_AUTHKEY_LEN, 4, addr, len, hash);
77 wpa_hexdump(MSG_DEBUG, "WPS: E-Hash1", hash, SHA256_MAC_LEN);
79 wpa_printf(MSG_DEBUG, "WPS: * E-Hash2");
84 addr[0] = wps->snonce + WPS_SECRET_NONCE_LEN;
85 addr[1] = wps->psk2;
86 hmac_sha256_vector(wps->authkey, WPS_AUTHKEY_LEN, 4, addr, len, hash);
87 wpa_hexdump(MSG_DEBUG, "WPS: E-Hash2", hash, SHA256_MAC_LEN);
93 static int wps_build_e_snonce1(struct wps_data *wps, struct wpabuf *msg)
95 wpa_printf(MSG_DEBUG, "WPS: * E-SNonce1");
98 wpabuf_put_data(msg, wps->snonce, WPS_SECRET_NONCE_LEN);
103 static int wps_build_e_snonce2(struct wps_data *wps, struct wpabuf *msg)
105 wpa_printf(MSG_DEBUG, "WPS: * E-SNonce2");
108 wpabuf_put_data(msg, wps->snonce + WPS_SECRET_NONCE_LEN,
114 static struct wpabuf * wps_build_m1(struct wps_data *wps)
119 if (random_get_bytes(wps->nonce_e, WPS_NONCE_LEN) < 0)
121 wpa_hexdump(MSG_DEBUG, "WPS: Enrollee Nonce",
122 wps->nonce_e, WPS_NONCE_LEN);
124 wpa_printf(MSG_DEBUG, "WPS: Building Message M1");
129 config_methods = wps->wps->config_methods;
130 if (wps->wps->ap && !wps->pbc_in_m1 &&
131 (wps->dev_password_len != 0 ||
137 * As a workaround for Windows 7 mechanism for probing WPS
139 * method is available or if WPS configuration enables PBC
151 wps_build_uuid_e(msg, wps->uuid_e) ||
152 wps_build_mac_addr(wps, msg) ||
153 wps_build_enrollee_nonce(wps, msg) ||
154 wps_build_public_key(wps, msg) ||
155 wps_build_auth_type_flags(wps, msg) ||
156 wps_build_encr_type_flags(wps, msg) ||
157 wps_build_conn_type_flags(wps, msg) ||
159 wps_build_wps_state(wps, msg) ||
160 wps_build_device_attrs(&wps->wps->dev, msg) ||
161 wps_build_rf_bands(&wps->wps->dev, msg) ||
162 wps_build_assoc_state(wps, msg) ||
163 wps_build_dev_password_id(msg, wps->dev_pw_id) ||
165 wps_build_os_version(&wps->wps->dev, msg) ||
167 wps_build_vendor_ext_m1(&wps->wps->dev, msg)) {
172 wps->state = RECV_M2;
177 static struct wpabuf * wps_build_m3(struct wps_data *wps)
181 wpa_printf(MSG_DEBUG, "WPS: Building Message M3");
183 if (wps->dev_password == NULL) {
184 wpa_printf(MSG_DEBUG, "WPS: No Device Password available");
187 wps_derive_psk(wps, wps->dev_password, wps->dev_password_len);
195 wps_build_registrar_nonce(wps, msg) ||
196 wps_build_e_hash(wps, msg) ||
198 wps_build_authenticator(wps, msg)) {
203 wps->state = RECV_M4;
208 static struct wpabuf * wps_build_m5(struct wps_data *wps)
212 wpa_printf(MSG_DEBUG, "WPS: Building Message M5");
226 wps_build_registrar_nonce(wps, msg) ||
227 wps_build_e_snonce1(wps, plain) ||
228 wps_build_key_wrap_auth(wps, plain) ||
229 wps_build_encr_settings(wps, msg, plain) ||
231 wps_build_authenticator(wps, msg)) {
238 wps->state = RECV_M6;
243 static int wps_build_cred_ssid(struct wps_data *wps, struct wpabuf *msg)
245 wpa_printf(MSG_DEBUG, "WPS: * SSID");
247 wpabuf_put_be16(msg, wps->wps->ssid_len);
248 wpabuf_put_data(msg, wps->wps->ssid, wps->wps->ssid_len);
253 static int wps_build_cred_auth_type(struct wps_data *wps, struct wpabuf *msg)
255 u16 auth_type = wps->wps->auth_types;
267 wpa_printf(MSG_DEBUG, "WPS: * Authentication Type (0x%x)", auth_type);
275 static int wps_build_cred_encr_type(struct wps_data *wps, struct wpabuf *msg)
277 u16 encr_type = wps->wps->encr_types;
280 if (wps->wps->auth_types & (WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK)) {
292 wpa_printf(MSG_DEBUG, "WPS: * Encryption Type (0x%x)", encr_type);
300 static int wps_build_cred_network_key(struct wps_data *wps, struct wpabuf *msg)
302 wpa_printf(MSG_DEBUG, "WPS: * Network Key");
304 wpabuf_put_be16(msg, wps->wps->network_key_len);
305 wpabuf_put_data(msg, wps->wps->network_key, wps->wps->network_key_len);
310 static int wps_build_cred_mac_addr(struct wps_data *wps, struct wpabuf *msg)
312 wpa_printf(MSG_DEBUG, "WPS: * MAC Address (AP BSSID)");
315 wpabuf_put_data(msg, wps->wps->dev.mac_addr, ETH_ALEN);
320 static int wps_build_ap_settings(struct wps_data *wps, struct wpabuf *plain)
322 if (wps->wps->ap_settings) {
323 wpa_printf(MSG_DEBUG, "WPS: * AP Settings (pre-configured)");
324 wpabuf_put_data(plain, wps->wps->ap_settings,
325 wps->wps->ap_settings_len);
329 return wps_build_cred_ssid(wps, plain) ||
330 wps_build_cred_mac_addr(wps, plain) ||
331 wps_build_cred_auth_type(wps, plain) ||
332 wps_build_cred_encr_type(wps, plain) ||
333 wps_build_cred_network_key(wps, plain);
337 static struct wpabuf * wps_build_m7(struct wps_data *wps)
341 wpa_printf(MSG_DEBUG, "WPS: Building Message M7");
343 plain = wpabuf_alloc(500 + wps->wps->ap_settings_len);
347 msg = wpabuf_alloc(1000 + wps->wps->ap_settings_len);
355 wps_build_registrar_nonce(wps, msg) ||
356 wps_build_e_snonce2(wps, plain) ||
357 (wps->wps->ap && wps_build_ap_settings(wps, plain)) ||
358 wps_build_key_wrap_auth(wps, plain) ||
359 wps_build_encr_settings(wps, msg, plain) ||
361 wps_build_authenticator(wps, msg)) {
368 if (wps->wps->ap && wps->wps->registrar) {
374 wps_device_store(wps->wps->registrar, &wps->peer_dev,
375 wps->uuid_r);
378 wps->state = RECV_M8;
383 static struct wpabuf * wps_build_wsc_done(struct wps_data *wps)
387 wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_Done");
395 wps_build_enrollee_nonce(wps, msg) ||
396 wps_build_registrar_nonce(wps, msg) ||
402 if (wps->wps->ap)
403 wps->state = RECV_ACK;
405 wps_success_event(wps->wps);
406 wps->state = WPS_FINISHED;
412 struct wpabuf * wps_enrollee_get_msg(struct wps_data *wps,
417 switch (wps->state) {
419 msg = wps_build_m1(wps);
423 msg = wps_build_m3(wps);
427 msg = wps_build_m5(wps);
431 msg = wps_build_m7(wps);
435 if (wps->wps->ap) {
436 msg = wps_build_wsc_nack(wps);
440 msg = wps_build_wsc_ack(wps);
444 wps->state = RECV_M2;
448 msg = wps_build_wsc_nack(wps);
452 msg = wps_build_wsc_done(wps);
456 wpa_printf(MSG_DEBUG, "WPS: Unsupported state %d for building "
457 "a message", wps->state);
465 wpabuf_free(wps->last_msg);
466 wps->last_msg = wpabuf_dup(msg);
473 static int wps_process_registrar_nonce(struct wps_data *wps, const u8 *r_nonce)
476 wpa_printf(MSG_DEBUG, "WPS: No Registrar Nonce received");
480 os_memcpy(wps->nonce_r, r_nonce, WPS_NONCE_LEN);
481 wpa_hexdump(MSG_DEBUG, "WPS: Registrar Nonce",
482 wps->nonce_r, WPS_NONCE_LEN);
488 static int wps_process_enrollee_nonce(struct wps_data *wps, const u8 *e_nonce)
491 wpa_printf(MSG_DEBUG, "WPS: No Enrollee Nonce received");
495 if (os_memcmp(wps->nonce_e, e_nonce, WPS_NONCE_LEN) != 0) {
496 wpa_printf(MSG_DEBUG, "WPS: Invalid Enrollee Nonce received");
504 static int wps_process_uuid_r(struct wps_data *wps, const u8 *uuid_r)
507 wpa_printf(MSG_DEBUG, "WPS: No UUID-R received");
511 os_memcpy(wps->uuid_r, uuid_r, WPS_UUID_LEN);
512 wpa_hexdump(MSG_DEBUG, "WPS: UUID-R", wps->uuid_r, WPS_UUID_LEN);
518 static int wps_process_pubkey(struct wps_data *wps, const u8 *pk,
522 wpa_printf(MSG_DEBUG, "WPS: No Public Key received");
527 if (wps->dev_pw_id != DEV_PW_DEFAULT &&
528 wps->wps->oob_conf.pubkey_hash) {
535 wpabuf_head(wps->wps->oob_conf.pubkey_hash),
537 wpa_printf(MSG_ERROR, "WPS: Public Key hash error");
543 wpabuf_free(wps->dh_pubkey_r);
544 wps->dh_pubkey_r = wpabuf_alloc_copy(pk, pk_len);
545 if (wps->dh_pubkey_r == NULL)
548 if (wps_derive_keys(wps) < 0)
555 static int wps_process_r_hash1(struct wps_data *wps, const u8 *r_hash1)
558 wpa_printf(MSG_DEBUG, "WPS: No R-Hash1 received");
562 os_memcpy(wps->peer_hash1, r_hash1, WPS_HASH_LEN);
563 wpa_hexdump(MSG_DEBUG, "WPS: R-Hash1", wps->peer_hash1, WPS_HASH_LEN);
569 static int wps_process_r_hash2(struct wps_data *wps, const u8 *r_hash2)
572 wpa_printf(MSG_DEBUG, "WPS: No R-Hash2 received");
576 os_memcpy(wps->peer_hash2, r_hash2, WPS_HASH_LEN);
577 wpa_hexdump(MSG_DEBUG, "WPS: R-Hash2", wps->peer_hash2, WPS_HASH_LEN);
583 static int wps_process_r_snonce1(struct wps_data *wps, const u8 *r_snonce1)
590 wpa_printf(MSG_DEBUG, "WPS: No R-SNonce1 received");
594 wpa_hexdump_key(MSG_DEBUG, "WPS: R-SNonce1", r_snonce1,
600 addr[1] = wps->psk1;
602 addr[2] = wpabuf_head(wps->dh_pubkey_e);
603 len[2] = wpabuf_len(wps->dh_pubkey_e);
604 addr[3] = wpabuf_head(wps->dh_pubkey_r);
605 len[3] = wpabuf_len(wps->dh_pubkey_r);
606 hmac_sha256_vector(wps->authkey, WPS_AUTHKEY_LEN, 4, addr, len, hash);
608 if (os_memcmp(wps->peer_hash1, hash, WPS_HASH_LEN) != 0) {
609 wpa_printf(MSG_DEBUG, "WPS: R-Hash1 derived from R-S1 does "
611 wps->config_error = WPS_CFG_DEV_PASSWORD_AUTH_FAILURE;
612 wps_pwd_auth_fail_event(wps->wps, 1, 1);
616 wpa_printf(MSG_DEBUG, "WPS: Registrar proved knowledge of the first "
623 static int wps_process_r_snonce2(struct wps_data *wps, const u8 *r_snonce2)
630 wpa_printf(MSG_DEBUG, "WPS: No R-SNonce2 received");
634 wpa_hexdump_key(MSG_DEBUG, "WPS: R-SNonce2", r_snonce2,
640 addr[1] = wps->psk2;
642 addr[2] = wpabuf_head(wps->dh_pubkey_e);
643 len[2] = wpabuf_len(wps->dh_pubkey_e);
644 addr[3] = wpabuf_head(wps->dh_pubkey_r);
645 len[3] = wpabuf_len(wps
646 hmac_sha256_vector(wps->authkey, WPS_AUTHKEY_LEN, 4, addr, len, hash);
648 if (os_memcmp(wps->peer_hash2, hash, WPS_HASH_LEN) != 0) {
649 wpa_printf(MSG_DEBUG, "WPS: R-Hash2 derived from R-S2 does "
651 wps->config_error = WPS_CFG_DEV_PASSWORD_AUTH_FAILURE;
652 wps_pwd_auth_fail_event(wps->wps, 1, 2);
656 wpa_printf(MSG_DEBUG, "WPS: Registrar proved knowledge of the second "
663 static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
669 wpa_printf(MSG_DEBUG, "WPS: Received Credential");
670 os_memset(&wps->cred, 0, sizeof(wps->cred));
673 wps_process_cred(&attr, &wps->cred))
676 if (os_memcmp(wps->cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN) !=
678 wpa_printf(MSG_DEBUG, "WPS: MAC Address in the Credential ("
680 ")", MAC2STR(wps->cred.mac_addr),
681 MAC2STR(wps->wps->dev.mac_addr));
691 wpa_printf(MSG_INFO, "WPS: Do not accept incorrect "
699 if (!(wps->cred.encr_type &
701 if (wps->cred.encr_type & WPS_ENCR_WEP) {
702 wpa_printf(MSG_INFO, "WPS: Reject Credential "
704 wps->error_indication = WPS_EI_SECURITY_WEP_PROHIBITED;
708 wpa_printf(MSG_INFO, "WPS: Reject Credential due to "
709 "invalid encr_type 0x%x", wps->cred.encr_type);
714 if (wps->wps->cred_cb) {
715 wps->cred.cred_attr = cred - 4;
716 wps->cred.cred_attr_len = cred_len + 4;
717 wps->wps->cred_cb(wps->wps->cb_ctx, &wps->cred);
718 wps->cred.cred_attr = NULL;
719 wps->cred.cred_attr_len = 0;
726 static int wps_process_creds(struct wps_data *wps, const u8 *cred[],
732 if (wps->wps->ap)
736 wpa_printf(MSG_DEBUG, "WPS: No Credential attributes "
743 res = wps_process_cred_e(wps, cred[i], cred_len[i], wps2);
747 wpa_printf(MSG_DEBUG, "WPS: WEP credential skipped");
753 wpa_printf(MSG_DEBUG, "WPS: No valid Credential attribute "
762 static int wps_process_ap_settings_e(struct wps_data *wps,
768 if (!wps->wps->ap)
774 wpa_printf(MSG_INFO, "WPS: Received new AP configuration from "
777 if (os_memcmp(cred.mac_addr, wps->wps->dev.mac_addr, ETH_ALEN) !=
779 wpa_printf(MSG_DEBUG, "WPS: MAC Address in the AP Settings ("
782 MAC2STR(wps->wps->dev.mac_addr));
792 wpa_printf(MSG_INFO, "WPS: Do not accept incorrect "
803 wpa_printf(MSG_INFO, "WPS: Reject new AP settings "
805 wps->error_indication = WPS_EI_SECURITY_WEP_PROHIBITED;
809 wpa_printf(MSG_INFO, "WPS: Reject new AP settings due to "
821 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid WSC 2.0 "
823 wps->error_indication =
833 wpa_printf(MSG_DEBUG, "WPS: Upgrade encr_type TKIP -> "
840 wpa_printf(MSG_DEBUG, "WPS: Upgrade auth_type WPAPSK -> "
846 if (wps->wps->cred_cb) {
849 wps->wps->cred_cb(wps->wps->cb_ctx, &cred);
856 static enum wps_process_res wps_process_m2(struct wps_data *wps,
860 wpa_printf(MSG_DEBUG, "WPS: Received M2");
862 if (wps->state != RECV_M2) {
863 wpa_printf(MSG_DEBUG, "WPS: Unexpected state (%d) for "
864 "receiving M2", wps->state);
865 wps->state = SEND_WSC_NACK;
869 if (wps_process_registrar_nonce(wps, attr->registrar_nonce) ||
870 wps_process_enrollee_nonce(wps, attr->enrollee_nonce) ||
871 wps_process_uuid_r(wps, attr->uuid_r)) {
872 wps->state = SEND_WSC_NACK;
882 if (wps->wps->ap &&
883 ((wps->wps->ap_setup_locked && wps->wps->ap_setup_locked != 2) ||
884 wps->dev_password == NULL)) {
885 wpa_printf(MSG_DEBUG, "WPS: AP Setup is locked - refuse "
887 wps->config_error = WPS_CFG_SETUP_LOCKED;
888 wps->state = SEND_WSC_NACK;
892 if (wps_process_pubkey(wps, attr->public_key, attr->public_key_len) ||
893 wps_process_authenticator(wps, attr->authenticator, msg) ||
894 wps_process_device_attrs(&wps->peer_dev, attr)) {
895 wps->state = SEND_WSC_NACK;
899 wps->state = SEND_M3;
904 static enum wps_process_res wps_process_m2d(struct wps_data *wps,
907 wpa_printf(MSG_DEBUG, "WPS: Received M2D");
909 if (wps->state != RECV_M2) {
910 wpa_printf(MSG_DEBUG, "WPS: Unexpected state (%d) for "
911 "receiving M2D", wps->state);
912 wps->state = SEND_WSC_NACK;
916 wpa_hexdump_ascii(MSG_DEBUG, "WPS: Manufacturer",
918 wpa_hexdump_ascii(MSG_DEBUG, "WPS: Model Name",
920 wpa_hexdump_ascii(MSG_DEBUG, "WPS: Model Number",
922 wpa_hexdump_ascii(MSG_DEBUG, "WPS: Serial Number",
924 wpa_hexdump_ascii(MSG_DEBUG, "WPS: Device Name",
927 if (wps->wps->event_cb) {
951 wps->wps->event_cb(wps->wps->cb_ctx, WPS_EV_M2D, &data);
954 wps->state = RECEIVED_M2D;
959 static enum wps_process_res wps_process_m4(struct wps_data *wps,
966 wpa_printf(MSG_DEBUG, "WPS: Received M4");
968 if (wps->state != RECV_M4) {
969 wpa_printf(MSG_DEBUG, "WPS: Unexpected state (%d) for "
970 "receiving M4", wps->state);
971 wps->state = SEND_WSC_NACK;
975 if (wps_process_enrollee_nonce(wps, attr->enrollee_nonce) ||
976 wps_process_authenticator(wps, attr->authenticator, msg) ||
977 wps_process_r_hash1(wps, attr->r_hash1) ||
978 wps_process_r_hash2(wps, attr->r_hash2)) {
979 wps->state = SEND_WSC_NACK;
983 decrypted = wps_decrypt_encr_settings(wps, attr->encr_settings,
986 wpa_printf(MSG_DEBUG, "WPS: Failed to decrypted Encrypted "
988 wps->state = SEND_WSC_NACK;
994 wps->state = SEND_WSC_NACK;
998 wpa_printf(MSG_DEBUG, "WPS: Processing decrypted Encrypted Settings "
1001 wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
1002 wps_process_r_snonce1(wps, eattr.r_snonce1)) {
1004 wps->state = SEND_WSC_NACK;
1009 wps->state = SEND_M5;
1014 static enum wps_process_res wps_process_m6(struct wps_data *wps,
1021 wpa_printf(MSG_DEBUG, "WPS: Received M6");
1023 if (wps->state != RECV_M6) {
1024 wpa_printf(MSG_DEBUG, "WPS: Unexpected state (%d) for "
1025 "receiving M6", wps->state);
1026 wps->state = SEND_WSC_NACK;
1030 if (wps_process_enrollee_nonce(wps, attr->enrollee_nonce) ||
1031 wps_process_authenticator(wps, attr->authenticator, msg)) {
1032 wps->state = SEND_WSC_NACK;
1036 decrypted = wps_decrypt_encr_settings(wps, attr->encr_settings,
1039 wpa_printf(MSG_DEBUG, "WPS: Failed to decrypted Encrypted "
1041 wps->state = SEND_WSC_NACK;
1047 wps->state = SEND_WSC_NACK;
1051 wpa_printf(MSG_DEBUG, "WPS: Processing decrypted Encrypted Settings "
1054 wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
1055 wps_process_r_snonce2(wps, eattr.r_snonce2)) {
1057 wps->state = SEND_WSC_NACK;
1062 if (wps->wps->ap)
1063 wps->wps->event_cb(wps->wps->cb_ctx, WPS_EV_AP_PIN_SUCCESS,
1066 wps->state = SEND_M7;
1071 static enum wps_process_res wps_process_m8(struct wps_data *wps,
1078 wpa_printf(MSG_DEBUG, "WPS: Received M8");
1080 if (wps->state != RECV_M8) {
1081 wpa_printf(MSG_DEBUG, "WPS: Unexpected state (%d) for "
1082 "receiving M8", wps->state);
1083 wps->state = SEND_WSC_NACK;
1087 if (wps_process_enrollee_nonce(wps, attr->enrollee_nonce) ||
1088 wps_process_authenticator(wps, attr->authenticator, msg)) {
1089 wps->state = SEND_WSC_NACK;
1093 if (wps->wps->ap && wps->wps->ap_setup_locked) {
1099 wpa_printf(MSG_DEBUG, "WPS: AP Setup is locked - refuse "
1101 wps->config_error = WPS_CFG_SETUP_LOCKED;
1102 wps->state = SEND_WSC_NACK;
1106 decrypted = wps_decrypt_encr_settings(wps, attr->encr_settings,
1109 wpa_printf(MSG_DEBUG, "WPS: Failed to decrypted Encrypted "
1111 wps->state = SEND_WSC_NACK;
1115 if (wps_validate_m8_encr(decrypted, wps->wps->ap,
1118 wps->state = SEND_WSC_NACK;
1122 wpa_printf(MSG_DEBUG, "WPS: Processing decrypted Encrypted Settings "
1125 wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
1126 wps_process_creds(wps, eattr.cred, eattr.cred_len,
1128 wps_process_ap_settings_e(wps, &eattr, decrypted,
1131 wps->state = SEND_WSC_NACK;
1136 wps->state = WPS_MSG_DONE;
1141 static enum wps_process_res wps_process_wsc_msg(struct wps_data *wps,
1147 wpa_printf(MSG_DEBUG, "WPS: Received WSC_MSG");
1153 os_memcmp(wps->nonce_e, attr.enrollee_nonce, WPS_NONCE_LEN) != 0) {
1154 wpa_printf(MSG_DEBUG, "WPS: Mismatch in enrollee nonce");
1159 wpa_printf(MSG_DEBUG, "WPS: No Message Type attribute");
1160 wps->state = SEND_WSC_NACK;
1168 ret = wps_process_m2(wps, msg, &attr);
1173 ret = wps_process_m2d(wps, &attr);
1178 ret = wps_process_m4(wps, msg, &attr);
1179 if (ret == WPS_FAILURE || wps->state == SEND_WSC_NACK)
1180 wps_fail_event(wps->wps, WPS_M4, wps->config_error,
1181 wps->error_indication);
1186 ret = wps_process_m6(wps, msg, &attr);
1187 if (ret == WPS_FAILURE || wps->state == SEND_WSC_NACK)
1188 wps_fail_event(wps->wps, WPS_M6, wps->config_error,
1189 wps->error_indication);
1194 ret = wps_process_m8(wps, msg, &attr);
1195 if (ret == WPS_FAILURE || wps->state == SEND_WSC_NACK)
1196 wps_fail_event(wps->wps, WPS_M8, wps->config_error,
1197 wps->error_indication);
1200 wpa_printf(MSG_DEBUG, "WPS: Unsupported Message Type %d",
1215 wpabuf_free(wps->last_msg);
1216 wps->last_msg = wpabuf_dup(msg);
1223 static enum wps_process_res wps_process_wsc_ack(struct wps_data *wps,
1228 wpa_printf(MSG_DEBUG, "WPS: Received WSC_ACK");
1234 wpa_printf(MSG_DEBUG, "WPS: No Message Type attribute");
1239 wpa_printf(MSG_DEBUG, "WPS: Invalid Message Type %d",
1245 os_memcmp(wps->nonce_r, attr.registrar_nonce, WPS_NONCE_LEN) != 0)
1247 wpa_printf(MSG_DEBUG, "WPS: Mismatch in registrar nonce");
1252 os_memcmp(wps->nonce_e, attr.enrollee_nonce, WPS_NONCE_LEN) != 0) {
1253 wpa_printf(MSG_DEBUG, "WPS: Mismatch in enrollee nonce");
1257 if (wps->state == RECV_ACK && wps->wps->ap) {
1258 wpa_printf(MSG_DEBUG, "WPS: External Registrar registration "
1260 wps_success_event(wps->wps);
1261 wps->state = WPS_FINISHED;
1269 static enum wps_process_res wps_process_wsc_nack(struct wps_data *wps,
1275 wpa_printf(MSG_DEBUG, "WPS: Received WSC_NACK");
1281 wpa_printf(MSG_DEBUG, "WPS: No Message Type attribute");
1286 wpa_printf(MSG_DEBUG, "WPS: Invalid Message Type %d",
1292 os_memcmp(wps->nonce_r, attr.registrar_nonce, WPS_NONCE_LEN) != 0)
1294 wpa_printf(MSG_DEBUG, "WPS: Mismatch in registrar nonce");
1295 wpa_hexdump(MSG_DEBUG, "WPS: Received Registrar Nonce",
1297 wpa_hexdump(MSG_DEBUG, "WPS: Expected Registrar Nonce",
1298 wps->nonce_r, WPS_NONCE_LEN);
1303 os_memcmp(wps->nonce_e, attr.enrollee_nonce, WPS_NONCE_LEN) != 0) {
1304 wpa_printf(MSG_DEBUG, "WPS: Mismatch in enrollee nonce");
1305 wpa_hexdump(MSG_DEBUG, "WPS: Received Enrollee Nonce",
1307 wpa_hexdump(MSG_DEBUG, "WPS: Expected Enrollee Nonce",
1308 wps->nonce_e, WPS_NONCE_LEN);
1313 wpa_printf(MSG_DEBUG, "WPS: No Configuration Error attribute "
1319 wpa_printf(MSG_DEBUG, "WPS: Registrar terminated negotiation with "
1322 switch (wps->state) {
1324 wps_fail_event(wps->wps, WPS_M3, config_error,
1325 wps->error_indication);
1328 wps_fail_event(wps->wps, WPS_M5, config_error,
1329 wps->error_indication);
1332 wps_fail_event(wps->wps, WPS_M7, config_error,
1333 wps->error_indication);
1341 wps->state = SEND_WSC_NACK;
1347 enum wps_process_res wps_enrollee_process_msg(struct wps_data *wps,
1352 wpa_printf(MSG_DEBUG, "WPS: Processing received message (len=%lu "
1370 return wps_process_wsc_msg(wps, msg);
1374 return wps_process_wsc_ack(wps, msg);
1378 return wps_process_wsc_nack(wps, msg);
1380 wpa_printf(MSG_DEBUG, "WPS: Unsupported op_code %d", op_code);