]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_peerkey.py
tests: Mark 525 tests as remote compatible
[thirdparty/hostap.git] / tests / hwsim / test_peerkey.py
1 # PeerKey tests
2 # Copyright (c) 2013-2015, 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
7 from remotehost import remote_compatible
8 import logging
9 logger = logging.getLogger()
10 import time
11
12 import hwsim_utils
13 import hostapd
14 from utils import skip_with_fips
15 from wlantest import Wlantest
16
17 @remote_compatible
18 def test_peerkey(dev, apdev):
19 """RSN AP and PeerKey between two STAs"""
20 ssid = "test-peerkey"
21 passphrase = "12345678"
22 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
23 params['peerkey'] = "1"
24 hostapd.add_ap(apdev[0], params)
25
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])
29
30 dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
31 time.sleep(0.5)
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.
36
37 def test_peerkey_unknown_peer(dev, apdev):
38 """RSN AP and PeerKey attempt with unknown peer"""
39 ssid = "test-peerkey"
40 passphrase = "12345678"
41 params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
42 params['peerkey'] = "1"
43 hostapd.add_ap(apdev[0], params)
44
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])
48
49 dev[0].request("STKSTART " + dev[2].p2p_interface_addr())
50 time.sleep(0.5)
51
52 @remote_compatible
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])
56 ssid = "test-peerkey"
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)
62
63 Wlantest.setup(hapd)
64 wt = Wlantest()
65 wt.flush()
66 wt.add_passphrase("12345678")
67
68 dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True,
69 pairwise="CCMP")
70 dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True,
71 pairwise="TKIP")
72 hwsim_utils.test_connectivity_sta(dev[0], dev[1])
73
74 dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
75 time.sleep(0.5)
76 dev[1].request("STKSTART " + dev[0].p2p_interface_addr())
77 time.sleep(0.5)