1 # Test cases for sigma_dut
2 # Copyright (c) 2017, Qualcomm Atheros, Inc.
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger
= logging
.getLogger()
16 from utils
import HwsimSkip
17 from hwsim
import HWSimRadio
18 from test_dpp
import check_dpp_capab
, update_hapd_config
19 from test_suite_b
import check_suite_b_192_capa
, suite_b_as_params
, suite_b_192_rsa_ap_params
21 def check_sigma_dut():
22 if not os
.path
.exists("./sigma_dut"):
23 raise HwsimSkip("sigma_dut not available")
25 def sigma_dut_cmd(cmd
, port
=9000, timeout
=2):
26 sock
= socket
.socket(socket
.AF_INET
, socket
.SOCK_STREAM
,
28 sock
.settimeout(timeout
)
29 addr
= ('127.0.0.1', port
)
31 sock
.send(cmd
+ "\r\n")
36 for line
in res
.splitlines():
37 if line
.startswith("status,RUNNING"):
39 elif line
.startswith("status,INVALID"):
41 elif line
.startswith("status,ERROR"):
43 elif line
.startswith("status,COMPLETE"):
45 if running
and not done
:
46 # Read the actual response
53 logger
.debug("sigma_dut: '%s' --> '%s'" % (cmd
, res
))
56 def sigma_dut_cmd_check(cmd
, port
=9000, timeout
=2):
57 res
= sigma_dut_cmd(cmd
, port
=port
, timeout
=timeout
)
58 if "COMPLETE" not in res
:
59 raise Exception("sigma_dut command failed: " + cmd
)
62 def start_sigma_dut(ifname
, debug
=False, hostapd_logdir
=None, cert_path
=None):
64 cmd
= [ './sigma_dut',
67 '-F', '../../hostapd/hostapd',
69 '-w', '/var/run/wpa_supplicant/',
74 cmd
+= [ '-H', hostapd_logdir
]
76 cmd
+= [ '-C', cert_path
]
77 sigma
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
,
78 stderr
=subprocess
.PIPE
)
81 res
= sigma_dut_cmd("HELLO")
87 def stop_sigma_dut(sigma
):
90 out
, err
= sigma
.communicate()
91 logger
.debug("sigma_dut stdout: " + str(out
))
92 logger
.debug("sigma_dut stderr: " + str(err
))
94 def sigma_dut_wait_connected(ifname
):
96 res
= sigma_dut_cmd("sta_is_connected,interface," + ifname
)
97 if "connected,1" in res
:
101 raise Exception("Connection did not complete")
103 def test_sigma_dut_basic(dev
, apdev
):
104 """sigma_dut basic functionality"""
105 sigma
= start_sigma_dut(dev
[0].ifname
)
107 res
= sigma_dut_cmd("UNKNOWN")
108 if "status,INVALID,errorCode,Unknown command" not in res
:
109 raise Exception("Unexpected sigma_dut response to unknown command")
111 tests
= [ ("ca_get_version", "status,COMPLETE,version,1.0"),
112 ("device_get_info", "status,COMPLETE,vendor"),
113 ("device_list_interfaces,interfaceType,foo", "status,ERROR"),
114 ("device_list_interfaces,interfaceType,802.11",
115 "status,COMPLETE,interfaceType,802.11,interfaceID," + dev
[0].ifname
) ]
116 for cmd
, response
in tests
:
117 res
= sigma_dut_cmd(cmd
)
118 if response
not in res
:
119 raise Exception("Unexpected %s response: %s" % (cmd
, res
))
121 stop_sigma_dut(sigma
)
123 def test_sigma_dut_open(dev
, apdev
):
124 """sigma_dut controlled open network association"""
126 run_sigma_dut_open(dev
, apdev
)
128 dev
[0].set("ignore_old_scan_res", "0")
130 def run_sigma_dut_open(dev
, apdev
):
131 ifname
= dev
[0].ifname
132 sigma
= start_sigma_dut(ifname
)
134 hapd
= hostapd
.add_ap(apdev
[0], { "ssid": "open" })
136 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
137 sigma_dut_cmd_check("sta_set_encryption,interface,%s,ssid,%s,encpType,none" % (ifname
, "open"))
138 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s" % (ifname
, "open"))
139 sigma_dut_wait_connected(ifname
)
140 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
141 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
142 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
144 stop_sigma_dut(sigma
)
146 def test_sigma_dut_psk_pmf(dev
, apdev
):
147 """sigma_dut controlled PSK+PMF association"""
149 run_sigma_dut_psk_pmf(dev
, apdev
)
151 dev
[0].set("ignore_old_scan_res", "0")
153 def run_sigma_dut_psk_pmf(dev
, apdev
):
154 ifname
= dev
[0].ifname
155 sigma
= start_sigma_dut(ifname
)
157 ssid
= "test-pmf-required"
158 params
= hostapd
.wpa2_params(ssid
=ssid
, passphrase
="12345678")
159 params
["wpa_key_mgmt"] = "WPA-PSK-SHA256"
160 params
["ieee80211w"] = "2"
161 hapd
= hostapd
.add_ap(apdev
[0], params
)
163 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname
)
164 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
165 sigma_dut_cmd_check("sta_set_psk,interface,%s,ssid,%s,passphrase,%s,encpType,aes-ccmp,keymgmttype,wpa2,PMF,Required" % (ifname
, "test-pmf-required", "12345678"))
166 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-pmf-required"))
167 sigma_dut_wait_connected(ifname
)
168 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
169 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
170 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
172 stop_sigma_dut(sigma
)
174 def test_sigma_dut_psk_pmf_bip_cmac_128(dev
, apdev
):
175 """sigma_dut controlled PSK+PMF association with BIP-CMAC-128"""
177 run_sigma_dut_psk_pmf_cipher(dev
, apdev
, "BIP-CMAC-128", "AES-128-CMAC")
179 dev
[0].set("ignore_old_scan_res", "0")
181 def test_sigma_dut_psk_pmf_bip_cmac_256(dev
, apdev
):
182 """sigma_dut controlled PSK+PMF association with BIP-CMAC-256"""
184 run_sigma_dut_psk_pmf_cipher(dev
, apdev
, "BIP-CMAC-256", "BIP-CMAC-256")
186 dev
[0].set("ignore_old_scan_res", "0")
188 def test_sigma_dut_psk_pmf_bip_gmac_128(dev
, apdev
):
189 """sigma_dut controlled PSK+PMF association with BIP-GMAC-128"""
191 run_sigma_dut_psk_pmf_cipher(dev
, apdev
, "BIP-GMAC-128", "BIP-GMAC-128")
193 dev
[0].set("ignore_old_scan_res", "0")
195 def test_sigma_dut_psk_pmf_bip_gmac_256(dev
, apdev
):
196 """sigma_dut controlled PSK+PMF association with BIP-GMAC-256"""
198 run_sigma_dut_psk_pmf_cipher(dev
, apdev
, "BIP-GMAC-256", "BIP-GMAC-256")
200 dev
[0].set("ignore_old_scan_res", "0")
202 def test_sigma_dut_psk_pmf_bip_gmac_256_mismatch(dev
, apdev
):
203 """sigma_dut controlled PSK+PMF association with BIP-GMAC-256 mismatch"""
205 run_sigma_dut_psk_pmf_cipher(dev
, apdev
, "BIP-GMAC-256", "AES-128-CMAC",
208 dev
[0].set("ignore_old_scan_res", "0")
210 def run_sigma_dut_psk_pmf_cipher(dev
, apdev
, sigma_cipher
, hostapd_cipher
,
212 ifname
= dev
[0].ifname
213 sigma
= start_sigma_dut(ifname
)
215 ssid
= "test-pmf-required"
216 params
= hostapd
.wpa2_params(ssid
=ssid
, passphrase
="12345678")
217 params
["wpa_key_mgmt"] = "WPA-PSK-SHA256"
218 params
["ieee80211w"] = "2"
219 params
["group_mgmt_cipher"] = hostapd_cipher
220 hapd
= hostapd
.add_ap(apdev
[0], params
)
222 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname
)
223 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
224 sigma_dut_cmd_check("sta_set_psk,interface,%s,ssid,%s,passphrase,%s,encpType,aes-ccmp,keymgmttype,wpa2,PMF,Required,GroupMgntCipher,%s" % (ifname
, "test-pmf-required", "12345678", sigma_cipher
))
225 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-pmf-required"))
227 ev
= dev
[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND",
228 "CTRL-EVENT-CONNECTED"], timeout
=10)
230 raise Exception("Network selection result not indicated")
231 if "CTRL-EVENT-CONNECTED" in ev
:
232 raise Exception("Unexpected connection")
233 res
= sigma_dut_cmd("sta_is_connected,interface," + ifname
)
234 if "connected,1" in res
:
235 raise Exception("Connection reported")
237 sigma_dut_wait_connected(ifname
)
238 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
240 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
241 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
243 stop_sigma_dut(sigma
)
245 def test_sigma_dut_sae(dev
, apdev
):
246 """sigma_dut controlled SAE association"""
247 if "SAE" not in dev
[0].get_capability("auth_alg"):
248 raise HwsimSkip("SAE not supported")
250 ifname
= dev
[0].ifname
251 sigma
= start_sigma_dut(ifname
)
254 params
= hostapd
.wpa2_params(ssid
=ssid
, passphrase
="12345678")
255 params
['wpa_key_mgmt'] = 'SAE'
256 hapd
= hostapd
.add_ap(apdev
[0], params
)
258 sigma_dut_cmd_check("sta_reset_default,interface,%s" % ifname
)
259 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
260 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,passphrase,%s,type,SAE,encpType,aes-ccmp,keymgmttype,wpa2" % (ifname
, "test-sae", "12345678"))
261 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-sae"))
262 sigma_dut_wait_connected(ifname
)
263 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
264 if dev
[0].get_status_field('sae_group') != '19':
265 raise Exception("Expected default SAE group not used")
266 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
268 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
270 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
271 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,passphrase,%s,type,SAE,encpType,aes-ccmp,keymgmttype,wpa2,ECGroupID,20" % (ifname
, "test-sae", "12345678"))
272 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-sae"))
273 sigma_dut_wait_connected(ifname
)
274 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
275 if dev
[0].get_status_field('sae_group') != '20':
276 raise Exception("Expected SAE group not used")
277 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
278 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
280 stop_sigma_dut(sigma
)
282 def test_sigma_dut_sae_password(dev
, apdev
):
283 """sigma_dut controlled SAE association and long password"""
284 if "SAE" not in dev
[0].get_capability("auth_alg"):
285 raise HwsimSkip("SAE not supported")
287 ifname
= dev
[0].ifname
288 sigma
= start_sigma_dut(ifname
)
292 params
= hostapd
.wpa2_params(ssid
=ssid
)
293 params
['sae_password'] = 100*'B'
294 params
['wpa_key_mgmt'] = 'SAE'
295 hapd
= hostapd
.add_ap(apdev
[0], params
)
297 sigma_dut_cmd_check("sta_reset_default,interface,%s" % ifname
)
298 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
299 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,passphrase,%s,type,SAE,encpType,aes-ccmp,keymgmttype,wpa2" % (ifname
, "test-sae", 100*'B'))
300 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-sae"))
301 sigma_dut_wait_connected(ifname
)
302 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
303 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
304 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
306 stop_sigma_dut(sigma
)
308 def test_sigma_dut_sta_override_rsne(dev
, apdev
):
309 """sigma_dut and RSNE override on STA"""
311 run_sigma_dut_sta_override_rsne(dev
, apdev
)
313 dev
[0].set("ignore_old_scan_res", "0")
315 def run_sigma_dut_sta_override_rsne(dev
, apdev
):
316 ifname
= dev
[0].ifname
317 sigma
= start_sigma_dut(ifname
)
320 params
= hostapd
.wpa2_params(ssid
=ssid
, passphrase
="12345678")
321 hapd
= hostapd
.add_ap(apdev
[0], params
)
323 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
325 tests
= [ "30120100000fac040100000fac040100000fac02",
326 "30140100000fac040100000fac040100000fac02ffff" ]
328 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,type,PSK,passphrase,%s,EncpType,aes-ccmp,KeyMgmtType,wpa2" % (ifname
, "test-psk", "12345678"))
329 sigma_dut_cmd_check("dev_configure_ie,interface,%s,IE_Name,RSNE,Contents,%s" % (ifname
, test
))
330 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-psk"))
331 sigma_dut_wait_connected(ifname
)
332 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
333 dev
[0].dump_monitor()
335 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,type,PSK,passphrase,%s,EncpType,aes-ccmp,KeyMgmtType,wpa2" % (ifname
, "test-psk", "12345678"))
336 sigma_dut_cmd_check("dev_configure_ie,interface,%s,IE_Name,RSNE,Contents,300101" % ifname
)
337 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-psk"))
339 ev
= dev
[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
341 raise Exception("Association rejection not reported")
342 if "status_code=40" not in ev
:
343 raise Exception("Unexpected status code: " + ev
)
345 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
347 stop_sigma_dut(sigma
)
349 def test_sigma_dut_ap_psk(dev
, apdev
):
350 """sigma_dut controlled AP"""
351 with
HWSimRadio() as (radio
, iface
):
352 sigma
= start_sigma_dut(iface
)
354 sigma_dut_cmd_check("ap_reset_default")
355 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng")
356 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK,PSK,12345678")
357 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
359 dev
[0].connect("test-psk", psk
="12345678", scan_freq
="2412")
361 sigma_dut_cmd_check("ap_reset_default")
363 stop_sigma_dut(sigma
)
365 def test_sigma_dut_ap_pskhex(dev
, apdev
, params
):
366 """sigma_dut controlled AP and PSKHEX"""
367 logdir
= os
.path
.join(params
['logdir'],
368 "sigma_dut_ap_pskhex.sigma-hostapd")
369 with
HWSimRadio() as (radio
, iface
):
370 sigma
= start_sigma_dut(iface
, hostapd_logdir
=logdir
)
372 psk
= "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
373 sigma_dut_cmd_check("ap_reset_default")
374 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng")
375 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK,PSKHEX," + psk
)
376 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
378 dev
[0].connect("test-psk", raw_psk
=psk
, scan_freq
="2412")
380 sigma_dut_cmd_check("ap_reset_default")
382 stop_sigma_dut(sigma
)
384 def test_sigma_dut_suite_b(dev
, apdev
, params
):
385 """sigma_dut controlled STA Suite B"""
386 check_suite_b_192_capa(dev
)
387 logdir
= params
['logdir']
389 with
open("auth_serv/ec2-ca.pem", "r") as f
:
390 with
open(os
.path
.join(logdir
, "suite_b_ca.pem"), "w") as f2
:
393 with
open("auth_serv/ec2-user.pem", "r") as f
:
394 with
open("auth_serv/ec2-user.key", "r") as f2
:
395 with
open(os
.path
.join(logdir
, "suite_b.pem"), "w") as f3
:
399 dev
[0].flush_scan_cache()
400 params
= suite_b_as_params()
401 params
['ca_cert'] = 'auth_serv/ec2-ca.pem'
402 params
['server_cert'] = 'auth_serv/ec2-server.pem'
403 params
['private_key'] = 'auth_serv/ec2-server.key'
404 params
['openssl_ciphers'] = 'SUITEB192'
405 hostapd
.add_ap(apdev
[1], params
)
407 params
= { "ssid": "test-suite-b",
409 "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
410 "rsn_pairwise": "GCMP-256",
411 "group_mgmt_cipher": "BIP-GMAC-256",
414 'auth_server_addr': "127.0.0.1",
415 'auth_server_port': "18129",
416 'auth_server_shared_secret': "radius",
417 'nas_identifier': "nas.w1.fi" }
418 hapd
= hostapd
.add_ap(apdev
[0], params
)
420 ifname
= dev
[0].ifname
421 sigma
= start_sigma_dut(ifname
, cert_path
=logdir
)
423 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname
)
424 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
425 sigma_dut_cmd_check("sta_set_security,type,eaptls,interface,%s,ssid,%s,PairwiseCipher,AES-GCMP-256,GroupCipher,AES-GCMP-256,GroupMgntCipher,BIP-GMAC-256,keymgmttype,SuiteB,PMF,Required,clientCertificate,suite_b.pem,trustedRootCA,suite_b_ca.pem,CertType,ECC" % (ifname
, "test-suite-b"))
426 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-suite-b"))
427 sigma_dut_wait_connected(ifname
)
428 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
429 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
430 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
432 stop_sigma_dut(sigma
)
434 def test_sigma_dut_suite_b_rsa(dev
, apdev
, params
):
435 """sigma_dut controlled STA Suite B (RSA)"""
436 check_suite_b_192_capa(dev
)
437 logdir
= params
['logdir']
439 with
open("auth_serv/rsa3072-ca.pem", "r") as f
:
440 with
open(os
.path
.join(logdir
, "suite_b_ca_rsa.pem"), "w") as f2
:
443 with
open("auth_serv/rsa3072-user.pem", "r") as f
:
444 with
open("auth_serv/rsa3072-user.key", "r") as f2
:
445 with
open(os
.path
.join(logdir
, "suite_b_rsa.pem"), "w") as f3
:
449 dev
[0].flush_scan_cache()
450 params
= suite_b_192_rsa_ap_params()
451 hapd
= hostapd
.add_ap(apdev
[0], params
)
453 ifname
= dev
[0].ifname
454 sigma
= start_sigma_dut(ifname
, cert_path
=logdir
)
456 cmd
= "sta_set_security,type,eaptls,interface,%s,ssid,%s,PairwiseCipher,AES-GCMP-256,GroupCipher,AES-GCMP-256,GroupMgntCipher,BIP-GMAC-256,keymgmttype,SuiteB,PMF,Required,clientCertificate,suite_b_rsa.pem,trustedRootCA,suite_b_ca_rsa.pem,CertType,RSA" % (ifname
, "test-suite-b")
459 ",TLSCipher,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
460 ",TLSCipher,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" ]
462 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname
)
463 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
464 sigma_dut_cmd_check(cmd
+ extra
)
465 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname
, "test-suite-b"))
466 sigma_dut_wait_connected(ifname
)
467 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
468 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
469 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
471 stop_sigma_dut(sigma
)
473 def test_sigma_dut_ap_suite_b(dev
, apdev
, params
):
474 """sigma_dut controlled AP Suite B"""
475 check_suite_b_192_capa(dev
)
476 logdir
= os
.path
.join(params
['logdir'],
477 "sigma_dut_ap_suite_b.sigma-hostapd")
478 params
= suite_b_as_params()
479 params
['ca_cert'] = 'auth_serv/ec2-ca.pem'
480 params
['server_cert'] = 'auth_serv/ec2-server.pem'
481 params
['private_key'] = 'auth_serv/ec2-server.key'
482 params
['openssl_ciphers'] = 'SUITEB192'
483 hostapd
.add_ap(apdev
[1], params
)
484 with
HWSimRadio() as (radio
, iface
):
485 sigma
= start_sigma_dut(iface
, hostapd_logdir
=logdir
)
487 sigma_dut_cmd_check("ap_reset_default")
488 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-suite-b,MODE,11ng")
489 sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,18129,PASSWORD,radius")
490 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,SuiteB,PMF,Required")
491 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
493 dev
[0].connect("test-suite-b", key_mgmt
="WPA-EAP-SUITE-B-192",
495 openssl_ciphers
="SUITEB192",
496 eap
="TLS", identity
="tls user",
497 ca_cert
="auth_serv/ec2-ca.pem",
498 client_cert
="auth_serv/ec2-user.pem",
499 private_key
="auth_serv/ec2-user.key",
500 pairwise
="GCMP-256", group
="GCMP-256",
503 sigma_dut_cmd_check("ap_reset_default")
505 stop_sigma_dut(sigma
)
507 def test_sigma_dut_ap_cipher_gcmp_128(dev
, apdev
, params
):
508 """sigma_dut controlled AP with GCMP-128/BIP-GMAC-128 cipher"""
509 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-GCMP-128", "BIP-GMAC-128",
512 def test_sigma_dut_ap_cipher_gcmp_256(dev
, apdev
, params
):
513 """sigma_dut controlled AP with GCMP-256/BIP-GMAC-256 cipher"""
514 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-GCMP-256", "BIP-GMAC-256",
517 def test_sigma_dut_ap_cipher_ccmp_128(dev
, apdev
, params
):
518 """sigma_dut controlled AP with CCMP-128/BIP-CMAC-128 cipher"""
519 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-CCMP-128", "BIP-CMAC-128",
522 def test_sigma_dut_ap_cipher_ccmp_256(dev
, apdev
, params
):
523 """sigma_dut controlled AP with CCMP-256/BIP-CMAC-256 cipher"""
524 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-CCMP-256", "BIP-CMAC-256",
527 def test_sigma_dut_ap_cipher_ccmp_gcmp_1(dev
, apdev
, params
):
528 """sigma_dut controlled AP with CCMP-128+GCMP-256 ciphers (1)"""
529 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-CCMP-128 AES-GCMP-256",
530 "BIP-GMAC-256", "CCMP")
532 def test_sigma_dut_ap_cipher_ccmp_gcmp_2(dev
, apdev
, params
):
533 """sigma_dut controlled AP with CCMP-128+GCMP-256 ciphers (2)"""
534 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-CCMP-128 AES-GCMP-256",
535 "BIP-GMAC-256", "GCMP-256", "CCMP")
537 def test_sigma_dut_ap_cipher_gcmp_256_group_ccmp(dev
, apdev
, params
):
538 """sigma_dut controlled AP with GCMP-256/CCMP/BIP-GMAC-256 cipher"""
539 run_sigma_dut_ap_cipher(dev
, apdev
, params
, "AES-GCMP-256", "BIP-GMAC-256",
540 "GCMP-256", "CCMP", "AES-CCMP-128")
542 def run_sigma_dut_ap_cipher(dev
, apdev
, params
, ap_pairwise
, ap_group_mgmt
,
543 sta_cipher
, sta_cipher_group
=None, ap_group
=None):
544 check_suite_b_192_capa(dev
)
545 logdir
= os
.path
.join(params
['logdir'],
546 "sigma_dut_ap_cipher.sigma-hostapd")
547 params
= suite_b_as_params()
548 params
['ca_cert'] = 'auth_serv/ec2-ca.pem'
549 params
['server_cert'] = 'auth_serv/ec2-server.pem'
550 params
['private_key'] = 'auth_serv/ec2-server.key'
551 params
['openssl_ciphers'] = 'SUITEB192'
552 hostapd
.add_ap(apdev
[1], params
)
553 with
HWSimRadio() as (radio
, iface
):
554 sigma
= start_sigma_dut(iface
, hostapd_logdir
=logdir
)
556 sigma_dut_cmd_check("ap_reset_default")
557 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-suite-b,MODE,11ng")
558 sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,18129,PASSWORD,radius")
559 cmd
= "ap_set_security,NAME,AP,KEYMGNT,SuiteB,PMF,Required,PairwiseCipher,%s,GroupMgntCipher,%s" % (ap_pairwise
, ap_group_mgmt
)
561 cmd
+= ",GroupCipher,%s" % ap_group
562 sigma_dut_cmd_check(cmd
)
563 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
565 if sta_cipher_group
is None:
566 sta_cipher_group
= sta_cipher
567 dev
[0].connect("test-suite-b", key_mgmt
="WPA-EAP-SUITE-B-192",
569 openssl_ciphers
="SUITEB192",
570 eap
="TLS", identity
="tls user",
571 ca_cert
="auth_serv/ec2-ca.pem",
572 client_cert
="auth_serv/ec2-user.pem",
573 private_key
="auth_serv/ec2-user.key",
574 pairwise
=sta_cipher
, group
=sta_cipher_group
,
577 sigma_dut_cmd_check("ap_reset_default")
579 stop_sigma_dut(sigma
)
581 def test_sigma_dut_ap_override_rsne(dev
, apdev
):
582 """sigma_dut controlled AP overriding RSNE"""
583 with
HWSimRadio() as (radio
, iface
):
584 sigma
= start_sigma_dut(iface
)
586 sigma_dut_cmd_check("ap_reset_default")
587 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng")
588 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK,PSK,12345678")
589 sigma_dut_cmd_check("dev_configure_ie,NAME,AP,interface,%s,IE_Name,RSNE,Contents,30180100000fac040200ffffffff000fac040100000fac020c00" % iface
)
590 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
592 dev
[0].connect("test-psk", psk
="12345678", scan_freq
="2412")
594 sigma_dut_cmd_check("ap_reset_default")
596 stop_sigma_dut(sigma
)
598 def test_sigma_dut_ap_sae(dev
, apdev
):
599 """sigma_dut controlled AP with SAE"""
600 with
HWSimRadio() as (radio
, iface
):
601 sigma
= start_sigma_dut(iface
)
603 sigma_dut_cmd_check("ap_reset_default")
604 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng")
605 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-SAE,PSK,12345678")
606 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
608 dev
[0].request("SET sae_groups ")
609 dev
[0].connect("test-sae", key_mgmt
="SAE", psk
="12345678",
611 if dev
[0].get_status_field('sae_group') != '19':
612 raise Exception("Expected default SAE group not used")
614 sigma_dut_cmd_check("ap_reset_default")
616 stop_sigma_dut(sigma
)
618 def test_sigma_dut_ap_sae_password(dev
, apdev
):
619 """sigma_dut controlled AP with SAE and long password"""
620 with
HWSimRadio() as (radio
, iface
):
621 sigma
= start_sigma_dut(iface
)
623 sigma_dut_cmd_check("ap_reset_default")
624 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng")
625 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-SAE,PSK," + 100*'C')
626 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
628 dev
[0].request("SET sae_groups ")
629 dev
[0].connect("test-sae", key_mgmt
="SAE", sae_password
=100*'C',
631 if dev
[0].get_status_field('sae_group') != '19':
632 raise Exception("Expected default SAE group not used")
634 sigma_dut_cmd_check("ap_reset_default")
636 stop_sigma_dut(sigma
)
638 def test_sigma_dut_ap_sae_group(dev
, apdev
):
639 """sigma_dut controlled AP with SAE and specific group"""
640 with
HWSimRadio() as (radio
, iface
):
641 sigma
= start_sigma_dut(iface
)
643 sigma_dut_cmd_check("ap_reset_default")
644 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng")
645 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-SAE,PSK,12345678,ECGroupID,20")
646 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
648 dev
[0].request("SET sae_groups ")
649 dev
[0].connect("test-sae", key_mgmt
="SAE", psk
="12345678",
651 if dev
[0].get_status_field('sae_group') != '20':
652 raise Exception("Expected SAE group not used")
654 sigma_dut_cmd_check("ap_reset_default")
656 stop_sigma_dut(sigma
)
658 def test_sigma_dut_ap_psk_sae(dev
, apdev
):
659 """sigma_dut controlled AP with PSK+SAE"""
660 with
HWSimRadio() as (radio
, iface
):
661 sigma
= start_sigma_dut(iface
)
663 sigma_dut_cmd_check("ap_reset_default")
664 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng")
665 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK-SAE,PSK,12345678")
666 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
668 dev
[0].request("SET sae_groups ")
669 dev
[0].connect("test-sae", key_mgmt
="SAE", psk
="12345678",
671 dev
[1].connect("test-sae", psk
="12345678", scan_freq
="2412")
673 sigma_dut_cmd_check("ap_reset_default")
675 stop_sigma_dut(sigma
)
677 def test_sigma_dut_owe(dev
, apdev
):
678 """sigma_dut controlled OWE station"""
680 run_sigma_dut_owe(dev
, apdev
)
682 dev
[0].set("ignore_old_scan_res", "0")
684 def run_sigma_dut_owe(dev
, apdev
):
685 if "OWE" not in dev
[0].get_capability("key_mgmt"):
686 raise HwsimSkip("OWE not supported")
688 ifname
= dev
[0].ifname
689 sigma
= start_sigma_dut(ifname
)
692 params
= { "ssid": "owe",
694 "wpa_key_mgmt": "OWE",
695 "rsn_pairwise": "CCMP" }
696 hapd
= hostapd
.add_ap(apdev
[0], params
)
697 bssid
= hapd
.own_addr()
699 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,WPA3" % ifname
)
700 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
701 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,owe,Type,OWE" % ifname
)
702 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,owe,channel,1" % ifname
)
703 sigma_dut_wait_connected(ifname
)
704 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
706 dev
[0].dump_monitor()
707 sigma_dut_cmd("sta_reassoc,interface,%s,Channel,1,bssid,%s" % (ifname
, bssid
))
708 dev
[0].wait_connected()
709 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
710 dev
[0].wait_disconnected()
711 dev
[0].dump_monitor()
713 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,WPA3" % ifname
)
714 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
715 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,owe,Type,OWE,ECGroupID,20" % ifname
)
716 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,owe,channel,1" % ifname
)
717 sigma_dut_wait_connected(ifname
)
718 sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname
)
719 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
720 dev
[0].wait_disconnected()
721 dev
[0].dump_monitor()
723 sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,WPA3" % ifname
)
724 sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname
)
725 sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,owe,Type,OWE,ECGroupID,0" % ifname
)
726 sigma_dut_cmd_check("sta_associate,interface,%s,ssid,owe,channel,1" % ifname
)
727 ev
= dev
[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout
=10)
728 sigma_dut_cmd_check("sta_disconnect,interface," + ifname
)
730 raise Exception("Association not rejected")
731 if "status_code=77" not in ev
:
732 raise Exception("Unexpected rejection reason: " + ev
)
734 sigma_dut_cmd_check("sta_reset_default,interface," + ifname
)
736 stop_sigma_dut(sigma
)
738 def test_sigma_dut_ap_owe(dev
, apdev
):
739 """sigma_dut controlled AP with OWE"""
740 if "OWE" not in dev
[0].get_capability("key_mgmt"):
741 raise HwsimSkip("OWE not supported")
742 with
HWSimRadio() as (radio
, iface
):
743 sigma
= start_sigma_dut(iface
)
745 sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3")
746 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,owe,MODE,11ng")
747 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,OWE")
748 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
750 dev
[0].connect("owe", key_mgmt
="OWE", scan_freq
="2412")
752 sigma_dut_cmd_check("ap_reset_default")
754 stop_sigma_dut(sigma
)
756 def test_sigma_dut_ap_owe_ecgroupid(dev
, apdev
):
757 """sigma_dut controlled AP with OWE and ECGroupID"""
758 if "OWE" not in dev
[0].get_capability("key_mgmt"):
759 raise HwsimSkip("OWE not supported")
760 with
HWSimRadio() as (radio
, iface
):
761 sigma
= start_sigma_dut(iface
)
763 sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3")
764 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,owe,MODE,11ng")
765 sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,OWE,ECGroupID,20 21,PMF,Required")
766 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
768 dev
[0].connect("owe", key_mgmt
="OWE", ieee80211w
="2",
769 owe_group
="20", scan_freq
="2412")
770 dev
[0].request("REMOVE_NETWORK all")
771 dev
[0].wait_disconnected()
773 dev
[0].connect("owe", key_mgmt
="OWE", ieee80211w
="2",
774 owe_group
="21", scan_freq
="2412")
775 dev
[0].request("REMOVE_NETWORK all")
776 dev
[0].wait_disconnected()
778 dev
[0].connect("owe", key_mgmt
="OWE", ieee80211w
="2",
779 owe_group
="19", scan_freq
="2412", wait_connect
=False)
780 ev
= dev
[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout
=10)
781 dev
[0].request("DISCONNECT")
783 raise Exception("Association not rejected")
784 if "status_code=77" not in ev
:
785 raise Exception("Unexpected rejection reason: " + ev
)
786 dev
[0].dump_monitor()
788 sigma_dut_cmd_check("ap_reset_default")
790 stop_sigma_dut(sigma
)
792 def test_sigma_dut_ap_owe_transition_mode(dev
, apdev
, params
):
793 """sigma_dut controlled AP with OWE and transition mode"""
794 if "OWE" not in dev
[0].get_capability("key_mgmt"):
795 raise HwsimSkip("OWE not supported")
796 logdir
= os
.path
.join(params
['logdir'],
797 "sigma_dut_ap_owe_transition_mode.sigma-hostapd")
798 with
HWSimRadio() as (radio
, iface
):
799 sigma
= start_sigma_dut(iface
, hostapd_logdir
=logdir
)
801 sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3")
802 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,WLAN_TAG,1,CHANNEL,1,SSID,owe,MODE,11ng")
803 sigma_dut_cmd_check("ap_set_security,NAME,AP,WLAN_TAG,1,KEYMGNT,OWE")
804 sigma_dut_cmd_check("ap_set_wireless,NAME,AP,WLAN_TAG,2,CHANNEL,1,SSID,owe,MODE,11ng")
805 sigma_dut_cmd_check("ap_set_security,NAME,AP,WLAN_TAG,2,KEYMGNT,NONE")
806 sigma_dut_cmd_check("ap_config_commit,NAME,AP")
808 res1
= sigma_dut_cmd_check("ap_get_mac_address,NAME,AP,WLAN_TAG,1,Interface,24G")
809 res2
= sigma_dut_cmd_check("ap_get_mac_address,NAME,AP,WLAN_TAG,2,Interface,24G")
811 dev
[0].connect("owe", key_mgmt
="OWE", scan_freq
="2412")
812 dev
[1].connect("owe", key_mgmt
="NONE", scan_freq
="2412")
813 if dev
[0].get_status_field('bssid') not in res1
:
814 raise Exception("Unexpected ap_get_mac_address WLAN_TAG,1: " + res1
)
815 if dev
[1].get_status_field('bssid') not in res2
:
816 raise Exception("Unexpected ap_get_mac_address WLAN_TAG,2: " + res2
)
818 sigma_dut_cmd_check("ap_reset_default")
820 stop_sigma_dut(sigma
)
822 def dpp_init_enrollee(dev
, id1
):
823 logger
.info("Starting DPP initiator/enrollee in a thread")
825 cmd
= "DPP_AUTH_INIT peer=%d role=enrollee" % id1
826 if "OK" not in dev
.request(cmd
):
827 raise Exception("Failed to initiate DPP Authentication")
828 ev
= dev
.wait_event(["DPP-CONF-RECEIVED"], timeout
=5)
830 raise Exception("DPP configuration not completed (Enrollee)")
831 logger
.info("DPP initiator/enrollee done")
833 def test_sigma_dut_dpp_qr_resp_1(dev
, apdev
):
834 """sigma_dut DPP/QR responder (conf index 1)"""
835 run_sigma_dut_dpp_qr_resp(dev
, apdev
, 1)
837 def test_sigma_dut_dpp_qr_resp_2(dev
, apdev
):
838 """sigma_dut DPP/QR responder (conf index 2)"""
839 run_sigma_dut_dpp_qr_resp(dev
, apdev
, 2)
841 def test_sigma_dut_dpp_qr_resp_3(dev
, apdev
):
842 """sigma_dut DPP/QR responder (conf index 3)"""
843 run_sigma_dut_dpp_qr_resp(dev
, apdev
, 3)
845 def test_sigma_dut_dpp_qr_resp_4(dev
, apdev
):
846 """sigma_dut DPP/QR responder (conf index 4)"""
847 run_sigma_dut_dpp_qr_resp(dev
, apdev
, 4)
849 def test_sigma_dut_dpp_qr_resp_chan_list(dev
, apdev
):
850 """sigma_dut DPP/QR responder (channel list override)"""
851 run_sigma_dut_dpp_qr_resp(dev
, apdev
, 1, chan_list
='81/2 81/6 81/1',
854 def run_sigma_dut_dpp_qr_resp(dev
, apdev
, conf_idx
, chan_list
=None,
856 check_dpp_capab(dev
[0])
857 check_dpp_capab(dev
[1])
858 sigma
= start_sigma_dut(dev
[0].ifname
)
860 cmd
= "dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR"
862 cmd
+= ",DPPChannelList," + chan_list
863 res
= sigma_dut_cmd(cmd
)
864 if "status,COMPLETE" not in res
:
865 raise Exception("dev_exec_action did not succeed: " + res
)
866 hex = res
.split(',')[3]
867 uri
= hex.decode('hex')
868 logger
.info("URI from sigma_dut: " + uri
)
870 res
= dev
[1].request("DPP_QR_CODE " + uri
)
872 raise Exception("Failed to parse QR Code URI")
875 t
= threading
.Thread(target
=dpp_init_enrollee
, args
=(dev
[1], id1
))
877 cmd
= "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPConfIndex,%d,DPPAuthDirection,Single,DPPProvisioningRole,Configurator,DPPConfEnrolleeRole,STA,DPPSigningKeyECC,P-256,DPPBS,QR,DPPTimeout,6" % conf_idx
879 cmd
+= ",DPPListenChannel," + str(listen_chan
)
880 res
= sigma_dut_cmd(cmd
, timeout
=10)
882 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res
:
883 raise Exception("Unexpected result: " + res
)
885 stop_sigma_dut(sigma
)
887 def test_sigma_dut_dpp_qr_init_enrollee(dev
, apdev
):
888 """sigma_dut DPP/QR initiator as Enrollee"""
889 check_dpp_capab(dev
[0])
890 check_dpp_capab(dev
[1])
892 csign
= "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
893 csign_pub
= "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
894 ap_connector
= "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
895 ap_netaccesskey
= "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
897 params
= { "ssid": "DPPNET01",
899 "wpa_key_mgmt": "DPP",
900 "rsn_pairwise": "CCMP",
901 "dpp_connector": ap_connector
,
902 "dpp_csign": csign_pub
,
903 "dpp_netaccesskey": ap_netaccesskey
}
905 hapd
= hostapd
.add_ap(apdev
[0], params
)
907 raise HwsimSkip("DPP not supported")
909 sigma
= start_sigma_dut(dev
[0].ifname
)
911 dev
[0].set("dpp_config_processing", "2")
913 cmd
= "DPP_CONFIGURATOR_ADD key=" + csign
914 res
= dev
[1].request(cmd
);
916 raise Exception("Failed to add configurator")
919 addr
= dev
[1].own_addr().replace(':', '')
920 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
921 res
= dev
[1].request(cmd
)
923 raise Exception("Failed to generate bootstrapping info")
925 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
927 dev
[1].set("dpp_configurator_params",
928 " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id
));
929 cmd
= "DPP_LISTEN 2437 role=configurator"
930 if "OK" not in dev
[1].request(cmd
):
931 raise Exception("Failed to start listen operation")
933 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
934 if "status,COMPLETE" not in res
:
935 raise Exception("dev_exec_action did not succeed: " + res
)
937 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPWaitForConnect,Yes", timeout
=10)
938 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res
:
939 raise Exception("Unexpected result: " + res
)
941 dev
[0].set("dpp_config_processing", "0")
942 stop_sigma_dut(sigma
)
944 def test_sigma_dut_dpp_qr_mutual_init_enrollee(dev
, apdev
):
945 """sigma_dut DPP/QR (mutual) initiator as Enrollee"""
946 check_dpp_capab(dev
[0])
947 check_dpp_capab(dev
[1])
949 csign
= "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
950 csign_pub
= "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
951 ap_connector
= "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
952 ap_netaccesskey
= "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
954 params
= { "ssid": "DPPNET01",
956 "wpa_key_mgmt": "DPP",
957 "rsn_pairwise": "CCMP",
958 "dpp_connector": ap_connector
,
959 "dpp_csign": csign_pub
,
960 "dpp_netaccesskey": ap_netaccesskey
}
962 hapd
= hostapd
.add_ap(apdev
[0], params
)
964 raise HwsimSkip("DPP not supported")
966 sigma
= start_sigma_dut(dev
[0].ifname
)
968 dev
[0].set("dpp_config_processing", "2")
970 cmd
= "DPP_CONFIGURATOR_ADD key=" + csign
971 res
= dev
[1].request(cmd
);
973 raise Exception("Failed to add configurator")
976 addr
= dev
[1].own_addr().replace(':', '')
977 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
978 res
= dev
[1].request(cmd
)
980 raise Exception("Failed to generate bootstrapping info")
982 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
984 dev
[1].set("dpp_configurator_params",
985 " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id
));
986 cmd
= "DPP_LISTEN 2437 role=configurator qr=mutual"
987 if "OK" not in dev
[1].request(cmd
):
988 raise Exception("Failed to start listen operation")
990 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR")
991 if "status,COMPLETE" not in res
:
992 raise Exception("dev_exec_action did not succeed: " + res
)
993 hex = res
.split(',')[3]
994 uri
= hex.decode('hex')
995 logger
.info("URI from sigma_dut: " + uri
)
997 res
= dev
[1].request("DPP_QR_CODE " + uri
)
999 raise Exception("Failed to parse QR Code URI")
1002 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1003 if "status,COMPLETE" not in res
:
1004 raise Exception("dev_exec_action did not succeed: " + res
)
1006 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPWaitForConnect,Yes", timeout
=10)
1007 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res
:
1008 raise Exception("Unexpected result: " + res
)
1010 dev
[0].set("dpp_config_processing", "0")
1011 stop_sigma_dut(sigma
)
1013 def dpp_init_conf_mutual(dev
, id1
, conf_id
, own_id
=None):
1015 logger
.info("Starting DPP initiator/configurator in a thread")
1016 cmd
= "DPP_AUTH_INIT peer=%d conf=sta-dpp ssid=%s configurator=%d" % (id1
, "DPPNET01".encode("hex"), conf_id
)
1017 if own_id
is not None:
1018 cmd
+= " own=%d" % own_id
1019 if "OK" not in dev
.request(cmd
):
1020 raise Exception("Failed to initiate DPP Authentication")
1021 ev
= dev
.wait_event(["DPP-CONF-SENT"], timeout
=10)
1023 raise Exception("DPP configuration not completed (Configurator)")
1024 logger
.info("DPP initiator/configurator done")
1026 def test_sigma_dut_dpp_qr_mutual_resp_enrollee(dev
, apdev
):
1027 """sigma_dut DPP/QR (mutual) responder as Enrollee"""
1028 run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev
, apdev
)
1030 def test_sigma_dut_dpp_qr_mutual_resp_enrollee_pending(dev
, apdev
):
1031 """sigma_dut DPP/QR (mutual) responder as Enrollee (response pending)"""
1032 run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev
, apdev
, ',DPPDelayQRResponse,1')
1034 def run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev
, apdev
, extra
=None):
1035 check_dpp_capab(dev
[0])
1036 check_dpp_capab(dev
[1])
1038 csign
= "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
1039 csign_pub
= "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
1040 ap_connector
= "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
1041 ap_netaccesskey
= "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
1043 params
= { "ssid": "DPPNET01",
1045 "wpa_key_mgmt": "DPP",
1046 "rsn_pairwise": "CCMP",
1047 "dpp_connector": ap_connector
,
1048 "dpp_csign": csign_pub
,
1049 "dpp_netaccesskey": ap_netaccesskey
}
1051 hapd
= hostapd
.add_ap(apdev
[0], params
)
1053 raise HwsimSkip("DPP not supported")
1055 sigma
= start_sigma_dut(dev
[0].ifname
)
1057 dev
[0].set("dpp_config_processing", "2")
1059 cmd
= "DPP_CONFIGURATOR_ADD key=" + csign
1060 res
= dev
[1].request(cmd
);
1062 raise Exception("Failed to add configurator")
1065 addr
= dev
[1].own_addr().replace(':', '')
1066 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
1067 res
= dev
[1].request(cmd
)
1069 raise Exception("Failed to generate bootstrapping info")
1071 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
1073 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR")
1074 if "status,COMPLETE" not in res
:
1075 raise Exception("dev_exec_action did not succeed: " + res
)
1076 hex = res
.split(',')[3]
1077 uri
= hex.decode('hex')
1078 logger
.info("URI from sigma_dut: " + uri
)
1080 res
= dev
[1].request("DPP_QR_CODE " + uri
)
1082 raise Exception("Failed to parse QR Code URI")
1085 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1086 if "status,COMPLETE" not in res
:
1087 raise Exception("dev_exec_action did not succeed: " + res
)
1089 t
= threading
.Thread(target
=dpp_init_conf_mutual
,
1090 args
=(dev
[1], id1
, conf_id
, id0
))
1093 cmd
= "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,20,DPPWaitForConnect,Yes"
1096 res
= sigma_dut_cmd(cmd
, timeout
=25)
1098 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res
:
1099 raise Exception("Unexpected result: " + res
)
1101 dev
[0].set("dpp_config_processing", "0")
1102 stop_sigma_dut(sigma
)
1104 def dpp_resp_conf_mutual(dev
, conf_id
, uri
):
1105 logger
.info("Starting DPP responder/configurator in a thread")
1106 dev
.set("dpp_configurator_params",
1107 " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id
));
1108 cmd
= "DPP_LISTEN 2437 role=configurator qr=mutual"
1109 if "OK" not in dev
.request(cmd
):
1110 raise Exception("Failed to initiate DPP listen")
1112 ev
= dev
.wait_event(["DPP-SCAN-PEER-QR-CODE"], timeout
=10)
1114 raise Exception("QR Code scan for mutual authentication not requested")
1115 res
= dev
.request("DPP_QR_CODE " + uri
)
1117 raise Exception("Failed to parse QR Code URI")
1118 ev
= dev
.wait_event(["DPP-CONF-SENT"], timeout
=10)
1120 raise Exception("DPP configuration not completed (Configurator)")
1121 logger
.info("DPP responder/configurator done")
1123 def test_sigma_dut_dpp_qr_mutual_init_enrollee(dev
, apdev
):
1124 """sigma_dut DPP/QR (mutual) initiator as Enrollee"""
1125 run_sigma_dut_dpp_qr_mutual_init_enrollee(dev
, apdev
, False)
1127 def test_sigma_dut_dpp_qr_mutual_init_enrollee_pending(dev
, apdev
):
1128 """sigma_dut DPP/QR (mutual) initiator as Enrollee (response pending)"""
1129 run_sigma_dut_dpp_qr_mutual_init_enrollee(dev
, apdev
, True)
1131 def run_sigma_dut_dpp_qr_mutual_init_enrollee(dev
, apdev
, resp_pending
):
1132 check_dpp_capab(dev
[0])
1133 check_dpp_capab(dev
[1])
1135 csign
= "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
1136 csign_pub
= "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
1137 ap_connector
= "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
1138 ap_netaccesskey
= "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
1140 params
= { "ssid": "DPPNET01",
1142 "wpa_key_mgmt": "DPP",
1143 "rsn_pairwise": "CCMP",
1144 "dpp_connector": ap_connector
,
1145 "dpp_csign": csign_pub
,
1146 "dpp_netaccesskey": ap_netaccesskey
}
1148 hapd
= hostapd
.add_ap(apdev
[0], params
)
1150 raise HwsimSkip("DPP not supported")
1152 sigma
= start_sigma_dut(dev
[0].ifname
)
1154 dev
[0].set("dpp_config_processing", "2")
1156 cmd
= "DPP_CONFIGURATOR_ADD key=" + csign
1157 res
= dev
[1].request(cmd
);
1159 raise Exception("Failed to add configurator")
1162 addr
= dev
[1].own_addr().replace(':', '')
1163 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
1164 res
= dev
[1].request(cmd
)
1166 raise Exception("Failed to generate bootstrapping info")
1168 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
1170 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR")
1171 if "status,COMPLETE" not in res
:
1172 raise Exception("dev_exec_action did not succeed: " + res
)
1173 hex = res
.split(',')[3]
1174 uri
= hex.decode('hex')
1175 logger
.info("URI from sigma_dut: " + uri
)
1177 if not resp_pending
:
1178 res
= dev
[1].request("DPP_QR_CODE " + uri
)
1180 raise Exception("Failed to parse QR Code URI")
1183 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1184 if "status,COMPLETE" not in res
:
1185 raise Exception("dev_exec_action did not succeed: " + res
)
1187 t
= threading
.Thread(target
=dpp_resp_conf_mutual
,
1188 args
=(dev
[1], conf_id
, uri
))
1192 cmd
= "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,10,DPPWaitForConnect,Yes"
1193 res
= sigma_dut_cmd(cmd
, timeout
=15)
1195 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res
:
1196 raise Exception("Unexpected result: " + res
)
1198 dev
[0].set("dpp_config_processing", "0")
1199 stop_sigma_dut(sigma
)
1201 def test_sigma_dut_dpp_qr_init_enrollee_psk(dev
, apdev
):
1202 """sigma_dut DPP/QR initiator as Enrollee (PSK)"""
1203 check_dpp_capab(dev
[0])
1204 check_dpp_capab(dev
[1])
1206 params
= hostapd
.wpa2_params(ssid
="DPPNET01",
1207 passphrase
="ThisIsDppPassphrase")
1208 hapd
= hostapd
.add_ap(apdev
[0], params
)
1210 sigma
= start_sigma_dut(dev
[0].ifname
)
1212 dev
[0].set("dpp_config_processing", "2")
1214 cmd
= "DPP_CONFIGURATOR_ADD"
1215 res
= dev
[1].request(cmd
);
1217 raise Exception("Failed to add configurator")
1220 addr
= dev
[1].own_addr().replace(':', '')
1221 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
1222 res
= dev
[1].request(cmd
)
1224 raise Exception("Failed to generate bootstrapping info")
1226 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
1228 dev
[1].set("dpp_configurator_params",
1229 " conf=sta-psk ssid=%s pass=%s configurator=%d" % ("DPPNET01".encode("hex"), "ThisIsDppPassphrase".encode("hex"), conf_id
));
1230 cmd
= "DPP_LISTEN 2437 role=configurator"
1231 if "OK" not in dev
[1].request(cmd
):
1232 raise Exception("Failed to start listen operation")
1234 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1235 if "status,COMPLETE" not in res
:
1236 raise Exception("dev_exec_action did not succeed: " + res
)
1238 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPWaitForConnect,Yes", timeout
=10)
1239 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,OK" not in res
:
1240 raise Exception("Unexpected result: " + res
)
1242 dev
[0].set("dpp_config_processing", "0")
1243 stop_sigma_dut(sigma
)
1245 def test_sigma_dut_dpp_qr_init_configurator_1(dev
, apdev
):
1246 """sigma_dut DPP/QR initiator as Configurator (conf index 1)"""
1247 run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, 1)
1249 def test_sigma_dut_dpp_qr_init_configurator_2(dev
, apdev
):
1250 """sigma_dut DPP/QR initiator as Configurator (conf index 2)"""
1251 run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, 2)
1253 def test_sigma_dut_dpp_qr_init_configurator_3(dev
, apdev
):
1254 """sigma_dut DPP/QR initiator as Configurator (conf index 3)"""
1255 run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, 3)
1257 def test_sigma_dut_dpp_qr_init_configurator_4(dev
, apdev
):
1258 """sigma_dut DPP/QR initiator as Configurator (conf index 4)"""
1259 run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, 4)
1261 def test_sigma_dut_dpp_qr_init_configurator_both(dev
, apdev
):
1262 """sigma_dut DPP/QR initiator as Configurator or Enrollee (conf index 1)"""
1263 run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, 1, "Both")
1265 def test_sigma_dut_dpp_qr_init_configurator_neg_freq(dev
, apdev
):
1266 """sigma_dut DPP/QR initiator as Configurator (neg_freq)"""
1267 run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, 1, extra
='DPPSubsequentChannel,81/11')
1269 def run_sigma_dut_dpp_qr_init_configurator(dev
, apdev
, conf_idx
,
1270 prov_role
="Configurator",
1272 check_dpp_capab(dev
[0])
1273 check_dpp_capab(dev
[1])
1274 sigma
= start_sigma_dut(dev
[0].ifname
)
1276 addr
= dev
[1].own_addr().replace(':', '')
1277 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
1278 res
= dev
[1].request(cmd
)
1280 raise Exception("Failed to generate bootstrapping info")
1282 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
1284 cmd
= "DPP_LISTEN 2437 role=enrollee"
1285 if "OK" not in dev
[1].request(cmd
):
1286 raise Exception("Failed to start listen operation")
1288 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1289 if "status,COMPLETE" not in res
:
1290 raise Exception("dev_exec_action did not succeed: " + res
)
1292 cmd
= "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,%s,DPPConfIndex,%d,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,QR,DPPTimeout,6" % (prov_role
, conf_idx
)
1295 res
= sigma_dut_cmd(cmd
)
1296 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res
:
1297 raise Exception("Unexpected result: " + res
)
1299 stop_sigma_dut(sigma
)
1301 def test_sigma_dut_dpp_pkex_init_configurator(dev
, apdev
):
1302 """sigma_dut DPP/PKEX initiator as Configurator"""
1303 check_dpp_capab(dev
[0])
1304 check_dpp_capab(dev
[1])
1305 sigma
= start_sigma_dut(dev
[0].ifname
)
1307 cmd
= "DPP_BOOTSTRAP_GEN type=pkex"
1308 res
= dev
[1].request(cmd
)
1310 raise Exception("Failed to generate bootstrapping info")
1312 cmd
= "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id1
)
1313 res
= dev
[1].request(cmd
)
1315 raise Exception("Failed to set PKEX data (responder)")
1316 cmd
= "DPP_LISTEN 2437 role=enrollee"
1317 if "OK" not in dev
[1].request(cmd
):
1318 raise Exception("Failed to start listen operation")
1320 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Mutual,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCodeIdentifier,test,DPPPKEXCode,secret,DPPTimeout,6")
1321 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res
:
1322 raise Exception("Unexpected result: " + res
)
1324 stop_sigma_dut(sigma
)
1326 def dpp_init_conf(dev
, id1
, conf
, conf_id
, extra
):
1327 logger
.info("Starting DPP initiator/configurator in a thread")
1328 cmd
= "DPP_AUTH_INIT peer=%d conf=%s %s configurator=%d" % (id1
, conf
, extra
, conf_id
)
1329 if "OK" not in dev
.request(cmd
):
1330 raise Exception("Failed to initiate DPP Authentication")
1331 ev
= dev
.wait_event(["DPP-CONF-SENT"], timeout
=5)
1333 raise Exception("DPP configuration not completed (Configurator)")
1334 logger
.info("DPP initiator/configurator done")
1336 def test_sigma_dut_ap_dpp_qr(dev
, apdev
, params
):
1337 """sigma_dut controlled AP (DPP)"""
1338 run_sigma_dut_ap_dpp_qr(dev
, apdev
, params
, "ap-dpp", "sta-dpp")
1340 def test_sigma_dut_ap_dpp_qr_legacy(dev
, apdev
, params
):
1341 """sigma_dut controlled AP (legacy)"""
1342 run_sigma_dut_ap_dpp_qr(dev
, apdev
, params
, "ap-psk", "sta-psk",
1343 extra
="pass=%s" % "qwertyuiop".encode("hex"))
1345 def test_sigma_dut_ap_dpp_qr_legacy_psk(dev
, apdev
, params
):
1346 """sigma_dut controlled AP (legacy)"""
1347 run_sigma_dut_ap_dpp_qr(dev
, apdev
, params
, "ap-psk", "sta-psk",
1348 extra
="psk=%s" % (32*"12"))
1350 def run_sigma_dut_ap_dpp_qr(dev
, apdev
, params
, ap_conf
, sta_conf
, extra
=""):
1351 logdir
= os
.path
.join(params
['logdir'], "sigma_dut_ap_dpp_qr.sigma-hostapd")
1352 with
HWSimRadio() as (radio
, iface
):
1353 sigma
= start_sigma_dut(iface
, hostapd_logdir
=logdir
)
1355 sigma_dut_cmd_check("ap_reset_default,program,DPP")
1356 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR")
1357 if "status,COMPLETE" not in res
:
1358 raise Exception("dev_exec_action did not succeed: " + res
)
1359 hex = res
.split(',')[3]
1360 uri
= hex.decode('hex')
1361 logger
.info("URI from sigma_dut: " + uri
)
1363 cmd
= "DPP_CONFIGURATOR_ADD"
1364 res
= dev
[0].request(cmd
);
1366 raise Exception("Failed to add configurator")
1369 res
= dev
[0].request("DPP_QR_CODE " + uri
)
1371 raise Exception("Failed to parse QR Code URI")
1374 t
= threading
.Thread(target
=dpp_init_conf
,
1375 args
=(dev
[0], id1
, ap_conf
, conf_id
, extra
))
1377 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6")
1379 if "ConfResult,OK" not in res
:
1380 raise Exception("Unexpected result: " + res
)
1382 addr
= dev
[1].own_addr().replace(':', '')
1383 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
1384 res
= dev
[1].request(cmd
)
1386 raise Exception("Failed to generate bootstrapping info")
1388 uri1
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1
)
1390 res
= dev
[0].request("DPP_QR_CODE " + uri1
)
1392 raise Exception("Failed to parse QR Code URI")
1395 dev
[1].set("dpp_config_processing", "2")
1396 cmd
= "DPP_LISTEN 2412"
1397 if "OK" not in dev
[1].request(cmd
):
1398 raise Exception("Failed to start listen operation")
1399 cmd
= "DPP_AUTH_INIT peer=%d conf=%s %s configurator=%d" % (id0b
, sta_conf
, extra
, conf_id
)
1400 if "OK" not in dev
[0].request(cmd
):
1401 raise Exception("Failed to initiate DPP Authentication")
1402 dev
[1].wait_connected()
1404 sigma_dut_cmd_check("ap_reset_default")
1406 dev
[1].set("dpp_config_processing", "0")
1407 stop_sigma_dut(sigma
)
1409 def test_sigma_dut_ap_dpp_pkex_responder(dev
, apdev
, params
):
1410 """sigma_dut controlled AP as DPP PKEX responder"""
1411 logdir
= os
.path
.join(params
['logdir'],
1412 "sigma_dut_ap_dpp_pkex_responder.sigma-hostapd")
1413 with
HWSimRadio() as (radio
, iface
):
1414 sigma
= start_sigma_dut(iface
, hostapd_logdir
=logdir
)
1416 run_sigma_dut_ap_dpp_pkex_responder(dev
, apdev
)
1418 stop_sigma_dut(sigma
)
1420 def dpp_init_conf_pkex(dev
, conf_id
):
1421 logger
.info("Starting DPP PKEX initiator/configurator in a thread")
1423 cmd
= "DPP_BOOTSTRAP_GEN type=pkex"
1424 res
= dev
.request(cmd
)
1426 raise Exception("Failed to generate bootstrapping info")
1428 cmd
= "DPP_PKEX_ADD own=%d init=1 conf=ap-dpp configurator=%d code=password" % (id, conf_id
)
1429 res
= dev
.request(cmd
)
1431 raise Exception("Failed to initiate DPP PKEX")
1432 ev
= dev
.wait_event(["DPP-CONF-SENT"], timeout
=5)
1434 raise Exception("DPP configuration not completed (Configurator)")
1435 logger
.info("DPP initiator/configurator done")
1437 def run_sigma_dut_ap_dpp_pkex_responder(dev
, apdev
):
1438 sigma_dut_cmd_check("ap_reset_default,program,DPP")
1440 cmd
= "DPP_CONFIGURATOR_ADD"
1441 res
= dev
[0].request(cmd
);
1443 raise Exception("Failed to add configurator")
1446 t
= threading
.Thread(target
=dpp_init_conf_pkex
, args
=(dev
[0], conf_id
))
1448 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,PKEX,DPPPKEXCode,password,DPPTimeout,6", timeout
=10)
1450 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res
:
1451 raise Exception("Unexpected result: " + res
)
1453 sigma_dut_cmd_check("ap_reset_default")
1455 def dpp_proto_init(dev
, id1
):
1457 logger
.info("Starting DPP initiator/configurator in a thread")
1458 cmd
= "DPP_CONFIGURATOR_ADD"
1459 res
= dev
.request(cmd
);
1461 raise Exception("Failed to add configurator")
1464 cmd
= "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1
, conf_id
)
1465 if "OK" not in dev
.request(cmd
):
1466 raise Exception("Failed to initiate DPP Authentication")
1468 def test_sigma_dut_dpp_proto_initiator(dev
, apdev
):
1469 """sigma_dut DPP protocol testing - Initiator"""
1470 check_dpp_capab(dev
[0])
1471 check_dpp_capab(dev
[1])
1472 tests
= [ ("InvalidValue", "AuthenticationRequest", "WrappedData",
1473 "BootstrapResult,OK,AuthResult,Errorsent",
1475 ("InvalidValue", "AuthenticationConfirm", "WrappedData",
1476 "BootstrapResult,OK,AuthResult,Errorsent",
1478 ("MissingAttribute", "AuthenticationRequest", "InitCapabilities",
1479 "BootstrapResult,OK,AuthResult,Errorsent",
1480 "Missing or invalid I-capabilities"),
1481 ("InvalidValue", "AuthenticationConfirm", "InitAuthTag",
1482 "BootstrapResult,OK,AuthResult,Errorsent",
1483 "Mismatching Initiator Authenticating Tag"),
1484 ("MissingAttribute", "ConfigurationResponse", "EnrolleeNonce",
1485 "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent",
1486 "Missing or invalid Enrollee Nonce attribute") ]
1487 for step
, frame
, attr
, result
, fail
in tests
:
1488 dev
[0].request("FLUSH")
1489 dev
[1].request("FLUSH")
1490 sigma
= start_sigma_dut(dev
[0].ifname
)
1492 run_sigma_dut_dpp_proto_initiator(dev
, step
, frame
, attr
, result
,
1495 stop_sigma_dut(sigma
)
1497 def run_sigma_dut_dpp_proto_initiator(dev
, step
, frame
, attr
, result
, fail
):
1498 addr
= dev
[1].own_addr().replace(':', '')
1499 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
1500 res
= dev
[1].request(cmd
)
1502 raise Exception("Failed to generate bootstrapping info")
1504 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
1506 cmd
= "DPP_LISTEN 2437 role=enrollee"
1507 if "OK" not in dev
[1].request(cmd
):
1508 raise Exception("Failed to start listen operation")
1510 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1511 if "status,COMPLETE" not in res
:
1512 raise Exception("dev_exec_action did not succeed: " + res
)
1514 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,QR,DPPTimeout,6,DPPStep,%s,DPPFrameType,%s,DPPIEAttribute,%s" % (step
, frame
, attr
))
1515 if result
not in res
:
1516 raise Exception("Unexpected result: " + res
)
1518 ev
= dev
[1].wait_event(["DPP-FAIL"], timeout
=5)
1519 if ev
is None or fail
not in ev
:
1520 raise Exception("Failure not reported correctly: " + str(ev
))
1522 dev
[1].request("DPP_STOP_LISTEN")
1523 dev
[0].dump_monitor()
1524 dev
[1].dump_monitor()
1526 def test_sigma_dut_dpp_proto_responder(dev
, apdev
):
1527 """sigma_dut DPP protocol testing - Responder"""
1528 check_dpp_capab(dev
[0])
1529 check_dpp_capab(dev
[1])
1530 tests
= [ ("MissingAttribute", "AuthenticationResponse", "DPPStatus",
1531 "BootstrapResult,OK,AuthResult,Errorsent",
1532 "Missing or invalid required DPP Status attribute"),
1533 ("MissingAttribute", "ConfigurationRequest", "EnrolleeNonce",
1534 "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent",
1535 "Missing or invalid Enrollee Nonce attribute") ]
1536 for step
, frame
, attr
, result
, fail
in tests
:
1537 dev
[0].request("FLUSH")
1538 dev
[1].request("FLUSH")
1539 sigma
= start_sigma_dut(dev
[0].ifname
)
1541 run_sigma_dut_dpp_proto_responder(dev
, step
, frame
, attr
, result
,
1544 stop_sigma_dut(sigma
)
1546 def run_sigma_dut_dpp_proto_responder(dev
, step
, frame
, attr
, result
, fail
):
1547 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR")
1548 if "status,COMPLETE" not in res
:
1549 raise Exception("dev_exec_action did not succeed: " + res
)
1550 hex = res
.split(',')[3]
1551 uri
= hex.decode('hex')
1552 logger
.info("URI from sigma_dut: " + uri
)
1554 res
= dev
[1].request("DPP_QR_CODE " + uri
)
1556 raise Exception("Failed to parse QR Code URI")
1559 t
= threading
.Thread(target
=dpp_proto_init
, args
=(dev
[1], id1
))
1561 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,QR,DPPTimeout,6,DPPStep,%s,DPPFrameType,%s,DPPIEAttribute,%s" % (step
, frame
, attr
), timeout
=10)
1563 if result
not in res
:
1564 raise Exception("Unexpected result: " + res
)
1566 ev
= dev
[1].wait_event(["DPP-FAIL"], timeout
=5)
1567 if ev
is None or fail
not in ev
:
1568 raise Exception("Failure not reported correctly:" + str(ev
))
1570 dev
[1].request("DPP_STOP_LISTEN")
1571 dev
[0].dump_monitor()
1572 dev
[1].dump_monitor()
1574 def dpp_proto_init_pkex(dev
):
1576 logger
.info("Starting DPP PKEX initiator/configurator in a thread")
1577 cmd
= "DPP_CONFIGURATOR_ADD"
1578 res
= dev
.request(cmd
);
1580 raise Exception("Failed to add configurator")
1583 cmd
= "DPP_BOOTSTRAP_GEN type=pkex"
1584 res
= dev
.request(cmd
)
1586 raise Exception("Failed to generate bootstrapping info")
1589 cmd
= "DPP_PKEX_ADD own=%d init=1 conf=sta-dpp configurator=%d code=secret" % (id, conf_id
)
1590 if "FAIL" in dev
.request(cmd
):
1591 raise Exception("Failed to initiate DPP PKEX")
1593 def test_sigma_dut_dpp_proto_initiator_pkex(dev
, apdev
):
1594 """sigma_dut DPP protocol testing - Initiator (PKEX)"""
1595 check_dpp_capab(dev
[0])
1596 check_dpp_capab(dev
[1])
1597 tests
= [ ("InvalidValue", "PKEXCRRequest", "WrappedData",
1598 "BootstrapResult,Errorsent",
1600 ("MissingAttribute", "PKEXExchangeRequest", "FiniteCyclicGroup",
1601 "BootstrapResult,Errorsent",
1602 "Missing or invalid Finite Cyclic Group attribute"),
1603 ("MissingAttribute", "PKEXCRRequest", "BSKey",
1604 "BootstrapResult,Errorsent",
1605 "No valid peer bootstrapping key found") ]
1606 for step
, frame
, attr
, result
, fail
in tests
:
1607 dev
[0].request("FLUSH")
1608 dev
[1].request("FLUSH")
1609 sigma
= start_sigma_dut(dev
[0].ifname
)
1611 run_sigma_dut_dpp_proto_initiator_pkex(dev
, step
, frame
, attr
,
1614 stop_sigma_dut(sigma
)
1616 def run_sigma_dut_dpp_proto_initiator_pkex(dev
, step
, frame
, attr
, result
, fail
):
1617 cmd
= "DPP_BOOTSTRAP_GEN type=pkex"
1618 res
= dev
[1].request(cmd
)
1620 raise Exception("Failed to generate bootstrapping info")
1623 cmd
= "DPP_PKEX_ADD own=%d code=secret" % (id1
)
1624 res
= dev
[1].request(cmd
)
1626 raise Exception("Failed to set PKEX data (responder)")
1628 cmd
= "DPP_LISTEN 2437 role=enrollee"
1629 if "OK" not in dev
[1].request(cmd
):
1630 raise Exception("Failed to start listen operation")
1632 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCode,secret,DPPTimeout,6,DPPStep,%s,DPPFrameType,%s,DPPIEAttribute,%s" % (step
, frame
, attr
))
1633 if result
not in res
:
1634 raise Exception("Unexpected result: " + res
)
1636 ev
= dev
[1].wait_event(["DPP-FAIL"], timeout
=5)
1637 if ev
is None or fail
not in ev
:
1638 raise Exception("Failure not reported correctly: " + str(ev
))
1640 dev
[1].request("DPP_STOP_LISTEN")
1641 dev
[0].dump_monitor()
1642 dev
[1].dump_monitor()
1644 def test_sigma_dut_dpp_proto_responder_pkex(dev
, apdev
):
1645 """sigma_dut DPP protocol testing - Responder (PKEX)"""
1646 check_dpp_capab(dev
[0])
1647 check_dpp_capab(dev
[1])
1648 tests
= [ ("InvalidValue", "PKEXCRResponse", "WrappedData",
1649 "BootstrapResult,Errorsent",
1651 ("MissingAttribute", "PKEXExchangeResponse", "DPPStatus",
1652 "BootstrapResult,Errorsent",
1653 "No DPP Status attribute"),
1654 ("MissingAttribute", "PKEXCRResponse", "BSKey",
1655 "BootstrapResult,Errorsent",
1656 "No valid peer bootstrapping key found") ]
1657 for step
, frame
, attr
, result
, fail
in tests
:
1658 dev
[0].request("FLUSH")
1659 dev
[1].request("FLUSH")
1660 sigma
= start_sigma_dut(dev
[0].ifname
)
1662 run_sigma_dut_dpp_proto_responder_pkex(dev
, step
, frame
, attr
,
1665 stop_sigma_dut(sigma
)
1667 def run_sigma_dut_dpp_proto_responder_pkex(dev
, step
, frame
, attr
, result
, fail
):
1668 t
= threading
.Thread(target
=dpp_proto_init_pkex
, args
=(dev
[1],))
1670 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCode,secret,DPPTimeout,6,DPPStep,%s,DPPFrameType,%s,DPPIEAttribute,%s" % (step
, frame
, attr
), timeout
=10)
1672 if result
not in res
:
1673 raise Exception("Unexpected result: " + res
)
1675 ev
= dev
[1].wait_event(["DPP-FAIL"], timeout
=5)
1676 if ev
is None or fail
not in ev
:
1677 raise Exception("Failure not reported correctly:" + str(ev
))
1679 dev
[1].request("DPP_STOP_LISTEN")
1680 dev
[0].dump_monitor()
1681 dev
[1].dump_monitor()
1683 def init_sigma_dut_dpp_proto_peer_disc_req(dev
, apdev
):
1684 check_dpp_capab(dev
[0])
1685 check_dpp_capab(dev
[1])
1687 csign
= "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
1688 csign_pub
= "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708"
1689 ap_connector
= "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg"
1690 ap_netaccesskey
= "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b"
1692 params
= { "ssid": "DPPNET01",
1694 "wpa_key_mgmt": "DPP",
1695 "rsn_pairwise": "CCMP",
1696 "dpp_connector": ap_connector
,
1697 "dpp_csign": csign_pub
,
1698 "dpp_netaccesskey": ap_netaccesskey
}
1700 hapd
= hostapd
.add_ap(apdev
[0], params
)
1702 raise HwsimSkip("DPP not supported")
1704 dev
[0].set("dpp_config_processing", "2")
1706 cmd
= "DPP_CONFIGURATOR_ADD key=" + csign
1707 res
= dev
[1].request(cmd
);
1709 raise Exception("Failed to add configurator")
1712 addr
= dev
[1].own_addr().replace(':', '')
1713 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr
1714 res
= dev
[1].request(cmd
)
1716 raise Exception("Failed to generate bootstrapping info")
1718 uri0
= dev
[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0
)
1720 dev
[1].set("dpp_configurator_params",
1721 " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id
));
1722 cmd
= "DPP_LISTEN 2437 role=configurator"
1723 if "OK" not in dev
[1].request(cmd
):
1724 raise Exception("Failed to start listen operation")
1726 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0
.encode('hex'))
1727 if "status,COMPLETE" not in res
:
1728 raise Exception("dev_exec_action did not succeed: " + res
)
1730 def test_sigma_dut_dpp_proto_peer_disc_req(dev
, apdev
):
1731 """sigma_dut DPP protocol testing - Peer Discovery Request"""
1732 sigma
= start_sigma_dut(dev
[0].ifname
)
1734 init_sigma_dut_dpp_proto_peer_disc_req(dev
, apdev
)
1736 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPWaitForConnect,Yes,DPPStep,MissingAttribute,DPPFrameType,PeerDiscoveryRequest,DPPIEAttribute,TransactionID", timeout
=10)
1737 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Errorsent" not in res
:
1738 raise Exception("Unexpected result: " + res
)
1740 dev
[0].set("dpp_config_processing", "0")
1741 stop_sigma_dut(sigma
)
1743 def test_sigma_dut_dpp_self_config(dev
, apdev
):
1744 """sigma_dut DPP Configurator enrolling an AP and using self-configuration"""
1745 check_dpp_capab(dev
[0])
1747 hapd
= hostapd
.add_ap(apdev
[0], { "ssid": "unconfigured" })
1748 check_dpp_capab(hapd
)
1750 sigma
= start_sigma_dut(dev
[0].ifname
)
1752 dev
[0].set("dpp_config_processing", "2")
1753 addr
= hapd
.own_addr().replace(':', '')
1754 cmd
= "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr
1755 res
= hapd
.request(cmd
)
1757 raise Exception("Failed to generate bootstrapping info")
1759 uri
= hapd
.request("DPP_BOOTSTRAP_GET_URI %d" % id)
1761 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri
.encode('hex'))
1762 if "status,COMPLETE" not in res
:
1763 raise Exception("dev_exec_action did not succeed: " + res
)
1765 res
= sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,AP,DPPBS,QR,DPPTimeout,6")
1766 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res
:
1767 raise Exception("Unexpected result: " + res
)
1768 update_hapd_config(hapd
)
1770 cmd
= "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPCryptoIdentifier,P-256,DPPBS,QR,DPPAuthRole,Initiator,DPPProvisioningRole,Configurator,DPPAuthDirection,Single,DPPConfIndex,1,DPPTimeout,6,DPPWaitForConnect,Yes,DPPSelfConfigure,Yes"
1771 res
= sigma_dut_cmd(cmd
, timeout
=10)
1772 if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res
:
1773 raise Exception("Unexpected result: " + res
)
1775 stop_sigma_dut(sigma
)
1776 dev
[0].set("dpp_config_processing", "0")