test_sae.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/python
  2. #
  3. # Test cases for SAE
  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 test_sae(dev, apdev):
  15. """SAE with default group"""
  16. params = hostapd.wpa2_params(ssid="test-sae",
  17. passphrase="12345678")
  18. params['wpa_key_mgmt'] = 'SAE'
  19. hostapd.add_ap(apdev[0]['ifname'], params)
  20. dev[0].request("SET sae_groups ")
  21. id = dev[0].connect("test-sae", psk="12345678", key_mgmt="SAE",
  22. scan_freq="2412")
  23. if dev[0].get_status_field('sae_group') != '19':
  24. raise Exception("Expected default SAE group not used")
  25. def test_sae_groups(dev, apdev):
  26. """SAE with all supported groups"""
  27. # This would be the full list of supported groups, but groups 14-16
  28. # (2048-4096 bit MODP) are a bit too slow on some VMs and can result in
  29. # hitting mac80211 authentication timeout, so skip them for now.
  30. #sae_groups = [ 19, 25, 26, 20, 21, 2, 5, 14, 15, 16, 22, 23, 24 ]
  31. sae_groups = [ 19, 25, 26, 20, 21, 2, 5, 22, 23, 24 ]
  32. groups = [str(g) for g in sae_groups]
  33. params = hostapd.wpa2_params(ssid="test-sae-groups",
  34. passphrase="12345678")
  35. params['wpa_key_mgmt'] = 'SAE'
  36. params['sae_groups'] = ' '.join(groups)
  37. hostapd.add_ap(apdev[0]['ifname'], params)
  38. for g in groups:
  39. logger.info("Testing SAE group " + g)
  40. dev[0].request("SET sae_groups " + g)
  41. id = dev[0].connect("test-sae-groups", psk="12345678", key_mgmt="SAE",
  42. scan_freq="2412")
  43. if dev[0].get_status_field('sae_group') != g:
  44. raise Exception("Expected SAE group not used")
  45. dev[0].remove_network(id)
  46. def test_sae_group_nego(dev, apdev):
  47. """SAE group negotiation"""
  48. params = hostapd.wpa2_params(ssid="test-sae-group-nego",
  49. passphrase="12345678")
  50. params['wpa_key_mgmt'] = 'SAE'
  51. params['sae_groups'] = '19'
  52. hostapd.add_ap(apdev[0]['ifname'], params)
  53. dev[0].request("SET sae_groups 25 26 20 19")
  54. dev[0].connect("test-sae-group-nego", psk="12345678", key_mgmt="SAE",
  55. scan_freq="2412")
  56. if dev[0].get_status_field('sae_group') != '19':
  57. raise Exception("Expected SAE group not used")