[PATCH 6/6] tests: Add PASN authentication with random own mac address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Test case to check PASN authentication with random own mac address if
underlying driver/hardware supports it, otherwise skip the test case.

Signed-off-by: Vinay Gannevaram <quic_vganneva@xxxxxxxxxxx>
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@xxxxxxxxxxx>
---
 tests/hwsim/test_pasn.py | 45 +++++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/tests/hwsim/test_pasn.py b/tests/hwsim/test_pasn.py
index 6f7a806f5..826609c27 100644
--- a/tests/hwsim/test_pasn.py
+++ b/tests/hwsim/test_pasn.py
@@ -27,6 +27,11 @@ def check_pasn_capab(dev):
     if "PASN" not in dev.get_capability("auth_alg"):
         raise HwsimSkip("PASN not supported")
 
+def check_pasn_random_ta_capab(dev):
+    res = dev.get_capability("auth_rand_mac")
+    if res is None or 'RANDOM-TA' not in res:
+        raise HwsimSkip("PASN random TA not supported")
+
 def pasn_ap_params(akmp="PASN", cipher="CCMP", group="19"):
     params = {"ssid": "test-wpa2-pasn",
               "wpa_passphrase": "12345678",
@@ -47,9 +52,13 @@ def start_pasn_ap(apdev, params):
             raise HwsimSkip("PASN not supported")
         raise
 
-def check_pasn_ptk(dev, hapd, cipher, fail_ptk=False, clear_keys=True):
+def check_pasn_ptk(dev, hapd, cipher, fail_ptk=False, clear_keys=True,
+                   own_addr=None):
     sta_ptksa = dev.get_ptksa(hapd.own_addr(), cipher)
-    ap_ptksa = hapd.get_ptksa(dev.own_addr(), cipher)
+    if own_addr is None:
+        ap_ptksa = hapd.get_ptksa(dev.own_addr(), cipher)
+    else:
+        ap_ptksa = hapd.get_ptksa(own_addr, cipher)
 
     if not (sta_ptksa and ap_ptksa):
         if fail_ptk:
@@ -64,24 +73,33 @@ def check_pasn_ptk(dev, hapd, cipher, fail_ptk=False, clear_keys=True):
     elif fail_ptk:
         raise Exception("TK/KDK match although key derivation should have failed")
     elif clear_keys:
-        cmd = "PASN_DEAUTH bssid=%s" % hapd.own_addr()
+        if own_addr is None:
+            cmd = "PASN_DEAUTH bssid=%s" % hapd.own_addr()
+        else:
+            cmd = "PASN_DEAUTH bssid=%s own_addr=%s" % (hapd.own_addr(), own_addr)
         dev.request(cmd)
 
         # Wait a little to let the AP process the deauth
         time.sleep(0.2)
 
         sta_ptksa = dev.get_ptksa(hapd.own_addr(), cipher)
-        ap_ptksa = hapd.get_ptksa(dev.own_addr(), cipher)
+        if own_addr is None:
+            ap_ptksa = hapd.get_ptksa(dev.own_addr(), cipher)
+        else:
+            ap_ptksa = hapd.get_ptksa(own_addr, cipher)
         if sta_ptksa or ap_ptksa:
             raise Exception("TK/KDK not deleted as expected")
 
 def check_pasn_akmp_cipher(dev, hapd, akmp="PASN", cipher="CCMP",
                            group="19", status=0, fail=0, nid="",
-                           fail_ptk=False):
+                           fail_ptk=False, own_addr=None):
     dev.flush_scan_cache()
     dev.scan(type="ONLY", freq=2412)
 
-    cmd = "PASN_START bssid=%s akmp=%s cipher=%s group=%s" % (hapd.own_addr(), akmp, cipher, group)
+    if own_addr is None:
+        cmd = "PASN_START bssid=%s akmp=%s cipher=%s group=%s" % (hapd.own_addr(), akmp, cipher, group)
+    else:
+        cmd = "PASN_START bssid=%s own_addr=%s akmp=%s cipher=%s group=%s" % (hapd.own_addr(), own_addr, akmp, cipher, group)
 
     if nid != "":
         cmd += " nid=%s" % nid
@@ -106,7 +124,10 @@ def check_pasn_akmp_cipher(dev, hapd, akmp="PASN", cipher="CCMP",
     if status:
         return
 
-    check_pasn_ptk(dev, hapd, cipher, fail_ptk)
+    if own_addr is None:
+        check_pasn_ptk(dev, hapd, cipher, fail_ptk)
+    else:
+        check_pasn_ptk(dev, hapd, cipher, fail_ptk, own_addr=own_addr)
 
 @remote_compatible
 def test_pasn_ccmp(dev, apdev):
@@ -852,3 +873,13 @@ def test_pasn_kdk_derivation(dev, apdev):
         check_pasn_akmp_cipher(dev[0], hapd1, "PASN", "CCMP")
     finally:
         dev[0].set("force_kdk_derivation", "0")
+
+def test_pasn_random_mac(dev, apdev):
+    """PASN authentication with random mac address"""
+    check_pasn_capab(dev[0])
+    check_pasn_random_ta_capab(dev[0])
+
+    params = pasn_ap_params("PASN", "CCMP", "19")
+    hapd = start_pasn_ap(apdev[0], params)
+
+    check_pasn_akmp_cipher(dev[0], hapd, "PASN", "CCMP", own_addr="aa:cd:ef:ab:cd:ef")
-- 
2.25.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux