test_owe.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Test cases for Opportunistic Wireless Encryption (OWE)
  2. # Copyright (c) 2017, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import hostapd
  7. import hwsim_utils
  8. from utils import HwsimSkip
  9. def test_owe(dev, apdev):
  10. """Opportunistic Wireless Encryption"""
  11. if "OWE" not in dev[0].get_capability("key_mgmt"):
  12. raise HwsimSkip("OWE not supported")
  13. params = { "ssid": "owe",
  14. "wpa": "2",
  15. "wpa_key_mgmt": "OWE",
  16. "rsn_pairwise": "CCMP" }
  17. hapd = hostapd.add_ap(apdev[0], params)
  18. bssid = hapd.own_addr()
  19. dev[0].scan_for_bss(bssid, freq="2412")
  20. bss = dev[0].get_bss(bssid)
  21. if "[WPA2-OWE-CCMP]" not in bss['flags']:
  22. raise Exception("OWE AKM not recognized: " + bss['flags'])
  23. dev[0].connect("owe", key_mgmt="OWE")
  24. hwsim_utils.test_connectivity(dev[0], hapd)
  25. val = dev[0].get_status_field("key_mgmt")
  26. if val != "OWE":
  27. raise Exception("Unexpected key_mgmt: " + val)
  28. def test_owe_and_psk(dev, apdev):
  29. """Opportunistic Wireless Encryption and WPA2-PSK enabled"""
  30. if "OWE" not in dev[0].get_capability("key_mgmt"):
  31. raise HwsimSkip("OWE not supported")
  32. params = { "ssid": "owe+psk",
  33. "wpa": "2",
  34. "wpa_key_mgmt": "OWE WPA-PSK",
  35. "rsn_pairwise": "CCMP",
  36. "wpa_passphrase": "12345678" }
  37. hapd = hostapd.add_ap(apdev[0], params)
  38. bssid = hapd.own_addr()
  39. dev[0].scan_for_bss(bssid, freq="2412")
  40. dev[0].connect("owe+psk", psk="12345678")
  41. hwsim_utils.test_connectivity(dev[0], hapd)
  42. dev[1].scan_for_bss(bssid, freq="2412")
  43. dev[1].connect("owe+psk", key_mgmt="OWE")
  44. hwsim_utils.test_connectivity(dev[1], hapd)