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.
7 from remotehost import remote_compatible
9 logger = logging.getLogger()
14 from utils import skip_with_fips
15 from wlantest import Wlantest
18 def test_peerkey(dev, apdev):
19 """RSN AP and PeerKey between two STAs"""
21 passphrase = "12345678"
22 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
23 params['peerkey'] = "1"
24 hostapd.add_ap(apdev[0], params)
26 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
27 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
28 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
30 dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
32 # NOTE: Actual use of the direct link (DLS) is not supported in
33 # mac80211_hwsim, so this operation fails at setting the keys after
34 # successfully completed 4-way handshake. This test case does allow the
35 # key negotiation part to be tested for coverage, though.
37 def test_peerkey_unknown_peer(dev, apdev):
38 """RSN AP and PeerKey attempt with unknown peer"""
40 passphrase = "12345678"
41 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
42 params['peerkey'] = "1"
43 hostapd.add_ap(apdev[0], params)
45 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
46 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
47 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
49 dev[0].request("STKSTART " + dev[2].p2p_interface_addr())
53 def test_peerkey_pairwise_mismatch(dev, apdev):
54 """RSN TKIP+CCMP AP and PeerKey between two STAs using different ciphers"""
55 skip_with_fips(dev[0])
57 passphrase = "12345678"
58 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
59 params['peerkey'] = "1"
60 params['rsn_pairwise'] = "TKIP CCMP"
61 hapd = hostapd.add_ap(apdev[0], params)
66 wt.add_passphrase("12345678")
68 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True,
70 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True,
72 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
74 dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
76 dev[1].request("STKSTART " + dev[0].p2p_interface_addr())