test_peerkey.py 1.1 KB

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