test_ap_mixed.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Mixed AP module parameters enabled
  2. # Copyright (c) 2014, Qualcomm Atheros, Inc.
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import logging
  7. logger = logging.getLogger()
  8. import hostapd
  9. import hwsim_utils
  10. from utils import skip_with_fips
  11. def test_ap_mixed_security(dev, apdev):
  12. """WPA/WPA2 with PSK, EAP, SAE, FT in a single BSS"""
  13. skip_with_fips(dev[0])
  14. dev[0].flush_scan_cache()
  15. sae = "SAE" in dev[0].get_capability("auth_alg")
  16. ssid = "test-mixed"
  17. passphrase = 'qwertyuiop'
  18. params = hostapd.wpa_mixed_params(ssid=ssid, passphrase=passphrase)
  19. params['wpa_key_mgmt'] = "WPA-PSK WPA-PSK-SHA256 WPA-EAP WPA-EAP-SHA256 SAE FT-PSK FT-EAP FT-SAE"
  20. params["ieee8021x"] = "1"
  21. params["eap_server"] = "1"
  22. params["eap_user_file"] = "auth_serv/eap_user.conf"
  23. params['nas_identifier'] = "nas1.w1.fi"
  24. hapd = hostapd.add_ap(apdev[0], params)
  25. dev[0].connect(ssid, key_mgmt="WPA-PSK", proto="WPA", pairwise="TKIP",
  26. psk=passphrase, scan_freq="2412")
  27. dev[1].connect(ssid, key_mgmt="WPA-EAP-SHA256", proto="WPA2", eap="GPSK",
  28. identity="gpsk user",
  29. password="abcdefghijklmnop0123456789abcdef",
  30. scan_freq="2412")
  31. if sae:
  32. dev[2].connect(ssid, psk=passphrase, key_mgmt="SAE", scan_freq="2412")
  33. logger.debug(dev[0].request("SCAN_RESULTS"))
  34. bss = dev[0].get_bss(apdev[0]['bssid'])
  35. logger.debug(bss)
  36. if "[WPA-EAP+PSK-TKIP]" not in bss['flags']:
  37. raise Exception("Unexpected flags (WPA): " + bss['flags'])
  38. if sae and "[WPA2-EAP+PSK+SAE+FT/EAP+FT/PSK+FT/SAE+EAP-SHA256+PSK-SHA256-CCMP]" not in bss['flags']:
  39. raise Exception("Unexpected flags (WPA2): " + bss['flags'])
  40. if dev[0].get_status_field("key_mgmt") != "WPA-PSK":
  41. raise Exception("Unexpected key_mgmt(1)")
  42. if dev[0].get_status_field("pairwise_cipher") != "TKIP":
  43. raise Exception("Unexpected pairwise(1)")
  44. if dev[1].get_status_field("key_mgmt") != "WPA2-EAP-SHA256":
  45. raise Exception("Unexpected key_mgmt(2)")
  46. if sae and dev[2].get_status_field("key_mgmt") != "SAE":
  47. raise Exception("Unexpected key_mgmt(3)")
  48. hwsim_utils.test_connectivity(dev[0], dev[1])
  49. if sae:
  50. hwsim_utils.test_connectivity(dev[1], dev[2])
  51. hwsim_utils.test_connectivity(dev[0], dev[2])
  52. for i in range(3):
  53. if i < 2 or sae:
  54. hwsim_utils.test_connectivity(dev[i], hapd)
  55. dev[i].request("DISCONNECT")
  56. dev[0].connect(ssid, key_mgmt="WPA-PSK WPA-PSK-SHA256", psk=passphrase,
  57. scan_freq="2412")
  58. dev[1].connect(ssid, key_mgmt="WPA-EAP", proto="WPA", eap="GPSK",
  59. identity="gpsk user",
  60. password="abcdefghijklmnop0123456789abcdef",
  61. scan_freq="2412")
  62. if sae:
  63. dev[2].connect(ssid, key_mgmt="WPA-PSK WPA-PSK-SHA256 SAE",
  64. psk=passphrase, scan_freq="2412")
  65. if dev[0].get_status_field("key_mgmt") != "WPA2-PSK-SHA256":
  66. raise Exception("Unexpected key_mgmt(1b)")
  67. if dev[0].get_status_field("pairwise_cipher") != "CCMP":
  68. raise Exception("Unexpected pairwise(1b)")
  69. if dev[1].get_status_field("key_mgmt") != "WPA/IEEE 802.1X/EAP":
  70. raise Exception("Unexpected key_mgmt(2b)")
  71. if sae and dev[2].get_status_field("key_mgmt") != "SAE":
  72. raise Exception("Unexpected key_mgmt(3b)")
  73. for i in range(3):
  74. dev[i].request("DISCONNECT")
  75. dev[0].connect(ssid, key_mgmt="FT-PSK", psk=passphrase, scan_freq="2412")
  76. dev[1].connect(ssid, key_mgmt="FT-EAP", eap="GPSK", identity="gpsk user",
  77. password="abcdefghijklmnop0123456789abcdef",
  78. scan_freq="2412")
  79. if sae:
  80. dev[2].connect(ssid, psk=passphrase, key_mgmt="FT-SAE",
  81. scan_freq="2412")
  82. if dev[0].get_status_field("key_mgmt") != "FT-PSK":
  83. raise Exception("Unexpected key_mgmt(1c)")
  84. if dev[1].get_status_field("key_mgmt") != "FT-EAP":
  85. raise Exception("Unexpected key_mgmt(2c)")
  86. if sae and dev[2].get_status_field("key_mgmt") != "FT-SAE":
  87. raise Exception("Unexpected key_mgmt(3c)")