test_wep.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # WEP 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 hostapd
  7. import hwsim_utils
  8. def test_wep_open_auth(dev, apdev):
  9. """WEP Open System authentication"""
  10. hostapd.add_ap(apdev[0]['ifname'],
  11. { "ssid": "wep-open",
  12. "wep_key0": '"hello"' })
  13. dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
  14. scan_freq="2412")
  15. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  16. if "[WEP]" not in dev[0].request("SCAN_RESULTS"):
  17. raise Exception("WEP flag not indicated in scan results")
  18. def test_wep_shared_key_auth(dev, apdev):
  19. """WEP Shared Key authentication"""
  20. hostapd.add_ap(apdev[0]['ifname'],
  21. { "ssid": "wep-shared-key",
  22. "wep_key0": '"hello12345678"',
  23. "auth_algs": "2" })
  24. dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
  25. wep_key0='"hello12345678"',
  26. scan_freq="2412")
  27. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  28. dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
  29. wep_key0='"hello12345678"',
  30. scan_freq="2412")
  31. def test_wep_shared_key_auth_not_allowed(dev, apdev):
  32. """WEP Shared Key authentication not allowed"""
  33. hostapd.add_ap(apdev[0]['ifname'],
  34. { "ssid": "wep-shared-key",
  35. "wep_key0": '"hello12345678"',
  36. "auth_algs": "1" })
  37. dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
  38. wep_key0='"hello12345678"',
  39. scan_freq="2412", wait_connect=False)
  40. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  41. if ev is not None:
  42. raise Exception("Unexpected association")