test_wep.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/python
  2. #
  3. # WEP tests
  4. # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
  5. #
  6. # This software may be distributed under the terms of the BSD license.
  7. # See README for more details.
  8. import hostapd
  9. import hwsim_utils
  10. def test_wep_open_auth(dev, apdev):
  11. """WEP Open System authentication"""
  12. hostapd.add_ap(apdev[0]['ifname'],
  13. { "ssid": "wep-open",
  14. "wep_key0": '"hello"' })
  15. dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
  16. scan_freq="2412")
  17. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  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")