]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Verify PeerKey handshake
authorJouni Malinen <j@w1.fi>
Sat, 28 Dec 2013 09:43:42 +0000 (11:43 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 28 Dec 2013 14:32:54 +0000 (16:32 +0200)
NOTE: Actual use of the direct link (DLS) is not supported in
mac80211_hwsim, so this operation fails at setting the keys after
successfully completed 4-way handshake. This test case does allow the
key negotiation part to be tested for coverage, though.

Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/test_peerkey.py [new file with mode: 0644]
tests/hwsim/wpasupplicant.py

diff --git a/tests/hwsim/test_peerkey.py b/tests/hwsim/test_peerkey.py
new file mode 100644 (file)
index 0000000..f4da06a
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+#
+# PeerKey tests
+# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import logging
+logger = logging.getLogger()
+import time
+
+import hwsim_utils
+import hostapd
+
+def test_peerkey(dev, apdev):
+    """RSN AP and PeerKey between two STAs"""
+    ssid = "test-peerkey"
+    passphrase = "12345678"
+    params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
+    params['peerkey'] = "1"
+    hostapd.add_ap(apdev[0]['ifname'], params)
+
+    dev[0].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
+    dev[1].connect(ssid, psk=passphrase, scan_freq="2412", peerkey=True)
+    hwsim_utils.test_connectivity_sta(dev[0], dev[1])
+
+    dev[0].request("STKSTART " + dev[1].p2p_interface_addr())
+    time.sleep(0.5)
+    # NOTE: Actual use of the direct link (DLS) is not supported in
+    # mac80211_hwsim, so this operation fails at setting the keys after
+    # successfully completed 4-way handshake. This test case does allow the
+    # key negotiation part to be tested for coverage, though.
index 9844ae6d614901810e84f8d7ca8d3aa52eec0a14..977eeb2378113960beb5a4da8815f27769d907d2 100644 (file)
@@ -532,7 +532,7 @@ class WpaSupplicant:
                 eap=None, identity=None, anonymous_identity=None,
                 password=None, phase1=None, phase2=None, ca_cert=None,
                 domain_suffix_match=None, password_hex=None,
-                client_cert=None, private_key=None,
+                client_cert=None, private_key=None, peerkey=False,
                 wait_connect=True):
         logger.info("Connect STA " + self.ifname + " to AP")
         id = self.add_network()
@@ -577,6 +577,8 @@ class WpaSupplicant:
         if domain_suffix_match:
             self.set_network_quoted(id, "domain_suffix_match",
                                     domain_suffix_match)
+        if peerkey:
+            self.set_network(id, "peerkey", "1")
         if wait_connect:
             self.connect_network(id)
         else: