test_ap_ciphers.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/python
  2. #
  3. # Cipher suite tests
  4. # Copyright (c) 2013, 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 time
  9. import subprocess
  10. import logging
  11. logger = logging.getLogger()
  12. import hwsim_utils
  13. import hostapd
  14. def check_cipher(dev, ap, cipher):
  15. if cipher not in dev.get_capability("pairwise"):
  16. return "skip"
  17. params = { "ssid": "test-wpa2-psk",
  18. "wpa_passphrase": "12345678",
  19. "wpa": "2",
  20. "wpa_key_mgmt": "WPA-PSK",
  21. "rsn_pairwise": cipher }
  22. hostapd.add_ap(ap['ifname'], params)
  23. dev.connect("test-wpa2-psk", psk="12345678",
  24. pairwise=cipher, group=cipher)
  25. hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
  26. def test_ap_cipher_tkip(dev, apdev):
  27. """WPA2-PSK/TKIP connection"""
  28. check_cipher(dev[0], apdev[0], "TKIP")
  29. def test_ap_cipher_ccmp(dev, apdev):
  30. """WPA2-PSK/CCMP connection"""
  31. check_cipher(dev[0], apdev[0], "CCMP")
  32. def test_ap_cipher_gcmp(dev, apdev):
  33. """WPA2-PSK/GCMP connection"""
  34. check_cipher(dev[0], apdev[0], "GCMP")
  35. def test_ap_cipher_ccmp_256(dev, apdev):
  36. """WPA2-PSK/CCMP-256 connection"""
  37. check_cipher(dev[0], apdev[0], "CCMP-256")
  38. def test_ap_cipher_gcmp_256(dev, apdev):
  39. """WPA2-PSK/GCMP-256 connection"""
  40. check_cipher(dev[0], apdev[0], "GCMP-256")