test_peerkey.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # PeerKey tests
  2. # Copyright (c) 2013, 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 logging
  7. logger = logging.getLogger()
  8. import time
  9. import hwsim_utils
  10. import hostapd
  11. def test_peerkey(dev, apdev):
  12. """RSN AP and PeerKey between two STAs"""
  13. ssid = "test-peerkey"
  14. passphrase = "12345678"
  15. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  16. params['peerkey'] = "1"
  17. hostapd.add_ap(apdev[0]['ifname'], params)
  18. dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
  19. dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
  20. hwsim_utils.test_connectivity_sta(dev[0], dev[1])
  21. dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
  22. time.sleep(0.5)
  23. # NOTE: Actual use of the direct link (DLS) is not supported in
  24. # mac80211_hwsim, so this operation fails at setting the keys after
  25. # successfully completed 4-way handshake. This test case does allow the
  26. # key negotiation part to be tested for coverage, though.
  27. def test_peerkey_unknown_peer(dev, apdev):
  28. """RSN AP and PeerKey attempt with unknown peer"""
  29. ssid = "test-peerkey"
  30. passphrase = "12345678"
  31. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  32. params['peerkey'] = "1"
  33. hostapd.add_ap(apdev[0]['ifname'], params)
  34. dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
  35. dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
  36. hwsim_utils.test_connectivity_sta(dev[0], dev[1])
  37. dev[0].request("STKSTART " + dev[2].p2p_interface_addr())
  38. time.sleep(0.5)