2 # Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger = logging.getLogger()
13 from utils import skip_with_fips
14 from wlantest import Wlantest
16 def test_peerkey(dev, apdev):
17 """RSN AP and PeerKey between two STAs"""
19 passphrase = "12345678"
20 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
21 params['peerkey'] = "1"
22 hostapd.add_ap(apdev[0], params)
24 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
25 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
26 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
28 dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
30 # NOTE: Actual use of the direct link (DLS) is not supported in
31 # mac80211_hwsim, so this operation fails at setting the keys after
32 # successfully completed 4-way handshake. This test case does allow the
33 # key negotiation part to be tested for coverage, though.
35 def test_peerkey_unknown_peer(dev, apdev):
36 """RSN AP and PeerKey attempt with unknown peer"""
38 passphrase = "12345678"
39 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
40 params['peerkey'] = "1"
41 hostapd.add_ap(apdev[0], params)
43 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
44 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
45 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
47 dev[0].request("STKSTART " + dev[2].p2p_interface_addr())
50 def test_peerkey_pairwise_mismatch(dev, apdev):
51 """RSN TKIP+CCMP AP and PeerKey between two STAs using different ciphers"""
52 skip_with_fips(dev[0])
54 passphrase = "12345678"
55 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
56 params['peerkey'] = "1"
57 params['rsn_pairwise'] = "TKIP CCMP"
58 hapd = hostapd.add_ap(apdev[0], params)
63 wt.add_passphrase("12345678")
65 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True,
67 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True,
69 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
71 dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
73 dev[1].request("STKSTART " + dev[0].p2p_interface_addr())