test_suite_b.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Suite B tests
  2. # Copyright (c) 2014, 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 time
  7. import logging
  8. logger = logging.getLogger()
  9. import hostapd
  10. def test_suite_b(dev, apdev):
  11. """WPA2-PSK/GCMP connection"""
  12. if "GCMP" not in dev[0].get_capability("pairwise"):
  13. return "skip"
  14. params = hostapd.wpa2_eap_params(ssid="test-suite-b")
  15. params["wpa_key_mgmt"] = "WPA-EAP-SUITE-B"
  16. params['rsn_pairwise'] = "GCMP"
  17. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  18. # TODO: Force Suite B configuration for TLS
  19. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B",
  20. eap="TLS", identity="tls user", ca_cert="auth_serv/ca.pem",
  21. client_cert="auth_serv/user.pem",
  22. private_key="auth_serv/user.key",
  23. pairwise="GCMP", group="GCMP", scan_freq="2412")
  24. bss = dev[0].get_bss(apdev[0]['bssid'])
  25. if 'flags' not in bss:
  26. raise Exception("Could not get BSS flags from BSS table")
  27. if "[WPA2-EAP-SUITE-B-GCMP]" not in bss['flags']:
  28. raise Exception("Unexpected BSS flags: " + bss['flags'])
  29. dev[0].request("DISCONNECT")
  30. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=20)
  31. if ev is None:
  32. raise Exception("Disconnection event timed out")
  33. dev[0].dump_monitor()
  34. dev[0].request("RECONNECT")
  35. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
  36. "CTRL-EVENT-CONNECTED"], timeout=20)
  37. if ev is None:
  38. raise Exception("Roaming with the AP timed out")
  39. if "CTRL-EVENT-EAP-STARTED" in ev:
  40. raise Exception("Unexpected EAP exchange")