]>
Commit | Line | Data |
---|---|---|
4a5a5792 JM |
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 | ||
7 | import logging | |
8 | logger = logging.getLogger() | |
9 | import time | |
10 | ||
11 | import hwsim_utils | |
12 | import hostapd | |
7b7328e3 | 13 | from wlantest import Wlantest |
4a5a5792 JM |
14 | |
15 | def test_peerkey(dev, apdev): | |
16 | """RSN AP and PeerKey between two STAs""" | |
17 | ssid = "test-peerkey" | |
18 | passphrase = "12345678" | |
19 | params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) | |
20 | params['peerkey'] = "1" | |
21 | hostapd.add_ap(apdev[0]['ifname'], params) | |
22 | ||
23 | dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) | |
24 | dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) | |
25 | hwsim_utils.test_connectivity_sta(dev[0], dev[1]) | |
26 | ||
27 | dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) | |
28 | time.sleep(0.5) | |
29 | # NOTE: Actual use of the direct link (DLS) is not supported in | |
30 | # mac80211_hwsim, so this operation fails at setting the keys after | |
31 | # successfully completed 4-way handshake. This test case does allow the | |
32 | # key negotiation part to be tested for coverage, though. | |
06eaa233 JM |
33 | |
34 | def test_peerkey_unknown_peer(dev, apdev): | |
35 | """RSN AP and PeerKey attempt with unknown peer""" | |
36 | ssid = "test-peerkey" | |
37 | passphrase = "12345678" | |
38 | params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) | |
39 | params['peerkey'] = "1" | |
40 | hostapd.add_ap(apdev[0]['ifname'], params) | |
41 | ||
42 | dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) | |
43 | dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True) | |
44 | hwsim_utils.test_connectivity_sta(dev[0], dev[1]) | |
45 | ||
46 | dev[0].request("STKSTART " + dev[2].p2p_interface_addr()) | |
47 | time.sleep(0.5) | |
7b7328e3 JM |
48 | |
49 | def test_peerkey_pairwise_mismatch(dev, apdev): | |
50 | """RSN TKIP+CCMP AP and PeerKey between two STAs using different ciphers""" | |
51 | wt = Wlantest() | |
52 | wt.flush() | |
53 | wt.add_passphrase("12345678") | |
54 | ssid = "test-peerkey" | |
55 | passphrase = "12345678" | |
56 | params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) | |
57 | params['peerkey'] = "1" | |
58 | params['rsn_pairwise'] = "TKIP CCMP" | |
59 | hostapd.add_ap(apdev[0]['ifname'], params) | |
60 | ||
61 | dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True, | |
62 | pairwise="CCMP") | |
63 | dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True, | |
64 | pairwise="TKIP") | |
65 | hwsim_utils.test_connectivity_sta(dev[0], dev[1]) | |
66 | ||
67 | dev[0].request("STKSTART " + dev[1].p2p_interface_addr()) | |
68 | time.sleep(0.5) | |
69 | dev[1].request("STKSTART " + dev[0].p2p_interface_addr()) | |
70 | time.sleep(0.5) |