2 * Wi-Fi Protected Setup - Strict protocol validation routines
3 * Copyright (c) 2010, Atheros Communications, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
22 #ifndef WPS_STRICT_ALL
23 #define WPS_STRICT_WPS2
24 #endif /* WPS_STRICT_ALL */
27 static int wps_validate_version(const u8 *version, int mandatory)
29 if (version == NULL) {
31 wpa_printf(MSG_INFO, "WPS-STRICT: Version attribute "
37 if (*version != 0x10) {
38 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Version attribute "
39 "value 0x%x", *version);
46 static int wps_validate_version2(const u8 *version2, int mandatory)
48 if (version2 == NULL) {
50 wpa_printf(MSG_INFO, "WPS-STRICT: Version2 attribute "
56 if (*version2 < 0x20) {
57 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Version2 attribute "
58 "value 0x%x", *version2);
65 static int wps_validate_request_type(const u8 *request_type, int mandatory)
67 if (request_type == NULL) {
69 wpa_printf(MSG_INFO, "WPS-STRICT: Request Type "
75 if (*request_type > 0x03) {
76 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Request Type "
77 "attribute value 0x%x", *request_type);
84 static int wps_validate_response_type(const u8 *response_type, int mandatory)
86 if (response_type == NULL) {
88 wpa_printf(MSG_INFO, "WPS-STRICT: Response Type "
94 if (*response_type > 0x03) {
95 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Response Type "
96 "attribute value 0x%x", *response_type);
103 static int valid_config_methods(u16 val, int wps2)
106 if ((val & 0x6000) && !(val & WPS_CONFIG_DISPLAY)) {
107 wpa_printf(MSG_INFO, "WPS-STRICT: Physical/Virtual "
108 "Display flag without old Display flag "
112 if (!(val & 0x6000) && (val & WPS_CONFIG_DISPLAY)) {
113 wpa_printf(MSG_INFO, "WPS-STRICT: Display flag "
114 "without Physical/Virtual Display flag");
117 if ((val & 0x0600) && !(val & WPS_CONFIG_PUSHBUTTON)) {
118 wpa_printf(MSG_INFO, "WPS-STRICT: Physical/Virtual "
119 "PushButton flag without old PushButton "
123 if (!(val & 0x0600) && (val & WPS_CONFIG_PUSHBUTTON)) {
124 wpa_printf(MSG_INFO, "WPS-STRICT: PushButton flag "
125 "without Physical/Virtual PushButton flag");
134 static int wps_validate_config_methods(const u8 *config_methods, int wps2,
139 if (config_methods == NULL) {
141 wpa_printf(MSG_INFO, "WPS-STRICT: Configuration "
142 "Methods attribute missing");
148 val = WPA_GET_BE16(config_methods);
149 if (!valid_config_methods(val, wps2)) {
150 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Configuration "
151 "Methods attribute value 0x%04x", val);
158 static int wps_validate_ap_config_methods(const u8 *config_methods, int wps2,
163 if (wps_validate_config_methods(config_methods, wps2, mandatory) < 0)
165 if (config_methods == NULL)
167 val = WPA_GET_BE16(config_methods);
168 if (val & WPS_CONFIG_PUSHBUTTON) {
169 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Configuration "
170 "Methods attribute value 0x%04x in AP info "
171 "(PushButton not allowed for registering new ER)",
179 static int wps_validate_uuid_e(const u8 *uuid_e, int mandatory)
181 if (uuid_e == NULL) {
183 wpa_printf(MSG_INFO, "WPS-STRICT: UUID-E "
184 "attribute missing");
193 static int wps_validate_uuid_r(const u8 *uuid_r, int mandatory)
195 if (uuid_r == NULL) {
197 wpa_printf(MSG_INFO, "WPS-STRICT: UUID-R "
198 "attribute missing");
207 static int wps_validate_primary_dev_type(const u8 *primary_dev_type,
210 if (primary_dev_type == NULL) {
212 wpa_printf(MSG_INFO, "WPS-STRICT: Primary Device Type "
213 "attribute missing");
222 static int wps_validate_rf_bands(const u8 *rf_bands, int mandatory)
224 if (rf_bands == NULL) {
226 wpa_printf(MSG_INFO, "WPS-STRICT: RF Bands "
227 "attribute missing");
232 if (*rf_bands != WPS_RF_24GHZ && *rf_bands != WPS_RF_50GHZ &&
233 *rf_bands != (WPS_RF_24GHZ | WPS_RF_50GHZ)) {
234 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Rf Bands "
235 "attribute value 0x%x", *rf_bands);
242 static int wps_validate_assoc_state(const u8 *assoc_state, int mandatory)
245 if (assoc_state == NULL) {
247 wpa_printf(MSG_INFO, "WPS-STRICT: Association State "
248 "attribute missing");
253 val = WPA_GET_BE16(assoc_state);
255 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Association State "
256 "attribute value 0x%04x", val);
263 static int wps_validate_config_error(const u8 *config_error, int mandatory)
267 if (config_error == NULL) {
269 wpa_printf(MSG_INFO, "WPS-STRICT: Configuration Error "
270 "attribute missing");
275 val = WPA_GET_BE16(config_error);
277 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Configuration Error "
278 "attribute value 0x%04x", val);
285 static int wps_validate_dev_password_id(const u8 *dev_password_id,
290 if (dev_password_id == NULL) {
292 wpa_printf(MSG_INFO, "WPS-STRICT: Device Password ID "
293 "attribute missing");
298 val = WPA_GET_BE16(dev_password_id);
299 if (val >= 0x0006 && val <= 0x000f) {
300 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Device Password ID "
301 "attribute value 0x%04x", val);
308 static int wps_validate_manufacturer(const u8 *manufacturer, size_t len,
311 if (manufacturer == NULL) {
313 wpa_printf(MSG_INFO, "WPS-STRICT: Manufacturer "
314 "attribute missing");
319 if (len > 0 && manufacturer[len - 1] == 0) {
320 wpa_hexdump_ascii(MSG_INFO, "WPS-STRICT: Invalid Manufacturer "
321 "attribute value", manufacturer, len);
328 static int wps_validate_model_name(const u8 *model_name, size_t len,
331 if (model_name == NULL) {
333 wpa_printf(MSG_INFO, "WPS-STRICT: Model Name "
334 "attribute missing");
339 if (len > 0 && model_name[len - 1] == 0) {
340 wpa_hexdump_ascii(MSG_INFO, "WPS-STRICT: Invalid Model Name "
341 "attribute value", model_name, len);
348 static int wps_validate_model_number(const u8 *model_number, size_t len,
351 if (model_number == NULL) {
353 wpa_printf(MSG_INFO, "WPS-STRICT: Model Number "
354 "attribute missing");
359 if (len > 0 && model_number[len - 1] == 0) {
360 wpa_hexdump_ascii(MSG_INFO, "WPS-STRICT: Invalid Model Number "
361 "attribute value", model_number, len);
368 static int wps_validate_serial_number(const u8 *serial_number, size_t len,
371 if (serial_number == NULL) {
373 wpa_printf(MSG_INFO, "WPS-STRICT: Serial Number "
374 "attribute missing");
379 if (len > 0 && serial_number[len - 1] == 0) {
380 wpa_hexdump_ascii(MSG_INFO, "WPS-STRICT: Invalid Serial "
381 "Number attribute value",
389 static int wps_validate_dev_name(const u8 *dev_name, size_t len,
392 if (dev_name == NULL) {
394 wpa_printf(MSG_INFO, "WPS-STRICT: Device Name "
395 "attribute missing");
400 if (len > 0 && dev_name[len - 1] == 0) {
401 wpa_hexdump_ascii(MSG_INFO, "WPS-STRICT: Invalid Device Name "
402 "attribute value", dev_name, len);
409 static int wps_validate_request_to_enroll(const u8 *request_to_enroll,
412 if (request_to_enroll == NULL) {
414 wpa_printf(MSG_INFO, "WPS-STRICT: Request to Enroll "
415 "attribute missing");
420 if (*request_to_enroll > 0x01) {
421 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Request to Enroll "
422 "attribute value 0x%x", *request_to_enroll);
429 static int wps_validate_req_dev_type(const u8 *req_dev_type[], size_t num,
434 wpa_printf(MSG_INFO, "WPS-STRICT: Requested Device "
435 "Type attribute missing");
444 static int wps_validate_wps_state(const u8 *wps_state, int mandatory)
446 if (wps_state == NULL) {
448 wpa_printf(MSG_INFO, "WPS-STRICT: Wi-Fi Protected "
449 "Setup State attribute missing");
454 if (*wps_state != WPS_STATE_NOT_CONFIGURED &&
455 *wps_state != WPS_STATE_CONFIGURED) {
456 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Wi-Fi Protected "
457 "Setup State attribute value 0x%x", *wps_state);
464 static int wps_validate_ap_setup_locked(const u8 *ap_setup_locked,
467 if (ap_setup_locked == NULL) {
469 wpa_printf(MSG_INFO, "WPS-STRICT: AP Setup Locked "
470 "attribute missing");
475 if (*ap_setup_locked > 1) {
476 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid AP Setup Locked "
477 "attribute value 0x%x", *ap_setup_locked);
484 static int wps_validate_selected_registrar(const u8 *selected_registrar,
487 if (selected_registrar == NULL) {
489 wpa_printf(MSG_INFO, "WPS-STRICT: Selected Registrar "
490 "attribute missing");
495 if (*selected_registrar > 1) {
496 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Selected Registrar "
497 "attribute value 0x%x", *selected_registrar);
504 static int wps_validate_sel_reg_config_methods(const u8 *config_methods,
505 int wps2, int mandatory)
509 if (config_methods == NULL) {
511 wpa_printf(MSG_INFO, "WPS-STRICT: Selected Registrar "
512 "Configuration Methods attribute missing");
518 val = WPA_GET_BE16(config_methods);
519 if (!valid_config_methods(val, wps2)) {
520 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Selected Registrar "
521 "Configuration Methods attribute value 0x%04x",
529 static int wps_validate_authorized_macs(const u8 *authorized_macs, size_t len,
532 if (authorized_macs == NULL) {
534 wpa_printf(MSG_INFO, "WPS-STRICT: Authorized MACs "
535 "attribute missing");
540 if (len > 30 && (len % ETH_ALEN) != 0) {
541 wpa_hexdump(MSG_INFO, "WPS-STRICT: Invalid Authorized "
542 "MACs attribute value", authorized_macs, len);
549 static int wps_validate_msg_type(const u8 *msg_type, int mandatory)
551 if (msg_type == NULL) {
553 wpa_printf(MSG_INFO, "WPS-STRICT: Message Type "
554 "attribute missing");
559 if (*msg_type < WPS_Beacon || *msg_type > WPS_WSC_DONE) {
560 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Message Type "
561 "attribute value 0x%x", *msg_type);
568 static int wps_validate_mac_addr(const u8 *mac_addr, int mandatory)
570 if (mac_addr == NULL) {
572 wpa_printf(MSG_INFO, "WPS-STRICT: MAC Address "
573 "attribute missing");
578 if (mac_addr[0] & 0x01) {
579 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid MAC Address "
580 "attribute value " MACSTR, MAC2STR(mac_addr));
587 static int wps_validate_enrollee_nonce(const u8 *enrollee_nonce, int mandatory)
589 if (enrollee_nonce == NULL) {
591 wpa_printf(MSG_INFO, "WPS-STRICT: Enrollee Nonce "
592 "attribute missing");
601 static int wps_validate_registrar_nonce(const u8 *registrar_nonce,
604 if (registrar_nonce == NULL) {
606 wpa_printf(MSG_INFO, "WPS-STRICT: Registrar Nonce "
607 "attribute missing");
616 static int wps_validate_public_key(const u8 *public_key, size_t len,
619 if (public_key == NULL) {
621 wpa_printf(MSG_INFO, "WPS-STRICT: Public Key "
622 "attribute missing");
628 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Public Key "
629 "attribute length %d", (int) len);
636 static int num_bits_set(u16 val)
639 for (c = 0; val; c++)
645 static int wps_validate_auth_type_flags(const u8 *flags, int mandatory)
651 wpa_printf(MSG_INFO, "WPS-STRICT: Authentication Type "
652 "Flags attribute missing");
657 val = WPA_GET_BE16(flags);
658 if ((val & ~WPS_AUTH_TYPES) || !(val & WPS_AUTH_WPA2PSK)) {
659 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Authentication Type "
660 "Flags attribute value 0x%04x", val);
667 static int wps_validate_auth_type(const u8 *type, int mandatory)
673 wpa_printf(MSG_INFO, "WPS-STRICT: Authentication Type "
674 "attribute missing");
679 val = WPA_GET_BE16(type);
680 if ((val & ~WPS_AUTH_TYPES) || val == 0 ||
681 (num_bits_set(val) > 1 &&
682 val != (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK))) {
683 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Authentication Type "
684 "attribute value 0x%04x", val);
691 static int wps_validate_encr_type_flags(const u8 *flags, int mandatory)
697 wpa_printf(MSG_INFO, "WPS-STRICT: Encryption Type "
698 "Flags attribute missing");
703 val = WPA_GET_BE16(flags);
704 if ((val & ~WPS_ENCR_TYPES) || !(val & WPS_ENCR_AES)) {
705 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Encryption Type "
706 "Flags attribute value 0x%04x", val);
713 static int wps_validate_encr_type(const u8 *type, int mandatory)
719 wpa_printf(MSG_INFO, "WPS-STRICT: Encryption Type "
720 "attribute missing");
725 val = WPA_GET_BE16(type);
726 if ((val & ~WPS_ENCR_TYPES) || val == 0 ||
727 (num_bits_set(val) > 1 && val != (WPS_ENCR_TKIP | WPS_ENCR_AES))) {
728 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Encryption Type "
729 "attribute value 0x%04x", val);
736 static int wps_validate_conn_type_flags(const u8 *flags, int mandatory)
740 wpa_printf(MSG_INFO, "WPS-STRICT: Connection Type "
741 "Flags attribute missing");
746 if ((*flags & ~(WPS_CONN_ESS | WPS_CONN_IBSS)) ||
747 !(*flags & WPS_CONN_ESS)) {
748 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Connection Type "
749 "Flags attribute value 0x%02x", *flags);
756 static int wps_validate_os_version(const u8 *os_version, int mandatory)
758 if (os_version == NULL) {
760 wpa_printf(MSG_INFO, "WPS-STRICT: OS Version "
761 "attribute missing");
770 static int wps_validate_authenticator(const u8 *authenticator, int mandatory)
772 if (authenticator == NULL) {
774 wpa_printf(MSG_INFO, "WPS-STRICT: Authenticator "
775 "attribute missing");
784 static int wps_validate_e_hash1(const u8 *hash, int mandatory)
788 wpa_printf(MSG_INFO, "WPS-STRICT: E-Hash1 "
789 "attribute missing");
798 static int wps_validate_e_hash2(const u8 *hash, int mandatory)
802 wpa_printf(MSG_INFO, "WPS-STRICT: E-Hash2 "
803 "attribute missing");
812 static int wps_validate_r_hash1(const u8 *hash, int mandatory)
816 wpa_printf(MSG_INFO, "WPS-STRICT: R-Hash1 "
817 "attribute missing");
826 static int wps_validate_r_hash2(const u8 *hash, int mandatory)
830 wpa_printf(MSG_INFO, "WPS-STRICT: R-Hash2 "
831 "attribute missing");
840 static int wps_validate_encr_settings(const u8 *encr_settings, size_t len,
843 if (encr_settings == NULL) {
845 wpa_printf(MSG_INFO, "WPS-STRICT: Encrypted Settings "
846 "attribute missing");
852 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Encrypted Settings "
853 "attribute length %d", (int) len);
860 static int wps_validate_settings_delay_time(const u8 *delay, int mandatory)
864 wpa_printf(MSG_INFO, "WPS-STRICT: Settings Delay Time "
865 "attribute missing");
874 static int wps_validate_r_snonce1(const u8 *nonce, int mandatory)
878 wpa_printf(MSG_INFO, "WPS-STRICT: R-SNonce1 "
879 "attribute missing");
888 static int wps_validate_r_snonce2(const u8 *nonce, int mandatory)
892 wpa_printf(MSG_INFO, "WPS-STRICT: R-SNonce2 "
893 "attribute missing");
902 static int wps_validate_e_snonce1(const u8 *nonce, int mandatory)
906 wpa_printf(MSG_INFO, "WPS-STRICT: E-SNonce1 "
907 "attribute missing");
916 static int wps_validate_e_snonce2(const u8 *nonce, int mandatory)
920 wpa_printf(MSG_INFO, "WPS-STRICT: E-SNonce2 "
921 "attribute missing");
930 static int wps_validate_key_wrap_auth(const u8 *auth, int mandatory)
934 wpa_printf(MSG_INFO, "WPS-STRICT: Key Wrap "
935 "Authenticator attribute missing");
944 static int wps_validate_ssid(const u8 *ssid, size_t ssid_len, int mandatory)
948 wpa_printf(MSG_INFO, "WPS-STRICT: SSID "
949 "attribute missing");
954 if (ssid_len == 0 || ssid[ssid_len - 1] == 0) {
955 wpa_hexdump_ascii(MSG_INFO, "WPS-STRICT: Invalid SSID "
956 "attribute value", ssid, ssid_len);
963 static int wps_validate_network_key_index(const u8 *idx, int mandatory)
967 wpa_printf(MSG_INFO, "WPS-STRICT: Network Key Index "
968 "attribute missing");
977 static int wps_validate_network_idx(const u8 *idx, int mandatory)
981 wpa_printf(MSG_INFO, "WPS-STRICT: Network Index "
982 "attribute missing");
991 static int wps_validate_network_key(const u8 *key, size_t key_len,
992 const u8 *encr_type, int mandatory)
996 wpa_printf(MSG_INFO, "WPS-STRICT: Network Key "
997 "attribute missing");
1002 if (((encr_type == NULL || WPA_GET_BE16(encr_type) != WPS_ENCR_WEP) &&
1003 key_len > 8 && key_len < 64 && key[key_len - 1] == 0) ||
1005 wpa_hexdump_ascii_key(MSG_INFO, "WPS-STRICT: Invalid Network "
1006 "Key attribute value", key, key_len);
1013 static int wps_validate_network_key_shareable(const u8 *val, int mandatory)
1017 wpa_printf(MSG_INFO, "WPS-STRICT: Network Key "
1018 "Shareable attribute missing");
1024 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Network Key "
1025 "Shareable attribute value 0x%x", *val);
1032 static int wps_validate_cred(const u8 *cred, size_t len)
1034 struct wps_parse_attr attr;
1039 wpabuf_set(&buf, cred, len);
1040 if (wps_parse_msg(&buf, &attr) < 0) {
1041 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse Credential");
1045 if (wps_validate_network_idx(attr.network_idx, 1) ||
1046 wps_validate_ssid(attr.ssid, attr.ssid_len, 1) ||
1047 wps_validate_auth_type(attr.auth_type, 1) ||
1048 wps_validate_encr_type(attr.encr_type, 1) ||
1049 wps_validate_network_key_index(attr.network_key_idx, 0) ||
1050 wps_validate_network_key(attr.network_key, attr.network_key_len,
1051 attr.encr_type, 1) ||
1052 wps_validate_mac_addr(attr.mac_addr, 1) ||
1053 wps_validate_network_key_shareable(attr.network_key_shareable, 0))
1055 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Credential");
1064 static int wps_validate_credential(const u8 *cred[], size_t len[], size_t num,
1071 wpa_printf(MSG_INFO, "WPS-STRICT: Credential "
1072 "attribute missing");
1078 for (i = 0; i < num; i++) {
1079 if (wps_validate_cred(cred[i], len[i]) < 0)
1087 int wps_validate_beacon(const struct wpabuf *wps_ie)
1089 struct wps_parse_attr attr;
1092 if (wps_ie == NULL) {
1093 wpa_printf(MSG_INFO, "WPS-STRICT: No WPS IE in Beacon frame");
1096 if (wps_parse_msg(wps_ie, &attr) < 0) {
1097 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse WPS IE in "
1102 wps2 = attr.version2 != NULL;
1103 sel_reg = attr.selected_registrar != NULL &&
1104 *attr.selected_registrar != 0;
1105 if (wps_validate_version(attr.version, 1) ||
1106 wps_validate_wps_state(attr.wps_state, 1) ||
1107 wps_validate_ap_setup_locked(attr.ap_setup_locked, 0) ||
1108 wps_validate_selected_registrar(attr.selected_registrar, 0) ||
1109 wps_validate_dev_password_id(attr.dev_password_id, sel_reg) ||
1110 wps_validate_sel_reg_config_methods(attr.sel_reg_config_methods,
1112 wps_validate_uuid_e(attr.uuid_e, 0) ||
1113 wps_validate_rf_bands(attr.rf_bands, 0) ||
1114 wps_validate_version2(attr.version2, wps2) ||
1115 wps_validate_authorized_macs(attr.authorized_macs,
1116 attr.authorized_macs_len, 0)) {
1117 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Beacon frame");
1125 int wps_validate_beacon_probe_resp(const struct wpabuf *wps_ie, int probe,
1128 struct wps_parse_attr attr;
1131 if (wps_ie == NULL) {
1132 wpa_printf(MSG_INFO, "WPS-STRICT: No WPS IE in "
1133 "%sProbe Response frame", probe ? "" : "Beacon/");
1136 if (wps_parse_msg(wps_ie, &attr) < 0) {
1137 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse WPS IE in "
1138 "%sProbe Response frame", probe ? "" : "Beacon/");
1142 wps2 = attr.version2 != NULL;
1143 sel_reg = attr.selected_registrar != NULL &&
1144 *attr.selected_registrar != 0;
1145 if (wps_validate_version(attr.version, 1) ||
1146 wps_validate_wps_state(attr.wps_state, 1) ||
1147 wps_validate_ap_setup_locked(attr.ap_setup_locked, 0) ||
1148 wps_validate_selected_registrar(attr.selected_registrar, 0) ||
1149 wps_validate_dev_password_id(attr.dev_password_id, sel_reg) ||
1150 wps_validate_sel_reg_config_methods(attr.sel_reg_config_methods,
1152 wps_validate_response_type(attr.response_type, probe) ||
1153 wps_validate_uuid_e(attr.uuid_e, probe) ||
1154 wps_validate_manufacturer(attr.manufacturer, attr.manufacturer_len,
1156 wps_validate_model_name(attr.model_name, attr.model_name_len,
1158 wps_validate_model_number(attr.model_number, attr.model_number_len,
1160 wps_validate_serial_number(attr.serial_number,
1161 attr.serial_number_len, probe) ||
1162 wps_validate_primary_dev_type(attr.primary_dev_type, probe) ||
1163 wps_validate_dev_name(attr.dev_name, attr.dev_name_len, probe) ||
1164 wps_validate_ap_config_methods(attr.config_methods, wps2, probe) ||
1165 wps_validate_rf_bands(attr.rf_bands, 0) ||
1166 wps_validate_version2(attr.version2, wps2) ||
1167 wps_validate_authorized_macs(attr.authorized_macs,
1168 attr.authorized_macs_len, 0)) {
1169 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid %sProbe Response "
1170 "frame from " MACSTR, probe ? "" : "Beacon/",
1172 #ifdef WPS_STRICT_WPS2
1175 #else /* WPS_STRICT_WPS2 */
1177 #endif /* WPS_STRICT_WPS2 */
1184 int wps_validate_probe_req(const struct wpabuf *wps_ie, const u8 *addr)
1186 struct wps_parse_attr attr;
1189 if (wps_ie == NULL) {
1190 wpa_printf(MSG_INFO, "WPS-STRICT: No WPS IE in "
1191 "Probe Request frame");
1194 if (wps_parse_msg(wps_ie, &attr) < 0) {
1195 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse WPS IE in "
1196 "Probe Request frame");
1200 wps2 = attr.version2 != NULL;
1201 if (wps_validate_version(attr.version, 1) ||
1202 wps_validate_request_type(attr.request_type, 1) ||
1203 wps_validate_config_methods(attr.config_methods, wps2, 1) ||
1204 wps_validate_uuid_e(attr.uuid_e, attr.uuid_r == NULL) ||
1205 wps_validate_uuid_r(attr.uuid_r, attr.uuid_e == NULL) ||
1206 wps_validate_primary_dev_type(attr.primary_dev_type, 1) ||
1207 wps_validate_rf_bands(attr.rf_bands, 1) ||
1208 wps_validate_assoc_state(attr.assoc_state, 1) ||
1209 wps_validate_config_error(attr.config_error, 1) ||
1210 wps_validate_dev_password_id(attr.dev_password_id, 1) ||
1211 wps_validate_version2(attr.version2, wps2) ||
1212 wps_validate_manufacturer(attr.manufacturer, attr.manufacturer_len,
1214 wps_validate_model_name(attr.model_name, attr.model_name_len,
1216 wps_validate_model_number(attr.model_number, attr.model_number_len,
1218 wps_validate_dev_name(attr.dev_name, attr.dev_name_len, wps2) ||
1219 wps_validate_request_to_enroll(attr.request_to_enroll, 0) ||
1220 wps_validate_req_dev_type(attr.req_dev_type, attr.num_req_dev_type,
1222 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid Probe Request "
1223 "frame from " MACSTR, MAC2STR(addr));
1231 int wps_validate_assoc_req(const struct wpabuf *wps_ie)
1233 struct wps_parse_attr attr;
1236 if (wps_ie == NULL) {
1237 wpa_printf(MSG_INFO, "WPS-STRICT: No WPS IE in "
1238 "(Re)Association Request frame");
1241 if (wps_parse_msg(wps_ie, &attr) < 0) {
1242 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse WPS IE in "
1243 "(Re)Association Request frame");
1247 wps2 = attr.version2 != NULL;
1248 if (wps_validate_version(attr.version, 1) ||
1249 wps_validate_request_type(attr.request_type, 1) ||
1250 wps_validate_version2(attr.version2, wps2)) {
1251 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid (Re)Association "
1260 int wps_validate_assoc_resp(const struct wpabuf *wps_ie)
1262 struct wps_parse_attr attr;
1265 if (wps_ie == NULL) {
1266 wpa_printf(MSG_INFO, "WPS-STRICT: No WPS IE in "
1267 "(Re)Association Response frame");
1270 if (wps_parse_msg(wps_ie, &attr) < 0) {
1271 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse WPS IE in "
1272 "(Re)Association Response frame");
1276 wps2 = attr.version2 != NULL;
1277 if (wps_validate_version(attr.version, 1) ||
1278 wps_validate_response_type(attr.response_type, 1) ||
1279 wps_validate_version2(attr.version2, wps2)) {
1280 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid (Re)Association "
1289 int wps_validate_m1(const struct wpabuf *tlvs)
1291 struct wps_parse_attr attr;
1295 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M1");
1298 if (wps_parse_msg(tlvs, &attr) < 0) {
1299 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1304 wps2 = attr.version2 != NULL;
1305 if (wps_validate_version(attr.version, 1) ||
1306 wps_validate_msg_type(attr.msg_type, 1) ||
1307 wps_validate_uuid_e(attr.uuid_e, 1) ||
1308 wps_validate_mac_addr(attr.mac_addr, 1) ||
1309 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1310 wps_validate_public_key(attr.public_key, attr.public_key_len, 1) ||
1311 wps_validate_auth_type_flags(attr.auth_type_flags, 1) ||
1312 wps_validate_encr_type_flags(attr.encr_type_flags, 1) ||
1313 wps_validate_conn_type_flags(attr.conn_type_flags, 1) ||
1314 wps_validate_config_methods(attr.config_methods, wps2, 1) ||
1315 wps_validate_wps_state(attr.wps_state, 1) ||
1316 wps_validate_manufacturer(attr.manufacturer, attr.manufacturer_len,
1318 wps_validate_model_name(attr.model_name, attr.model_name_len, 1) ||
1319 wps_validate_model_number(attr.model_number, attr.model_number_len,
1321 wps_validate_serial_number(attr.serial_number,
1322 attr.serial_number_len, 1) ||
1323 wps_validate_primary_dev_type(attr.primary_dev_type, 1) ||
1324 wps_validate_dev_name(attr.dev_name, attr.dev_name_len, 1) ||
1325 wps_validate_rf_bands(attr.rf_bands, 1) ||
1326 wps_validate_assoc_state(attr.assoc_state, 1) ||
1327 wps_validate_dev_password_id(attr.dev_password_id, 1) ||
1328 wps_validate_config_error(attr.config_error, 1) ||
1329 wps_validate_os_version(attr.os_version, 1) ||
1330 wps_validate_version2(attr.version2, wps2) ||
1331 wps_validate_request_to_enroll(attr.request_to_enroll, 0)) {
1332 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M1");
1333 #ifdef WPS_STRICT_WPS2
1336 #else /* WPS_STRICT_WPS2 */
1338 #endif /* WPS_STRICT_WPS2 */
1345 int wps_validate_m2(const struct wpabuf *tlvs)
1347 struct wps_parse_attr attr;
1351 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M2");
1354 if (wps_parse_msg(tlvs, &attr) < 0) {
1355 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1360 wps2 = attr.version2 != NULL;
1361 if (wps_validate_version(attr.version, 1) ||
1362 wps_validate_msg_type(attr.msg_type, 1) ||
1363 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1364 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1365 wps_validate_uuid_r(attr.uuid_r, 1) ||
1366 wps_validate_public_key(attr.public_key, attr.public_key_len, 1) ||
1367 wps_validate_auth_type_flags(attr.auth_type_flags, 1) ||
1368 wps_validate_encr_type_flags(attr.encr_type_flags, 1) ||
1369 wps_validate_conn_type_flags(attr.conn_type_flags, 1) ||
1370 wps_validate_config_methods(attr.config_methods, wps2, 1) ||
1371 wps_validate_manufacturer(attr.manufacturer, attr.manufacturer_len,
1373 wps_validate_model_name(attr.model_name, attr.model_name_len, 1) ||
1374 wps_validate_model_number(attr.model_number, attr.model_number_len,
1376 wps_validate_serial_number(attr.serial_number,
1377 attr.serial_number_len, 1) ||
1378 wps_validate_primary_dev_type(attr.primary_dev_type, 1) ||
1379 wps_validate_dev_name(attr.dev_name, attr.dev_name_len, 1) ||
1380 wps_validate_rf_bands(attr.rf_bands, 1) ||
1381 wps_validate_assoc_state(attr.assoc_state, 1) ||
1382 wps_validate_config_error(attr.config_error, 1) ||
1383 wps_validate_dev_password_id(attr.dev_password_id, 1) ||
1384 wps_validate_os_version(attr.os_version, 1) ||
1385 wps_validate_version2(attr.version2, wps2) ||
1386 wps_validate_authenticator(attr.authenticator, 1)) {
1387 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M2");
1388 #ifdef WPS_STRICT_WPS2
1391 #else /* WPS_STRICT_WPS2 */
1393 #endif /* WPS_STRICT_WPS2 */
1400 int wps_validate_m2d(const struct wpabuf *tlvs)
1402 struct wps_parse_attr attr;
1406 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M2D");
1409 if (wps_parse_msg(tlvs, &attr) < 0) {
1410 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1415 wps2 = attr.version2 != NULL;
1416 if (wps_validate_version(attr.version, 1) ||
1417 wps_validate_msg_type(attr.msg_type, 1) ||
1418 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1419 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1420 wps_validate_uuid_r(attr.uuid_r, 1) ||
1421 wps_validate_auth_type_flags(attr.auth_type_flags, 1) ||
1422 wps_validate_encr_type_flags(attr.encr_type_flags, 1) ||
1423 wps_validate_conn_type_flags(attr.conn_type_flags, 1) ||
1424 wps_validate_config_methods(attr.config_methods, wps2, 1) ||
1425 wps_validate_manufacturer(attr.manufacturer, attr.manufacturer_len,
1427 wps_validate_model_name(attr.model_name, attr.model_name_len, 1) ||
1428 wps_validate_model_number(attr.model_number, attr.model_number_len,
1430 wps_validate_serial_number(attr.serial_number,
1431 attr.serial_number_len, 1) ||
1432 wps_validate_primary_dev_type(attr.primary_dev_type, 1) ||
1433 wps_validate_dev_name(attr.dev_name, attr.dev_name_len, 1) ||
1434 wps_validate_rf_bands(attr.rf_bands, 1) ||
1435 wps_validate_assoc_state(attr.assoc_state, 1) ||
1436 wps_validate_config_error(attr.config_error, 1) ||
1437 wps_validate_os_version(attr.os_version, 1) ||
1438 wps_validate_version2(attr.version2, wps2)) {
1439 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M2D");
1440 #ifdef WPS_STRICT_WPS2
1443 #else /* WPS_STRICT_WPS2 */
1445 #endif /* WPS_STRICT_WPS2 */
1452 int wps_validate_m3(const struct wpabuf *tlvs)
1454 struct wps_parse_attr attr;
1458 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M3");
1461 if (wps_parse_msg(tlvs, &attr) < 0) {
1462 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1467 wps2 = attr.version2 != NULL;
1468 if (wps_validate_version(attr.version, 1) ||
1469 wps_validate_msg_type(attr.msg_type, 1) ||
1470 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1471 wps_validate_e_hash1(attr.e_hash1, 1) ||
1472 wps_validate_e_hash2(attr.e_hash2, 1) ||
1473 wps_validate_version2(attr.version2, wps2) ||
1474 wps_validate_authenticator(attr.authenticator, 1)) {
1475 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M3");
1476 #ifdef WPS_STRICT_WPS2
1479 #else /* WPS_STRICT_WPS2 */
1481 #endif /* WPS_STRICT_WPS2 */
1488 int wps_validate_m4(const struct wpabuf *tlvs)
1490 struct wps_parse_attr attr;
1494 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M4");
1497 if (wps_parse_msg(tlvs, &attr) < 0) {
1498 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1503 wps2 = attr.version2 != NULL;
1504 if (wps_validate_version(attr.version, 1) ||
1505 wps_validate_msg_type(attr.msg_type, 1) ||
1506 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1507 wps_validate_r_hash1(attr.r_hash1, 1) ||
1508 wps_validate_r_hash2(attr.r_hash2, 1) ||
1509 wps_validate_encr_settings(attr.encr_settings,
1510 attr.encr_settings_len, 1) ||
1511 wps_validate_version2(attr.version2, wps2) ||
1512 wps_validate_authenticator(attr.authenticator, 1)) {
1513 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M4");
1514 #ifdef WPS_STRICT_WPS2
1517 #else /* WPS_STRICT_WPS2 */
1519 #endif /* WPS_STRICT_WPS2 */
1526 int wps_validate_m4_encr(const struct wpabuf *tlvs, int wps2)
1528 struct wps_parse_attr attr;
1531 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M4 encrypted "
1535 if (wps_parse_msg(tlvs, &attr) < 0) {
1536 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1537 "in M4 encrypted settings");
1541 if (wps_validate_r_snonce1(attr.r_snonce1, 1) ||
1542 wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
1543 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M4 encrypted "
1545 #ifdef WPS_STRICT_WPS2
1548 #else /* WPS_STRICT_WPS2 */
1550 #endif /* WPS_STRICT_WPS2 */
1557 int wps_validate_m5(const struct wpabuf *tlvs)
1559 struct wps_parse_attr attr;
1563 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M5");
1566 if (wps_parse_msg(tlvs, &attr) < 0) {
1567 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1572 wps2 = attr.version2 != NULL;
1573 if (wps_validate_version(attr.version, 1) ||
1574 wps_validate_msg_type(attr.msg_type, 1) ||
1575 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1576 wps_validate_encr_settings(attr.encr_settings,
1577 attr.encr_settings_len, 1) ||
1578 wps_validate_version2(attr.version2, wps2) ||
1579 wps_validate_authenticator(attr.authenticator, 1)) {
1580 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M5");
1581 #ifdef WPS_STRICT_WPS2
1584 #else /* WPS_STRICT_WPS2 */
1586 #endif /* WPS_STRICT_WPS2 */
1593 int wps_validate_m5_encr(const struct wpabuf *tlvs, int wps2)
1595 struct wps_parse_attr attr;
1598 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M5 encrypted "
1602 if (wps_parse_msg(tlvs, &attr) < 0) {
1603 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1604 "in M5 encrypted settings");
1608 if (wps_validate_e_snonce1(attr.e_snonce1, 1) ||
1609 wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
1610 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M5 encrypted "
1612 #ifdef WPS_STRICT_WPS2
1615 #else /* WPS_STRICT_WPS2 */
1617 #endif /* WPS_STRICT_WPS2 */
1624 int wps_validate_m6(const struct wpabuf *tlvs)
1626 struct wps_parse_attr attr;
1630 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M6");
1633 if (wps_parse_msg(tlvs, &attr) < 0) {
1634 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1639 wps2 = attr.version2 != NULL;
1640 if (wps_validate_version(attr.version, 1) ||
1641 wps_validate_msg_type(attr.msg_type, 1) ||
1642 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1643 wps_validate_encr_settings(attr.encr_settings,
1644 attr.encr_settings_len, 1) ||
1645 wps_validate_version2(attr.version2, wps2) ||
1646 wps_validate_authenticator(attr.authenticator, 1)) {
1647 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M6");
1648 #ifdef WPS_STRICT_WPS2
1651 #else /* WPS_STRICT_WPS2 */
1653 #endif /* WPS_STRICT_WPS2 */
1660 int wps_validate_m6_encr(const struct wpabuf *tlvs, int wps2)
1662 struct wps_parse_attr attr;
1665 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M6 encrypted "
1669 if (wps_parse_msg(tlvs, &attr) < 0) {
1670 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1671 "in M6 encrypted settings");
1675 if (wps_validate_r_snonce2(attr.r_snonce2, 1) ||
1676 wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
1677 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M6 encrypted "
1679 #ifdef WPS_STRICT_WPS2
1682 #else /* WPS_STRICT_WPS2 */
1684 #endif /* WPS_STRICT_WPS2 */
1691 int wps_validate_m7(const struct wpabuf *tlvs)
1693 struct wps_parse_attr attr;
1697 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M7");
1700 if (wps_parse_msg(tlvs, &attr) < 0) {
1701 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1706 wps2 = attr.version2 != NULL;
1707 if (wps_validate_version(attr.version, 1) ||
1708 wps_validate_msg_type(attr.msg_type, 1) ||
1709 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1710 wps_validate_encr_settings(attr.encr_settings,
1711 attr.encr_settings_len, 1) ||
1712 wps_validate_settings_delay_time(attr.settings_delay_time, 0) ||
1713 wps_validate_version2(attr.version2, wps2) ||
1714 wps_validate_authenticator(attr.authenticator, 1)) {
1715 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M7");
1716 #ifdef WPS_STRICT_WPS2
1719 #else /* WPS_STRICT_WPS2 */
1721 #endif /* WPS_STRICT_WPS2 */
1728 int wps_validate_m7_encr(const struct wpabuf *tlvs, int ap, int wps2)
1730 struct wps_parse_attr attr;
1733 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M7 encrypted "
1737 if (wps_parse_msg(tlvs, &attr) < 0) {
1738 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1739 "in M7 encrypted settings");
1743 if (wps_validate_e_snonce2(attr.e_snonce2, 1) ||
1744 wps_validate_ssid(attr.ssid, attr.ssid_len, !ap) ||
1745 wps_validate_mac_addr(attr.mac_addr, !ap) ||
1746 wps_validate_auth_type(attr.auth_type, !ap) ||
1747 wps_validate_encr_type(attr.encr_type, !ap) ||
1748 wps_validate_network_key_index(attr.network_key_idx, 0) ||
1749 wps_validate_network_key(attr.network_key, attr.network_key_len,
1750 attr.encr_type, !ap) ||
1751 wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
1752 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M7 encrypted "
1754 #ifdef WPS_STRICT_WPS2
1757 #else /* WPS_STRICT_WPS2 */
1759 #endif /* WPS_STRICT_WPS2 */
1766 int wps_validate_m8(const struct wpabuf *tlvs)
1768 struct wps_parse_attr attr;
1772 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M8");
1775 if (wps_parse_msg(tlvs, &attr) < 0) {
1776 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1781 wps2 = attr.version2 != NULL;
1782 if (wps_validate_version(attr.version, 1) ||
1783 wps_validate_msg_type(attr.msg_type, 1) ||
1784 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1785 wps_validate_encr_settings(attr.encr_settings,
1786 attr.encr_settings_len, 1) ||
1787 wps_validate_version2(attr.version2, wps2) ||
1788 wps_validate_authenticator(attr.authenticator, 1)) {
1789 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M8");
1790 #ifdef WPS_STRICT_WPS2
1793 #else /* WPS_STRICT_WPS2 */
1795 #endif /* WPS_STRICT_WPS2 */
1802 int wps_validate_m8_encr(const struct wpabuf *tlvs, int ap, int wps2)
1804 struct wps_parse_attr attr;
1807 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in M8 encrypted "
1811 if (wps_parse_msg(tlvs, &attr) < 0) {
1812 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1813 "in M8 encrypted settings");
1817 if (wps_validate_ssid(attr.ssid, attr.ssid_len, ap) ||
1818 wps_validate_auth_type(attr.auth_type, ap) ||
1819 wps_validate_encr_type(attr.encr_type, ap) ||
1820 wps_validate_network_key_index(attr.network_key_idx, 0) ||
1821 wps_validate_mac_addr(attr.mac_addr, ap) ||
1822 wps_validate_credential(attr.cred, attr.cred_len, attr.num_cred,
1824 wps_validate_key_wrap_auth(attr.key_wrap_auth, 1)) {
1825 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid M8 encrypted "
1827 #ifdef WPS_STRICT_WPS2
1830 #else /* WPS_STRICT_WPS2 */
1832 #endif /* WPS_STRICT_WPS2 */
1839 int wps_validate_wsc_ack(const struct wpabuf *tlvs)
1841 struct wps_parse_attr attr;
1845 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in WSC_ACK");
1848 if (wps_parse_msg(tlvs, &attr) < 0) {
1849 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1854 wps2 = attr.version2 != NULL;
1855 if (wps_validate_version(attr.version, 1) ||
1856 wps_validate_msg_type(attr.msg_type, 1) ||
1857 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1858 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1859 wps_validate_version2(attr.version2, wps2)) {
1860 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid WSC_ACK");
1861 #ifdef WPS_STRICT_WPS2
1864 #else /* WPS_STRICT_WPS2 */
1866 #endif /* WPS_STRICT_WPS2 */
1873 int wps_validate_wsc_nack(const struct wpabuf *tlvs)
1875 struct wps_parse_attr attr;
1879 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in WSC_NACK");
1882 if (wps_parse_msg(tlvs, &attr) < 0) {
1883 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1888 wps2 = attr.version2 != NULL;
1889 if (wps_validate_version(attr.version, 1) ||
1890 wps_validate_msg_type(attr.msg_type, 1) ||
1891 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1892 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1893 wps_validate_config_error(attr.config_error, 1) ||
1894 wps_validate_version2(attr.version2, wps2)) {
1895 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid WSC_NACK");
1896 #ifdef WPS_STRICT_WPS2
1899 #else /* WPS_STRICT_WPS2 */
1901 #endif /* WPS_STRICT_WPS2 */
1908 int wps_validate_wsc_done(const struct wpabuf *tlvs)
1910 struct wps_parse_attr attr;
1914 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in WSC_Done");
1917 if (wps_parse_msg(tlvs, &attr) < 0) {
1918 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1923 wps2 = attr.version2 != NULL;
1924 if (wps_validate_version(attr.version, 1) ||
1925 wps_validate_msg_type(attr.msg_type, 1) ||
1926 wps_validate_enrollee_nonce(attr.enrollee_nonce, 1) ||
1927 wps_validate_registrar_nonce(attr.registrar_nonce, 1) ||
1928 wps_validate_version2(attr.version2, wps2)) {
1929 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid WSC_Done");
1930 #ifdef WPS_STRICT_WPS2
1933 #else /* WPS_STRICT_WPS2 */
1935 #endif /* WPS_STRICT_WPS2 */
1942 int wps_validate_upnp_set_selected_registrar(const struct wpabuf *tlvs)
1944 struct wps_parse_attr attr;
1949 wpa_printf(MSG_INFO, "WPS-STRICT: No TLVs in "
1950 "SetSelectedRegistrar");
1953 if (wps_parse_msg(tlvs, &attr) < 0) {
1954 wpa_printf(MSG_INFO, "WPS-STRICT: Failed to parse attributes "
1955 "in SetSelectedRegistrar");
1959 wps2 = attr.version2 != NULL;
1960 sel_reg = attr.selected_registrar != NULL &&
1961 *attr.selected_registrar != 0;
1962 if (wps_validate_version(attr.version, 1) ||
1963 wps_validate_dev_password_id(attr.dev_password_id, sel_reg) ||
1964 wps_validate_sel_reg_config_methods(attr.sel_reg_config_methods,
1966 wps_validate_version2(attr.version2, wps2) ||
1967 wps_validate_authorized_macs(attr.authorized_macs,
1968 attr.authorized_macs_len, wps2) ||
1969 wps_validate_uuid_r(attr.uuid_r, wps2)) {
1970 wpa_printf(MSG_INFO, "WPS-STRICT: Invalid "
1971 "SetSelectedRegistrar");
1972 #ifdef WPS_STRICT_WPS2
1975 #else /* WPS_STRICT_WPS2 */
1977 #endif /* WPS_STRICT_WPS2 */