test_suite_b.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Suite B tests
  2. # Copyright (c) 2014-2015, 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. from utils import HwsimSkip
  11. def test_suite_b(dev, apdev):
  12. """WPA2-PSK/GCMP connection at Suite B 128-bit level"""
  13. if "GCMP" not in dev[0].get_capability("pairwise"):
  14. raise HwsimSkip("GCMP not supported")
  15. if "BIP-GMAC-128" not in dev[0].get_capability("group_mgmt"):
  16. raise HwsimSkip("BIP-GMAC-128 not supported")
  17. if "WPA-EAP-SUITE-B" not in dev[0].get_capability("key_mgmt"):
  18. raise HwsimSkip("WPA-EAP-SUITE-B not supported")
  19. tls = dev[0].request("GET tls_library")
  20. if not tls.startswith("OpenSSL"):
  21. raise HwsimSkip("TLS library not supported for Suite B: " + tls);
  22. if "build=OpenSSL 1.0.2" not in tls or "run=OpenSSL 1.0.2" not in tls:
  23. raise HwsimSkip("OpenSSL version not supported for Suite B: " + tls)
  24. params = { "ssid": "test-suite-b",
  25. "wpa": "2",
  26. "wpa_key_mgmt": "WPA-EAP-SUITE-B",
  27. "rsn_pairwise": "GCMP",
  28. "group_mgmt_cipher": "BIP-GMAC-128",
  29. "ieee80211w": "2",
  30. "ieee8021x": "1",
  31. "openssl_ciphers": "SUITEB128",
  32. #"dh_file": "auth_serv/dh.conf",
  33. "eap_server": "1",
  34. "eap_user_file": "auth_serv/eap_user.conf",
  35. "ca_cert": "auth_serv/ec-ca.pem",
  36. "server_cert": "auth_serv/ec-server.pem",
  37. "private_key": "auth_serv/ec-server.key" }
  38. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  39. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B", ieee80211w="2",
  40. openssl_ciphers="SUITEB128",
  41. eap="TLS", identity="tls user",
  42. ca_cert="auth_serv/ec-ca.pem",
  43. client_cert="auth_serv/ec-user.pem",
  44. private_key="auth_serv/ec-user.key",
  45. pairwise="GCMP", group="GCMP", scan_freq="2412")
  46. tls_cipher = dev[0].get_status_field("EAP TLS cipher")
  47. if tls_cipher != "ECDHE-ECDSA-AES128-GCM-SHA256":
  48. raise Exception("Unexpected TLS cipher: " + tls_cipher)
  49. bss = dev[0].get_bss(apdev[0]['bssid'])
  50. if 'flags' not in bss:
  51. raise Exception("Could not get BSS flags from BSS table")
  52. if "[WPA2-EAP-SUITE-B-GCMP]" not in bss['flags']:
  53. raise Exception("Unexpected BSS flags: " + bss['flags'])
  54. dev[0].request("DISCONNECT")
  55. dev[0].wait_disconnected(timeout=20)
  56. dev[0].dump_monitor()
  57. dev[0].request("RECONNECT")
  58. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
  59. "CTRL-EVENT-CONNECTED"], timeout=20)
  60. if ev is None:
  61. raise Exception("Roaming with the AP timed out")
  62. if "CTRL-EVENT-EAP-STARTED" in ev:
  63. raise Exception("Unexpected EAP exchange")