[PATCH v3 3/3] tests: DPP Enterprise certBag with lost or held GAS comeback frames

Gustavo Bertoli gubertoli at gmail.com
Sun Nov 15 12:47:29 PST 2026


hwsim does not lose frames, so inject the faults during the CA delay.
dpp_enterprise_gas_lost_wait_ack reports the ACK of a comeback delay
response as lost; the Configurator must keep the exchange.
dpp_enterprise_gas_missed_comeback drops one Comeback Request and
dpp_enterprise_gas_held_comeback delays one by 2.5 s; the Enrollee must
keep its dialog token.

Signed-off-by: Gustavo Bertoli <gubertoli at gmail.com>
---
 src/common/dpp.h                |  1 +
 tests/hwsim/test_dpp.py         | 74 +++++++++++++++++++++++++++++++--
 wpa_supplicant/wpa_supplicant.c | 12 ++++++
 3 files changed, 83 insertions(+), 4 deletions(-)

diff --git a/src/common/dpp.h b/src/common/dpp.h
index 6aef72165..6ac0c4860 100644
--- a/src/common/dpp.h
+++ b/src/common/dpp.h
@@ -568,6 +568,7 @@ enum dpp_test_behavior {
 	DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_PB_REQ = 98,
 	DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_PB_RESP = 99,
 	DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_PB_RESP = 100,
+	DPP_TEST_GAS_COMEBACK_WAIT_NO_ACK = 101,
 };
 
 extern enum dpp_test_behavior dpp_test;
diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py
index 1b661748d..3b7dc17a2 100644
--- a/tests/hwsim/test_dpp.py
+++ b/tests/hwsim/test_dpp.py
@@ -7448,15 +7448,19 @@ def test_dpp_enterprise_5000ms(dev, apdev, params):
     """DPP and enterprise EAP-TLS provisioning (5000 ms CA delay)"""
     dpp_enterprise(dev, apdev, params, 5)
 
-def dpp_enterprise(dev, apdev, params, ca_delay):
+def dpp_enterprise(dev, apdev, params, ca_delay, dpp_test=0, ca_wait=None):
     check_dpp_capab(dev[0], min_ver=2)
     try:
         dev[0].set("dpp_config_processing", "2")
-        run_dpp_enterprise(dev, apdev, params, ca_delay=ca_delay)
+        if dpp_test:
+            dev[1].set("dpp_test", str(dpp_test))
+        run_dpp_enterprise(dev, apdev, params, ca_delay=ca_delay,
+                           ca_wait=ca_wait)
     finally:
         dev[0].set("dpp_config_processing", "0", allow_fail=True)
+        dev[1].set("dpp_test", "0", allow_fail=True)
 
-def run_dpp_enterprise(dev, apdev, params, ca_delay=0):
+def run_dpp_enterprise(dev, apdev, params, ca_delay=0, ca_wait=None):
     if not cryptography_imported:
         raise HwsimSkip("cryptography python module not available")
     check_dpp_capab(dev[0])
@@ -7504,7 +7508,9 @@ def run_dpp_enterprise(dev, apdev, params, ca_delay=0):
     csr = base64.b64decode(csr.encode())
     logger.info("CSR: " + binascii.hexlify(csr).decode())
 
-    if ca_delay:
+    if ca_wait:
+        ca_wait(dev[1])
+    elif ca_delay:
         logger.info("Wait for %d s before signing" % ca_delay)
         time.sleep(ca_delay)
 
@@ -7604,6 +7610,66 @@ def test_dpp_enterprise_reject(dev, apdev, params):
     if "DPP-CONF-FAILED" not in ev:
         raise Exception("DPP configuration did not fail (Enrollee)")
 
+def dpp_gas_relay_process(dev, msg):
+    cmd = "MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(
+        msg['freq'], msg['datarate'], msg['ssi_signal'],
+        binascii.hexlify(msg['frame']).decode())
+    if "OK" not in dev.request(cmd):
+        raise Exception("MGMT_RX_PROCESS failed")
+
+def dpp_gas_relay(dev, hold=None, duration=4):
+    # Pass on the Configurator's received frames during the CA delay, but
+    # drop the second GAS Comeback Request, or hold it for hold seconds. The
+    # Enrollee must keep its dialog token.
+    dev.set("ext_mgmt_frame_handling", "1")
+    count = 0
+    try:
+        end = time.time() + duration
+        while True:
+            ev = dev.wait_event(["MGMT-RX"], timeout=0.1)
+            if ev is None:
+                # Stop only when no frame is pending
+                if time.time() >= end:
+                    break
+                continue
+            msg = dev.mgmt_rx_parse(ev)
+            categ, action = struct.unpack('BB', msg['payload'][0:2])
+            if count >= 2 and categ == 4 and action == 10:
+                raise Exception("GAS query restarted with a new dialog token")
+            if categ == 4 and action == 12:
+                count += 1
+                if count == 2:
+                    if hold is None:
+                        continue
+                    time.sleep(hold)
+            dpp_gas_relay_process(dev, msg)
+    finally:
+        dev.set("ext_mgmt_frame_handling", "0")
+    if count < 2:
+        raise Exception("No GAS Comeback Request to drop or hold")
+
+def test_dpp_enterprise_gas_lost_wait_ack(dev, apdev, params):
+    """DPP and enterprise EAP-TLS provisioning with a GAS comeback ACK lost"""
+    # DPP_TEST_GAS_COMEBACK_WAIT_NO_ACK
+    dpp_enterprise(dev, apdev, params, 1, dpp_test=101)
+    with open(os.path.join(params['logdir'], 'log1'), 'r') as f:
+        log = f.read()
+    if "TESTING - comeback delay response not ACKed" not in log:
+        raise Exception("Comeback delay response ACK was not dropped")
+    if "No pending GAS response" in log:
+        raise Exception("Configurator dropped the GAS exchange")
+
+def test_dpp_enterprise_gas_missed_comeback(dev, apdev, params):
+    """DPP and enterprise EAP-TLS provisioning with a GAS comeback missed"""
+    # The request is sent again 5 s after the dropped one
+    dpp_enterprise(dev, apdev, params, 0,
+                   ca_wait=lambda dev: dpp_gas_relay(dev, duration=6))
+
+def test_dpp_enterprise_gas_held_comeback(dev, apdev, params):
+    """DPP and enterprise EAP-TLS provisioning with a GAS comeback held"""
+    dpp_enterprise(dev, apdev, params, 0,
+                   ca_wait=lambda dev: dpp_gas_relay(dev, hold=2.5))
+
 def test_dpp_enterprise_tcp(dev, apdev, params):
     """DPP over TCP for enterprise provisioning"""
     if not cryptography_imported:
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 4c73b4971..92bfca1e9 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -8741,6 +8741,18 @@ static void wpas_gas_server_tx_status(struct wpa_supplicant *wpa_s,
 		   result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" :
 		   (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" :
 		    "FAILED"));
+#ifdef CONFIG_TESTING_OPTIONS
+	/* Report one comeback delay response as not ACKed */
+	if (dpp_test == DPP_TEST_GAS_COMEBACK_WAIT_NO_ACK &&
+	    data_len >= 24 + 8 && data[24] == WLAN_ACTION_PUBLIC &&
+	    data[25] == WLAN_PA_GAS_COMEBACK_RESP &&
+	    WPA_GET_LE16(&data[24 + 6])) {
+		dpp_test = DPP_TEST_DISABLED;
+		wpa_printf(MSG_INFO,
+			   "GAS: TESTING - comeback delay response not ACKed");
+		result = OFFCHANNEL_SEND_ACTION_NO_ACK;
+	}
+#endif /* CONFIG_TESTING_OPTIONS */
 	gas_server_tx_status(wpa_s->gas_server, dst, data, data_len,
 			     result == OFFCHANNEL_SEND_ACTION_SUCCESS);
 }
-- 
2.43.0




More information about the Hostap mailing list