test_ap_wps.py 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. #!/usr/bin/python
  2. #
  3. # WPS tests
  4. # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
  5. #
  6. # This software may be distributed under the terms of the BSD license.
  7. # See README for more details.
  8. import time
  9. import subprocess
  10. import logging
  11. logger = logging.getLogger()
  12. import hwsim_utils
  13. import hostapd
  14. def test_ap_wps_init(dev, apdev):
  15. """Initial AP configuration with first WPS Enrollee"""
  16. ssid = "test-wps"
  17. hostapd.add_ap(apdev[0]['ifname'],
  18. { "ssid": ssid, "eap_server": "1", "wps_state": "1" })
  19. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  20. logger.info("WPS provisioning step")
  21. hapd.request("WPS_PBC")
  22. if "PBC Status: Active" not in hapd.request("WPS_GET_STATUS"):
  23. raise Exception("PBC status not shown correctly")
  24. dev[0].request("SET ignore_old_scan_res 1")
  25. dev[0].dump_monitor()
  26. dev[0].request("WPS_PBC")
  27. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  28. if ev is None:
  29. raise Exception("Association with the AP timed out")
  30. status = dev[0].get_status()
  31. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  32. raise Exception("Not fully connected")
  33. if status['ssid'] != ssid:
  34. raise Exception("Unexpected SSID")
  35. if status['pairwise_cipher'] != 'CCMP':
  36. raise Exception("Unexpected encryption configuration")
  37. if status['key_mgmt'] != 'WPA2-PSK':
  38. raise Exception("Unexpected key_mgmt")
  39. status = hapd.request("WPS_GET_STATUS")
  40. if "PBC Status: Disabled" not in status:
  41. raise Exception("PBC status not shown correctly")
  42. if "Last WPS result: Success" not in status:
  43. raise Exception("Last WPS result not shown correctly")
  44. if "Peer Address: " + dev[0].p2p_interface_addr() not in status:
  45. raise Exception("Peer address not shown correctly")
  46. conf = hapd.request("GET_CONFIG")
  47. if "wps_state=configured" not in conf:
  48. raise Exception("AP not in WPS configured state")
  49. if "rsn_pairwise_cipher=CCMP TKIP" not in conf:
  50. raise Exception("Unexpected rsn_pairwise_cipher")
  51. if "wpa_pairwise_cipher=CCMP TKIP" not in conf:
  52. raise Exception("Unexpected wpa_pairwise_cipher")
  53. if "group_cipher=TKIP" not in conf:
  54. raise Exception("Unexpected group_cipher")
  55. def test_ap_wps_init_2ap_pbc(dev, apdev):
  56. """Initial two-radio AP configuration with first WPS PBC Enrollee"""
  57. ssid = "test-wps"
  58. params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" }
  59. hostapd.add_ap(apdev[0]['ifname'], params)
  60. hostapd.add_ap(apdev[1]['ifname'], params)
  61. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  62. logger.info("WPS provisioning step")
  63. hapd.request("WPS_PBC")
  64. dev[0].request("SET ignore_old_scan_res 1")
  65. dev[0].scan(freq="2412")
  66. bss = dev[0].get_bss(apdev[0]['bssid'])
  67. if "[WPS-PBC]" not in bss['flags']:
  68. raise Exception("WPS-PBC flag missing from AP1")
  69. bss = dev[0].get_bss(apdev[1]['bssid'])
  70. if "[WPS-PBC]" not in bss['flags']:
  71. raise Exception("WPS-PBC flag missing from AP2")
  72. dev[0].dump_monitor()
  73. dev[0].request("WPS_PBC")
  74. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  75. if ev is None:
  76. raise Exception("Association with the AP timed out")
  77. dev[1].request("SET ignore_old_scan_res 1")
  78. dev[1].scan(freq="2412")
  79. bss = dev[1].get_bss(apdev[0]['bssid'])
  80. if "[WPS-PBC]" in bss['flags']:
  81. raise Exception("WPS-PBC flag not cleared from AP1")
  82. bss = dev[1].get_bss(apdev[1]['bssid'])
  83. if "[WPS-PBC]" in bss['flags']:
  84. raise Exception("WPS-PBC flag bit ckeared from AP2")
  85. def test_ap_wps_init_2ap_pin(dev, apdev):
  86. """Initial two-radio AP configuration with first WPS PIN Enrollee"""
  87. ssid = "test-wps"
  88. params = { "ssid": ssid, "eap_server": "1", "wps_state": "1" }
  89. hostapd.add_ap(apdev[0]['ifname'], params)
  90. hostapd.add_ap(apdev[1]['ifname'], params)
  91. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  92. logger.info("WPS provisioning step")
  93. pin = dev[0].wps_read_pin()
  94. hapd.request("WPS_PIN any " + pin)
  95. dev[0].request("SET ignore_old_scan_res 1")
  96. dev[0].scan(freq="2412")
  97. bss = dev[0].get_bss(apdev[0]['bssid'])
  98. if "[WPS-AUTH]" not in bss['flags']:
  99. raise Exception("WPS-AUTH flag missing from AP1")
  100. bss = dev[0].get_bss(apdev[1]['bssid'])
  101. if "[WPS-AUTH]" not in bss['flags']:
  102. raise Exception("WPS-AUTH flag missing from AP2")
  103. dev[0].dump_monitor()
  104. dev[0].request("WPS_PIN any " + pin)
  105. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  106. if ev is None:
  107. raise Exception("Association with the AP timed out")
  108. dev[1].request("SET ignore_old_scan_res 1")
  109. dev[1].scan(freq="2412")
  110. bss = dev[1].get_bss(apdev[0]['bssid'])
  111. if "[WPS-AUTH]" in bss['flags']:
  112. raise Exception("WPS-AUTH flag not cleared from AP1")
  113. bss = dev[1].get_bss(apdev[1]['bssid'])
  114. if "[WPS-AUTH]" in bss['flags']:
  115. raise Exception("WPS-AUTH flag bit ckeared from AP2")
  116. def test_ap_wps_init_through_wps_config(dev, apdev):
  117. """Initial AP configuration using wps_config command"""
  118. ssid = "test-wps-init-config"
  119. hostapd.add_ap(apdev[0]['ifname'],
  120. { "ssid": ssid, "eap_server": "1", "wps_state": "1" })
  121. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  122. if "FAIL" in hapd.request("WPS_CONFIG " + ssid.encode("hex") + " WPA2PSK CCMP " + "12345678".encode("hex")):
  123. raise Exception("WPS_CONFIG command failed")
  124. dev[0].connect(ssid, psk="12345678", scan_freq="2412", proto="WPA2",
  125. pairwise="CCMP", group="CCMP")
  126. def test_ap_wps_conf(dev, apdev):
  127. """WPS PBC provisioning with configured AP"""
  128. ssid = "test-wps-conf"
  129. hostapd.add_ap(apdev[0]['ifname'],
  130. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  131. "wpa_passphrase": "12345678", "wpa": "2",
  132. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  133. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  134. logger.info("WPS provisioning step")
  135. hapd.request("WPS_PBC")
  136. dev[0].dump_monitor()
  137. dev[0].request("WPS_PBC")
  138. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  139. if ev is None:
  140. raise Exception("Association with the AP timed out")
  141. status = dev[0].get_status()
  142. if status['wpa_state'] != 'COMPLETED':
  143. raise Exception("Not fully connected")
  144. if status['bssid'] != apdev[0]['bssid']:
  145. raise Exception("Unexpected BSSID")
  146. if status['ssid'] != ssid:
  147. raise Exception("Unexpected SSID")
  148. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  149. raise Exception("Unexpected encryption configuration")
  150. if status['key_mgmt'] != 'WPA2-PSK':
  151. raise Exception("Unexpected key_mgmt")
  152. sta = hapd.get_sta(dev[0].p2p_interface_addr())
  153. if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A":
  154. raise Exception("Device name not available in STA command")
  155. def test_ap_wps_twice(dev, apdev):
  156. """WPS provisioning with twice to change passphrase"""
  157. ssid = "test-wps-twice"
  158. params = { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  159. "wpa_passphrase": "12345678", "wpa": "2",
  160. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }
  161. hostapd.add_ap(apdev[0]['ifname'], params)
  162. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  163. logger.info("WPS provisioning step")
  164. hapd.request("WPS_PBC")
  165. dev[0].request("SET ignore_old_scan_res 1")
  166. dev[0].dump_monitor()
  167. dev[0].request("WPS_PBC")
  168. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  169. if ev is None:
  170. raise Exception("Association with the AP timed out")
  171. dev[0].request("DISCONNECT")
  172. logger.info("Restart AP with different passphrase and re-run WPS")
  173. hapd_global = hostapd.HostapdGlobal()
  174. hapd_global.remove(apdev[0]['ifname'])
  175. params['wpa_passphrase'] = 'another passphrase'
  176. hostapd.add_ap(apdev[0]['ifname'], params)
  177. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  178. logger.info("WPS provisioning step")
  179. hapd.request("WPS_PBC")
  180. dev[0].dump_monitor()
  181. dev[0].request("WPS_PBC")
  182. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  183. if ev is None:
  184. raise Exception("Association with the AP timed out")
  185. networks = dev[0].list_networks()
  186. if len(networks) > 1:
  187. raise Exception("Unexpected duplicated network block present")
  188. def test_ap_wps_incorrect_pin(dev, apdev):
  189. """WPS PIN provisioning with incorrect PIN"""
  190. ssid = "test-wps-incorrect-pin"
  191. hostapd.add_ap(apdev[0]['ifname'],
  192. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  193. "wpa_passphrase": "12345678", "wpa": "2",
  194. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  195. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  196. logger.info("WPS provisioning attempt 1")
  197. hapd.request("WPS_PIN any 12345670")
  198. dev[0].request("SET ignore_old_scan_res 1")
  199. dev[0].dump_monitor()
  200. dev[0].request("WPS_PIN any 55554444")
  201. ev = dev[0].wait_event(["WPS-FAIL"], timeout=30)
  202. if ev is None:
  203. raise Exception("WPS operation timed out")
  204. if "config_error=18" not in ev:
  205. raise Exception("Incorrect config_error reported")
  206. if "msg=8" not in ev:
  207. raise Exception("PIN error detected on incorrect message")
  208. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
  209. if ev is None:
  210. raise Exception("Timeout on disconnection event")
  211. dev[0].request("WPS_CANCEL")
  212. # if a scan was in progress, wait for it to complete before trying WPS again
  213. ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 5)
  214. status = hapd.request("WPS_GET_STATUS")
  215. if "Last WPS result: Failed" not in status:
  216. raise Exception("WPS failure result not shown correctly")
  217. logger.info("WPS provisioning attempt 2")
  218. hapd.request("WPS_PIN any 12345670")
  219. dev[0].dump_monitor()
  220. dev[0].request("WPS_PIN any 12344444")
  221. ev = dev[0].wait_event(["WPS-FAIL"], timeout=30)
  222. if ev is None:
  223. raise Exception("WPS operation timed out")
  224. if "config_error=18" not in ev:
  225. raise Exception("Incorrect config_error reported")
  226. if "msg=10" not in ev:
  227. raise Exception("PIN error detected on incorrect message")
  228. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
  229. if ev is None:
  230. raise Exception("Timeout on disconnection event")
  231. def test_ap_wps_conf_pin(dev, apdev):
  232. """WPS PIN provisioning with configured AP"""
  233. ssid = "test-wps-conf-pin"
  234. hostapd.add_ap(apdev[0]['ifname'],
  235. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  236. "wpa_passphrase": "12345678", "wpa": "2",
  237. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  238. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  239. logger.info("WPS provisioning step")
  240. pin = dev[0].wps_read_pin()
  241. hapd.request("WPS_PIN any " + pin)
  242. dev[0].request("SET ignore_old_scan_res 1")
  243. dev[0].dump_monitor()
  244. dev[0].request("WPS_PIN any " + pin)
  245. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  246. if ev is None:
  247. raise Exception("Association with the AP timed out")
  248. status = dev[0].get_status()
  249. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  250. raise Exception("Not fully connected")
  251. if status['ssid'] != ssid:
  252. raise Exception("Unexpected SSID")
  253. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  254. raise Exception("Unexpected encryption configuration")
  255. if status['key_mgmt'] != 'WPA2-PSK':
  256. raise Exception("Unexpected key_mgmt")
  257. dev[1].request("SET ignore_old_scan_res 1")
  258. dev[1].scan(freq="2412")
  259. bss = dev[1].get_bss(apdev[0]['bssid'])
  260. if "[WPS-AUTH]" in bss['flags']:
  261. raise Exception("WPS-AUTH flag not cleared")
  262. logger.info("Try to connect from another station using the same PIN")
  263. dev[1].request("WPS_PIN any " + pin)
  264. ev = dev[1].wait_event(["WPS-M2D","CTRL-EVENT-CONNECTED"], timeout=30)
  265. if ev is None:
  266. raise Exception("Operation timed out")
  267. if "WPS-M2D" not in ev:
  268. raise Exception("Unexpected WPS operation started")
  269. def test_ap_wps_conf_pin_2sta(dev, apdev):
  270. """Two stations trying to use WPS PIN at the same time"""
  271. ssid = "test-wps-conf-pin2"
  272. hostapd.add_ap(apdev[0]['ifname'],
  273. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  274. "wpa_passphrase": "12345678", "wpa": "2",
  275. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  276. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  277. logger.info("WPS provisioning step")
  278. pin = "12345670"
  279. pin2 = "55554444"
  280. hapd.request("WPS_PIN " + dev[0].get_status_field("uuid") + " " + pin)
  281. hapd.request("WPS_PIN " + dev[1].get_status_field("uuid") + " " + pin)
  282. dev[0].request("SET ignore_old_scan_res 1")
  283. dev[0].dump_monitor()
  284. dev[1].request("SET ignore_old_scan_res 1")
  285. dev[1].dump_monitor()
  286. dev[0].request("WPS_PIN any " + pin)
  287. dev[1].request("WPS_PIN any " + pin)
  288. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  289. if ev is None:
  290. raise Exception("Association with the AP timed out")
  291. ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  292. if ev is None:
  293. raise Exception("Association with the AP timed out")
  294. def test_ap_wps_reg_connect(dev, apdev):
  295. """WPS registrar using AP PIN to connect"""
  296. ssid = "test-wps-reg-ap-pin"
  297. appin = "12345670"
  298. hostapd.add_ap(apdev[0]['ifname'],
  299. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  300. "wpa_passphrase": "12345678", "wpa": "2",
  301. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  302. "ap_pin": appin})
  303. logger.info("WPS provisioning step")
  304. dev[0].request("SET ignore_old_scan_res 1")
  305. dev[0].dump_monitor()
  306. dev[0].wps_reg(apdev[0]['bssid'], appin)
  307. status = dev[0].get_status()
  308. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  309. raise Exception("Not fully connected")
  310. if status['ssid'] != ssid:
  311. raise Exception("Unexpected SSID")
  312. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  313. raise Exception("Unexpected encryption configuration")
  314. if status['key_mgmt'] != 'WPA2-PSK':
  315. raise Exception("Unexpected key_mgmt")
  316. def check_wps_reg_failure(dev, ap, appin):
  317. dev.request("WPS_REG " + ap['bssid'] + " " + appin)
  318. ev = dev.wait_event(["WPS-SUCCESS", "WPS-FAIL"], timeout=15)
  319. if ev is None:
  320. raise Exception("WPS operation timed out")
  321. if "WPS-SUCCESS" in ev:
  322. raise Exception("WPS operation succeeded unexpectedly")
  323. if "config_error=15" not in ev:
  324. raise Exception("WPS setup locked state was not reported correctly")
  325. def test_ap_wps_random_ap_pin(dev, apdev):
  326. """WPS registrar using random AP PIN"""
  327. ssid = "test-wps-reg-random-ap-pin"
  328. ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
  329. hostapd.add_ap(apdev[0]['ifname'],
  330. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  331. "wpa_passphrase": "12345678", "wpa": "2",
  332. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  333. "device_name": "Wireless AP", "manufacturer": "Company",
  334. "model_name": "WAP", "model_number": "123",
  335. "serial_number": "12345", "device_type": "6-0050F204-1",
  336. "os_version": "01020300",
  337. "config_methods": "label push_button",
  338. "uuid": ap_uuid, "upnp_iface": "lo" })
  339. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  340. appin = hapd.request("WPS_AP_PIN random")
  341. if "FAIL" in appin:
  342. raise Exception("Could not generate random AP PIN")
  343. if appin not in hapd.request("WPS_AP_PIN get"):
  344. raise Exception("Could not fetch current AP PIN")
  345. logger.info("WPS provisioning step")
  346. dev[0].request("SET ignore_old_scan_res 1")
  347. dev[0].wps_reg(apdev[0]['bssid'], appin)
  348. hapd.request("WPS_AP_PIN disable")
  349. logger.info("WPS provisioning step with AP PIN disabled")
  350. dev[1].request("SET ignore_old_scan_res 1")
  351. check_wps_reg_failure(dev[1], apdev[0], appin)
  352. logger.info("WPS provisioning step with AP PIN reset")
  353. appin = "12345670"
  354. hapd.request("WPS_AP_PIN set " + appin)
  355. dev[1].wps_reg(apdev[0]['bssid'], appin)
  356. dev[0].request("REMOVE_NETWORK all")
  357. dev[1].request("REMOVE_NETWORK all")
  358. dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
  359. dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
  360. logger.info("WPS provisioning step after AP PIN timeout")
  361. hapd.request("WPS_AP_PIN disable")
  362. appin = hapd.request("WPS_AP_PIN random 1")
  363. time.sleep(1.1)
  364. if "FAIL" not in hapd.request("WPS_AP_PIN get"):
  365. raise Exception("AP PIN unexpectedly still enabled")
  366. check_wps_reg_failure(dev[0], apdev[0], appin)
  367. logger.info("WPS provisioning step after AP PIN timeout(2)")
  368. hapd.request("WPS_AP_PIN disable")
  369. appin = "12345670"
  370. hapd.request("WPS_AP_PIN set " + appin + " 1")
  371. time.sleep(1.1)
  372. if "FAIL" not in hapd.request("WPS_AP_PIN get"):
  373. raise Exception("AP PIN unexpectedly still enabled")
  374. check_wps_reg_failure(dev[1], apdev[0], appin)
  375. def test_ap_wps_reg_config(dev, apdev):
  376. """WPS registrar configuring and AP using AP PIN"""
  377. ssid = "test-wps-init-ap-pin"
  378. appin = "12345670"
  379. hostapd.add_ap(apdev[0]['ifname'],
  380. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  381. "ap_pin": appin})
  382. logger.info("WPS configuration step")
  383. dev[0].request("SET ignore_old_scan_res 1")
  384. dev[0].dump_monitor()
  385. new_ssid = "wps-new-ssid"
  386. new_passphrase = "1234567890"
  387. dev[0].wps_reg(apdev[0]['bssid'], appin, new_ssid, "WPA2PSK", "CCMP",
  388. new_passphrase)
  389. status = dev[0].get_status()
  390. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  391. raise Exception("Not fully connected")
  392. if status['ssid'] != new_ssid:
  393. raise Exception("Unexpected SSID")
  394. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  395. raise Exception("Unexpected encryption configuration")
  396. if status['key_mgmt'] != 'WPA2-PSK':
  397. raise Exception("Unexpected key_mgmt")
  398. def test_ap_wps_reg_config_tkip(dev, apdev):
  399. """WPS registrar configuring AP to use TKIP and AP upgrading to TKIP+CCMP"""
  400. ssid = "test-wps-init-ap"
  401. appin = "12345670"
  402. hostapd.add_ap(apdev[0]['ifname'],
  403. { "ssid": ssid, "eap_server": "1", "wps_state": "1",
  404. "ap_pin": appin})
  405. logger.info("WPS configuration step")
  406. dev[0].request("SET ignore_old_scan_res 1")
  407. dev[0].request("SET wps_version_number 0x10")
  408. dev[0].dump_monitor()
  409. new_ssid = "wps-new-ssid-with-tkip"
  410. new_passphrase = "1234567890"
  411. dev[0].wps_reg(apdev[0]['bssid'], appin, new_ssid, "WPAPSK", "TKIP",
  412. new_passphrase)
  413. logger.info("Re-connect to verify WPA2 mixed mode")
  414. dev[0].request("DISCONNECT")
  415. id = 0
  416. dev[0].set_network(id, "pairwise", "CCMP")
  417. dev[0].set_network(id, "proto", "RSN")
  418. dev[0].connect_network(id)
  419. status = dev[0].get_status()
  420. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  421. raise Exception("Not fully connected")
  422. if status['ssid'] != new_ssid:
  423. raise Exception("Unexpected SSID")
  424. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'TKIP':
  425. raise Exception("Unexpected encryption configuration")
  426. if status['key_mgmt'] != 'WPA2-PSK':
  427. raise Exception("Unexpected key_mgmt")
  428. def test_ap_wps_setup_locked(dev, apdev):
  429. """WPS registrar locking up AP setup on AP PIN failures"""
  430. ssid = "test-wps-incorrect-ap-pin"
  431. appin = "12345670"
  432. hostapd.add_ap(apdev[0]['ifname'],
  433. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  434. "wpa_passphrase": "12345678", "wpa": "2",
  435. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  436. "ap_pin": appin})
  437. dev[0].request("SET ignore_old_scan_res 1")
  438. new_ssid = "wps-new-ssid-test"
  439. new_passphrase = "1234567890"
  440. ap_setup_locked=False
  441. for pin in ["55554444", "1234", "12345678", "00000000", "11111111"]:
  442. dev[0].dump_monitor()
  443. logger.info("Try incorrect AP PIN - attempt " + pin)
  444. dev[0].wps_reg(apdev[0]['bssid'], pin, new_ssid, "WPA2PSK",
  445. "CCMP", new_passphrase, no_wait=True)
  446. ev = dev[0].wait_event(["WPS-FAIL", "CTRL-EVENT-CONNECTED"])
  447. if ev is None:
  448. raise Exception("Timeout on receiving WPS operation failure event")
  449. if "CTRL-EVENT-CONNECTED" in ev:
  450. raise Exception("Unexpected connection")
  451. if "config_error=15" in ev:
  452. logger.info("AP Setup Locked")
  453. ap_setup_locked=True
  454. elif "config_error=18" not in ev:
  455. raise Exception("config_error=18 not reported")
  456. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
  457. if ev is None:
  458. raise Exception("Timeout on disconnection event")
  459. time.sleep(0.1)
  460. if not ap_setup_locked:
  461. raise Exception("AP setup was not locked")
  462. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  463. status = hapd.request("WPS_GET_STATUS")
  464. if "Last WPS result: Failed" not in status:
  465. raise Exception("WPS failure result not shown correctly")
  466. if "Peer Address: " + dev[0].p2p_interface_addr() not in status:
  467. raise Exception("Peer address not shown correctly")
  468. time.sleep(0.5)
  469. dev[0].dump_monitor()
  470. logger.info("WPS provisioning step")
  471. pin = dev[0].wps_read_pin()
  472. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  473. hapd.request("WPS_PIN any " + pin)
  474. dev[0].request("WPS_PIN any " + pin)
  475. ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=30)
  476. if ev is None:
  477. raise Exception("WPS success was not reported")
  478. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  479. if ev is None:
  480. raise Exception("Association with the AP timed out")
  481. def test_ap_wps_pbc_overlap_2ap(dev, apdev):
  482. """WPS PBC session overlap with two active APs"""
  483. hostapd.add_ap(apdev[0]['ifname'],
  484. { "ssid": "wps1", "eap_server": "1", "wps_state": "2",
  485. "wpa_passphrase": "12345678", "wpa": "2",
  486. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  487. "wps_independent": "1"})
  488. hostapd.add_ap(apdev[1]['ifname'],
  489. { "ssid": "wps2", "eap_server": "1", "wps_state": "2",
  490. "wpa_passphrase": "123456789", "wpa": "2",
  491. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  492. "wps_independent": "1"})
  493. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  494. hapd.request("WPS_PBC")
  495. hapd2 = hostapd.Hostapd(apdev[1]['ifname'])
  496. hapd2.request("WPS_PBC")
  497. logger.info("WPS provisioning step")
  498. dev[0].dump_monitor()
  499. dev[0].request("WPS_PBC")
  500. ev = dev[0].wait_event(["WPS-OVERLAP-DETECTED"], timeout=15)
  501. if ev is None:
  502. raise Exception("PBC session overlap not detected")
  503. def test_ap_wps_pbc_overlap_2sta(dev, apdev):
  504. """WPS PBC session overlap with two active STAs"""
  505. ssid = "test-wps-pbc-overlap"
  506. hostapd.add_ap(apdev[0]['ifname'],
  507. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  508. "wpa_passphrase": "12345678", "wpa": "2",
  509. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
  510. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  511. logger.info("WPS provisioning step")
  512. hapd.request("WPS_PBC")
  513. dev[0].request("SET ignore_old_scan_res 1")
  514. dev[1].request("SET ignore_old_scan_res 1")
  515. dev[0].dump_monitor()
  516. dev[1].dump_monitor()
  517. dev[0].request("WPS_PBC")
  518. dev[1].request("WPS_PBC")
  519. ev = dev[0].wait_event(["WPS-M2D"], timeout=15)
  520. if ev is None:
  521. raise Exception("PBC session overlap not detected (dev0)")
  522. if "config_error=12" not in ev:
  523. raise Exception("PBC session overlap not correctly reported (dev0)")
  524. ev = dev[1].wait_event(["WPS-M2D"], timeout=15)
  525. if ev is None:
  526. raise Exception("PBC session overlap not detected (dev1)")
  527. if "config_error=12" not in ev:
  528. raise Exception("PBC session overlap not correctly reported (dev1)")
  529. def test_ap_wps_cancel(dev, apdev):
  530. """WPS AP cancelling enabled config method"""
  531. ssid = "test-wps-ap-cancel"
  532. hostapd.add_ap(apdev[0]['ifname'],
  533. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  534. "wpa_passphrase": "12345678", "wpa": "2",
  535. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
  536. bssid = apdev[0]['bssid']
  537. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  538. logger.info("Verify PBC enable/cancel")
  539. hapd.request("WPS_PBC")
  540. dev[0].request("SET ignore_old_scan_res 1")
  541. dev[0].scan(freq="2412")
  542. bss = dev[0].get_bss(apdev[0]['bssid'])
  543. if "[WPS-PBC]" not in bss['flags']:
  544. raise Exception("WPS-PBC flag missing")
  545. if "FAIL" in hapd.request("WPS_CANCEL"):
  546. raise Exception("WPS_CANCEL failed")
  547. dev[0].scan(freq="2412")
  548. bss = dev[0].get_bss(apdev[0]['bssid'])
  549. if "[WPS-PBC]" in bss['flags']:
  550. raise Exception("WPS-PBC flag not cleared")
  551. logger.info("Verify PIN enable/cancel")
  552. hapd.request("WPS_PIN any 12345670")
  553. dev[0].scan(freq="2412")
  554. bss = dev[0].get_bss(apdev[0]['bssid'])
  555. if "[WPS-AUTH]" not in bss['flags']:
  556. raise Exception("WPS-AUTH flag missing")
  557. if "FAIL" in hapd.request("WPS_CANCEL"):
  558. raise Exception("WPS_CANCEL failed")
  559. dev[0].scan(freq="2412")
  560. bss = dev[0].get_bss(apdev[0]['bssid'])
  561. if "[WPS-AUTH]" in bss['flags']:
  562. raise Exception("WPS-AUTH flag not cleared")
  563. def test_ap_wps_er_add_enrollee(dev, apdev):
  564. """WPS ER configuring AP and adding a new enrollee using PIN"""
  565. ssid = "wps-er-add-enrollee"
  566. ap_pin = "12345670"
  567. ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
  568. hostapd.add_ap(apdev[0]['ifname'],
  569. { "ssid": ssid, "eap_server": "1", "wps_state": "1",
  570. "device_name": "Wireless AP", "manufacturer": "Company",
  571. "model_name": "WAP", "model_number": "123",
  572. "serial_number": "12345", "device_type": "6-0050F204-1",
  573. "os_version": "01020300",
  574. "config_methods": "label push_button",
  575. "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
  576. logger.info("WPS configuration step")
  577. new_passphrase = "1234567890"
  578. dev[0].dump_monitor()
  579. dev[0].request("SET ignore_old_scan_res 1")
  580. dev[0].wps_reg(apdev[0]['bssid'], ap_pin, ssid, "WPA2PSK", "CCMP",
  581. new_passphrase)
  582. status = dev[0].get_status()
  583. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  584. raise Exception("Not fully connected")
  585. if status['ssid'] != ssid:
  586. raise Exception("Unexpected SSID")
  587. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
  588. raise Exception("Unexpected encryption configuration")
  589. if status['key_mgmt'] != 'WPA2-PSK':
  590. raise Exception("Unexpected key_mgmt")
  591. logger.info("Start ER")
  592. dev[0].request("WPS_ER_START ifname=lo")
  593. ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
  594. if ev is None:
  595. raise Exception("AP discovery timed out")
  596. if ap_uuid not in ev:
  597. raise Exception("Expected AP UUID not found")
  598. logger.info("Learn AP configuration through UPnP")
  599. dev[0].dump_monitor()
  600. dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin)
  601. ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=15)
  602. if ev is None:
  603. raise Exception("AP learn timed out")
  604. if ap_uuid not in ev:
  605. raise Exception("Expected AP UUID not in settings")
  606. if "ssid=" + ssid not in ev:
  607. raise Exception("Expected SSID not in settings")
  608. if "key=" + new_passphrase not in ev:
  609. raise Exception("Expected passphrase not in settings")
  610. logger.info("Add Enrollee using ER")
  611. pin = dev[1].wps_read_pin()
  612. dev[0].dump_monitor()
  613. dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr())
  614. dev[1].request("SET ignore_old_scan_res 1")
  615. dev[1].dump_monitor()
  616. dev[1].request("WPS_PIN any " + pin)
  617. ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=30)
  618. if ev is None:
  619. raise Exception("Enrollee did not report success")
  620. ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
  621. if ev is None:
  622. raise Exception("Association with the AP timed out")
  623. ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
  624. if ev is None:
  625. raise Exception("WPS ER did not report success")
  626. hwsim_utils.test_connectivity_sta(dev[0], dev[1])
  627. logger.info("Verify registrar selection behavior")
  628. dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr())
  629. dev[1].request("DISCONNECT")
  630. dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
  631. dev[1].scan(freq="2412")
  632. bss = dev[1].get_bss(apdev[0]['bssid'])
  633. if "[WPS-AUTH]" not in bss['flags']:
  634. raise Exception("WPS-AUTH flag missing")
  635. logger.info("Stop ER")
  636. dev[0].dump_monitor()
  637. dev[0].request("WPS_ER_STOP")
  638. ev = dev[0].wait_event(["WPS-ER-AP-REMOVE"])
  639. if ev is None:
  640. raise Exception("WPS ER unsubscription timed out")
  641. dev[1].scan(freq="2412")
  642. bss = dev[1].get_bss(apdev[0]['bssid'])
  643. if "[WPS-AUTH]" in bss['flags']:
  644. raise Exception("WPS-AUTH flag not removed")
  645. def test_ap_wps_er_add_enrollee_pbc(dev, apdev):
  646. """WPS ER connected to AP and adding a new enrollee using PBC"""
  647. ssid = "wps-er-add-enrollee-pbc"
  648. ap_pin = "12345670"
  649. ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
  650. hostapd.add_ap(apdev[0]['ifname'],
  651. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  652. "wpa_passphrase": "12345678", "wpa": "2",
  653. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  654. "device_name": "Wireless AP", "manufacturer": "Company",
  655. "model_name": "WAP", "model_number": "123",
  656. "serial_number": "12345", "device_type": "6-0050F204-1",
  657. "os_version": "01020300",
  658. "config_methods": "label push_button",
  659. "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
  660. logger.info("Learn AP configuration")
  661. dev[0].dump_monitor()
  662. dev[0].request("SET ignore_old_scan_res 1")
  663. dev[0].wps_reg(apdev[0]['bssid'], ap_pin)
  664. status = dev[0].get_status()
  665. if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
  666. raise Exception("Not fully connected")
  667. logger.info("Start ER")
  668. dev[0].request("WPS_ER_START ifname=lo")
  669. ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
  670. if ev is None:
  671. raise Exception("AP discovery timed out")
  672. if ap_uuid not in ev:
  673. raise Exception("Expected AP UUID not found")
  674. logger.info("Use learned network configuration on ER")
  675. dev[0].request("WPS_ER_SET_CONFIG " + ap_uuid + " 0")
  676. logger.info("Add Enrollee using ER and PBC")
  677. dev[0].dump_monitor()
  678. enrollee = dev[1].p2p_interface_addr()
  679. dev[1].request("SET ignore_old_scan_res 1")
  680. dev[1].dump_monitor()
  681. dev[1].request("WPS_PBC")
  682. ev = dev[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout=15)
  683. if ev is None:
  684. raise Exception("Enrollee discovery timed out")
  685. if enrollee not in ev:
  686. raise Exception("Expected Enrollee not found")
  687. dev[0].request("WPS_ER_PBC " + enrollee)
  688. ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15)
  689. if ev is None:
  690. raise Exception("Enrollee did not report success")
  691. ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
  692. if ev is None:
  693. raise Exception("Association with the AP timed out")
  694. ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
  695. if ev is None:
  696. raise Exception("WPS ER did not report success")
  697. hwsim_utils.test_connectivity_sta(dev[0], dev[1])
  698. # verify BSSID selection of the AP instead of UUID
  699. if "FAIL" in dev[0].request("WPS_ER_SET_CONFIG " + apdev[0]['bssid'] + " 0"):
  700. raise Exception("Could not select AP based on BSSID")
  701. def test_ap_wps_er_config_ap(dev, apdev):
  702. """WPS ER configuring AP over UPnP"""
  703. ssid = "wps-er-ap-config"
  704. ap_pin = "12345670"
  705. ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e"
  706. hostapd.add_ap(apdev[0]['ifname'],
  707. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  708. "wpa_passphrase": "12345678", "wpa": "2",
  709. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  710. "device_name": "Wireless AP", "manufacturer": "Company",
  711. "model_name": "WAP", "model_number": "123",
  712. "serial_number": "12345", "device_type": "6-0050F204-1",
  713. "os_version": "01020300",
  714. "config_methods": "label push_button",
  715. "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"})
  716. logger.info("Connect ER to the AP")
  717. dev[0].connect(ssid, psk="12345678", scan_freq="2412")
  718. logger.info("WPS configuration step")
  719. dev[0].request("WPS_ER_START ifname=lo")
  720. ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15)
  721. if ev is None:
  722. raise Exception("AP discovery timed out")
  723. if ap_uuid not in ev:
  724. raise Exception("Expected AP UUID not found")
  725. new_passphrase = "1234567890"
  726. dev[0].request("WPS_ER_CONFIG " + apdev[0]['bssid'] + " " + ap_pin + " " +
  727. ssid.encode("hex") + " WPA2PSK CCMP " +
  728. new_passphrase.encode("hex"))
  729. ev = dev[0].wait_event(["WPS-SUCCESS"])
  730. if ev is None:
  731. raise Exception("WPS ER configuration operation timed out")
  732. dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
  733. dev[0].connect(ssid, psk="1234567890", scan_freq="2412")
  734. def test_ap_wps_fragmentation(dev, apdev):
  735. """WPS with fragmentation in EAP-WSC and mixed mode WPA+WPA2"""
  736. ssid = "test-wps-fragmentation"
  737. hostapd.add_ap(apdev[0]['ifname'],
  738. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  739. "wpa_passphrase": "12345678", "wpa": "3",
  740. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
  741. "wpa_pairwise": "TKIP",
  742. "fragment_size": "50" })
  743. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  744. logger.info("WPS provisioning step")
  745. hapd.request("WPS_PBC")
  746. dev[0].request("SET ignore_old_scan_res 1")
  747. dev[0].dump_monitor()
  748. dev[0].request("SET wps_fragment_size 50")
  749. dev[0].request("WPS_PBC")
  750. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  751. if ev is None:
  752. raise Exception("Association with the AP timed out")
  753. status = dev[0].get_status()
  754. if status['wpa_state'] != 'COMPLETED':
  755. raise Exception("Not fully connected")
  756. if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'TKIP':
  757. raise Exception("Unexpected encryption configuration")
  758. if status['key_mgmt'] != 'WPA2-PSK':
  759. raise Exception("Unexpected key_mgmt")
  760. def test_ap_wps_new_version_sta(dev, apdev):
  761. """WPS compatibility with new version number on the station"""
  762. ssid = "test-wps-ver"
  763. hostapd.add_ap(apdev[0]['ifname'],
  764. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  765. "wpa_passphrase": "12345678", "wpa": "2",
  766. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
  767. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  768. logger.info("WPS provisioning step")
  769. hapd.request("WPS_PBC")
  770. dev[0].request("SET ignore_old_scan_res 1")
  771. dev[0].dump_monitor()
  772. dev[0].request("SET wps_version_number 0x43")
  773. dev[0].request("WPS_PBC")
  774. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  775. if ev is None:
  776. raise Exception("Association with the AP timed out")
  777. def test_ap_wps_new_version_ap(dev, apdev):
  778. """WPS compatibility with new version number on the AP"""
  779. ssid = "test-wps-ver"
  780. hostapd.add_ap(apdev[0]['ifname'],
  781. { "ssid": ssid, "eap_server": "1", "wps_state": "2",
  782. "wpa_passphrase": "12345678", "wpa": "2",
  783. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
  784. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  785. logger.info("WPS provisioning step")
  786. if "FAIL" in hapd.request("SET wps_version_number 0x43"):
  787. raise Exception("Failed to enable test functionality")
  788. hapd.request("WPS_PBC")
  789. dev[0].request("SET ignore_old_scan_res 1")
  790. dev[0].dump_monitor()
  791. dev[0].request("WPS_PBC")
  792. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  793. hapd.request("SET wps_version_number 0x20")
  794. if ev is None:
  795. raise Exception("Association with the AP timed out")
  796. def test_ap_wps_check_pin(dev, apdev):
  797. """Verify PIN checking through control interface"""
  798. hostapd.add_ap(apdev[0]['ifname'],
  799. { "ssid": "wps", "eap_server": "1", "wps_state": "2",
  800. "wpa_passphrase": "12345678", "wpa": "2",
  801. "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" })
  802. hapd = hostapd.Hostapd(apdev[0]['ifname'])
  803. for t in [ ("12345670", "12345670"),
  804. ("12345678", "FAIL-CHECKSUM"),
  805. ("1234-5670", "12345670"),
  806. ("1234 5670", "12345670"),
  807. ("1-2.3:4 5670", "12345670") ]:
  808. res = hapd.request("WPS_CHECK_PIN " + t[0]).rstrip('\n')
  809. res2 = dev[0].request("WPS_CHECK_PIN " + t[0]).rstrip('\n')
  810. if res != res2:
  811. raise Exception("Unexpected difference in WPS_CHECK_PIN responses")
  812. if res != t[1]:
  813. raise Exception("Incorrect WPS_CHECK_PIN response {} (expected {})".format(res, t[1]))