]>
Commit | Line | Data |
---|---|---|
f6f33f8f JM |
1 | # Test cases for sigma_dut |
2 | # Copyright (c) 2017, Qualcomm Atheros, Inc. | |
3 | # | |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
dc60d564 | 7 | import binascii |
f6f33f8f JM |
8 | import logging |
9 | logger = logging.getLogger() | |
10 | import os | |
11 | import socket | |
dc60d564 | 12 | import struct |
f6f33f8f | 13 | import subprocess |
d84c0cf4 | 14 | import threading |
f6f33f8f JM |
15 | import time |
16 | ||
17 | import hostapd | |
18 | from utils import HwsimSkip | |
19 | from hwsim import HWSimRadio | |
211b5d1b | 20 | from test_dpp import check_dpp_capab, update_hapd_config |
002b49ed | 21 | from test_suite_b import check_suite_b_192_capa, suite_b_as_params, suite_b_192_rsa_ap_params |
f6f33f8f JM |
22 | |
23 | def check_sigma_dut(): | |
24 | if not os.path.exists("./sigma_dut"): | |
25 | raise HwsimSkip("sigma_dut not available") | |
26 | ||
d84c0cf4 | 27 | def sigma_dut_cmd(cmd, port=9000, timeout=2): |
f6f33f8f JM |
28 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, |
29 | socket.IPPROTO_TCP) | |
d84c0cf4 | 30 | sock.settimeout(timeout) |
f6f33f8f JM |
31 | addr = ('127.0.0.1', port) |
32 | sock.connect(addr) | |
33 | sock.send(cmd + "\r\n") | |
34 | try: | |
35 | res = sock.recv(1000) | |
36 | running = False | |
37 | done = False | |
38 | for line in res.splitlines(): | |
39 | if line.startswith("status,RUNNING"): | |
40 | running = True | |
41 | elif line.startswith("status,INVALID"): | |
42 | done = True | |
43 | elif line.startswith("status,ERROR"): | |
44 | done = True | |
45 | elif line.startswith("status,COMPLETE"): | |
46 | done = True | |
47 | if running and not done: | |
48 | # Read the actual response | |
49 | res = sock.recv(1000) | |
50 | except: | |
51 | res = '' | |
52 | pass | |
53 | sock.close() | |
54 | res = res.rstrip() | |
55 | logger.debug("sigma_dut: '%s' --> '%s'" % (cmd, res)) | |
56 | return res | |
57 | ||
d84c0cf4 JM |
58 | def sigma_dut_cmd_check(cmd, port=9000, timeout=2): |
59 | res = sigma_dut_cmd(cmd, port=port, timeout=timeout) | |
f6f33f8f JM |
60 | if "COMPLETE" not in res: |
61 | raise Exception("sigma_dut command failed: " + cmd) | |
62 | return res | |
63 | ||
2ef00a36 | 64 | def start_sigma_dut(ifname, debug=False, hostapd_logdir=None, cert_path=None): |
f6f33f8f JM |
65 | check_sigma_dut() |
66 | cmd = [ './sigma_dut', | |
67 | '-M', ifname, | |
68 | '-S', ifname, | |
69 | '-F', '../../hostapd/hostapd', | |
70 | '-G', | |
d84c0cf4 | 71 | '-w', '/var/run/wpa_supplicant/', |
f6f33f8f JM |
72 | '-j', ifname ] |
73 | if debug: | |
74 | cmd += [ '-d' ] | |
2ef00a36 JM |
75 | if hostapd_logdir: |
76 | cmd += [ '-H', hostapd_logdir ] | |
77 | if cert_path: | |
78 | cmd += [ '-C', cert_path ] | |
f6f33f8f JM |
79 | sigma = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
80 | stderr=subprocess.PIPE) | |
81 | for i in range(20): | |
82 | try: | |
83 | res = sigma_dut_cmd("HELLO") | |
84 | break | |
85 | except: | |
86 | time.sleep(0.05) | |
87 | return sigma | |
88 | ||
89 | def stop_sigma_dut(sigma): | |
90 | sigma.terminate() | |
91 | sigma.wait() | |
92 | out, err = sigma.communicate() | |
93 | logger.debug("sigma_dut stdout: " + str(out)) | |
94 | logger.debug("sigma_dut stderr: " + str(err)) | |
95 | ||
96 | def sigma_dut_wait_connected(ifname): | |
97 | for i in range(50): | |
98 | res = sigma_dut_cmd("sta_is_connected,interface," + ifname) | |
99 | if "connected,1" in res: | |
100 | break | |
101 | time.sleep(0.2) | |
102 | if i == 49: | |
103 | raise Exception("Connection did not complete") | |
104 | ||
105 | def test_sigma_dut_basic(dev, apdev): | |
106 | """sigma_dut basic functionality""" | |
107 | sigma = start_sigma_dut(dev[0].ifname) | |
108 | ||
109 | res = sigma_dut_cmd("UNKNOWN") | |
110 | if "status,INVALID,errorCode,Unknown command" not in res: | |
111 | raise Exception("Unexpected sigma_dut response to unknown command") | |
112 | ||
113 | tests = [ ("ca_get_version", "status,COMPLETE,version,1.0"), | |
114 | ("device_get_info", "status,COMPLETE,vendor"), | |
115 | ("device_list_interfaces,interfaceType,foo", "status,ERROR"), | |
116 | ("device_list_interfaces,interfaceType,802.11", | |
117 | "status,COMPLETE,interfaceType,802.11,interfaceID," + dev[0].ifname) ] | |
118 | for cmd, response in tests: | |
119 | res = sigma_dut_cmd(cmd) | |
120 | if response not in res: | |
121 | raise Exception("Unexpected %s response: %s" % (cmd, res)) | |
122 | ||
123 | stop_sigma_dut(sigma) | |
124 | ||
125 | def test_sigma_dut_open(dev, apdev): | |
126 | """sigma_dut controlled open network association""" | |
65fa9d96 JM |
127 | try: |
128 | run_sigma_dut_open(dev, apdev) | |
129 | finally: | |
130 | dev[0].set("ignore_old_scan_res", "0") | |
131 | ||
132 | def run_sigma_dut_open(dev, apdev): | |
f6f33f8f JM |
133 | ifname = dev[0].ifname |
134 | sigma = start_sigma_dut(ifname) | |
135 | ||
136 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
137 | ||
138 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
139 | sigma_dut_cmd_check("sta_set_encryption,interface,%s,ssid,%s,encpType,none" % (ifname, "open")) | |
140 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s" % (ifname, "open")) | |
141 | sigma_dut_wait_connected(ifname) | |
142 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
143 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
144 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
145 | ||
146 | stop_sigma_dut(sigma) | |
147 | ||
148 | def test_sigma_dut_psk_pmf(dev, apdev): | |
149 | """sigma_dut controlled PSK+PMF association""" | |
65fa9d96 JM |
150 | try: |
151 | run_sigma_dut_psk_pmf(dev, apdev) | |
152 | finally: | |
153 | dev[0].set("ignore_old_scan_res", "0") | |
154 | ||
155 | def run_sigma_dut_psk_pmf(dev, apdev): | |
f6f33f8f JM |
156 | ifname = dev[0].ifname |
157 | sigma = start_sigma_dut(ifname) | |
158 | ||
159 | ssid = "test-pmf-required" | |
160 | params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") | |
161 | params["wpa_key_mgmt"] = "WPA-PSK-SHA256" | |
162 | params["ieee80211w"] = "2" | |
163 | hapd = hostapd.add_ap(apdev[0], params) | |
164 | ||
165 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname) | |
166 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
167 | 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")) | |
168 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-pmf-required")) | |
169 | sigma_dut_wait_connected(ifname) | |
170 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
171 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
172 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
173 | ||
174 | stop_sigma_dut(sigma) | |
175 | ||
8cfdca12 JM |
176 | def test_sigma_dut_psk_pmf_bip_cmac_128(dev, apdev): |
177 | """sigma_dut controlled PSK+PMF association with BIP-CMAC-128""" | |
178 | try: | |
179 | run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-CMAC-128", "AES-128-CMAC") | |
180 | finally: | |
181 | dev[0].set("ignore_old_scan_res", "0") | |
182 | ||
183 | def test_sigma_dut_psk_pmf_bip_cmac_256(dev, apdev): | |
184 | """sigma_dut controlled PSK+PMF association with BIP-CMAC-256""" | |
185 | try: | |
186 | run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-CMAC-256", "BIP-CMAC-256") | |
187 | finally: | |
188 | dev[0].set("ignore_old_scan_res", "0") | |
189 | ||
190 | def test_sigma_dut_psk_pmf_bip_gmac_128(dev, apdev): | |
191 | """sigma_dut controlled PSK+PMF association with BIP-GMAC-128""" | |
192 | try: | |
193 | run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-128", "BIP-GMAC-128") | |
194 | finally: | |
195 | dev[0].set("ignore_old_scan_res", "0") | |
196 | ||
197 | def test_sigma_dut_psk_pmf_bip_gmac_256(dev, apdev): | |
198 | """sigma_dut controlled PSK+PMF association with BIP-GMAC-256""" | |
199 | try: | |
200 | run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-256", "BIP-GMAC-256") | |
201 | finally: | |
202 | dev[0].set("ignore_old_scan_res", "0") | |
203 | ||
204 | def test_sigma_dut_psk_pmf_bip_gmac_256_mismatch(dev, apdev): | |
205 | """sigma_dut controlled PSK+PMF association with BIP-GMAC-256 mismatch""" | |
206 | try: | |
207 | run_sigma_dut_psk_pmf_cipher(dev, apdev, "BIP-GMAC-256", "AES-128-CMAC", | |
208 | failure=True) | |
209 | finally: | |
210 | dev[0].set("ignore_old_scan_res", "0") | |
211 | ||
212 | def run_sigma_dut_psk_pmf_cipher(dev, apdev, sigma_cipher, hostapd_cipher, | |
213 | failure=False): | |
214 | ifname = dev[0].ifname | |
215 | sigma = start_sigma_dut(ifname) | |
216 | ||
217 | ssid = "test-pmf-required" | |
218 | params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") | |
219 | params["wpa_key_mgmt"] = "WPA-PSK-SHA256" | |
220 | params["ieee80211w"] = "2" | |
221 | params["group_mgmt_cipher"] = hostapd_cipher | |
222 | hapd = hostapd.add_ap(apdev[0], params) | |
223 | ||
224 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname) | |
225 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
226 | 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)) | |
227 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-pmf-required")) | |
228 | if failure: | |
229 | ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND", | |
230 | "CTRL-EVENT-CONNECTED"], timeout=10) | |
231 | if ev is None: | |
232 | raise Exception("Network selection result not indicated") | |
233 | if "CTRL-EVENT-CONNECTED" in ev: | |
234 | raise Exception("Unexpected connection") | |
235 | res = sigma_dut_cmd("sta_is_connected,interface," + ifname) | |
236 | if "connected,1" in res: | |
237 | raise Exception("Connection reported") | |
238 | else: | |
239 | sigma_dut_wait_connected(ifname) | |
240 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
241 | ||
242 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
243 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
244 | ||
245 | stop_sigma_dut(sigma) | |
246 | ||
1ed508d9 JM |
247 | def test_sigma_dut_sae(dev, apdev): |
248 | """sigma_dut controlled SAE association""" | |
249 | if "SAE" not in dev[0].get_capability("auth_alg"): | |
250 | raise HwsimSkip("SAE not supported") | |
251 | ||
252 | ifname = dev[0].ifname | |
253 | sigma = start_sigma_dut(ifname) | |
254 | ||
255 | ssid = "test-sae" | |
256 | params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") | |
257 | params['wpa_key_mgmt'] = 'SAE' | |
7b498eca | 258 | params["ieee80211w"] = "2" |
1ed508d9 JM |
259 | hapd = hostapd.add_ap(apdev[0], params) |
260 | ||
261 | sigma_dut_cmd_check("sta_reset_default,interface,%s" % ifname) | |
262 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
263 | sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,passphrase,%s,type,SAE,encpType,aes-ccmp,keymgmttype,wpa2" % (ifname, "test-sae", "12345678")) | |
264 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-sae")) | |
265 | sigma_dut_wait_connected(ifname) | |
266 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
267 | if dev[0].get_status_field('sae_group') != '19': | |
268 | raise Exception("Expected default SAE group not used") | |
269 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
270 | ||
271 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
272 | ||
273 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
274 | 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")) | |
275 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-sae")) | |
276 | sigma_dut_wait_connected(ifname) | |
277 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
278 | if dev[0].get_status_field('sae_group') != '20': | |
279 | raise Exception("Expected SAE group not used") | |
280 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
281 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
282 | ||
283 | stop_sigma_dut(sigma) | |
284 | ||
6644069c JM |
285 | def test_sigma_dut_sae_password(dev, apdev): |
286 | """sigma_dut controlled SAE association and long password""" | |
287 | if "SAE" not in dev[0].get_capability("auth_alg"): | |
288 | raise HwsimSkip("SAE not supported") | |
289 | ||
290 | ifname = dev[0].ifname | |
291 | sigma = start_sigma_dut(ifname) | |
292 | ||
293 | try: | |
294 | ssid = "test-sae" | |
295 | params = hostapd.wpa2_params(ssid=ssid) | |
296 | params['sae_password'] = 100*'B' | |
297 | params['wpa_key_mgmt'] = 'SAE' | |
7b498eca | 298 | params["ieee80211w"] = "2" |
6644069c JM |
299 | hapd = hostapd.add_ap(apdev[0], params) |
300 | ||
301 | sigma_dut_cmd_check("sta_reset_default,interface,%s" % ifname) | |
302 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
303 | 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')) | |
304 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-sae")) | |
305 | sigma_dut_wait_connected(ifname) | |
306 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
307 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
308 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
309 | finally: | |
310 | stop_sigma_dut(sigma) | |
311 | ||
f6f33f8f JM |
312 | def test_sigma_dut_sta_override_rsne(dev, apdev): |
313 | """sigma_dut and RSNE override on STA""" | |
65fa9d96 JM |
314 | try: |
315 | run_sigma_dut_sta_override_rsne(dev, apdev) | |
316 | finally: | |
317 | dev[0].set("ignore_old_scan_res", "0") | |
318 | ||
319 | def run_sigma_dut_sta_override_rsne(dev, apdev): | |
f6f33f8f JM |
320 | ifname = dev[0].ifname |
321 | sigma = start_sigma_dut(ifname) | |
322 | ||
323 | ssid = "test-psk" | |
324 | params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") | |
325 | hapd = hostapd.add_ap(apdev[0], params) | |
326 | ||
327 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
328 | ||
329 | tests = [ "30120100000fac040100000fac040100000fac02", | |
330 | "30140100000fac040100000fac040100000fac02ffff" ] | |
331 | for test in tests: | |
332 | sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,type,PSK,passphrase,%s,EncpType,aes-ccmp,KeyMgmtType,wpa2" % (ifname, "test-psk", "12345678")) | |
333 | sigma_dut_cmd_check("dev_configure_ie,interface,%s,IE_Name,RSNE,Contents,%s" % (ifname, test)) | |
334 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-psk")) | |
335 | sigma_dut_wait_connected(ifname) | |
336 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
337 | dev[0].dump_monitor() | |
338 | ||
339 | sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,%s,type,PSK,passphrase,%s,EncpType,aes-ccmp,KeyMgmtType,wpa2" % (ifname, "test-psk", "12345678")) | |
340 | sigma_dut_cmd_check("dev_configure_ie,interface,%s,IE_Name,RSNE,Contents,300101" % ifname) | |
341 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-psk")) | |
342 | ||
343 | ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"]) | |
344 | if ev is None: | |
345 | raise Exception("Association rejection not reported") | |
346 | if "status_code=40" not in ev: | |
347 | raise Exception("Unexpected status code: " + ev) | |
348 | ||
349 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
350 | ||
351 | stop_sigma_dut(sigma) | |
352 | ||
353 | def test_sigma_dut_ap_psk(dev, apdev): | |
354 | """sigma_dut controlled AP""" | |
355 | with HWSimRadio() as (radio, iface): | |
356 | sigma = start_sigma_dut(iface) | |
357 | try: | |
358 | sigma_dut_cmd_check("ap_reset_default") | |
359 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng") | |
360 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK,PSK,12345678") | |
361 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
362 | ||
363 | dev[0].connect("test-psk", psk="12345678", scan_freq="2412") | |
364 | ||
365 | sigma_dut_cmd_check("ap_reset_default") | |
366 | finally: | |
367 | stop_sigma_dut(sigma) | |
368 | ||
20c18348 JM |
369 | def test_sigma_dut_ap_pskhex(dev, apdev, params): |
370 | """sigma_dut controlled AP and PSKHEX""" | |
371 | logdir = os.path.join(params['logdir'], | |
372 | "sigma_dut_ap_pskhex.sigma-hostapd") | |
373 | with HWSimRadio() as (radio, iface): | |
374 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
375 | try: | |
376 | psk = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" | |
377 | sigma_dut_cmd_check("ap_reset_default") | |
378 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng") | |
379 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK,PSKHEX," + psk) | |
380 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
381 | ||
382 | dev[0].connect("test-psk", raw_psk=psk, scan_freq="2412") | |
383 | ||
384 | sigma_dut_cmd_check("ap_reset_default") | |
385 | finally: | |
386 | stop_sigma_dut(sigma) | |
387 | ||
63add34e JM |
388 | def test_sigma_dut_ap_psk_sha256(dev, apdev, params): |
389 | """sigma_dut controlled AP PSK SHA256""" | |
390 | logdir = os.path.join(params['logdir'], | |
391 | "sigma_dut_ap_psk_sha256.sigma-hostapd") | |
392 | with HWSimRadio() as (radio, iface): | |
393 | sigma = start_sigma_dut(iface) | |
394 | try: | |
395 | sigma_dut_cmd_check("ap_reset_default") | |
396 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng") | |
397 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK-256,PSK,12345678") | |
398 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
399 | ||
400 | dev[0].connect("test-psk", key_mgmt="WPA-PSK-SHA256", | |
401 | psk="12345678", scan_freq="2412") | |
402 | ||
403 | sigma_dut_cmd_check("ap_reset_default") | |
404 | finally: | |
405 | stop_sigma_dut(sigma) | |
406 | ||
2ef00a36 JM |
407 | def test_sigma_dut_suite_b(dev, apdev, params): |
408 | """sigma_dut controlled STA Suite B""" | |
409 | check_suite_b_192_capa(dev) | |
410 | logdir = params['logdir'] | |
411 | ||
412 | with open("auth_serv/ec2-ca.pem", "r") as f: | |
413 | with open(os.path.join(logdir, "suite_b_ca.pem"), "w") as f2: | |
414 | f2.write(f.read()) | |
415 | ||
416 | with open("auth_serv/ec2-user.pem", "r") as f: | |
417 | with open("auth_serv/ec2-user.key", "r") as f2: | |
418 | with open(os.path.join(logdir, "suite_b.pem"), "w") as f3: | |
419 | f3.write(f.read()) | |
420 | f3.write(f2.read()) | |
421 | ||
422 | dev[0].flush_scan_cache() | |
423 | params = suite_b_as_params() | |
424 | params['ca_cert'] = 'auth_serv/ec2-ca.pem' | |
425 | params['server_cert'] = 'auth_serv/ec2-server.pem' | |
426 | params['private_key'] = 'auth_serv/ec2-server.key' | |
427 | params['openssl_ciphers'] = 'SUITEB192' | |
428 | hostapd.add_ap(apdev[1], params) | |
429 | ||
430 | params = { "ssid": "test-suite-b", | |
431 | "wpa": "2", | |
432 | "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", | |
433 | "rsn_pairwise": "GCMP-256", | |
434 | "group_mgmt_cipher": "BIP-GMAC-256", | |
435 | "ieee80211w": "2", | |
436 | "ieee8021x": "1", | |
437 | 'auth_server_addr': "127.0.0.1", | |
438 | 'auth_server_port': "18129", | |
439 | 'auth_server_shared_secret': "radius", | |
440 | 'nas_identifier': "nas.w1.fi" } | |
441 | hapd = hostapd.add_ap(apdev[0], params) | |
442 | ||
443 | ifname = dev[0].ifname | |
444 | sigma = start_sigma_dut(ifname, cert_path=logdir) | |
445 | ||
446 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname) | |
447 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
6f90cfd7 | 448 | 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,clientCertificate,suite_b.pem,trustedRootCA,suite_b_ca.pem,CertType,ECC" % (ifname, "test-suite-b")) |
2ef00a36 JM |
449 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-suite-b")) |
450 | sigma_dut_wait_connected(ifname) | |
451 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
452 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
453 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
454 | ||
455 | stop_sigma_dut(sigma) | |
456 | ||
002b49ed JM |
457 | def test_sigma_dut_suite_b_rsa(dev, apdev, params): |
458 | """sigma_dut controlled STA Suite B (RSA)""" | |
459 | check_suite_b_192_capa(dev) | |
460 | logdir = params['logdir'] | |
461 | ||
462 | with open("auth_serv/rsa3072-ca.pem", "r") as f: | |
463 | with open(os.path.join(logdir, "suite_b_ca_rsa.pem"), "w") as f2: | |
464 | f2.write(f.read()) | |
465 | ||
466 | with open("auth_serv/rsa3072-user.pem", "r") as f: | |
467 | with open("auth_serv/rsa3072-user.key", "r") as f2: | |
468 | with open(os.path.join(logdir, "suite_b_rsa.pem"), "w") as f3: | |
469 | f3.write(f.read()) | |
470 | f3.write(f2.read()) | |
471 | ||
472 | dev[0].flush_scan_cache() | |
473 | params = suite_b_192_rsa_ap_params() | |
474 | hapd = hostapd.add_ap(apdev[0], params) | |
475 | ||
476 | ifname = dev[0].ifname | |
477 | sigma = start_sigma_dut(ifname, cert_path=logdir) | |
478 | ||
6f90cfd7 | 479 | cmd = "sta_set_security,type,eaptls,interface,%s,ssid,%s,PairwiseCipher,AES-GCMP-256,GroupCipher,AES-GCMP-256,GroupMgntCipher,BIP-GMAC-256,keymgmttype,SuiteB,clientCertificate,suite_b_rsa.pem,trustedRootCA,suite_b_ca_rsa.pem,CertType,RSA" % (ifname, "test-suite-b") |
002b49ed JM |
480 | |
481 | tests = [ "", | |
482 | ",TLSCipher,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", | |
483 | ",TLSCipher,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" ] | |
484 | for extra in tests: | |
485 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname) | |
486 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
487 | sigma_dut_cmd_check(cmd + extra) | |
488 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "test-suite-b")) | |
489 | sigma_dut_wait_connected(ifname) | |
490 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
491 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
492 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
493 | ||
494 | stop_sigma_dut(sigma) | |
495 | ||
2ef00a36 JM |
496 | def test_sigma_dut_ap_suite_b(dev, apdev, params): |
497 | """sigma_dut controlled AP Suite B""" | |
498 | check_suite_b_192_capa(dev) | |
499 | logdir = os.path.join(params['logdir'], | |
500 | "sigma_dut_ap_suite_b.sigma-hostapd") | |
501 | params = suite_b_as_params() | |
502 | params['ca_cert'] = 'auth_serv/ec2-ca.pem' | |
503 | params['server_cert'] = 'auth_serv/ec2-server.pem' | |
504 | params['private_key'] = 'auth_serv/ec2-server.key' | |
505 | params['openssl_ciphers'] = 'SUITEB192' | |
506 | hostapd.add_ap(apdev[1], params) | |
507 | with HWSimRadio() as (radio, iface): | |
508 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
509 | try: | |
510 | sigma_dut_cmd_check("ap_reset_default") | |
511 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-suite-b,MODE,11ng") | |
512 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,18129,PASSWORD,radius") | |
6f90cfd7 | 513 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,SuiteB") |
2ef00a36 JM |
514 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") |
515 | ||
516 | dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", | |
517 | ieee80211w="2", | |
518 | openssl_ciphers="SUITEB192", | |
519 | eap="TLS", identity="tls user", | |
520 | ca_cert="auth_serv/ec2-ca.pem", | |
521 | client_cert="auth_serv/ec2-user.pem", | |
522 | private_key="auth_serv/ec2-user.key", | |
523 | pairwise="GCMP-256", group="GCMP-256", | |
524 | scan_freq="2412") | |
525 | ||
526 | sigma_dut_cmd_check("ap_reset_default") | |
527 | finally: | |
528 | stop_sigma_dut(sigma) | |
529 | ||
530 | def test_sigma_dut_ap_cipher_gcmp_128(dev, apdev, params): | |
531 | """sigma_dut controlled AP with GCMP-128/BIP-GMAC-128 cipher""" | |
532 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-GCMP-128", "BIP-GMAC-128", | |
533 | "GCMP") | |
534 | ||
535 | def test_sigma_dut_ap_cipher_gcmp_256(dev, apdev, params): | |
536 | """sigma_dut controlled AP with GCMP-256/BIP-GMAC-256 cipher""" | |
537 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-GCMP-256", "BIP-GMAC-256", | |
538 | "GCMP-256") | |
539 | ||
540 | def test_sigma_dut_ap_cipher_ccmp_128(dev, apdev, params): | |
541 | """sigma_dut controlled AP with CCMP-128/BIP-CMAC-128 cipher""" | |
542 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-CCMP-128", "BIP-CMAC-128", | |
543 | "CCMP") | |
544 | ||
545 | def test_sigma_dut_ap_cipher_ccmp_256(dev, apdev, params): | |
546 | """sigma_dut controlled AP with CCMP-256/BIP-CMAC-256 cipher""" | |
547 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-CCMP-256", "BIP-CMAC-256", | |
548 | "CCMP-256") | |
549 | ||
6af3b593 JM |
550 | def test_sigma_dut_ap_cipher_ccmp_gcmp_1(dev, apdev, params): |
551 | """sigma_dut controlled AP with CCMP-128+GCMP-256 ciphers (1)""" | |
552 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-CCMP-128 AES-GCMP-256", | |
553 | "BIP-GMAC-256", "CCMP") | |
554 | ||
555 | def test_sigma_dut_ap_cipher_ccmp_gcmp_2(dev, apdev, params): | |
556 | """sigma_dut controlled AP with CCMP-128+GCMP-256 ciphers (2)""" | |
557 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-CCMP-128 AES-GCMP-256", | |
558 | "BIP-GMAC-256", "GCMP-256", "CCMP") | |
559 | ||
21fd5576 JM |
560 | def test_sigma_dut_ap_cipher_gcmp_256_group_ccmp(dev, apdev, params): |
561 | """sigma_dut controlled AP with GCMP-256/CCMP/BIP-GMAC-256 cipher""" | |
562 | run_sigma_dut_ap_cipher(dev, apdev, params, "AES-GCMP-256", "BIP-GMAC-256", | |
563 | "GCMP-256", "CCMP", "AES-CCMP-128") | |
564 | ||
2ef00a36 | 565 | def run_sigma_dut_ap_cipher(dev, apdev, params, ap_pairwise, ap_group_mgmt, |
21fd5576 | 566 | sta_cipher, sta_cipher_group=None, ap_group=None): |
2ef00a36 JM |
567 | check_suite_b_192_capa(dev) |
568 | logdir = os.path.join(params['logdir'], | |
569 | "sigma_dut_ap_cipher.sigma-hostapd") | |
570 | params = suite_b_as_params() | |
571 | params['ca_cert'] = 'auth_serv/ec2-ca.pem' | |
572 | params['server_cert'] = 'auth_serv/ec2-server.pem' | |
573 | params['private_key'] = 'auth_serv/ec2-server.key' | |
574 | params['openssl_ciphers'] = 'SUITEB192' | |
575 | hostapd.add_ap(apdev[1], params) | |
576 | with HWSimRadio() as (radio, iface): | |
577 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
578 | try: | |
579 | sigma_dut_cmd_check("ap_reset_default") | |
580 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-suite-b,MODE,11ng") | |
581 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,18129,PASSWORD,radius") | |
21fd5576 JM |
582 | cmd = "ap_set_security,NAME,AP,KEYMGNT,SuiteB,PMF,Required,PairwiseCipher,%s,GroupMgntCipher,%s" % (ap_pairwise, ap_group_mgmt) |
583 | if ap_group: | |
584 | cmd += ",GroupCipher,%s" % ap_group | |
585 | sigma_dut_cmd_check(cmd) | |
2ef00a36 JM |
586 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") |
587 | ||
6af3b593 JM |
588 | if sta_cipher_group is None: |
589 | sta_cipher_group = sta_cipher | |
2ef00a36 JM |
590 | dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", |
591 | ieee80211w="2", | |
592 | openssl_ciphers="SUITEB192", | |
593 | eap="TLS", identity="tls user", | |
594 | ca_cert="auth_serv/ec2-ca.pem", | |
595 | client_cert="auth_serv/ec2-user.pem", | |
596 | private_key="auth_serv/ec2-user.key", | |
6af3b593 | 597 | pairwise=sta_cipher, group=sta_cipher_group, |
2ef00a36 JM |
598 | scan_freq="2412") |
599 | ||
600 | sigma_dut_cmd_check("ap_reset_default") | |
601 | finally: | |
602 | stop_sigma_dut(sigma) | |
603 | ||
f6f33f8f JM |
604 | def test_sigma_dut_ap_override_rsne(dev, apdev): |
605 | """sigma_dut controlled AP overriding RSNE""" | |
606 | with HWSimRadio() as (radio, iface): | |
607 | sigma = start_sigma_dut(iface) | |
608 | try: | |
609 | sigma_dut_cmd_check("ap_reset_default") | |
610 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-psk,MODE,11ng") | |
611 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK,PSK,12345678") | |
612 | sigma_dut_cmd_check("dev_configure_ie,NAME,AP,interface,%s,IE_Name,RSNE,Contents,30180100000fac040200ffffffff000fac040100000fac020c00" % iface) | |
613 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
614 | ||
615 | dev[0].connect("test-psk", psk="12345678", scan_freq="2412") | |
616 | ||
617 | sigma_dut_cmd_check("ap_reset_default") | |
618 | finally: | |
619 | stop_sigma_dut(sigma) | |
1ed508d9 | 620 | |
7b498eca | 621 | def test_sigma_dut_ap_sae(dev, apdev, params): |
1ed508d9 | 622 | """sigma_dut controlled AP with SAE""" |
7b498eca JM |
623 | logdir = os.path.join(params['logdir'], |
624 | "sigma_dut_ap_sae.sigma-hostapd") | |
6e6651d0 JM |
625 | if "SAE" not in dev[0].get_capability("auth_alg"): |
626 | raise HwsimSkip("SAE not supported") | |
1ed508d9 | 627 | with HWSimRadio() as (radio, iface): |
7b498eca | 628 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) |
1ed508d9 JM |
629 | try: |
630 | sigma_dut_cmd_check("ap_reset_default") | |
631 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng") | |
632 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-SAE,PSK,12345678") | |
633 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
634 | ||
635 | dev[0].request("SET sae_groups ") | |
636 | dev[0].connect("test-sae", key_mgmt="SAE", psk="12345678", | |
7b498eca | 637 | ieee80211w="2", scan_freq="2412") |
1ed508d9 JM |
638 | if dev[0].get_status_field('sae_group') != '19': |
639 | raise Exception("Expected default SAE group not used") | |
640 | ||
641 | sigma_dut_cmd_check("ap_reset_default") | |
6644069c JM |
642 | finally: |
643 | stop_sigma_dut(sigma) | |
644 | ||
7b498eca | 645 | def test_sigma_dut_ap_sae_password(dev, apdev, params): |
6644069c | 646 | """sigma_dut controlled AP with SAE and long password""" |
7b498eca JM |
647 | logdir = os.path.join(params['logdir'], |
648 | "sigma_dut_ap_sae_password.sigma-hostapd") | |
6e6651d0 JM |
649 | if "SAE" not in dev[0].get_capability("auth_alg"): |
650 | raise HwsimSkip("SAE not supported") | |
6644069c | 651 | with HWSimRadio() as (radio, iface): |
7b498eca | 652 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) |
6644069c JM |
653 | try: |
654 | sigma_dut_cmd_check("ap_reset_default") | |
655 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng") | |
656 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-SAE,PSK," + 100*'C') | |
657 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
658 | ||
659 | dev[0].request("SET sae_groups ") | |
660 | dev[0].connect("test-sae", key_mgmt="SAE", sae_password=100*'C', | |
7b498eca | 661 | ieee80211w="2", scan_freq="2412") |
6644069c JM |
662 | if dev[0].get_status_field('sae_group') != '19': |
663 | raise Exception("Expected default SAE group not used") | |
664 | ||
665 | sigma_dut_cmd_check("ap_reset_default") | |
1ed508d9 JM |
666 | finally: |
667 | stop_sigma_dut(sigma) | |
668 | ||
7b498eca | 669 | def test_sigma_dut_ap_sae_group(dev, apdev, params): |
1ed508d9 | 670 | """sigma_dut controlled AP with SAE and specific group""" |
7b498eca JM |
671 | logdir = os.path.join(params['logdir'], |
672 | "sigma_dut_ap_sae_group.sigma-hostapd") | |
6e6651d0 JM |
673 | if "SAE" not in dev[0].get_capability("auth_alg"): |
674 | raise HwsimSkip("SAE not supported") | |
1ed508d9 | 675 | with HWSimRadio() as (radio, iface): |
7b498eca | 676 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) |
1ed508d9 JM |
677 | try: |
678 | sigma_dut_cmd_check("ap_reset_default") | |
679 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng") | |
680 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-SAE,PSK,12345678,ECGroupID,20") | |
681 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
682 | ||
683 | dev[0].request("SET sae_groups ") | |
684 | dev[0].connect("test-sae", key_mgmt="SAE", psk="12345678", | |
7b498eca | 685 | ieee80211w="2", scan_freq="2412") |
1ed508d9 JM |
686 | if dev[0].get_status_field('sae_group') != '20': |
687 | raise Exception("Expected SAE group not used") | |
688 | ||
689 | sigma_dut_cmd_check("ap_reset_default") | |
690 | finally: | |
691 | stop_sigma_dut(sigma) | |
692 | ||
7b498eca | 693 | def test_sigma_dut_ap_psk_sae(dev, apdev, params): |
1ed508d9 | 694 | """sigma_dut controlled AP with PSK+SAE""" |
6e6651d0 JM |
695 | if "SAE" not in dev[0].get_capability("auth_alg"): |
696 | raise HwsimSkip("SAE not supported") | |
7b498eca JM |
697 | logdir = os.path.join(params['logdir'], |
698 | "sigma_dut_ap_psk_sae.sigma-hostapd") | |
1ed508d9 | 699 | with HWSimRadio() as (radio, iface): |
7b498eca | 700 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) |
1ed508d9 JM |
701 | try: |
702 | sigma_dut_cmd_check("ap_reset_default") | |
703 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-sae,MODE,11ng") | |
704 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-PSK-SAE,PSK,12345678") | |
705 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
706 | ||
7b498eca JM |
707 | dev[2].request("SET sae_groups ") |
708 | dev[2].connect("test-sae", key_mgmt="SAE", psk="12345678", | |
709 | scan_freq="2412", ieee80211w="0", wait_connect=False) | |
1ed508d9 JM |
710 | dev[0].request("SET sae_groups ") |
711 | dev[0].connect("test-sae", key_mgmt="SAE", psk="12345678", | |
7b498eca | 712 | scan_freq="2412", ieee80211w="2") |
1ed508d9 JM |
713 | dev[1].connect("test-sae", psk="12345678", scan_freq="2412") |
714 | ||
7b498eca JM |
715 | ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) |
716 | dev[2].request("DISCONNECT") | |
717 | if ev is not None: | |
718 | raise Exception("Unexpected connection without PMF") | |
719 | ||
1ed508d9 JM |
720 | sigma_dut_cmd_check("ap_reset_default") |
721 | finally: | |
722 | stop_sigma_dut(sigma) | |
b9c0e1fa JM |
723 | |
724 | def test_sigma_dut_owe(dev, apdev): | |
725 | """sigma_dut controlled OWE station""" | |
726 | try: | |
727 | run_sigma_dut_owe(dev, apdev) | |
728 | finally: | |
729 | dev[0].set("ignore_old_scan_res", "0") | |
730 | ||
731 | def run_sigma_dut_owe(dev, apdev): | |
732 | if "OWE" not in dev[0].get_capability("key_mgmt"): | |
733 | raise HwsimSkip("OWE not supported") | |
734 | ||
735 | ifname = dev[0].ifname | |
736 | sigma = start_sigma_dut(ifname) | |
737 | ||
738 | try: | |
739 | params = { "ssid": "owe", | |
740 | "wpa": "2", | |
741 | "wpa_key_mgmt": "OWE", | |
7b498eca | 742 | "ieee80211w": "2", |
b9c0e1fa JM |
743 | "rsn_pairwise": "CCMP" } |
744 | hapd = hostapd.add_ap(apdev[0], params) | |
745 | bssid = hapd.own_addr() | |
746 | ||
747 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,WPA3" % ifname) | |
748 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
749 | sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,owe,Type,OWE" % ifname) | |
750 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,owe,channel,1" % ifname) | |
751 | sigma_dut_wait_connected(ifname) | |
752 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
753 | ||
754 | dev[0].dump_monitor() | |
755 | sigma_dut_cmd("sta_reassoc,interface,%s,Channel,1,bssid,%s" % (ifname, bssid)) | |
756 | dev[0].wait_connected() | |
757 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
758 | dev[0].wait_disconnected() | |
759 | dev[0].dump_monitor() | |
760 | ||
761 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,WPA3" % ifname) | |
762 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
763 | sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,owe,Type,OWE,ECGroupID,20" % ifname) | |
764 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,owe,channel,1" % ifname) | |
765 | sigma_dut_wait_connected(ifname) | |
766 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
e30de6c2 JM |
767 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) |
768 | dev[0].wait_disconnected() | |
769 | dev[0].dump_monitor() | |
770 | ||
771 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,WPA3" % ifname) | |
772 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
773 | sigma_dut_cmd_check("sta_set_security,interface,%s,ssid,owe,Type,OWE,ECGroupID,0" % ifname) | |
774 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,owe,channel,1" % ifname) | |
775 | ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout=10) | |
776 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
777 | if ev is None: | |
778 | raise Exception("Association not rejected") | |
779 | if "status_code=77" not in ev: | |
780 | raise Exception("Unexpected rejection reason: " + ev) | |
b9c0e1fa JM |
781 | |
782 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
783 | finally: | |
784 | stop_sigma_dut(sigma) | |
785 | ||
7b498eca | 786 | def test_sigma_dut_ap_owe(dev, apdev, params): |
b9c0e1fa | 787 | """sigma_dut controlled AP with OWE""" |
7b498eca JM |
788 | logdir = os.path.join(params['logdir'], |
789 | "sigma_dut_ap_owe.sigma-hostapd") | |
b9c0e1fa JM |
790 | if "OWE" not in dev[0].get_capability("key_mgmt"): |
791 | raise HwsimSkip("OWE not supported") | |
792 | with HWSimRadio() as (radio, iface): | |
7b498eca | 793 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) |
b9c0e1fa JM |
794 | try: |
795 | sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3") | |
796 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,owe,MODE,11ng") | |
797 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,OWE") | |
798 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
799 | ||
7b498eca JM |
800 | dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", |
801 | scan_freq="2412") | |
b9c0e1fa JM |
802 | |
803 | sigma_dut_cmd_check("ap_reset_default") | |
804 | finally: | |
805 | stop_sigma_dut(sigma) | |
7f811be5 JM |
806 | |
807 | def test_sigma_dut_ap_owe_ecgroupid(dev, apdev): | |
808 | """sigma_dut controlled AP with OWE and ECGroupID""" | |
809 | if "OWE" not in dev[0].get_capability("key_mgmt"): | |
810 | raise HwsimSkip("OWE not supported") | |
811 | with HWSimRadio() as (radio, iface): | |
812 | sigma = start_sigma_dut(iface) | |
813 | try: | |
814 | sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3") | |
815 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,owe,MODE,11ng") | |
816 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,OWE,ECGroupID,20 21,PMF,Required") | |
817 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
818 | ||
819 | dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", | |
820 | owe_group="20", scan_freq="2412") | |
821 | dev[0].request("REMOVE_NETWORK all") | |
822 | dev[0].wait_disconnected() | |
823 | ||
824 | dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", | |
825 | owe_group="21", scan_freq="2412") | |
826 | dev[0].request("REMOVE_NETWORK all") | |
827 | dev[0].wait_disconnected() | |
828 | ||
829 | dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", | |
830 | owe_group="19", scan_freq="2412", wait_connect=False) | |
831 | ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout=10) | |
832 | dev[0].request("DISCONNECT") | |
833 | if ev is None: | |
834 | raise Exception("Association not rejected") | |
835 | if "status_code=77" not in ev: | |
836 | raise Exception("Unexpected rejection reason: " + ev) | |
837 | dev[0].dump_monitor() | |
838 | ||
839 | sigma_dut_cmd_check("ap_reset_default") | |
840 | finally: | |
841 | stop_sigma_dut(sigma) | |
86fd7d70 JM |
842 | |
843 | def test_sigma_dut_ap_owe_transition_mode(dev, apdev, params): | |
844 | """sigma_dut controlled AP with OWE and transition mode""" | |
845 | if "OWE" not in dev[0].get_capability("key_mgmt"): | |
846 | raise HwsimSkip("OWE not supported") | |
847 | logdir = os.path.join(params['logdir'], | |
848 | "sigma_dut_ap_owe_transition_mode.sigma-hostapd") | |
849 | with HWSimRadio() as (radio, iface): | |
850 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
851 | try: | |
852 | sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3") | |
853 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,WLAN_TAG,1,CHANNEL,1,SSID,owe,MODE,11ng") | |
854 | sigma_dut_cmd_check("ap_set_security,NAME,AP,WLAN_TAG,1,KEYMGNT,OWE") | |
855 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,WLAN_TAG,2,CHANNEL,1,SSID,owe,MODE,11ng") | |
856 | sigma_dut_cmd_check("ap_set_security,NAME,AP,WLAN_TAG,2,KEYMGNT,NONE") | |
857 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
858 | ||
89c343e8 JM |
859 | res1 = sigma_dut_cmd_check("ap_get_mac_address,NAME,AP,WLAN_TAG,1,Interface,24G") |
860 | res2 = sigma_dut_cmd_check("ap_get_mac_address,NAME,AP,WLAN_TAG,2,Interface,24G") | |
861 | ||
7b498eca JM |
862 | dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", |
863 | scan_freq="2412") | |
86fd7d70 | 864 | dev[1].connect("owe", key_mgmt="NONE", scan_freq="2412") |
89c343e8 JM |
865 | if dev[0].get_status_field('bssid') not in res1: |
866 | raise Exception("Unexpected ap_get_mac_address WLAN_TAG,1: " + res1) | |
867 | if dev[1].get_status_field('bssid') not in res2: | |
868 | raise Exception("Unexpected ap_get_mac_address WLAN_TAG,2: " + res2) | |
86fd7d70 JM |
869 | |
870 | sigma_dut_cmd_check("ap_reset_default") | |
871 | finally: | |
872 | stop_sigma_dut(sigma) | |
d84c0cf4 | 873 | |
c5238c48 JM |
874 | def test_sigma_dut_ap_owe_transition_mode_2(dev, apdev, params): |
875 | """sigma_dut controlled AP with OWE and transition mode (2)""" | |
876 | if "OWE" not in dev[0].get_capability("key_mgmt"): | |
877 | raise HwsimSkip("OWE not supported") | |
878 | logdir = os.path.join(params['logdir'], | |
879 | "sigma_dut_ap_owe_transition_mode_2.sigma-hostapd") | |
880 | with HWSimRadio() as (radio, iface): | |
881 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
882 | try: | |
883 | sigma_dut_cmd_check("ap_reset_default,NAME,AP,Program,WPA3") | |
884 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,WLAN_TAG,1,CHANNEL,1,SSID,owe,MODE,11ng") | |
885 | sigma_dut_cmd_check("ap_set_security,NAME,AP,WLAN_TAG,1,KEYMGNT,NONE") | |
886 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,WLAN_TAG,2,CHANNEL,1,MODE,11ng") | |
887 | sigma_dut_cmd_check("ap_set_security,NAME,AP,WLAN_TAG,2,KEYMGNT,OWE") | |
888 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
889 | ||
890 | res1 = sigma_dut_cmd_check("ap_get_mac_address,NAME,AP,WLAN_TAG,1,Interface,24G") | |
891 | res2 = sigma_dut_cmd_check("ap_get_mac_address,NAME,AP,WLAN_TAG,2,Interface,24G") | |
892 | ||
893 | dev[0].connect("owe", key_mgmt="OWE", ieee80211w="2", | |
894 | scan_freq="2412") | |
895 | dev[1].connect("owe", key_mgmt="NONE", scan_freq="2412") | |
896 | if dev[0].get_status_field('bssid') not in res2: | |
897 | raise Exception("Unexpected ap_get_mac_address WLAN_TAG,2: " + res1) | |
898 | if dev[1].get_status_field('bssid') not in res1: | |
899 | raise Exception("Unexpected ap_get_mac_address WLAN_TAG,1: " + res2) | |
900 | ||
901 | sigma_dut_cmd_check("ap_reset_default") | |
902 | finally: | |
903 | stop_sigma_dut(sigma) | |
904 | ||
d84c0cf4 JM |
905 | def dpp_init_enrollee(dev, id1): |
906 | logger.info("Starting DPP initiator/enrollee in a thread") | |
907 | time.sleep(1) | |
908 | cmd = "DPP_AUTH_INIT peer=%d role=enrollee" % id1 | |
909 | if "OK" not in dev.request(cmd): | |
910 | raise Exception("Failed to initiate DPP Authentication") | |
911 | ev = dev.wait_event(["DPP-CONF-RECEIVED"], timeout=5) | |
912 | if ev is None: | |
913 | raise Exception("DPP configuration not completed (Enrollee)") | |
914 | logger.info("DPP initiator/enrollee done") | |
915 | ||
916 | def test_sigma_dut_dpp_qr_resp_1(dev, apdev): | |
917 | """sigma_dut DPP/QR responder (conf index 1)""" | |
918 | run_sigma_dut_dpp_qr_resp(dev, apdev, 1) | |
919 | ||
920 | def test_sigma_dut_dpp_qr_resp_2(dev, apdev): | |
921 | """sigma_dut DPP/QR responder (conf index 2)""" | |
922 | run_sigma_dut_dpp_qr_resp(dev, apdev, 2) | |
923 | ||
924 | def test_sigma_dut_dpp_qr_resp_3(dev, apdev): | |
925 | """sigma_dut DPP/QR responder (conf index 3)""" | |
926 | run_sigma_dut_dpp_qr_resp(dev, apdev, 3) | |
927 | ||
928 | def test_sigma_dut_dpp_qr_resp_4(dev, apdev): | |
929 | """sigma_dut DPP/QR responder (conf index 4)""" | |
930 | run_sigma_dut_dpp_qr_resp(dev, apdev, 4) | |
931 | ||
23c45cd0 JM |
932 | def test_sigma_dut_dpp_qr_resp_5(dev, apdev): |
933 | """sigma_dut DPP/QR responder (conf index 5)""" | |
934 | run_sigma_dut_dpp_qr_resp(dev, apdev, 5) | |
935 | ||
936 | def test_sigma_dut_dpp_qr_resp_6(dev, apdev): | |
937 | """sigma_dut DPP/QR responder (conf index 6)""" | |
938 | run_sigma_dut_dpp_qr_resp(dev, apdev, 6) | |
939 | ||
940 | def test_sigma_dut_dpp_qr_resp_7(dev, apdev): | |
941 | """sigma_dut DPP/QR responder (conf index 7)""" | |
942 | run_sigma_dut_dpp_qr_resp(dev, apdev, 7) | |
943 | ||
b014624b JM |
944 | def test_sigma_dut_dpp_qr_resp_chan_list(dev, apdev): |
945 | """sigma_dut DPP/QR responder (channel list override)""" | |
946 | run_sigma_dut_dpp_qr_resp(dev, apdev, 1, chan_list='81/2 81/6 81/1', | |
947 | listen_chan=2) | |
948 | ||
949 | def run_sigma_dut_dpp_qr_resp(dev, apdev, conf_idx, chan_list=None, | |
950 | listen_chan=None): | |
d84c0cf4 JM |
951 | check_dpp_capab(dev[0]) |
952 | check_dpp_capab(dev[1]) | |
953 | sigma = start_sigma_dut(dev[0].ifname) | |
954 | try: | |
b014624b JM |
955 | cmd = "dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR" |
956 | if chan_list: | |
957 | cmd += ",DPPChannelList," + chan_list | |
958 | res = sigma_dut_cmd(cmd) | |
d84c0cf4 JM |
959 | if "status,COMPLETE" not in res: |
960 | raise Exception("dev_exec_action did not succeed: " + res) | |
961 | hex = res.split(',')[3] | |
962 | uri = hex.decode('hex') | |
963 | logger.info("URI from sigma_dut: " + uri) | |
964 | ||
965 | res = dev[1].request("DPP_QR_CODE " + uri) | |
966 | if "FAIL" in res: | |
967 | raise Exception("Failed to parse QR Code URI") | |
968 | id1 = int(res) | |
969 | ||
970 | t = threading.Thread(target=dpp_init_enrollee, args=(dev[1], id1)) | |
971 | t.start() | |
14f8e081 | 972 | 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 |
b014624b JM |
973 | if listen_chan: |
974 | cmd += ",DPPListenChannel," + str(listen_chan) | |
975 | res = sigma_dut_cmd(cmd, timeout=10) | |
d84c0cf4 JM |
976 | t.join() |
977 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: | |
978 | raise Exception("Unexpected result: " + res) | |
979 | finally: | |
980 | stop_sigma_dut(sigma) | |
981 | ||
982 | def test_sigma_dut_dpp_qr_init_enrollee(dev, apdev): | |
983 | """sigma_dut DPP/QR initiator as Enrollee""" | |
984 | check_dpp_capab(dev[0]) | |
985 | check_dpp_capab(dev[1]) | |
986 | ||
987 | csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
988 | csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
989 | ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" | |
990 | ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" | |
991 | ||
992 | params = { "ssid": "DPPNET01", | |
993 | "wpa": "2", | |
3e3d634f | 994 | "ieee80211w": "2", |
d84c0cf4 JM |
995 | "wpa_key_mgmt": "DPP", |
996 | "rsn_pairwise": "CCMP", | |
997 | "dpp_connector": ap_connector, | |
998 | "dpp_csign": csign_pub, | |
999 | "dpp_netaccesskey": ap_netaccesskey } | |
1000 | try: | |
1001 | hapd = hostapd.add_ap(apdev[0], params) | |
1002 | except: | |
1003 | raise HwsimSkip("DPP not supported") | |
1004 | ||
1005 | sigma = start_sigma_dut(dev[0].ifname) | |
1006 | try: | |
1007 | dev[0].set("dpp_config_processing", "2") | |
1008 | ||
1009 | cmd = "DPP_CONFIGURATOR_ADD key=" + csign | |
1010 | res = dev[1].request(cmd); | |
1011 | if "FAIL" in res: | |
1012 | raise Exception("Failed to add configurator") | |
1013 | conf_id = int(res) | |
1014 | ||
1015 | addr = dev[1].own_addr().replace(':', '') | |
1016 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1017 | res = dev[1].request(cmd) | |
1018 | if "FAIL" in res: | |
1019 | raise Exception("Failed to generate bootstrapping info") | |
1020 | id0 = int(res) | |
1021 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1022 | ||
1023 | dev[1].set("dpp_configurator_params", | |
1024 | " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id)); | |
1025 | cmd = "DPP_LISTEN 2437 role=configurator" | |
1026 | if "OK" not in dev[1].request(cmd): | |
1027 | raise Exception("Failed to start listen operation") | |
1028 | ||
1029 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1030 | if "status,COMPLETE" not in res: | |
1031 | raise Exception("dev_exec_action did not succeed: " + res) | |
1032 | ||
1033 | 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) | |
1034 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res: | |
1035 | raise Exception("Unexpected result: " + res) | |
1036 | finally: | |
1037 | dev[0].set("dpp_config_processing", "0") | |
1038 | stop_sigma_dut(sigma) | |
1039 | ||
1040 | def test_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev): | |
1041 | """sigma_dut DPP/QR (mutual) initiator as Enrollee""" | |
33cddd7f JM |
1042 | run_sigma_dut_dpp_qr_mutual_init_enrollee_check(dev, apdev) |
1043 | ||
1044 | def test_sigma_dut_dpp_qr_mutual_init_enrollee_check(dev, apdev): | |
1045 | """sigma_dut DPP/QR (mutual) initiator as Enrollee (extra check)""" | |
1046 | run_sigma_dut_dpp_qr_mutual_init_enrollee_check(dev, apdev, | |
1047 | extra="DPPAuthDirection,Mutual,") | |
1048 | ||
1049 | def run_sigma_dut_dpp_qr_mutual_init_enrollee_check(dev, apdev, extra=''): | |
d84c0cf4 JM |
1050 | check_dpp_capab(dev[0]) |
1051 | check_dpp_capab(dev[1]) | |
1052 | ||
1053 | csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
1054 | csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
1055 | ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" | |
1056 | ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" | |
1057 | ||
1058 | params = { "ssid": "DPPNET01", | |
1059 | "wpa": "2", | |
3e3d634f | 1060 | "ieee80211w": "2", |
d84c0cf4 JM |
1061 | "wpa_key_mgmt": "DPP", |
1062 | "rsn_pairwise": "CCMP", | |
1063 | "dpp_connector": ap_connector, | |
1064 | "dpp_csign": csign_pub, | |
1065 | "dpp_netaccesskey": ap_netaccesskey } | |
1066 | try: | |
1067 | hapd = hostapd.add_ap(apdev[0], params) | |
1068 | except: | |
1069 | raise HwsimSkip("DPP not supported") | |
1070 | ||
1071 | sigma = start_sigma_dut(dev[0].ifname) | |
1072 | try: | |
1073 | dev[0].set("dpp_config_processing", "2") | |
1074 | ||
1075 | cmd = "DPP_CONFIGURATOR_ADD key=" + csign | |
1076 | res = dev[1].request(cmd); | |
1077 | if "FAIL" in res: | |
1078 | raise Exception("Failed to add configurator") | |
1079 | conf_id = int(res) | |
1080 | ||
1081 | addr = dev[1].own_addr().replace(':', '') | |
1082 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1083 | res = dev[1].request(cmd) | |
1084 | if "FAIL" in res: | |
1085 | raise Exception("Failed to generate bootstrapping info") | |
1086 | id0 = int(res) | |
1087 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1088 | ||
1089 | dev[1].set("dpp_configurator_params", | |
1090 | " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id)); | |
1091 | cmd = "DPP_LISTEN 2437 role=configurator qr=mutual" | |
1092 | if "OK" not in dev[1].request(cmd): | |
1093 | raise Exception("Failed to start listen operation") | |
1094 | ||
1095 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") | |
1096 | if "status,COMPLETE" not in res: | |
1097 | raise Exception("dev_exec_action did not succeed: " + res) | |
1098 | hex = res.split(',')[3] | |
1099 | uri = hex.decode('hex') | |
1100 | logger.info("URI from sigma_dut: " + uri) | |
1101 | ||
1102 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1103 | if "FAIL" in res: | |
1104 | raise Exception("Failed to parse QR Code URI") | |
1105 | id1 = int(res) | |
1106 | ||
1107 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1108 | if "status,COMPLETE" not in res: | |
1109 | raise Exception("dev_exec_action did not succeed: " + res) | |
1110 | ||
33cddd7f | 1111 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,%sDPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPWaitForConnect,Yes" % extra, timeout=10) |
d84c0cf4 JM |
1112 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res: |
1113 | raise Exception("Unexpected result: " + res) | |
1114 | finally: | |
1115 | dev[0].set("dpp_config_processing", "0") | |
1116 | stop_sigma_dut(sigma) | |
1117 | ||
1118 | def dpp_init_conf_mutual(dev, id1, conf_id, own_id=None): | |
1119 | time.sleep(1) | |
1120 | logger.info("Starting DPP initiator/configurator in a thread") | |
1121 | cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp ssid=%s configurator=%d" % (id1, "DPPNET01".encode("hex"), conf_id) | |
1122 | if own_id is not None: | |
1123 | cmd += " own=%d" % own_id | |
1124 | if "OK" not in dev.request(cmd): | |
1125 | raise Exception("Failed to initiate DPP Authentication") | |
1126 | ev = dev.wait_event(["DPP-CONF-SENT"], timeout=10) | |
1127 | if ev is None: | |
1128 | raise Exception("DPP configuration not completed (Configurator)") | |
1129 | logger.info("DPP initiator/configurator done") | |
1130 | ||
1131 | def test_sigma_dut_dpp_qr_mutual_resp_enrollee(dev, apdev): | |
1132 | """sigma_dut DPP/QR (mutual) responder as Enrollee""" | |
71db91db JM |
1133 | run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev, apdev) |
1134 | ||
1135 | def test_sigma_dut_dpp_qr_mutual_resp_enrollee_pending(dev, apdev): | |
1136 | """sigma_dut DPP/QR (mutual) responder as Enrollee (response pending)""" | |
1137 | run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev, apdev, ',DPPDelayQRResponse,1') | |
1138 | ||
1139 | def run_sigma_dut_dpp_qr_mutual_resp_enrollee(dev, apdev, extra=None): | |
d84c0cf4 JM |
1140 | check_dpp_capab(dev[0]) |
1141 | check_dpp_capab(dev[1]) | |
1142 | ||
1143 | csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
1144 | csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
1145 | ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" | |
1146 | ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" | |
1147 | ||
1148 | params = { "ssid": "DPPNET01", | |
1149 | "wpa": "2", | |
3e3d634f | 1150 | "ieee80211w": "2", |
d84c0cf4 JM |
1151 | "wpa_key_mgmt": "DPP", |
1152 | "rsn_pairwise": "CCMP", | |
1153 | "dpp_connector": ap_connector, | |
1154 | "dpp_csign": csign_pub, | |
1155 | "dpp_netaccesskey": ap_netaccesskey } | |
1156 | try: | |
1157 | hapd = hostapd.add_ap(apdev[0], params) | |
1158 | except: | |
1159 | raise HwsimSkip("DPP not supported") | |
1160 | ||
1161 | sigma = start_sigma_dut(dev[0].ifname) | |
1162 | try: | |
1163 | dev[0].set("dpp_config_processing", "2") | |
1164 | ||
1165 | cmd = "DPP_CONFIGURATOR_ADD key=" + csign | |
1166 | res = dev[1].request(cmd); | |
1167 | if "FAIL" in res: | |
1168 | raise Exception("Failed to add configurator") | |
1169 | conf_id = int(res) | |
1170 | ||
1171 | addr = dev[1].own_addr().replace(':', '') | |
1172 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1173 | res = dev[1].request(cmd) | |
1174 | if "FAIL" in res: | |
1175 | raise Exception("Failed to generate bootstrapping info") | |
1176 | id0 = int(res) | |
1177 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1178 | ||
d84c0cf4 JM |
1179 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") |
1180 | if "status,COMPLETE" not in res: | |
1181 | raise Exception("dev_exec_action did not succeed: " + res) | |
1182 | hex = res.split(',')[3] | |
1183 | uri = hex.decode('hex') | |
1184 | logger.info("URI from sigma_dut: " + uri) | |
1185 | ||
1186 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1187 | if "FAIL" in res: | |
1188 | raise Exception("Failed to parse QR Code URI") | |
1189 | id1 = int(res) | |
1190 | ||
1191 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1192 | if "status,COMPLETE" not in res: | |
1193 | raise Exception("dev_exec_action did not succeed: " + res) | |
1194 | ||
1195 | t = threading.Thread(target=dpp_init_conf_mutual, | |
1196 | args=(dev[1], id1, conf_id, id0)) | |
1197 | t.start() | |
1198 | ||
71db91db JM |
1199 | cmd = "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,20,DPPWaitForConnect,Yes" |
1200 | if extra: | |
1201 | cmd += extra | |
1202 | res = sigma_dut_cmd(cmd, timeout=25) | |
d84c0cf4 JM |
1203 | t.join() |
1204 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res: | |
1205 | raise Exception("Unexpected result: " + res) | |
1206 | finally: | |
1207 | dev[0].set("dpp_config_processing", "0") | |
1208 | stop_sigma_dut(sigma) | |
1209 | ||
e486e5fd JM |
1210 | def dpp_resp_conf_mutual(dev, conf_id, uri): |
1211 | logger.info("Starting DPP responder/configurator in a thread") | |
1212 | dev.set("dpp_configurator_params", | |
1213 | " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id)); | |
1214 | cmd = "DPP_LISTEN 2437 role=configurator qr=mutual" | |
1215 | if "OK" not in dev.request(cmd): | |
1216 | raise Exception("Failed to initiate DPP listen") | |
1217 | if uri: | |
1218 | ev = dev.wait_event(["DPP-SCAN-PEER-QR-CODE"], timeout=10) | |
1219 | if ev is None: | |
1220 | raise Exception("QR Code scan for mutual authentication not requested") | |
1221 | res = dev.request("DPP_QR_CODE " + uri) | |
1222 | if "FAIL" in res: | |
1223 | raise Exception("Failed to parse QR Code URI") | |
1224 | ev = dev.wait_event(["DPP-CONF-SENT"], timeout=10) | |
1225 | if ev is None: | |
1226 | raise Exception("DPP configuration not completed (Configurator)") | |
1227 | logger.info("DPP responder/configurator done") | |
1228 | ||
1229 | def test_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev): | |
1230 | """sigma_dut DPP/QR (mutual) initiator as Enrollee""" | |
1231 | run_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev, False) | |
1232 | ||
1233 | def test_sigma_dut_dpp_qr_mutual_init_enrollee_pending(dev, apdev): | |
1234 | """sigma_dut DPP/QR (mutual) initiator as Enrollee (response pending)""" | |
1235 | run_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev, True) | |
1236 | ||
1237 | def run_sigma_dut_dpp_qr_mutual_init_enrollee(dev, apdev, resp_pending): | |
1238 | check_dpp_capab(dev[0]) | |
1239 | check_dpp_capab(dev[1]) | |
1240 | ||
1241 | csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
1242 | csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
1243 | ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" | |
1244 | ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" | |
1245 | ||
1246 | params = { "ssid": "DPPNET01", | |
1247 | "wpa": "2", | |
3e3d634f | 1248 | "ieee80211w": "2", |
e486e5fd JM |
1249 | "wpa_key_mgmt": "DPP", |
1250 | "rsn_pairwise": "CCMP", | |
1251 | "dpp_connector": ap_connector, | |
1252 | "dpp_csign": csign_pub, | |
1253 | "dpp_netaccesskey": ap_netaccesskey } | |
1254 | try: | |
1255 | hapd = hostapd.add_ap(apdev[0], params) | |
1256 | except: | |
1257 | raise HwsimSkip("DPP not supported") | |
1258 | ||
1259 | sigma = start_sigma_dut(dev[0].ifname) | |
1260 | try: | |
1261 | dev[0].set("dpp_config_processing", "2") | |
1262 | ||
1263 | cmd = "DPP_CONFIGURATOR_ADD key=" + csign | |
1264 | res = dev[1].request(cmd); | |
1265 | if "FAIL" in res: | |
1266 | raise Exception("Failed to add configurator") | |
1267 | conf_id = int(res) | |
1268 | ||
1269 | addr = dev[1].own_addr().replace(':', '') | |
1270 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1271 | res = dev[1].request(cmd) | |
1272 | if "FAIL" in res: | |
1273 | raise Exception("Failed to generate bootstrapping info") | |
1274 | id0 = int(res) | |
1275 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1276 | ||
1277 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") | |
1278 | if "status,COMPLETE" not in res: | |
1279 | raise Exception("dev_exec_action did not succeed: " + res) | |
1280 | hex = res.split(',')[3] | |
1281 | uri = hex.decode('hex') | |
1282 | logger.info("URI from sigma_dut: " + uri) | |
1283 | ||
1284 | if not resp_pending: | |
1285 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1286 | if "FAIL" in res: | |
1287 | raise Exception("Failed to parse QR Code URI") | |
1288 | uri = None | |
1289 | ||
1290 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1291 | if "status,COMPLETE" not in res: | |
1292 | raise Exception("dev_exec_action did not succeed: " + res) | |
1293 | ||
1294 | t = threading.Thread(target=dpp_resp_conf_mutual, | |
1295 | args=(dev[1], conf_id, uri)) | |
1296 | t.start() | |
1297 | ||
1298 | time.sleep(1) | |
33cddd7f | 1299 | cmd = "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,10,DPPWaitForConnect,Yes" |
e486e5fd JM |
1300 | res = sigma_dut_cmd(cmd, timeout=15) |
1301 | t.join() | |
1302 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res: | |
1303 | raise Exception("Unexpected result: " + res) | |
1304 | finally: | |
1305 | dev[0].set("dpp_config_processing", "0") | |
1306 | stop_sigma_dut(sigma) | |
1307 | ||
d84c0cf4 JM |
1308 | def test_sigma_dut_dpp_qr_init_enrollee_psk(dev, apdev): |
1309 | """sigma_dut DPP/QR initiator as Enrollee (PSK)""" | |
1310 | check_dpp_capab(dev[0]) | |
1311 | check_dpp_capab(dev[1]) | |
1312 | ||
1313 | params = hostapd.wpa2_params(ssid="DPPNET01", | |
1314 | passphrase="ThisIsDppPassphrase") | |
1315 | hapd = hostapd.add_ap(apdev[0], params) | |
1316 | ||
1317 | sigma = start_sigma_dut(dev[0].ifname) | |
1318 | try: | |
1319 | dev[0].set("dpp_config_processing", "2") | |
1320 | ||
1321 | cmd = "DPP_CONFIGURATOR_ADD" | |
1322 | res = dev[1].request(cmd); | |
1323 | if "FAIL" in res: | |
1324 | raise Exception("Failed to add configurator") | |
1325 | conf_id = int(res) | |
1326 | ||
1327 | addr = dev[1].own_addr().replace(':', '') | |
1328 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1329 | res = dev[1].request(cmd) | |
1330 | if "FAIL" in res: | |
1331 | raise Exception("Failed to generate bootstrapping info") | |
1332 | id0 = int(res) | |
1333 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1334 | ||
1335 | dev[1].set("dpp_configurator_params", | |
1336 | " conf=sta-psk ssid=%s pass=%s configurator=%d" % ("DPPNET01".encode("hex"), "ThisIsDppPassphrase".encode("hex"), conf_id)); | |
1337 | cmd = "DPP_LISTEN 2437 role=configurator" | |
1338 | if "OK" not in dev[1].request(cmd): | |
1339 | raise Exception("Failed to start listen operation") | |
1340 | ||
1341 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1342 | if "status,COMPLETE" not in res: | |
1343 | raise Exception("dev_exec_action did not succeed: " + res) | |
1344 | ||
1345 | 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) | |
3dfccf7c JM |
1346 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,OK" not in res: |
1347 | raise Exception("Unexpected result: " + res) | |
1348 | finally: | |
1349 | dev[0].set("dpp_config_processing", "0") | |
1350 | stop_sigma_dut(sigma) | |
1351 | ||
1352 | def test_sigma_dut_dpp_qr_init_enrollee_sae(dev, apdev): | |
1353 | """sigma_dut DPP/QR initiator as Enrollee (SAE)""" | |
1354 | check_dpp_capab(dev[0]) | |
1355 | check_dpp_capab(dev[1]) | |
1356 | if "SAE" not in dev[0].get_capability("auth_alg"): | |
1357 | raise HwsimSkip("SAE not supported") | |
1358 | ||
1359 | params = hostapd.wpa2_params(ssid="DPPNET01", | |
1360 | passphrase="ThisIsDppPassphrase") | |
1361 | params['wpa_key_mgmt'] = 'SAE' | |
1362 | params["ieee80211w"] = "2" | |
1363 | hapd = hostapd.add_ap(apdev[0], params) | |
1364 | ||
1365 | sigma = start_sigma_dut(dev[0].ifname) | |
1366 | try: | |
1367 | dev[0].set("dpp_config_processing", "2") | |
1368 | ||
1369 | cmd = "DPP_CONFIGURATOR_ADD" | |
1370 | res = dev[1].request(cmd); | |
1371 | if "FAIL" in res: | |
1372 | raise Exception("Failed to add configurator") | |
1373 | conf_id = int(res) | |
1374 | ||
1375 | addr = dev[1].own_addr().replace(':', '') | |
1376 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1377 | res = dev[1].request(cmd) | |
1378 | if "FAIL" in res: | |
1379 | raise Exception("Failed to generate bootstrapping info") | |
1380 | id0 = int(res) | |
1381 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1382 | ||
1383 | dev[1].set("dpp_configurator_params", | |
1384 | " conf=sta-sae ssid=%s pass=%s configurator=%d" % ("DPPNET01".encode("hex"), "ThisIsDppPassphrase".encode("hex"), conf_id)); | |
1385 | cmd = "DPP_LISTEN 2437 role=configurator" | |
1386 | if "OK" not in dev[1].request(cmd): | |
1387 | raise Exception("Failed to start listen operation") | |
1388 | ||
1389 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1390 | if "status,COMPLETE" not in res: | |
1391 | raise Exception("dev_exec_action did not succeed: " + res) | |
1392 | ||
1393 | 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) | |
d84c0cf4 JM |
1394 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,OK" not in res: |
1395 | raise Exception("Unexpected result: " + res) | |
1396 | finally: | |
1397 | dev[0].set("dpp_config_processing", "0") | |
1398 | stop_sigma_dut(sigma) | |
1399 | ||
1400 | def test_sigma_dut_dpp_qr_init_configurator_1(dev, apdev): | |
1401 | """sigma_dut DPP/QR initiator as Configurator (conf index 1)""" | |
1402 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 1) | |
1403 | ||
1404 | def test_sigma_dut_dpp_qr_init_configurator_2(dev, apdev): | |
1405 | """sigma_dut DPP/QR initiator as Configurator (conf index 2)""" | |
1406 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 2) | |
1407 | ||
1408 | def test_sigma_dut_dpp_qr_init_configurator_3(dev, apdev): | |
1409 | """sigma_dut DPP/QR initiator as Configurator (conf index 3)""" | |
1410 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 3) | |
1411 | ||
1412 | def test_sigma_dut_dpp_qr_init_configurator_4(dev, apdev): | |
1413 | """sigma_dut DPP/QR initiator as Configurator (conf index 4)""" | |
1414 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 4) | |
1415 | ||
23c45cd0 JM |
1416 | def test_sigma_dut_dpp_qr_init_configurator_5(dev, apdev): |
1417 | """sigma_dut DPP/QR initiator as Configurator (conf index 5)""" | |
1418 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 5) | |
1419 | ||
1420 | def test_sigma_dut_dpp_qr_init_configurator_6(dev, apdev): | |
1421 | """sigma_dut DPP/QR initiator as Configurator (conf index 6)""" | |
1422 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 6) | |
1423 | ||
1424 | def test_sigma_dut_dpp_qr_init_configurator_7(dev, apdev): | |
1425 | """sigma_dut DPP/QR initiator as Configurator (conf index 7)""" | |
1426 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 7) | |
1427 | ||
0e664e0c JM |
1428 | def test_sigma_dut_dpp_qr_init_configurator_both(dev, apdev): |
1429 | """sigma_dut DPP/QR initiator as Configurator or Enrollee (conf index 1)""" | |
1430 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 1, "Both") | |
1431 | ||
cb6b2232 JM |
1432 | def test_sigma_dut_dpp_qr_init_configurator_neg_freq(dev, apdev): |
1433 | """sigma_dut DPP/QR initiator as Configurator (neg_freq)""" | |
1434 | run_sigma_dut_dpp_qr_init_configurator(dev, apdev, 1, extra='DPPSubsequentChannel,81/11') | |
1435 | ||
0e664e0c | 1436 | def run_sigma_dut_dpp_qr_init_configurator(dev, apdev, conf_idx, |
cb6b2232 JM |
1437 | prov_role="Configurator", |
1438 | extra=None): | |
d84c0cf4 JM |
1439 | check_dpp_capab(dev[0]) |
1440 | check_dpp_capab(dev[1]) | |
1441 | sigma = start_sigma_dut(dev[0].ifname) | |
1442 | try: | |
1443 | addr = dev[1].own_addr().replace(':', '') | |
1444 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1445 | res = dev[1].request(cmd) | |
1446 | if "FAIL" in res: | |
1447 | raise Exception("Failed to generate bootstrapping info") | |
1448 | id0 = int(res) | |
1449 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1450 | ||
1451 | cmd = "DPP_LISTEN 2437 role=enrollee" | |
1452 | if "OK" not in dev[1].request(cmd): | |
1453 | raise Exception("Failed to start listen operation") | |
1454 | ||
1455 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1456 | if "status,COMPLETE" not in res: | |
1457 | raise Exception("dev_exec_action did not succeed: " + res) | |
1458 | ||
cb6b2232 JM |
1459 | 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) |
1460 | if extra: | |
1461 | cmd += "," + extra | |
1462 | res = sigma_dut_cmd(cmd) | |
d84c0cf4 JM |
1463 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: |
1464 | raise Exception("Unexpected result: " + res) | |
1465 | finally: | |
1466 | stop_sigma_dut(sigma) | |
1467 | ||
e129e6bd JM |
1468 | def test_sigma_dut_dpp_incompatible_roles_init(dev, apdev): |
1469 | """sigma_dut DPP roles incompatible (Initiator)""" | |
1470 | check_dpp_capab(dev[0]) | |
1471 | check_dpp_capab(dev[1]) | |
1472 | sigma = start_sigma_dut(dev[0].ifname) | |
1473 | try: | |
1474 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") | |
1475 | if "status,COMPLETE" not in res: | |
1476 | raise Exception("dev_exec_action did not succeed: " + res) | |
1477 | hex = res.split(',')[3] | |
1478 | uri = hex.decode('hex') | |
1479 | logger.info("URI from sigma_dut: " + uri) | |
1480 | ||
1481 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1482 | if "FAIL" in res: | |
1483 | raise Exception("Failed to parse QR Code URI") | |
1484 | id1 = int(res) | |
1485 | ||
1486 | addr = dev[1].own_addr().replace(':', '') | |
1487 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1488 | res = dev[1].request(cmd) | |
1489 | if "FAIL" in res: | |
1490 | raise Exception("Failed to generate bootstrapping info") | |
1491 | id0 = int(res) | |
1492 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1493 | ||
1494 | cmd = "DPP_LISTEN 2437 role=enrollee" | |
1495 | if "OK" not in dev[1].request(cmd): | |
1496 | raise Exception("Failed to start listen operation") | |
1497 | ||
1498 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1499 | if "status,COMPLETE" not in res: | |
1500 | raise Exception("dev_exec_action did not succeed: " + res) | |
1501 | ||
1502 | cmd = "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6" | |
1503 | res = sigma_dut_cmd(cmd) | |
1504 | if "BootstrapResult,OK,AuthResult,ROLES_NOT_COMPATIBLE" not in res: | |
1505 | raise Exception("Unexpected result: " + res) | |
1506 | finally: | |
1507 | stop_sigma_dut(sigma) | |
1508 | ||
1509 | def dpp_init_enrollee_mutual(dev, id1, own_id): | |
1510 | logger.info("Starting DPP initiator/enrollee in a thread") | |
1511 | time.sleep(1) | |
1512 | cmd = "DPP_AUTH_INIT peer=%d own=%d role=enrollee" % (id1, own_id) | |
1513 | if "OK" not in dev.request(cmd): | |
1514 | raise Exception("Failed to initiate DPP Authentication") | |
1515 | ev = dev.wait_event(["DPP-CONF-RECEIVED", | |
1516 | "DPP-NOT-COMPATIBLE"], timeout=5) | |
1517 | if ev is None: | |
1518 | raise Exception("DPP configuration not completed (Enrollee)") | |
1519 | logger.info("DPP initiator/enrollee done") | |
1520 | ||
1521 | def test_sigma_dut_dpp_incompatible_roles_resp(dev, apdev): | |
1522 | """sigma_dut DPP roles incompatible (Responder)""" | |
1523 | check_dpp_capab(dev[0]) | |
1524 | check_dpp_capab(dev[1]) | |
1525 | sigma = start_sigma_dut(dev[0].ifname) | |
1526 | try: | |
1527 | cmd = "dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR" | |
1528 | res = sigma_dut_cmd(cmd) | |
1529 | if "status,COMPLETE" not in res: | |
1530 | raise Exception("dev_exec_action did not succeed: " + res) | |
1531 | hex = res.split(',')[3] | |
1532 | uri = hex.decode('hex') | |
1533 | logger.info("URI from sigma_dut: " + uri) | |
1534 | ||
1535 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1536 | if "FAIL" in res: | |
1537 | raise Exception("Failed to parse QR Code URI") | |
1538 | id1 = int(res) | |
1539 | ||
1540 | addr = dev[1].own_addr().replace(':', '') | |
1541 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1542 | res = dev[1].request(cmd) | |
1543 | if "FAIL" in res: | |
1544 | raise Exception("Failed to generate bootstrapping info") | |
1545 | id0 = int(res) | |
1546 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1547 | ||
1548 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1549 | if "status,COMPLETE" not in res: | |
1550 | raise Exception("dev_exec_action did not succeed: " + res) | |
1551 | ||
1552 | t = threading.Thread(target=dpp_init_enrollee_mutual, args=(dev[1], id1, id0)) | |
1553 | t.start() | |
1554 | cmd = "dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6" | |
1555 | res = sigma_dut_cmd(cmd, timeout=10) | |
1556 | t.join() | |
1557 | if "BootstrapResult,OK,AuthResult,ROLES_NOT_COMPATIBLE" not in res: | |
1558 | raise Exception("Unexpected result: " + res) | |
1559 | finally: | |
1560 | stop_sigma_dut(sigma) | |
1561 | ||
d84c0cf4 JM |
1562 | def test_sigma_dut_dpp_pkex_init_configurator(dev, apdev): |
1563 | """sigma_dut DPP/PKEX initiator as Configurator""" | |
1564 | check_dpp_capab(dev[0]) | |
1565 | check_dpp_capab(dev[1]) | |
1566 | sigma = start_sigma_dut(dev[0].ifname) | |
1567 | try: | |
1568 | cmd = "DPP_BOOTSTRAP_GEN type=pkex" | |
1569 | res = dev[1].request(cmd) | |
1570 | if "FAIL" in res: | |
1571 | raise Exception("Failed to generate bootstrapping info") | |
1572 | id1 = int(res) | |
1573 | cmd = "DPP_PKEX_ADD own=%d identifier=test code=secret" % (id1) | |
1574 | res = dev[1].request(cmd) | |
1575 | if "FAIL" in res: | |
1576 | raise Exception("Failed to set PKEX data (responder)") | |
1577 | cmd = "DPP_LISTEN 2437 role=enrollee" | |
1578 | if "OK" not in dev[1].request(cmd): | |
1579 | raise Exception("Failed to start listen operation") | |
1580 | ||
33cddd7f | 1581 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPProvisioningRole,Configurator,DPPConfIndex,1,DPPSigningKeyECC,P-256,DPPConfEnrolleeRole,STA,DPPBS,PKEX,DPPPKEXCodeIdentifier,test,DPPPKEXCode,secret,DPPTimeout,6") |
d84c0cf4 JM |
1582 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: |
1583 | raise Exception("Unexpected result: " + res) | |
1584 | finally: | |
1585 | stop_sigma_dut(sigma) | |
1586 | ||
1587 | def dpp_init_conf(dev, id1, conf, conf_id, extra): | |
1588 | logger.info("Starting DPP initiator/configurator in a thread") | |
1589 | cmd = "DPP_AUTH_INIT peer=%d conf=%s %s configurator=%d" % (id1, conf, extra, conf_id) | |
1590 | if "OK" not in dev.request(cmd): | |
1591 | raise Exception("Failed to initiate DPP Authentication") | |
1592 | ev = dev.wait_event(["DPP-CONF-SENT"], timeout=5) | |
1593 | if ev is None: | |
1594 | raise Exception("DPP configuration not completed (Configurator)") | |
1595 | logger.info("DPP initiator/configurator done") | |
1596 | ||
1597 | def test_sigma_dut_ap_dpp_qr(dev, apdev, params): | |
1598 | """sigma_dut controlled AP (DPP)""" | |
1599 | run_sigma_dut_ap_dpp_qr(dev, apdev, params, "ap-dpp", "sta-dpp") | |
1600 | ||
1601 | def test_sigma_dut_ap_dpp_qr_legacy(dev, apdev, params): | |
1602 | """sigma_dut controlled AP (legacy)""" | |
1603 | run_sigma_dut_ap_dpp_qr(dev, apdev, params, "ap-psk", "sta-psk", | |
1604 | extra="pass=%s" % "qwertyuiop".encode("hex")) | |
1605 | ||
1606 | def test_sigma_dut_ap_dpp_qr_legacy_psk(dev, apdev, params): | |
1607 | """sigma_dut controlled AP (legacy)""" | |
1608 | run_sigma_dut_ap_dpp_qr(dev, apdev, params, "ap-psk", "sta-psk", | |
1609 | extra="psk=%s" % (32*"12")) | |
1610 | ||
1611 | def run_sigma_dut_ap_dpp_qr(dev, apdev, params, ap_conf, sta_conf, extra=""): | |
6e6651d0 | 1612 | check_dpp_capab(dev[0]) |
d84c0cf4 JM |
1613 | logdir = os.path.join(params['logdir'], "sigma_dut_ap_dpp_qr.sigma-hostapd") |
1614 | with HWSimRadio() as (radio, iface): | |
1615 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
1616 | try: | |
1617 | sigma_dut_cmd_check("ap_reset_default,program,DPP") | |
1618 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") | |
1619 | if "status,COMPLETE" not in res: | |
1620 | raise Exception("dev_exec_action did not succeed: " + res) | |
1621 | hex = res.split(',')[3] | |
1622 | uri = hex.decode('hex') | |
1623 | logger.info("URI from sigma_dut: " + uri) | |
1624 | ||
1625 | cmd = "DPP_CONFIGURATOR_ADD" | |
1626 | res = dev[0].request(cmd); | |
1627 | if "FAIL" in res: | |
1628 | raise Exception("Failed to add configurator") | |
1629 | conf_id = int(res) | |
1630 | ||
1631 | res = dev[0].request("DPP_QR_CODE " + uri) | |
1632 | if "FAIL" in res: | |
1633 | raise Exception("Failed to parse QR Code URI") | |
1634 | id1 = int(res) | |
1635 | ||
1636 | t = threading.Thread(target=dpp_init_conf, | |
1637 | args=(dev[0], id1, ap_conf, conf_id, extra)) | |
1638 | t.start() | |
1639 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6") | |
1640 | t.join() | |
1641 | if "ConfResult,OK" not in res: | |
1642 | raise Exception("Unexpected result: " + res) | |
1643 | ||
1644 | addr = dev[1].own_addr().replace(':', '') | |
1645 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr | |
1646 | res = dev[1].request(cmd) | |
1647 | if "FAIL" in res: | |
1648 | raise Exception("Failed to generate bootstrapping info") | |
1649 | id1 = int(res) | |
1650 | uri1 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id1) | |
1651 | ||
1652 | res = dev[0].request("DPP_QR_CODE " + uri1) | |
1653 | if "FAIL" in res: | |
1654 | raise Exception("Failed to parse QR Code URI") | |
1655 | id0b = int(res) | |
1656 | ||
1657 | dev[1].set("dpp_config_processing", "2") | |
1658 | cmd = "DPP_LISTEN 2412" | |
1659 | if "OK" not in dev[1].request(cmd): | |
1660 | raise Exception("Failed to start listen operation") | |
1661 | cmd = "DPP_AUTH_INIT peer=%d conf=%s %s configurator=%d" % (id0b, sta_conf, extra, conf_id) | |
1662 | if "OK" not in dev[0].request(cmd): | |
1663 | raise Exception("Failed to initiate DPP Authentication") | |
1664 | dev[1].wait_connected() | |
1665 | ||
1666 | sigma_dut_cmd_check("ap_reset_default") | |
1667 | finally: | |
1668 | dev[1].set("dpp_config_processing", "0") | |
1669 | stop_sigma_dut(sigma) | |
b900fb1a JM |
1670 | |
1671 | def test_sigma_dut_ap_dpp_pkex_responder(dev, apdev, params): | |
1672 | """sigma_dut controlled AP as DPP PKEX responder""" | |
6e6651d0 | 1673 | check_dpp_capab(dev[0]) |
b900fb1a JM |
1674 | logdir = os.path.join(params['logdir'], |
1675 | "sigma_dut_ap_dpp_pkex_responder.sigma-hostapd") | |
1676 | with HWSimRadio() as (radio, iface): | |
1677 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
1678 | try: | |
1679 | run_sigma_dut_ap_dpp_pkex_responder(dev, apdev) | |
1680 | finally: | |
1681 | stop_sigma_dut(sigma) | |
1682 | ||
a8ec0b8c | 1683 | def dpp_init_conf_pkex(dev, conf_id, check_config=True): |
b900fb1a JM |
1684 | logger.info("Starting DPP PKEX initiator/configurator in a thread") |
1685 | time.sleep(1.5) | |
1686 | cmd = "DPP_BOOTSTRAP_GEN type=pkex" | |
1687 | res = dev.request(cmd) | |
1688 | if "FAIL" in res: | |
1689 | raise Exception("Failed to generate bootstrapping info") | |
1690 | id = int(res) | |
1691 | cmd = "DPP_PKEX_ADD own=%d init=1 conf=ap-dpp configurator=%d code=password" % (id, conf_id) | |
1692 | res = dev.request(cmd) | |
1693 | if "FAIL" in res: | |
1694 | raise Exception("Failed to initiate DPP PKEX") | |
a8ec0b8c JM |
1695 | if not check_config: |
1696 | return | |
b900fb1a JM |
1697 | ev = dev.wait_event(["DPP-CONF-SENT"], timeout=5) |
1698 | if ev is None: | |
1699 | raise Exception("DPP configuration not completed (Configurator)") | |
1700 | logger.info("DPP initiator/configurator done") | |
1701 | ||
1702 | def run_sigma_dut_ap_dpp_pkex_responder(dev, apdev): | |
1703 | sigma_dut_cmd_check("ap_reset_default,program,DPP") | |
1704 | ||
1705 | cmd = "DPP_CONFIGURATOR_ADD" | |
1706 | res = dev[0].request(cmd); | |
1707 | if "FAIL" in res: | |
1708 | raise Exception("Failed to add configurator") | |
1709 | conf_id = int(res) | |
1710 | ||
1711 | t = threading.Thread(target=dpp_init_conf_pkex, args=(dev[0], conf_id)) | |
1712 | t.start() | |
a8ec0b8c | 1713 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPAuthDirection,Mutual,DPPProvisioningRole,Enrollee,DPPBS,PKEX,DPPPKEXCode,password,DPPTimeout,6,DPPWaitForConnect,No", timeout=10) |
b900fb1a JM |
1714 | t.join() |
1715 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: | |
1716 | raise Exception("Unexpected result: " + res) | |
1717 | ||
1718 | sigma_dut_cmd_check("ap_reset_default") | |
8c735316 | 1719 | |
a8ec0b8c JM |
1720 | def test_sigma_dut_dpp_pkex_responder_proto(dev, apdev): |
1721 | """sigma_dut controlled STA as DPP PKEX responder and error case""" | |
1722 | check_dpp_capab(dev[0]) | |
1723 | sigma = start_sigma_dut(dev[0].ifname) | |
1724 | try: | |
1725 | run_sigma_dut_dpp_pkex_responder_proto(dev, apdev) | |
1726 | finally: | |
1727 | stop_sigma_dut(sigma) | |
1728 | ||
1729 | def run_sigma_dut_dpp_pkex_responder_proto(dev, apdev): | |
1730 | cmd = "DPP_CONFIGURATOR_ADD" | |
1731 | res = dev[1].request(cmd); | |
1732 | if "FAIL" in res: | |
1733 | raise Exception("Failed to add configurator") | |
1734 | conf_id = int(res) | |
1735 | ||
1736 | dev[1].set("dpp_test", "44") | |
1737 | ||
1738 | t = threading.Thread(target=dpp_init_conf_pkex, args=(dev[1], conf_id, | |
1739 | False)) | |
1740 | t.start() | |
1741 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Responder,DPPProvisioningRole,Enrollee,DPPBS,PKEX,DPPPKEXCode,password,DPPTimeout,6", timeout=10) | |
1742 | t.join() | |
1743 | if "BootstrapResult,Timeout" not in res: | |
1744 | raise Exception("Unexpected result: " + res) | |
1745 | ||
8c735316 JM |
1746 | def dpp_proto_init(dev, id1): |
1747 | time.sleep(1) | |
1748 | logger.info("Starting DPP initiator/configurator in a thread") | |
1749 | cmd = "DPP_CONFIGURATOR_ADD" | |
1750 | res = dev.request(cmd); | |
1751 | if "FAIL" in res: | |
1752 | raise Exception("Failed to add configurator") | |
1753 | conf_id = int(res) | |
1754 | ||
1755 | cmd = "DPP_AUTH_INIT peer=%d conf=sta-dpp configurator=%d" % (id1, conf_id) | |
1756 | if "OK" not in dev.request(cmd): | |
1757 | raise Exception("Failed to initiate DPP Authentication") | |
1758 | ||
1759 | def test_sigma_dut_dpp_proto_initiator(dev, apdev): | |
1760 | """sigma_dut DPP protocol testing - Initiator""" | |
1761 | check_dpp_capab(dev[0]) | |
1762 | check_dpp_capab(dev[1]) | |
1763 | tests = [ ("InvalidValue", "AuthenticationRequest", "WrappedData", | |
1764 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1765 | None), | |
1766 | ("InvalidValue", "AuthenticationConfirm", "WrappedData", | |
1767 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1768 | None), | |
1769 | ("MissingAttribute", "AuthenticationRequest", "InitCapabilities", | |
1770 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1771 | "Missing or invalid I-capabilities"), | |
1772 | ("InvalidValue", "AuthenticationConfirm", "InitAuthTag", | |
1773 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1774 | "Mismatching Initiator Authenticating Tag"), | |
1775 | ("MissingAttribute", "ConfigurationResponse", "EnrolleeNonce", | |
1776 | "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", | |
1777 | "Missing or invalid Enrollee Nonce attribute") ] | |
1778 | for step, frame, attr, result, fail in tests: | |
1779 | dev[0].request("FLUSH") | |
1780 | dev[1].request("FLUSH") | |
1781 | sigma = start_sigma_dut(dev[0].ifname) | |
1782 | try: | |
1783 | run_sigma_dut_dpp_proto_initiator(dev, step, frame, attr, result, | |
1784 | fail) | |
1785 | finally: | |
1786 | stop_sigma_dut(sigma) | |
1787 | ||
1788 | def run_sigma_dut_dpp_proto_initiator(dev, step, frame, attr, result, fail): | |
1789 | addr = dev[1].own_addr().replace(':', '') | |
1790 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1791 | res = dev[1].request(cmd) | |
1792 | if "FAIL" in res: | |
1793 | raise Exception("Failed to generate bootstrapping info") | |
1794 | id0 = int(res) | |
1795 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1796 | ||
1797 | cmd = "DPP_LISTEN 2437 role=enrollee" | |
1798 | if "OK" not in dev[1].request(cmd): | |
1799 | raise Exception("Failed to start listen operation") | |
1800 | ||
1801 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1802 | if "status,COMPLETE" not in res: | |
1803 | raise Exception("dev_exec_action did not succeed: " + res) | |
1804 | ||
6333cb81 JM |
1805 | 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), |
1806 | timeout=10) | |
8c735316 JM |
1807 | if result not in res: |
1808 | raise Exception("Unexpected result: " + res) | |
1809 | if fail: | |
1810 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
1811 | if ev is None or fail not in ev: | |
1812 | raise Exception("Failure not reported correctly: " + str(ev)) | |
1813 | ||
1814 | dev[1].request("DPP_STOP_LISTEN") | |
1815 | dev[0].dump_monitor() | |
1816 | dev[1].dump_monitor() | |
1817 | ||
1818 | def test_sigma_dut_dpp_proto_responder(dev, apdev): | |
1819 | """sigma_dut DPP protocol testing - Responder""" | |
1820 | check_dpp_capab(dev[0]) | |
1821 | check_dpp_capab(dev[1]) | |
1822 | tests = [ ("MissingAttribute", "AuthenticationResponse", "DPPStatus", | |
1823 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1824 | "Missing or invalid required DPP Status attribute"), | |
1825 | ("MissingAttribute", "ConfigurationRequest", "EnrolleeNonce", | |
1826 | "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", | |
1827 | "Missing or invalid Enrollee Nonce attribute") ] | |
1828 | for step, frame, attr, result, fail in tests: | |
1829 | dev[0].request("FLUSH") | |
1830 | dev[1].request("FLUSH") | |
1831 | sigma = start_sigma_dut(dev[0].ifname) | |
1832 | try: | |
1833 | run_sigma_dut_dpp_proto_responder(dev, step, frame, attr, result, | |
1834 | fail) | |
1835 | finally: | |
1836 | stop_sigma_dut(sigma) | |
1837 | ||
1838 | def run_sigma_dut_dpp_proto_responder(dev, step, frame, attr, result, fail): | |
1839 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") | |
1840 | if "status,COMPLETE" not in res: | |
1841 | raise Exception("dev_exec_action did not succeed: " + res) | |
1842 | hex = res.split(',')[3] | |
1843 | uri = hex.decode('hex') | |
1844 | logger.info("URI from sigma_dut: " + uri) | |
1845 | ||
1846 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1847 | if "FAIL" in res: | |
1848 | raise Exception("Failed to parse QR Code URI") | |
1849 | id1 = int(res) | |
1850 | ||
1851 | t = threading.Thread(target=dpp_proto_init, args=(dev[1], id1)) | |
1852 | t.start() | |
14f8e081 | 1853 | 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) |
8c735316 JM |
1854 | t.join() |
1855 | if result not in res: | |
1856 | raise Exception("Unexpected result: " + res) | |
1857 | if fail: | |
1858 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
1859 | if ev is None or fail not in ev: | |
1860 | raise Exception("Failure not reported correctly:" + str(ev)) | |
1861 | ||
1862 | dev[1].request("DPP_STOP_LISTEN") | |
1863 | dev[0].dump_monitor() | |
1864 | dev[1].dump_monitor() | |
1865 | ||
c79b9db0 JM |
1866 | def test_sigma_dut_dpp_proto_stop_at_initiator(dev, apdev): |
1867 | """sigma_dut DPP protocol testing - Stop at RX on Initiator""" | |
1868 | check_dpp_capab(dev[0]) | |
1869 | check_dpp_capab(dev[1]) | |
1870 | tests = [ ("AuthenticationResponse", | |
1871 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1872 | None), | |
1873 | ("ConfigurationRequest", | |
1874 | "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent", | |
1875 | None)] | |
1876 | for frame, result, fail in tests: | |
1877 | dev[0].request("FLUSH") | |
1878 | dev[1].request("FLUSH") | |
1879 | sigma = start_sigma_dut(dev[0].ifname) | |
1880 | try: | |
1881 | run_sigma_dut_dpp_proto_stop_at_initiator(dev, frame, result, fail) | |
1882 | finally: | |
1883 | stop_sigma_dut(sigma) | |
1884 | ||
1885 | def run_sigma_dut_dpp_proto_stop_at_initiator(dev, frame, result, fail): | |
1886 | addr = dev[1].own_addr().replace(':', '') | |
1887 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1888 | res = dev[1].request(cmd) | |
1889 | if "FAIL" in res: | |
1890 | raise Exception("Failed to generate bootstrapping info") | |
1891 | id0 = int(res) | |
1892 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1893 | ||
1894 | cmd = "DPP_LISTEN 2437 role=enrollee" | |
1895 | if "OK" not in dev[1].request(cmd): | |
1896 | raise Exception("Failed to start listen operation") | |
1897 | ||
1898 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1899 | if "status,COMPLETE" not in res: | |
1900 | raise Exception("dev_exec_action did not succeed: " + res) | |
1901 | ||
1902 | 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,Timeout,DPPFrameType,%s" % (frame)) | |
1903 | if result not in res: | |
1904 | raise Exception("Unexpected result: " + res) | |
4ae39c12 JM |
1905 | if fail: |
1906 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
1907 | if ev is None or fail not in ev: | |
1908 | raise Exception("Failure not reported correctly: " + str(ev)) | |
1909 | ||
1910 | dev[1].request("DPP_STOP_LISTEN") | |
1911 | dev[0].dump_monitor() | |
1912 | dev[1].dump_monitor() | |
1913 | ||
1914 | def test_sigma_dut_dpp_proto_stop_at_initiator_enrollee(dev, apdev): | |
1915 | """sigma_dut DPP protocol testing - Stop at TX on Initiator/Enrollee""" | |
1916 | check_dpp_capab(dev[0]) | |
1917 | check_dpp_capab(dev[1]) | |
1918 | tests = [ ("AuthenticationConfirm", | |
1919 | "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponse", | |
1920 | None) ] | |
1921 | for frame, result, fail in tests: | |
1922 | dev[0].request("FLUSH") | |
1923 | dev[1].request("FLUSH") | |
1924 | sigma = start_sigma_dut(dev[0].ifname, debug=True) | |
1925 | try: | |
1926 | run_sigma_dut_dpp_proto_stop_at_initiator_enrollee(dev, frame, | |
1927 | result, fail) | |
1928 | finally: | |
1929 | stop_sigma_dut(sigma) | |
1930 | ||
1931 | def run_sigma_dut_dpp_proto_stop_at_initiator_enrollee(dev, frame, result, | |
1932 | fail): | |
1933 | addr = dev[1].own_addr().replace(':', '') | |
1934 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
1935 | res = dev[1].request(cmd) | |
1936 | if "FAIL" in res: | |
1937 | raise Exception("Failed to generate bootstrapping info") | |
1938 | id0 = int(res) | |
1939 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
1940 | ||
1941 | cmd = "DPP_LISTEN 2437 role=configurator" | |
1942 | if "OK" not in dev[1].request(cmd): | |
1943 | raise Exception("Failed to start listen operation") | |
1944 | ||
1945 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
1946 | if "status,COMPLETE" not in res: | |
1947 | raise Exception("dev_exec_action did not succeed: " + res) | |
1948 | ||
1949 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Enrollee,DPPBS,QR,DPPTimeout,6,DPPStep,Timeout,DPPFrameType,%s" % (frame), timeout=10) | |
1950 | if result not in res: | |
1951 | raise Exception("Unexpected result: " + res) | |
c79b9db0 JM |
1952 | if fail: |
1953 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
1954 | if ev is None or fail not in ev: | |
1955 | raise Exception("Failure not reported correctly: " + str(ev)) | |
1956 | ||
1957 | dev[1].request("DPP_STOP_LISTEN") | |
1958 | dev[0].dump_monitor() | |
1959 | dev[1].dump_monitor() | |
1960 | ||
1961 | def test_sigma_dut_dpp_proto_stop_at_responder(dev, apdev): | |
1962 | """sigma_dut DPP protocol testing - Stop at RX on Responder""" | |
1963 | check_dpp_capab(dev[0]) | |
1964 | check_dpp_capab(dev[1]) | |
1965 | tests = [ ("AuthenticationRequest", | |
1966 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1967 | None), | |
1968 | ("AuthenticationConfirm", | |
1969 | "BootstrapResult,OK,AuthResult,Errorsent", | |
1970 | None) ] | |
1971 | for frame, result, fail in tests: | |
1972 | dev[0].request("FLUSH") | |
1973 | dev[1].request("FLUSH") | |
1974 | sigma = start_sigma_dut(dev[0].ifname) | |
1975 | try: | |
1976 | run_sigma_dut_dpp_proto_stop_at_responder(dev, frame, result, fail) | |
1977 | finally: | |
1978 | stop_sigma_dut(sigma) | |
1979 | ||
1980 | def run_sigma_dut_dpp_proto_stop_at_responder(dev, frame, result, fail): | |
1981 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,GetLocalBootstrap,DPPCryptoIdentifier,P-256,DPPBS,QR") | |
1982 | if "status,COMPLETE" not in res: | |
1983 | raise Exception("dev_exec_action did not succeed: " + res) | |
1984 | hex = res.split(',')[3] | |
1985 | uri = hex.decode('hex') | |
1986 | logger.info("URI from sigma_dut: " + uri) | |
1987 | ||
1988 | res = dev[1].request("DPP_QR_CODE " + uri) | |
1989 | if "FAIL" in res: | |
1990 | raise Exception("Failed to parse QR Code URI") | |
1991 | id1 = int(res) | |
1992 | ||
1993 | t = threading.Thread(target=dpp_proto_init, args=(dev[1], id1)) | |
1994 | t.start() | |
1995 | 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,Timeout,DPPFrameType,%s" % (frame), timeout=10) | |
1996 | t.join() | |
1997 | if result not in res: | |
1998 | raise Exception("Unexpected result: " + res) | |
1999 | if fail: | |
2000 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
2001 | if ev is None or fail not in ev: | |
2002 | raise Exception("Failure not reported correctly:" + str(ev)) | |
2003 | ||
2004 | dev[1].request("DPP_STOP_LISTEN") | |
2005 | dev[0].dump_monitor() | |
2006 | dev[1].dump_monitor() | |
2007 | ||
8c735316 JM |
2008 | def dpp_proto_init_pkex(dev): |
2009 | time.sleep(1) | |
2010 | logger.info("Starting DPP PKEX initiator/configurator in a thread") | |
2011 | cmd = "DPP_CONFIGURATOR_ADD" | |
2012 | res = dev.request(cmd); | |
2013 | if "FAIL" in res: | |
2014 | raise Exception("Failed to add configurator") | |
2015 | conf_id = int(res) | |
2016 | ||
2017 | cmd = "DPP_BOOTSTRAP_GEN type=pkex" | |
2018 | res = dev.request(cmd) | |
2019 | if "FAIL" in res: | |
2020 | raise Exception("Failed to generate bootstrapping info") | |
2021 | id = int(res) | |
2022 | ||
2023 | cmd = "DPP_PKEX_ADD own=%d init=1 conf=sta-dpp configurator=%d code=secret" % (id, conf_id) | |
2024 | if "FAIL" in dev.request(cmd): | |
2025 | raise Exception("Failed to initiate DPP PKEX") | |
2026 | ||
2027 | def test_sigma_dut_dpp_proto_initiator_pkex(dev, apdev): | |
2028 | """sigma_dut DPP protocol testing - Initiator (PKEX)""" | |
2029 | check_dpp_capab(dev[0]) | |
2030 | check_dpp_capab(dev[1]) | |
2031 | tests = [ ("InvalidValue", "PKEXCRRequest", "WrappedData", | |
2032 | "BootstrapResult,Errorsent", | |
2033 | None), | |
2034 | ("MissingAttribute", "PKEXExchangeRequest", "FiniteCyclicGroup", | |
2035 | "BootstrapResult,Errorsent", | |
2036 | "Missing or invalid Finite Cyclic Group attribute"), | |
2037 | ("MissingAttribute", "PKEXCRRequest", "BSKey", | |
2038 | "BootstrapResult,Errorsent", | |
2039 | "No valid peer bootstrapping key found") ] | |
2040 | for step, frame, attr, result, fail in tests: | |
2041 | dev[0].request("FLUSH") | |
2042 | dev[1].request("FLUSH") | |
2043 | sigma = start_sigma_dut(dev[0].ifname) | |
2044 | try: | |
2045 | run_sigma_dut_dpp_proto_initiator_pkex(dev, step, frame, attr, | |
2046 | result, fail) | |
2047 | finally: | |
2048 | stop_sigma_dut(sigma) | |
2049 | ||
2050 | def run_sigma_dut_dpp_proto_initiator_pkex(dev, step, frame, attr, result, fail): | |
2051 | cmd = "DPP_BOOTSTRAP_GEN type=pkex" | |
2052 | res = dev[1].request(cmd) | |
2053 | if "FAIL" in res: | |
2054 | raise Exception("Failed to generate bootstrapping info") | |
2055 | id1 = int(res) | |
2056 | ||
2057 | cmd = "DPP_PKEX_ADD own=%d code=secret" % (id1) | |
2058 | res = dev[1].request(cmd) | |
2059 | if "FAIL" in res: | |
2060 | raise Exception("Failed to set PKEX data (responder)") | |
2061 | ||
2062 | cmd = "DPP_LISTEN 2437 role=enrollee" | |
2063 | if "OK" not in dev[1].request(cmd): | |
2064 | raise Exception("Failed to start listen operation") | |
2065 | ||
14f8e081 | 2066 | 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)) |
8c735316 JM |
2067 | if result not in res: |
2068 | raise Exception("Unexpected result: " + res) | |
2069 | if fail: | |
2070 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
2071 | if ev is None or fail not in ev: | |
2072 | raise Exception("Failure not reported correctly: " + str(ev)) | |
2073 | ||
2074 | dev[1].request("DPP_STOP_LISTEN") | |
2075 | dev[0].dump_monitor() | |
2076 | dev[1].dump_monitor() | |
2077 | ||
2078 | def test_sigma_dut_dpp_proto_responder_pkex(dev, apdev): | |
2079 | """sigma_dut DPP protocol testing - Responder (PKEX)""" | |
2080 | check_dpp_capab(dev[0]) | |
2081 | check_dpp_capab(dev[1]) | |
2082 | tests = [ ("InvalidValue", "PKEXCRResponse", "WrappedData", | |
2083 | "BootstrapResult,Errorsent", | |
2084 | None), | |
2085 | ("MissingAttribute", "PKEXExchangeResponse", "DPPStatus", | |
2086 | "BootstrapResult,Errorsent", | |
2087 | "No DPP Status attribute"), | |
2088 | ("MissingAttribute", "PKEXCRResponse", "BSKey", | |
2089 | "BootstrapResult,Errorsent", | |
2090 | "No valid peer bootstrapping key found") ] | |
2091 | for step, frame, attr, result, fail in tests: | |
2092 | dev[0].request("FLUSH") | |
2093 | dev[1].request("FLUSH") | |
2094 | sigma = start_sigma_dut(dev[0].ifname) | |
2095 | try: | |
2096 | run_sigma_dut_dpp_proto_responder_pkex(dev, step, frame, attr, | |
2097 | result, fail) | |
2098 | finally: | |
2099 | stop_sigma_dut(sigma) | |
2100 | ||
2101 | def run_sigma_dut_dpp_proto_responder_pkex(dev, step, frame, attr, result, fail): | |
2102 | t = threading.Thread(target=dpp_proto_init_pkex, args=(dev[1],)) | |
2103 | t.start() | |
14f8e081 | 2104 | 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) |
8c735316 JM |
2105 | t.join() |
2106 | if result not in res: | |
2107 | raise Exception("Unexpected result: " + res) | |
2108 | if fail: | |
2109 | ev = dev[1].wait_event(["DPP-FAIL"], timeout=5) | |
2110 | if ev is None or fail not in ev: | |
2111 | raise Exception("Failure not reported correctly:" + str(ev)) | |
2112 | ||
2113 | dev[1].request("DPP_STOP_LISTEN") | |
2114 | dev[0].dump_monitor() | |
2115 | dev[1].dump_monitor() | |
a0604a42 JM |
2116 | |
2117 | def init_sigma_dut_dpp_proto_peer_disc_req(dev, apdev): | |
2118 | check_dpp_capab(dev[0]) | |
2119 | check_dpp_capab(dev[1]) | |
2120 | ||
2121 | csign = "30770201010420768240a3fc89d6662d9782f120527fe7fb9edc6366ab0b9c7dde96125cfd250fa00a06082a8648ce3d030107a144034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
2122 | csign_pub = "3059301306072a8648ce3d020106082a8648ce3d030107034200042908e1baf7bf413cc66f9e878a03e8bb1835ba94b033dbe3d6969fc8575d5eb5dfda1cb81c95cee21d0cd7d92ba30541ffa05cb6296f5dd808b0c1c2a83c0708" | |
2123 | ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJwYWtZbXVzd1dCdWpSYTl5OEsweDViaTVrT3VNT3dzZHRlaml2UG55ZHZzIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIybU5vNXZuRkI5bEw3d1VWb1hJbGVPYzBNSEE1QXZKbnpwZXZULVVTYzVNIiwieSI6IlhzS3dqVHJlLTg5WWdpU3pKaG9CN1haeUttTU05OTl3V2ZaSVl0bi01Q3MifX0.XhjFpZgcSa7G2lHy0OCYTvaZFRo5Hyx6b7g7oYyusLC7C_73AJ4_BxEZQVYJXAtDuGvb3dXSkHEKxREP9Q6Qeg" | |
2124 | ap_netaccesskey = "30770201010420ceba752db2ad5200fa7bc565b9c05c69b7eb006751b0b329b0279de1c19ca67ca00a06082a8648ce3d030107a14403420004da6368e6f9c507d94bef0515a1722578e73430703902f267ce97af4fe51273935ec2b08d3adefbcf588224b3261a01ed76722a630cf7df7059f64862d9fee42b" | |
2125 | ||
2126 | params = { "ssid": "DPPNET01", | |
2127 | "wpa": "2", | |
3e3d634f | 2128 | "ieee80211w": "2", |
a0604a42 JM |
2129 | "wpa_key_mgmt": "DPP", |
2130 | "rsn_pairwise": "CCMP", | |
2131 | "dpp_connector": ap_connector, | |
2132 | "dpp_csign": csign_pub, | |
2133 | "dpp_netaccesskey": ap_netaccesskey } | |
2134 | try: | |
2135 | hapd = hostapd.add_ap(apdev[0], params) | |
2136 | except: | |
2137 | raise HwsimSkip("DPP not supported") | |
2138 | ||
2139 | dev[0].set("dpp_config_processing", "2") | |
2140 | ||
2141 | cmd = "DPP_CONFIGURATOR_ADD key=" + csign | |
2142 | res = dev[1].request(cmd); | |
2143 | if "FAIL" in res: | |
2144 | raise Exception("Failed to add configurator") | |
2145 | conf_id = int(res) | |
2146 | ||
2147 | addr = dev[1].own_addr().replace(':', '') | |
2148 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/6 mac=" + addr | |
2149 | res = dev[1].request(cmd) | |
2150 | if "FAIL" in res: | |
2151 | raise Exception("Failed to generate bootstrapping info") | |
2152 | id0 = int(res) | |
2153 | uri0 = dev[1].request("DPP_BOOTSTRAP_GET_URI %d" % id0) | |
2154 | ||
2155 | dev[1].set("dpp_configurator_params", | |
2156 | " conf=sta-dpp ssid=%s configurator=%d" % ("DPPNET01".encode("hex"), conf_id)); | |
2157 | cmd = "DPP_LISTEN 2437 role=configurator" | |
2158 | if "OK" not in dev[1].request(cmd): | |
2159 | raise Exception("Failed to start listen operation") | |
2160 | ||
2161 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri0.encode('hex')) | |
2162 | if "status,COMPLETE" not in res: | |
2163 | raise Exception("dev_exec_action did not succeed: " + res) | |
2164 | ||
2165 | def test_sigma_dut_dpp_proto_peer_disc_req(dev, apdev): | |
2166 | """sigma_dut DPP protocol testing - Peer Discovery Request""" | |
2167 | sigma = start_sigma_dut(dev[0].ifname) | |
2168 | try: | |
2169 | init_sigma_dut_dpp_proto_peer_disc_req(dev, apdev) | |
2170 | ||
2171 | 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) | |
2172 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Errorsent" not in res: | |
2173 | raise Exception("Unexpected result: " + res) | |
2174 | finally: | |
2175 | dev[0].set("dpp_config_processing", "0") | |
2176 | stop_sigma_dut(sigma) | |
211b5d1b JM |
2177 | |
2178 | def test_sigma_dut_dpp_self_config(dev, apdev): | |
2179 | """sigma_dut DPP Configurator enrolling an AP and using self-configuration""" | |
2180 | check_dpp_capab(dev[0]) | |
2181 | ||
2182 | hapd = hostapd.add_ap(apdev[0], { "ssid": "unconfigured" }) | |
2183 | check_dpp_capab(hapd) | |
2184 | ||
2185 | sigma = start_sigma_dut(dev[0].ifname) | |
2186 | try: | |
2187 | dev[0].set("dpp_config_processing", "2") | |
2188 | addr = hapd.own_addr().replace(':', '') | |
2189 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/1 mac=" + addr | |
2190 | res = hapd.request(cmd) | |
2191 | if "FAIL" in res: | |
2192 | raise Exception("Failed to generate bootstrapping info") | |
2193 | id = int(res) | |
2194 | uri = hapd.request("DPP_BOOTSTRAP_GET_URI %d" % id) | |
2195 | ||
2196 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri.encode('hex')) | |
2197 | if "status,COMPLETE" not in res: | |
2198 | raise Exception("dev_exec_action did not succeed: " + res) | |
2199 | ||
2200 | 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") | |
2201 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: | |
2202 | raise Exception("Unexpected result: " + res) | |
2203 | update_hapd_config(hapd) | |
2204 | ||
2205 | 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" | |
2206 | res = sigma_dut_cmd(cmd, timeout=10) | |
2207 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK" not in res: | |
2208 | raise Exception("Unexpected result: " + res) | |
2209 | finally: | |
2210 | stop_sigma_dut(sigma) | |
2211 | dev[0].set("dpp_config_processing", "0") | |
8b4adc38 JM |
2212 | |
2213 | def test_sigma_dut_ap_dpp_self_config(dev, apdev, params): | |
2214 | """sigma_dut DPP AP Configurator using self-configuration""" | |
2215 | logdir = os.path.join(params['logdir'], | |
2216 | "sigma_dut_ap_dpp_self_config.sigma-hostapd") | |
2217 | with HWSimRadio() as (radio, iface): | |
2218 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
2219 | try: | |
2220 | run_sigma_dut_ap_dpp_self_config(dev, apdev) | |
2221 | finally: | |
2222 | stop_sigma_dut(sigma) | |
2223 | dev[0].set("dpp_config_processing", "0") | |
2224 | ||
2225 | def run_sigma_dut_ap_dpp_self_config(dev, apdev): | |
2226 | check_dpp_capab(dev[0]) | |
2227 | ||
2228 | sigma_dut_cmd_check("ap_reset_default,program,DPP") | |
2229 | ||
2230 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,AutomaticDPP,DPPAuthRole,Initiator,DPPAuthDirection,Single,DPPProvisioningRole,Configurator,DPPConfEnrolleeRole,AP,DPPBS,QR,DPPConfIndex,1,DPPSelfConfigure,Yes,DPPTimeout,6", timeout=10) | |
2231 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: | |
2232 | raise Exception("Unexpected result: " + res) | |
2233 | ||
2234 | dev[0].set("dpp_config_processing", "2") | |
2235 | ||
2236 | addr = dev[0].own_addr().replace(':', '') | |
2237 | cmd = "DPP_BOOTSTRAP_GEN type=qrcode chan=81/11 mac=" + addr | |
2238 | res = dev[0].request(cmd) | |
2239 | if "FAIL" in res: | |
2240 | raise Exception("Failed to generate bootstrapping info") | |
2241 | id = int(res) | |
2242 | uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id) | |
2243 | cmd = "DPP_LISTEN 2462 role=enrollee" | |
2244 | if "OK" not in dev[0].request(cmd): | |
2245 | raise Exception("Failed to start listen operation") | |
2246 | ||
2247 | res = sigma_dut_cmd("dev_exec_action,program,DPP,DPPActionType,SetPeerBootstrap,DPPBootstrappingdata,%s,DPPBS,QR" % uri.encode('hex')) | |
2248 | if "status,COMPLETE" not in res: | |
2249 | raise Exception("dev_exec_action did not succeed: " + res) | |
2250 | 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" | |
2251 | res = sigma_dut_cmd(cmd) | |
2252 | if "BootstrapResult,OK,AuthResult,OK,ConfResult,OK" not in res: | |
2253 | raise Exception("Unexpected result: " + res) | |
2254 | dev[0].wait_connected() | |
2255 | dev[0].request("DISCONNECT") | |
2256 | dev[0].wait_disconnected() | |
2257 | sigma_dut_cmd_check("ap_reset_default") | |
6923312d JM |
2258 | |
2259 | def test_sigma_dut_preconfigured_profile(dev, apdev): | |
2260 | """sigma_dut controlled connection using preconfigured profile""" | |
2261 | try: | |
2262 | run_sigma_dut_preconfigured_profile(dev, apdev) | |
2263 | finally: | |
2264 | dev[0].set("ignore_old_scan_res", "0") | |
2265 | ||
2266 | def run_sigma_dut_preconfigured_profile(dev, apdev): | |
2267 | ifname = dev[0].ifname | |
2268 | sigma = start_sigma_dut(ifname) | |
2269 | ||
2270 | params = hostapd.wpa2_params(ssid="test-psk", passphrase="12345678") | |
2271 | hapd = hostapd.add_ap(apdev[0], params) | |
2272 | dev[0].connect("test-psk", psk="12345678", scan_freq="2412", | |
2273 | only_add_network=True) | |
2274 | ||
2275 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
2276 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s" % (ifname, "test-psk")) | |
2277 | sigma_dut_wait_connected(ifname) | |
2278 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
2279 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
2280 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
2281 | ||
2282 | stop_sigma_dut(sigma) | |
ce83008c JM |
2283 | |
2284 | def test_sigma_dut_wps_pbc(dev, apdev): | |
2285 | """sigma_dut and WPS PBC Enrollee""" | |
2286 | try: | |
2287 | run_sigma_dut_wps_pbc(dev, apdev) | |
2288 | finally: | |
2289 | dev[0].set("ignore_old_scan_res", "0") | |
2290 | ||
2291 | def run_sigma_dut_wps_pbc(dev, apdev): | |
2292 | ssid = "test-wps-conf" | |
2293 | hapd = hostapd.add_ap(apdev[0], | |
2294 | { "ssid": "wps", "eap_server": "1", "wps_state": "2", | |
2295 | "wpa_passphrase": "12345678", "wpa": "2", | |
2296 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) | |
2297 | hapd.request("WPS_PBC") | |
2298 | ||
2299 | ifname = dev[0].ifname | |
2300 | sigma = start_sigma_dut(ifname) | |
2301 | ||
2302 | cmd = "start_wps_registration,interface,%s" % ifname | |
2303 | cmd += ",WpsRole,Enrollee" | |
2304 | cmd += ",WpsConfigMethod,PBC" | |
2305 | sigma_dut_cmd_check(cmd, timeout=15) | |
2306 | ||
2307 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
2308 | hapd.disable() | |
2309 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
2310 | stop_sigma_dut(sigma) | |
2311 | dev[0].flush_scan_cache() | |
7e526fa7 JM |
2312 | |
2313 | def test_sigma_dut_sta_scan_bss(dev, apdev): | |
2314 | """sigma_dut sta_scan_bss""" | |
2315 | hapd = hostapd.add_ap(apdev[0], { "ssid": "test" }) | |
2316 | sigma = start_sigma_dut(dev[0].ifname) | |
2317 | try: | |
2318 | cmd = "sta_scan_bss,Interface,%s,BSSID,%s" % (dev[0].ifname, \ | |
2319 | hapd.own_addr()) | |
2320 | res = sigma_dut_cmd(cmd, timeout=10) | |
2321 | if "ssid,test,bsschannel,1" not in res: | |
2322 | raise Exception("Unexpected result: " + res) | |
2323 | finally: | |
2324 | stop_sigma_dut(sigma) | |
b1e11877 | 2325 | |
0beb6c2f JM |
2326 | def test_sigma_dut_ap_osen(dev, apdev, params): |
2327 | """sigma_dut controlled AP with OSEN""" | |
2328 | logdir = os.path.join(params['logdir'], | |
2329 | "sigma_dut_ap_osen.sigma-hostapd") | |
2330 | with HWSimRadio() as (radio, iface): | |
2331 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
2332 | try: | |
2333 | sigma_dut_cmd_check("ap_reset_default") | |
2334 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-hs20,MODE,11ng") | |
2335 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,1812,PASSWORD,radius") | |
2336 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,OSEN,PMF,Optional") | |
2337 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2338 | ||
2339 | # RSN-OSEN (for OSU) | |
2340 | dev[0].connect("test-hs20", proto="OSEN", key_mgmt="OSEN", | |
2341 | pairwise="CCMP", group="GTK_NOT_USED", | |
2342 | eap="WFA-UNAUTH-TLS", identity="osen@example.com", | |
2343 | ca_cert="auth_serv/ca.pem", scan_freq="2412") | |
2344 | ||
2345 | sigma_dut_cmd_check("ap_reset_default") | |
2346 | finally: | |
2347 | stop_sigma_dut(sigma) | |
2348 | ||
b1e11877 JM |
2349 | def test_sigma_dut_ap_eap_osen(dev, apdev, params): |
2350 | """sigma_dut controlled AP with EAP+OSEN""" | |
2351 | logdir = os.path.join(params['logdir'], | |
2352 | "sigma_dut_ap_eap_osen.sigma-hostapd") | |
2353 | with HWSimRadio() as (radio, iface): | |
2354 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir) | |
2355 | try: | |
2356 | sigma_dut_cmd_check("ap_reset_default") | |
2357 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-hs20,MODE,11ng") | |
2358 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,1812,PASSWORD,radius") | |
2359 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-ENT-OSEN,PMF,Optional") | |
2360 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2361 | ||
2362 | # RSN-OSEN (for OSU) | |
2363 | dev[0].connect("test-hs20", proto="OSEN", key_mgmt="OSEN", | |
2364 | pairwise="CCMP", | |
2365 | eap="WFA-UNAUTH-TLS", identity="osen@example.com", | |
2366 | ca_cert="auth_serv/ca.pem", ieee80211w='2', | |
2367 | scan_freq="2412") | |
2368 | # RSN-EAP (for data connection) | |
2369 | dev[1].connect("test-hs20", key_mgmt="WPA-EAP", eap="TTLS", | |
2370 | identity="hs20-test", password="password", | |
2371 | ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", | |
2372 | ieee80211w='2', scan_freq="2412") | |
2373 | ||
2374 | sigma_dut_cmd_check("ap_reset_default") | |
2375 | finally: | |
2376 | stop_sigma_dut(sigma) | |
63add34e JM |
2377 | |
2378 | def test_sigma_dut_ap_eap(dev, apdev, params): | |
2379 | """sigma_dut controlled AP WPA2-Enterprise""" | |
2380 | logdir = os.path.join(params['logdir'], "sigma_dut_ap_eap.sigma-hostapd") | |
2381 | with HWSimRadio() as (radio, iface): | |
2382 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir, debug=True) | |
2383 | try: | |
2384 | sigma_dut_cmd_check("ap_reset_default") | |
2385 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-eap,MODE,11ng") | |
2386 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,1812,PASSWORD,radius") | |
2387 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-ENT") | |
2388 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2389 | ||
2390 | dev[0].connect("test-eap", key_mgmt="WPA-EAP", eap="GPSK", | |
2391 | identity="gpsk user", | |
2392 | password="abcdefghijklmnop0123456789abcdef", | |
2393 | scan_freq="2412") | |
2394 | ||
2395 | sigma_dut_cmd_check("ap_reset_default") | |
2396 | finally: | |
2397 | stop_sigma_dut(sigma) | |
2398 | ||
2399 | def test_sigma_dut_ap_eap_sha256(dev, apdev, params): | |
2400 | """sigma_dut controlled AP WPA2-Enterprise SHA256""" | |
2401 | logdir = os.path.join(params['logdir'], | |
2402 | "sigma_dut_ap_eap_sha256.sigma-hostapd") | |
2403 | with HWSimRadio() as (radio, iface): | |
2404 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir, debug=True) | |
2405 | try: | |
2406 | sigma_dut_cmd_check("ap_reset_default") | |
2407 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-eap,MODE,11ng") | |
2408 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,1812,PASSWORD,radius") | |
2409 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-ENT-256") | |
2410 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2411 | ||
2412 | dev[0].connect("test-eap", key_mgmt="WPA-EAP-SHA256", eap="GPSK", | |
2413 | identity="gpsk user", | |
2414 | password="abcdefghijklmnop0123456789abcdef", | |
2415 | scan_freq="2412") | |
2416 | ||
2417 | sigma_dut_cmd_check("ap_reset_default") | |
2418 | finally: | |
2419 | stop_sigma_dut(sigma) | |
2420 | ||
2421 | def test_sigma_dut_ap_ft_eap(dev, apdev, params): | |
2422 | """sigma_dut controlled AP FT-EAP""" | |
2423 | logdir = os.path.join(params['logdir'], "sigma_dut_ap_ft_eap.sigma-hostapd") | |
2424 | with HWSimRadio() as (radio, iface): | |
2425 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir, debug=True) | |
2426 | try: | |
2427 | sigma_dut_cmd_check("ap_reset_default") | |
2428 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-ft-eap,MODE,11ng,DOMAIN,0101,FT_OA,Enable") | |
2429 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,1812,PASSWORD,radius") | |
2430 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,FT-EAP") | |
2431 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2432 | ||
2433 | dev[0].connect("test-ft-eap", key_mgmt="FT-EAP", eap="GPSK", | |
2434 | identity="gpsk user", | |
2435 | password="abcdefghijklmnop0123456789abcdef", | |
2436 | scan_freq="2412") | |
2437 | ||
2438 | sigma_dut_cmd_check("ap_reset_default") | |
2439 | finally: | |
2440 | stop_sigma_dut(sigma) | |
2441 | ||
2442 | def test_sigma_dut_ap_ft_psk(dev, apdev, params): | |
2443 | """sigma_dut controlled AP FT-PSK""" | |
2444 | logdir = os.path.join(params['logdir'], "sigma_dut_ap_ft_psk.sigma-hostapd") | |
2445 | with HWSimRadio() as (radio, iface): | |
2446 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir, debug=True) | |
2447 | try: | |
2448 | sigma_dut_cmd_check("ap_reset_default") | |
2449 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-ft-psk,MODE,11ng,DOMAIN,0101,FT_OA,Enable") | |
2450 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,FT-PSK,PSK,12345678") | |
2451 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2452 | ||
2453 | dev[0].connect("test-ft-psk", key_mgmt="FT-PSK", psk="12345678", | |
2454 | scan_freq="2412") | |
2455 | ||
2456 | sigma_dut_cmd_check("ap_reset_default") | |
2457 | finally: | |
2458 | stop_sigma_dut(sigma) | |
2459 | ||
2460 | def test_sigma_dut_ap_ent_ft_eap(dev, apdev, params): | |
2461 | """sigma_dut controlled AP WPA-EAP and FT-EAP""" | |
2462 | logdir = os.path.join(params['logdir'], | |
2463 | "sigma_dut_ap_ent_ft_eap.sigma-hostapd") | |
2464 | with HWSimRadio() as (radio, iface): | |
2465 | sigma = start_sigma_dut(iface, hostapd_logdir=logdir, debug=True) | |
2466 | try: | |
2467 | sigma_dut_cmd_check("ap_reset_default") | |
2468 | sigma_dut_cmd_check("ap_set_wireless,NAME,AP,CHANNEL,1,SSID,test-ent-ft-eap,MODE,11ng,DOMAIN,0101,FT_OA,Enable") | |
2469 | sigma_dut_cmd_check("ap_set_radius,NAME,AP,IPADDR,127.0.0.1,PORT,1812,PASSWORD,radius") | |
2470 | sigma_dut_cmd_check("ap_set_security,NAME,AP,KEYMGNT,WPA2-ENT-FT-EAP") | |
2471 | sigma_dut_cmd_check("ap_config_commit,NAME,AP") | |
2472 | ||
2473 | dev[0].connect("test-ent-ft-eap", key_mgmt="FT-EAP", eap="GPSK", | |
2474 | identity="gpsk user", | |
2475 | password="abcdefghijklmnop0123456789abcdef", | |
2476 | scan_freq="2412") | |
2477 | dev[1].connect("test-ent-ft-eap", key_mgmt="WPA-EAP", eap="GPSK", | |
2478 | identity="gpsk user", | |
2479 | password="abcdefghijklmnop0123456789abcdef", | |
2480 | scan_freq="2412") | |
2481 | ||
2482 | sigma_dut_cmd_check("ap_reset_default") | |
2483 | finally: | |
2484 | stop_sigma_dut(sigma) | |
dc60d564 JM |
2485 | |
2486 | def test_sigma_dut_venue_url(dev, apdev): | |
2487 | """sigma_dut controlled Venue URL fetch""" | |
2488 | try: | |
2489 | run_sigma_dut_venue_url(dev, apdev) | |
2490 | finally: | |
2491 | dev[0].set("ignore_old_scan_res", "0") | |
2492 | ||
2493 | def run_sigma_dut_venue_url(dev, apdev): | |
2494 | ifname = dev[0].ifname | |
2495 | sigma = start_sigma_dut(ifname, debug=True) | |
2496 | ||
2497 | ssid = "venue" | |
2498 | params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") | |
2499 | params["wpa_key_mgmt"] = "WPA-PSK-SHA256" | |
2500 | params["ieee80211w"] = "2" | |
2501 | ||
2502 | venue_group = 1 | |
2503 | venue_type = 13 | |
2504 | venue_info = struct.pack('BB', venue_group, venue_type) | |
2505 | lang1 = "eng" | |
2506 | name1= "Example venue" | |
2507 | lang2 = "fin" | |
2508 | name2 = "Esimerkkipaikka" | |
2509 | venue1 = struct.pack('B', len(lang1 + name1)) + lang1 + name1 | |
2510 | venue2 = struct.pack('B', len(lang2 + name2)) + lang2 + name2 | |
2511 | venue_name = binascii.hexlify(venue_info + venue1 + venue2) | |
2512 | ||
2513 | url1 = "http://example.com/venue" | |
2514 | url2 = "https://example.org/venue-info/" | |
2515 | params["venue_group"] = str(venue_group) | |
2516 | params["venue_type"] = str(venue_type) | |
2517 | params["venue_name"] = [ lang1 + ":" + name1, lang2 + ":" + name2 ] | |
2518 | params["venue_url"] = [ "1:" + url1, "2:" + url2 ] | |
2519 | ||
2520 | hapd = hostapd.add_ap(apdev[0], params) | |
2521 | ||
2522 | sigma_dut_cmd_check("sta_reset_default,interface,%s,prog,PMF" % ifname) | |
2523 | sigma_dut_cmd_check("sta_set_ip_config,interface,%s,dhcp,0,ip,127.0.0.11,mask,255.255.255.0" % ifname) | |
2524 | sigma_dut_cmd_check("sta_set_psk,interface,%s,ssid,%s,passphrase,%s,encpType,aes-ccmp,keymgmttype,wpa2,PMF,Required" % (ifname, "venue", "12345678")) | |
2525 | sigma_dut_cmd_check("sta_associate,interface,%s,ssid,%s,channel,1" % (ifname, "venue")) | |
2526 | sigma_dut_wait_connected(ifname) | |
2527 | sigma_dut_cmd_check("sta_get_ip_config,interface," + ifname) | |
2528 | sigma_dut_cmd_check("sta_hs2_venue_info,interface," + ifname + ",Display,Yes") | |
2529 | sigma_dut_cmd_check("sta_disconnect,interface," + ifname) | |
2530 | sigma_dut_cmd_check("sta_reset_default,interface," + ifname) | |
2531 | ||
2532 | stop_sigma_dut(sigma) |