]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Testing mechanism to force auth/encr type flags
authorJouni Malinen <j@w1.fi>
Fri, 1 Jan 2016 11:03:25 +0000 (13:03 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 1 Jan 2016 11:42:04 +0000 (13:42 +0200)
The new wps_force_{auth,encr}_types parameters can be used in test build
(CONFIG_WPS_TESTING) to force wpa_supplicant to use the specified value
in the Authentication/Encryption Type flags attribute. This can be used
to test AP behavior on various error cases for which there are
workarounds to cover deployed device behavior.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/wps/wps.c
src/wps/wps_attr_build.c
src/wps/wps_defs.h
wpa_supplicant/ctrl_iface.c

index fbaf85aabab4afc949ebb39dbcb77020fa717742..7c6dcb2b35a13085696c9ca900adbd7f32616b4d 100644 (file)
 int wps_version_number = 0x20;
 int wps_testing_dummy_cred = 0;
 int wps_corrupt_pkhash = 0;
+int wps_force_auth_types_in_use = 0;
+u16 wps_force_auth_types = 0;
+int wps_force_encr_types_in_use = 0;
+u16 wps_force_encr_types = 0;
 #endif /* CONFIG_WPS_TESTING */
 
 
index b689357a280a657eb0a0df072fe28bffdf2cdd3a..748620f9476630709852adf4aba36ed9e394e5d6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Wi-Fi Protected Setup - attribute building
- * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2008-2016, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -298,7 +298,16 @@ int wps_build_auth_type_flags(struct wps_data *wps, struct wpabuf *msg)
        auth_types &= ~WPS_AUTH_WPA;
        auth_types &= ~WPS_AUTH_WPA2;
        auth_types &= ~WPS_AUTH_SHARED;
-       wpa_printf(MSG_DEBUG, "WPS:  * Authentication Type Flags");
+#ifdef CONFIG_WPS_TESTING
+       if (wps_force_auth_types_in_use) {
+               wpa_printf(MSG_DEBUG,
+                          "WPS: Testing - replace auth type 0x%x with 0x%x",
+                          auth_types, wps_force_auth_types);
+               auth_types = wps_force_auth_types;
+       }
+#endif /* CONFIG_WPS_TESTING */
+       wpa_printf(MSG_DEBUG, "WPS:  * Authentication Type Flags (0x%x)",
+                  auth_types);
        wpabuf_put_be16(msg, ATTR_AUTH_TYPE_FLAGS);
        wpabuf_put_be16(msg, 2);
        wpabuf_put_be16(msg, auth_types);
@@ -310,7 +319,16 @@ int wps_build_encr_type_flags(struct wps_data *wps, struct wpabuf *msg)
 {
        u16 encr_types = WPS_ENCR_TYPES;
        encr_types &= ~WPS_ENCR_WEP;
-       wpa_printf(MSG_DEBUG, "WPS:  * Encryption Type Flags");
+#ifdef CONFIG_WPS_TESTING
+       if (wps_force_encr_types_in_use) {
+               wpa_printf(MSG_DEBUG,
+                          "WPS: Testing - replace encr type 0x%x with 0x%x",
+                          encr_types, wps_force_encr_types);
+               encr_types = wps_force_encr_types;
+       }
+#endif /* CONFIG_WPS_TESTING */
+       wpa_printf(MSG_DEBUG, "WPS:  * Encryption Type Flags (0x%x)",
+                  encr_types);
        wpabuf_put_be16(msg, ATTR_ENCR_TYPE_FLAGS);
        wpabuf_put_be16(msg, 2);
        wpabuf_put_be16(msg, encr_types);
index a23b979d2e3c7d6835f5d61c6e42edf60c3bc323..301864da433d028a743b5f03abddb55d0a26722e 100644 (file)
 extern int wps_version_number;
 extern int wps_testing_dummy_cred;
 extern int wps_corrupt_pkhash;
+extern int wps_force_auth_types_in_use;
+extern u16 wps_force_auth_types;
+extern int wps_force_encr_types_in_use;
+extern u16 wps_force_encr_types;
 #define WPS_VERSION wps_version_number
 
 #else /* CONFIG_WPS_TESTING */
index 58b8db41632695a01ab24142d30c5e8cf9175af6..10d86f5552424650f2699771202258b25d282b25 100644 (file)
@@ -371,6 +371,20 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                wps_corrupt_pkhash = atoi(value);
                wpa_printf(MSG_DEBUG, "WPS: Testing - wps_corrupt_pkhash=%d",
                           wps_corrupt_pkhash);
+       } else if (os_strcasecmp(cmd, "wps_force_auth_types") == 0) {
+               if (value[0] == '\0') {
+                       wps_force_auth_types_in_use = 0;
+               } else {
+                       wps_force_auth_types = strtol(value, NULL, 0);
+                       wps_force_auth_types_in_use = 1;
+               }
+       } else if (os_strcasecmp(cmd, "wps_force_encr_types") == 0) {
+               if (value[0] == '\0') {
+                       wps_force_encr_types_in_use = 0;
+               } else {
+                       wps_force_encr_types = strtol(value, NULL, 0);
+                       wps_force_encr_types_in_use = 1;
+               }
 #endif /* CONFIG_WPS_TESTING */
        } else if (os_strcasecmp(cmd, "ampdu") == 0) {
                if (wpa_drv_ampdu(wpa_s, atoi(value)) < 0)
@@ -6979,6 +6993,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        wps_version_number = 0x20;
        wps_testing_dummy_cred = 0;
        wps_corrupt_pkhash = 0;
+       wps_force_auth_types_in_use = 0;
+       wps_force_encr_types_in_use = 0;
 #endif /* CONFIG_WPS_TESTING */
 #ifdef CONFIG_WPS
        wpa_s->wps_fragment_size = 0;